@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class PhortuneTestPaymentProvider extends PhortunePaymentProvider {
4
5 public function isAcceptingLivePayments() {
6 return false;
7 }
8
9 public function getName() {
10 return pht('Test Payments');
11 }
12
13 public function getConfigureName() {
14 return pht('Test Payments');
15 }
16
17 public function getConfigureDescription() {
18 return pht(
19 'Adds a test provider to allow you to test payments. This allows '.
20 'users to make purchases by clicking a button without actually paying '.
21 'any money.');
22 }
23
24 public function getConfigureProvidesDescription() {
25 return pht('This merchant accepts test payments.');
26 }
27
28 public function getConfigureInstructions() {
29 return pht('This provider does not require any special configuration.');
30 }
31
32 public function canRunConfigurationTest() {
33 return false;
34 }
35
36 public function getPaymentMethodDescription() {
37 return pht('Add Mountain of Virtual Wealth');
38 }
39
40 public function getPaymentMethodIcon() {
41 return 'TestPayment';
42 }
43
44 public function getPaymentMethodProviderDescription() {
45 return pht('Infinite Free Money');
46 }
47
48 public function getDefaultPaymentMethodDisplayName(
49 PhortunePaymentMethod $method) {
50 return pht('Vast Wealth');
51 }
52
53 protected function executeCharge(
54 PhortunePaymentMethod $payment_method,
55 PhortuneCharge $charge) {
56 return;
57 }
58
59 protected function executeRefund(
60 PhortuneCharge $charge,
61 PhortuneCharge $refund) {
62 return;
63 }
64
65 public function updateCharge(PhortuneCharge $charge) {
66 return;
67 }
68
69 public function getAllConfigurableProperties() {
70 return array();
71 }
72
73 public function getAllConfigurableSecretProperties() {
74 return array();
75 }
76
77 public function processEditForm(
78 AphrontRequest $request,
79 array $values) {
80
81 $errors = array();
82 $issues = array();
83 $values = array();
84
85 return array($errors, $issues, $values);
86 }
87
88 public function extendEditForm(
89 AphrontRequest $request,
90 AphrontFormView $form,
91 array $values,
92 array $issues) {
93 return;
94 }
95
96
97
98/* -( Adding Payment Methods )--------------------------------------------- */
99
100
101 public function canCreatePaymentMethods() {
102 return true;
103 }
104
105
106 public function translateCreatePaymentMethodErrorCode($error_code) {
107 return $error_code;
108 }
109
110
111 public function getCreatePaymentMethodErrorMessage($error_code) {
112 return null;
113 }
114
115
116 public function validateCreatePaymentMethodToken(array $token) {
117 return true;
118 }
119
120
121 public function createPaymentMethodFromRequest(
122 AphrontRequest $request,
123 PhortunePaymentMethod $method,
124 array $token) {
125
126 $method
127 ->setExpires('2050', '01')
128 ->setBrand('FreeMoney')
129 ->setLastFourDigits('9999')
130 ->setMetadata(
131 array(
132 'type' => 'test.wealth',
133 ));
134
135 return array();
136 }
137
138
139 /**
140 * @task addmethod
141 */
142 public function renderCreatePaymentMethodForm(
143 AphrontRequest $request,
144 array $errors) {
145
146 $ccform = id(new PhortuneCreditCardForm())
147 ->setSecurityAssurance(
148 pht('This is a test payment provider.'))
149 ->setUser($request->getUser())
150 ->setErrors($errors);
151
152 Javelin::initBehavior(
153 'test-payment-form',
154 array(
155 'formID' => $ccform->getFormID(),
156 ));
157
158 return $ccform->buildForm();
159 }
160}