-
Notifications
You must be signed in to change notification settings - Fork 1
/
Charge.php
291 lines (285 loc) · 13 KB
/
Charge.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
<?php
namespace Dfe\PostFinance;
use Magento\Sales\Model\Order\Address as OA;
/**
* 2017-08-18
* 2017-08-19
* Note 1.
* The charge parameters are described in the Chapter 4.2 «Form parameters» of the web documentation:
* https://e-payment-postfinance.v-psp.com/en/en/guides/integration%20guides/e-commerce#formparameters
*
* Note 2.
* Although strictly taken the PSPID, ORDERID, AMOUNT, CURRENCY and LANGUAGE fields are sufficient,
* we nevertheless strongly recommend you to also send us:
* address (OWNERADDRESS)
* country (OWNERCTY)
* customer name (CN)
* customer’s e-mail (EMAIL)
* postcode/ZIP (OWNERZIP)
* telephone number (OWNERTELNO)
* town/city (OWNERTOWN)
* as they can be useful tools for fraud prevention.
*
* Note 3.
* The data format is described here:
* 3.1) BillPay: https://e-payment-postfinance.v-psp.com/it/it/guides/integration%20guides/billpay/integration
* 3.2) DirectLink (server-to-server)
* https://e-payment-postfinance.v-psp.com/en/en/guides/integration%20guides/directlink#requestparameters
* 3.3) [PostFinance] «Fraud Detection Module Advanced: Scoring», v.4.4.5: https://mage2.pro/t/4351
* 3.4) [PostFinance] «Fraud Detection Module Advanced: Checklist», v.4.4.5: https://mage2.pro/t/4352
* @method Method m()
* @method Settings s()
*/
final class Charge extends \Df\PaypalClone\Charge {
/**
* 2017-08-19
* «Amount to be paid,
* MULTIPLIED BY 100 since the format of the amount must not contain any decimals or other separators.
* The AMOUNT has to be assigned dynamically.»
* Required. Numeric.
* @override
* @see \Df\PaypalClone\Charge::k_Amount()
* @used-by \Df\PaypalClone\Charge::p()
*/
protected function k_Amount():string {return 'AMOUNT';}
/**
* 2017-08-19
* «Currency of the order. ISO alpha code, e.g. EUR, USD, GBP, etc.».
* Required. Alphanumeric (3).
* @override
* @see \Df\PaypalClone\Charge::k_Currency()
* @used-by \Df\PaypalClone\Charge::p()
*/
protected function k_Currency():string {return 'CURRENCY';}
/**
* 2017-08-19 «Customer email address». Optional.
* @override
* @see \Df\PaypalClone\Charge::k_Email()
* @used-by \Df\PaypalClone\Charge::p()
*/
protected function k_Email():string {return 'EMAIL';}
/**
* 2017-08-19
* «Your affiliation name in our system».
* `[PostFinance] What is my PSPID?` https://mage2.pro/t/4349
* Required. Alphanumeric (30).
* @override
* @see \Df\PaypalClone\Charge::k_MerchantId()
* @used-by \Df\PaypalClone\Charge::p()
*/
protected function k_MerchantId():string {return 'PSPID';}
/**
* 2017-08-18
* 2017-08-19
* «Your order number (merchant reference).
* The system checks that a payment has not been requested twice for the same order.
* The ORDERID has to be assigned dynamically.»
* Required. Alphanumeric (40).
* 2017-08-21
* Despite the documentation says that an order number should be alphanumeric,
* really the numbers like «ORD-2017/08-01050» are allowed.
* @override
* @see \Df\PaypalClone\Charge::k_RequestId()
* @used-by \Df\PaypalClone\Charge::p()
*/
protected function k_RequestId():string {return 'ORDERID';}
/**
* 2017-08-18
* @override
* @see \Df\PaypalClone\Charge::k_Signature()
* @used-by \Df\PaypalClone\Charge::p()
*/
protected function k_Signature():string {return 'SHASIGN';}
/**
* 2017-08-18
* @override
* @see \Df\PaypalClone\Charge::pCharge()
* @used-by \Df\PaypalClone\Charge::p()
* @return array(string => mixed)
*/
protected function pCharge():array {
$ba = $this->addressB(); /** @var OA $oa */
return [
/**
* 2017-08-22
* «Integrate with PostFinance e-Commerce» → «7. Transaction feedback» →
* «7.2. Redirection depending on transaction result»:
*
* «There are four URLs which our system can redirect the customer to after a transaction,
* depending on the result.
* These are "ACCEPTURL", "EXCEPTIONURL", "CANCELURL" and "DECLINEURL".
* The URLs can be configured or submitted as follows:
* <...>
* Submission of the URLs in the hidden fields of the order form:
* <input type="hidden" name="ACCEPTURL" value="">
* <input type="hidden" name="DECLINEURL" value="">
* <input type="hidden" name="EXCEPTIONURL" value="">
* <input type="hidden" name="CANCELURL" value="">
*
* `ACCEPTURL`
* URL of the web page to display to the customer when the payment has been authorised (status 5),
* stored (status 4), accepted (status 9) or is waiting to be accepted (pending status 41, 51 or 91).
*
* `CANCELURL`
* URL of the web page to display to the customer when he cancels the payment (status 1).
* If this field is empty, the customer will be redirected to the DECLINEURL instead.
*
* `DECLINEURL`
* URL of the web page to show the customer when the acquirer declines the authorisation (status 2 or 93)
* more than the maximum permissible number of times.
*
* `EXCEPTIONURL`
* URL of the web page to display to the customer when the payment result is uncertain (status 52 or 92).
* If this field is empty, the customer will be redirected to the ACCEPTURL instead.»
* https://e-payment-postfinance.v-psp.com/en/en/guides/integration%20guides/e-commerce/transaction-feedback#basicredirection
*/
'ACCEPTURL' => $this->customerReturnRemote()
/**
* 2017-08-19
* *) Integrate with PostFinance e-Commerce:
* «Customer name. Will be pre-initialised (but still editable)
* in the Customer Name field of the credit card details.»
* Optional.
* https://e-payment-postfinance.v-psp.com/en/en/guides/integration%20guides/e-commerce#formparameters
* *) BillPay: not mentioned.
* *) DirectLink (server-to-server): «Customer name». Optional. Alphanumeric (35).
* *) Fraud Detection Module:
* «The cardholder name can contain a maximum of 35 characters.
* This parameter can be sent via Ogone e-Commerce, DirectLink and Batch.
* Please note that for Ogone e-Commerce the cardholder’s name
* will also be captured via the Ogone payment page,
* where the cardholder’s name is a mandatory field.»
* Rules/Checks:
* *) Name blacklist
* *) Name greylist
* *) Passenger name different from cardholder name.
* https://mage2.pro/t/4351
* https://mage2.pro/t/4352
*/
,'CN' => $this->customerName()
/**
* 2017-08-19
* *) Integrate with PostFinance e-Commerce: «Customer street name and number». Optional.
* https://e-payment-postfinance.v-psp.com/en/en/guides/integration%20guides/e-commerce#formparameters
* *) BillPay: «Invoicing address». Optional. Alphanumeric (35).
* https://e-payment-postfinance.v-psp.com/it/it/guides/integration%20guides/billpay/integration#deliveryinvoicingdata
* *) DirectLink (server-to-server): «Customer street name and number». Optional. Alphanumeric (50).
* https://e-payment-postfinance.v-psp.com/en/en/guides/integration%20guides/directlink#requestparameters
* *) Fraud Detection Module:
* «Customer’s address may contain a maximum of 35 characters.»
* Rules/Checks: «Invoicing address is a P.O. Box.»
* https://mage2.pro/t/4351
* https://mage2.pro/t/4352
*/
,'OWNERADDRESS' => df_cc_s($ba->getStreet())
/**
* 2017-08-19
* *) Integrate with PostFinance e-Commerce: «Customer country». Optional.
* https://e-payment-postfinance.v-psp.com/en/en/guides/integration%20guides/e-commerce#formparameters
* *) BillPay: «Invoicing country code». Optional. Alphanumeric (2).
* https://e-payment-postfinance.v-psp.com/it/it/guides/integration%20guides/billpay/integration#deliveryinvoicingdata
* *) DirectLink (server-to-server): «Customer’s country, e.g. BE, NL, FR, etc.».
* Optional. Alphanumeric (2).
* https://e-payment-postfinance.v-psp.com/en/en/guides/integration%20guides/directlink#requestparameters
* *) Fraud Detection Module:
* «Customers invoicing country may contain a maximum of 2 characters.
* Country in ISO 3166-1-alpha-2 code as can be found on
* http://www.iso.org/iso/en/prodsservices/iso3166ma/02iso-3166-code-lists/list-en1.html.»
* Rules/Checks: «Number of different countries.»
* https://mage2.pro/t/4351
* https://mage2.pro/t/4352
* *) Fraud Detection Module (basic):
* «Before our system can apply the filters you set,
* you must either send your customer's country code
* in the hidden `OWNERCTY` field for each transaction,
* or enter `?` in the `OWNERCTY` field
* if you want our system to automatically detect your customer's country from his IP address.»
* https://mage2.pro/t/4353
*/
,'OWNERCTY' => $ba->getCountryId()
/**
* 2017-08-19
* *) Integrate with PostFinance e-Commerce: «Customer telephone number». Optional.
* https://e-payment-postfinance.v-psp.com/en/en/guides/integration%20guides/e-commerce#formparameters
* *) BillPay: not mentioned.
* *) DirectLink (server-to-server): «Customer’s telephone number». Optional. Alphanumeric (30).
* https://e-payment-postfinance.v-psp.com/en/en/guides/integration%20guides/directlink#requestparameters
* *) Fraud Detection Module:
* «Customer’s telephone number may contain a maximum of 30 characters for all Ogone modules
* with the exception of Ogone Batch which has a maximum of 20 characters.
* Special characters (“+” or “/” for instance) are allowed in this field.
* It’s best to be consistent in the way you send the phone numbers.»
* Rules/Checks:
* *) Telephone number greylist
* *) Telephone number blacklist
* https://mage2.pro/t/4351
* https://mage2.pro/t/4352
*/
,'OWNERTELNO' => $this->customerPhone()
/**
* 2017-08-19
* *) Integrate with PostFinance e-Commerce: «Customer town/city/...». Optional.
* https://e-payment-postfinance.v-psp.com/en/en/guides/integration%20guides/e-commerce#formparameters
* *) BillPay: «Invoicing city». Optional. Alphanumeric (25).
* *) DirectLink (server-to-server): «Customer’s town/city name». Optional. Alphanumeric (40).
* https://e-payment-postfinance.v-psp.com/en/en/guides/integration%20guides/directlink#requestparameters
* *) Fraud Detection Module: not mentioned.
*/
,'OWNERTOWN' => $ba->getCity()
# 2017-08-19 «Customer postcode or ZIP code». Optional. Alphanumeric (10).
/**
* 2017-08-19
* *) Integrate with PostFinance e-Commerce:
* «Customer postcode or ZIP code», Optional.
* https://e-payment-postfinance.v-psp.com/en/en/guides/integration%20guides/e-commerce#formparameters
* *) BillPay: «Invoicing zip/postcode». Optional. Alphanumeric (10).
* https://e-payment-postfinance.v-psp.com/it/it/guides/integration%20guides/billpay/integration#deliveryinvoicingdata
* *) DirectLink (server-to-server): «Customer’s postcode.». Optional. Alphanumeric (10).
* https://e-payment-postfinance.v-psp.com/en/en/guides/integration%20guides/directlink#requestparameters
* *) Fraud Detection Module:
* «Customer’s zip/postal code may contain a maximum of 10 characters»
* Rules/Checks:
* *) Risky zip/postcodes
* *) Advanced address verification check for specific card brands only
* https://mage2.pro/t/4351
* https://mage2.pro/t/4352
*/
,'OWNERZIP' => $ba->getPostcode()
/**
* 2017-08-22
* «Integrate with PostFinance e-Commerce» → «7. Transaction feedback» →
* «7.2. Redirection depending on transaction result»:
*
* «There are four URLs which our system can redirect the customer to after a transaction,
* depending on the result.
* These are "ACCEPTURL", "EXCEPTIONURL", "CANCELURL" and "DECLINEURL".
* The URLs can be configured or submitted as follows:
* <...>
* Submission of the URLs in the hidden fields of the order form:
* <input type="hidden" name="ACCEPTURL" value="">
* <input type="hidden" name="DECLINEURL" value="">
* <input type="hidden" name="EXCEPTIONURL" value="">
* <input type="hidden" name="CANCELURL" value="">
*
* `ACCEPTURL`
* URL of the web page to display to the customer when the payment has been authorised (status 5),
* stored (status 4), accepted (status 9) or is waiting to be accepted (pending status 41, 51 or 91).
*
* `CANCELURL`
* URL of the web page to display to the customer when he cancels the payment (status 1).
* If this field is empty, the customer will be redirected to the DECLINEURL instead.
*
* `DECLINEURL`
* URL of the web page to show the customer when the acquirer declines the authorisation (status 2 or 93)
* more than the maximum permissible number of times.
*
* `EXCEPTIONURL`
* URL of the web page to display to the customer when the payment result is uncertain (status 52 or 92).
* If this field is empty, the customer will be redirected to the ACCEPTURL instead.»
* https://e-payment-postfinance.v-psp.com/en/en/guides/integration%20guides/e-commerce/transaction-feedback#basicredirection
*/
] + array_fill_keys(['CANCELURL', 'DECLINEURL', 'EXCEPTIONURL'],
$this->customerReturnRemoteWithFailure()
);
}
}