|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Abstract payment request |
|
4
|
|
|
* |
|
5
|
|
|
* @author Pronamic <[email protected]> |
|
6
|
|
|
* @copyright 2005-2020 Pronamic |
|
7
|
|
|
* @license GPL-3.0-or-later |
|
8
|
|
|
* @package Pronamic\WordPress\Pay\Gateways\Adyen |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace Pronamic\WordPress\Pay\Gateways\Adyen; |
|
12
|
|
|
|
|
13
|
|
|
use DateTime; |
|
14
|
|
|
use InvalidArgumentException; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Abstract payment request |
|
18
|
|
|
* |
|
19
|
|
|
* @link https://docs.adyen.com/api-explorer/#/PaymentSetupAndVerificationService/v41/payments |
|
20
|
|
|
* @link https://docs.adyen.com/api-explorer/#/PaymentSetupAndVerificationService/v41/paymentSession |
|
21
|
|
|
* |
|
22
|
|
|
* @author Remco Tolsma |
|
23
|
|
|
* @version 1.1.2 |
|
24
|
|
|
* @since 1.0.0 |
|
25
|
|
|
*/ |
|
26
|
|
|
abstract class AbstractPaymentRequest extends Request { |
|
27
|
|
|
/** |
|
28
|
|
|
* Amount. |
|
29
|
|
|
* |
|
30
|
|
|
* @var Amount |
|
31
|
|
|
*/ |
|
32
|
|
|
private $amount; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Information about your application. |
|
36
|
|
|
* |
|
37
|
|
|
* @link https://docs.adyen.com/api-explorer/#/PaymentSetupAndVerificationService/v51/payments__reqParam_applicationInfo |
|
38
|
|
|
* @var ApplicationInfo|null |
|
39
|
|
|
*/ |
|
40
|
|
|
private $application_info; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Billing address. |
|
44
|
|
|
* |
|
45
|
|
|
* @var Address|null |
|
46
|
|
|
*/ |
|
47
|
|
|
private $billing_address; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Channel. |
|
51
|
|
|
* |
|
52
|
|
|
* The platform where a payment transaction takes place. This field is optional for filtering out |
|
53
|
|
|
* payment methods that are only available on specific platforms. If this value is not set, |
|
54
|
|
|
* then we will try to infer it from the sdkVersion or token. |
|
55
|
|
|
* |
|
56
|
|
|
* Possible values: Android, iOS, Web. |
|
57
|
|
|
* |
|
58
|
|
|
* @var string|null |
|
59
|
|
|
*/ |
|
60
|
|
|
private $channel; |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* The shopper country. |
|
64
|
|
|
* |
|
65
|
|
|
* Format: ISO 3166-1 alpha-2 Example: NL or DE |
|
66
|
|
|
* |
|
67
|
|
|
* @var string|null |
|
68
|
|
|
*/ |
|
69
|
|
|
private $country_code; |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Date of birth. |
|
73
|
|
|
* |
|
74
|
|
|
* @var DateTime|null |
|
75
|
|
|
*/ |
|
76
|
|
|
private $date_of_birth; |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* The address where the purchased goods should be delivered |
|
80
|
|
|
* |
|
81
|
|
|
* @var Address|null |
|
82
|
|
|
*/ |
|
83
|
|
|
private $delivery_address; |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* Line items regarding the payment. |
|
87
|
|
|
* |
|
88
|
|
|
* @var LineItems|null |
|
89
|
|
|
*/ |
|
90
|
|
|
private $line_items; |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* The merchant account identifier, with which you want to process the transaction. |
|
94
|
|
|
* |
|
95
|
|
|
* @var string |
|
96
|
|
|
*/ |
|
97
|
|
|
private $merchant_account; |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* This reference allows linking multiple transactions to each other for reporting |
|
101
|
|
|
* purposes (i.e. order auth-rate). The reference should be unique per billing cycle. |
|
102
|
|
|
* The same merchant order reference should never be reused after the first authorised |
|
103
|
|
|
* attempt. If used, this field should be supplied for all incoming authorisations. |
|
104
|
|
|
* |
|
105
|
|
|
* @var string|null |
|
106
|
|
|
*/ |
|
107
|
|
|
private $merchant_order_reference; |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* Metadata consists of entries, each of which includes a key and a value. Limitations: Maximum 20 key-value |
|
111
|
|
|
* pairs per request. When exceeding, the "177" error occurs: "Metadata size exceeds limit". |
|
112
|
|
|
* |
|
113
|
|
|
* @var array<string,int|string>|null |
|
114
|
|
|
*/ |
|
115
|
|
|
private $metadata; |
|
116
|
|
|
|
|
117
|
|
|
/** |
|
118
|
|
|
* The reference to uniquely identify a payment. This reference is used in all communication |
|
119
|
|
|
* with you about the payment status. We recommend using a unique value per payment; |
|
120
|
|
|
* however, it is not a requirement. If you need to provide multiple references for |
|
121
|
|
|
* a transaction, separate them with hyphens ("-"). Maximum length: 80 characters. |
|
122
|
|
|
* |
|
123
|
|
|
* @var string |
|
124
|
|
|
*/ |
|
125
|
|
|
private $reference; |
|
126
|
|
|
|
|
127
|
|
|
/** |
|
128
|
|
|
* The URL to return to. |
|
129
|
|
|
* |
|
130
|
|
|
* @var string |
|
131
|
|
|
*/ |
|
132
|
|
|
private $return_url; |
|
133
|
|
|
|
|
134
|
|
|
/** |
|
135
|
|
|
* The shopper's IP address. |
|
136
|
|
|
* |
|
137
|
|
|
* @var string|null |
|
138
|
|
|
*/ |
|
139
|
|
|
private $shopper_ip; |
|
140
|
|
|
|
|
141
|
|
|
/** |
|
142
|
|
|
* The combination of a language code and a country code to specify the language to be used in the payment. |
|
143
|
|
|
* |
|
144
|
|
|
* @var string|null |
|
145
|
|
|
*/ |
|
146
|
|
|
private $shopper_locale; |
|
147
|
|
|
|
|
148
|
|
|
/** |
|
149
|
|
|
* The shopper's full name and gender (if specified) |
|
150
|
|
|
* |
|
151
|
|
|
* @var Name|null |
|
152
|
|
|
*/ |
|
153
|
|
|
private $shopper_name; |
|
154
|
|
|
|
|
155
|
|
|
/** |
|
156
|
|
|
* The shopper's email address. We recommend that you provide this data, as it is used in velocity fraud checks. |
|
157
|
|
|
* |
|
158
|
|
|
* @var string|null |
|
159
|
|
|
*/ |
|
160
|
|
|
private $shopper_email; |
|
161
|
|
|
|
|
162
|
|
|
/** |
|
163
|
|
|
* The shopper's reference to uniquely identify this shopper (e.g. user ID or account ID). This field is |
|
164
|
|
|
* required for recurring payments |
|
165
|
|
|
* |
|
166
|
|
|
* @link https://docs.adyen.com/api-explorer/#/PaymentSetupAndVerificationService/v51/payments__reqParam_shopperReference |
|
167
|
|
|
* @var string|null |
|
168
|
|
|
*/ |
|
169
|
|
|
private $shopper_reference; |
|
170
|
|
|
|
|
171
|
|
|
/** |
|
172
|
|
|
* The text to appear on the shopper's bank statement. |
|
173
|
|
|
* |
|
174
|
|
|
* @var string|null |
|
175
|
|
|
*/ |
|
176
|
|
|
private $shopper_statement; |
|
177
|
|
|
|
|
178
|
|
|
/** |
|
179
|
|
|
* The shopper's telephone number |
|
180
|
|
|
* |
|
181
|
|
|
* @var string|null |
|
182
|
|
|
*/ |
|
183
|
|
|
private $telephone_number; |
|
184
|
|
|
|
|
185
|
|
|
/** |
|
186
|
|
|
* Construct a payment request object. |
|
187
|
|
|
* |
|
188
|
|
|
* @param Amount $amount The amount information for the transaction. |
|
189
|
|
|
* @param string $merchant_account The merchant account identifier, with which you want to process the transaction. |
|
190
|
|
|
* @param string $reference The reference to uniquely identify a payment. |
|
191
|
|
|
* @param string $return_url The URL to return to. |
|
192
|
|
|
*/ |
|
193
|
8 |
|
public function __construct( Amount $amount, $merchant_account, $reference, $return_url ) { |
|
194
|
8 |
|
$this->amount = $amount; |
|
195
|
8 |
|
$this->merchant_account = $merchant_account; |
|
196
|
8 |
|
$this->reference = $reference; |
|
197
|
8 |
|
$this->return_url = $return_url; |
|
198
|
8 |
|
} |
|
199
|
|
|
|
|
200
|
|
|
/** |
|
201
|
|
|
* Get amount. |
|
202
|
|
|
* |
|
203
|
|
|
* @return Amount |
|
204
|
|
|
*/ |
|
205
|
6 |
|
public function get_amount() { |
|
206
|
6 |
|
return $this->amount; |
|
207
|
|
|
} |
|
208
|
|
|
|
|
209
|
|
|
/** |
|
210
|
|
|
* Get application info. |
|
211
|
|
|
* |
|
212
|
|
|
* @return ApplicationInfo|null |
|
213
|
|
|
*/ |
|
214
|
|
|
public function get_application_info() { |
|
215
|
|
|
return $this->application_info; |
|
216
|
|
|
} |
|
217
|
|
|
|
|
218
|
|
|
/** |
|
219
|
|
|
* Set application info. |
|
220
|
|
|
* |
|
221
|
|
|
* @param ApplicationInfo|null $application_info Application info. |
|
222
|
|
|
* @return void |
|
223
|
|
|
*/ |
|
224
|
1 |
|
public function set_application_info( $application_info ) { |
|
225
|
1 |
|
$this->application_info = $application_info; |
|
226
|
1 |
|
} |
|
227
|
|
|
|
|
228
|
|
|
/** |
|
229
|
|
|
* Get billing address. |
|
230
|
|
|
* |
|
231
|
|
|
* @return Address|null |
|
232
|
|
|
*/ |
|
233
|
1 |
|
public function get_billing_address() { |
|
234
|
1 |
|
return $this->billing_address; |
|
235
|
|
|
} |
|
236
|
|
|
|
|
237
|
|
|
/** |
|
238
|
|
|
* Set billing address. |
|
239
|
|
|
* |
|
240
|
|
|
* @param Address|null $billing_address Billing address. |
|
241
|
|
|
* @return void |
|
242
|
|
|
*/ |
|
243
|
1 |
|
public function set_billing_address( Address $billing_address = null ) { |
|
244
|
1 |
|
$this->billing_address = $billing_address; |
|
245
|
1 |
|
} |
|
246
|
|
|
|
|
247
|
|
|
/** |
|
248
|
|
|
* Get channel. |
|
249
|
|
|
* |
|
250
|
|
|
* @return string|null |
|
251
|
|
|
*/ |
|
252
|
2 |
|
public function get_channel() { |
|
253
|
2 |
|
return $this->channel; |
|
254
|
|
|
} |
|
255
|
|
|
|
|
256
|
|
|
/** |
|
257
|
|
|
* Set channel. |
|
258
|
|
|
* |
|
259
|
|
|
* @param string|null $channel Channel. |
|
260
|
|
|
* @return void |
|
261
|
|
|
*/ |
|
262
|
2 |
|
public function set_channel( $channel ) { |
|
263
|
2 |
|
$this->channel = $channel; |
|
264
|
2 |
|
} |
|
265
|
|
|
|
|
266
|
|
|
/** |
|
267
|
|
|
* Get country code. |
|
268
|
|
|
* |
|
269
|
|
|
* @return string|null |
|
270
|
|
|
*/ |
|
271
|
2 |
|
public function get_country_code() { |
|
272
|
2 |
|
return $this->country_code; |
|
273
|
|
|
} |
|
274
|
|
|
|
|
275
|
|
|
/** |
|
276
|
|
|
* Set country code. |
|
277
|
|
|
* |
|
278
|
|
|
* @param string|null $country_code Country code. |
|
279
|
|
|
* @return void |
|
280
|
|
|
* @throws InvalidArgumentException Throws invalid argument exception when country code is not 2 characters. |
|
281
|
|
|
*/ |
|
282
|
5 |
|
public function set_country_code( $country_code ) { |
|
283
|
5 |
|
if ( null !== $country_code && 2 !== strlen( $country_code ) ) { |
|
284
|
1 |
|
throw new InvalidArgumentException( |
|
285
|
1 |
|
sprintf( |
|
286
|
1 |
|
'Given country code `%s` not ISO 3166-1 alpha-2 value.', |
|
287
|
|
|
$country_code |
|
288
|
|
|
) |
|
289
|
|
|
); |
|
290
|
|
|
} |
|
291
|
|
|
|
|
292
|
4 |
|
$this->country_code = $country_code; |
|
293
|
4 |
|
} |
|
294
|
|
|
|
|
295
|
|
|
/** |
|
296
|
|
|
* Get date of birth. |
|
297
|
|
|
* |
|
298
|
|
|
* @return DateTime|null |
|
299
|
|
|
*/ |
|
300
|
1 |
|
public function get_date_of_birth() { |
|
301
|
1 |
|
return $this->date_of_birth; |
|
302
|
|
|
} |
|
303
|
|
|
|
|
304
|
|
|
/** |
|
305
|
|
|
* Set date of birth. |
|
306
|
|
|
* |
|
307
|
|
|
* @param DateTime|null $date_of_birth Date of birth. |
|
308
|
|
|
* @return void |
|
309
|
|
|
*/ |
|
310
|
2 |
|
public function set_date_of_birth( DateTime $date_of_birth = null ) { |
|
311
|
2 |
|
$this->date_of_birth = $date_of_birth; |
|
312
|
2 |
|
} |
|
313
|
|
|
|
|
314
|
|
|
/** |
|
315
|
|
|
* Get delivery address. |
|
316
|
|
|
* |
|
317
|
|
|
* @return Address|null |
|
318
|
|
|
*/ |
|
319
|
1 |
|
public function get_delivery_address() { |
|
320
|
1 |
|
return $this->delivery_address; |
|
321
|
|
|
} |
|
322
|
|
|
|
|
323
|
|
|
/** |
|
324
|
|
|
* Set delivery address. |
|
325
|
|
|
* |
|
326
|
|
|
* @param Address|null $delivery_address Delivery address. |
|
327
|
|
|
* @return void |
|
328
|
|
|
*/ |
|
329
|
1 |
|
public function set_delivery_address( Address $delivery_address = null ) { |
|
330
|
1 |
|
$this->delivery_address = $delivery_address; |
|
331
|
1 |
|
} |
|
332
|
|
|
|
|
333
|
|
|
/** |
|
334
|
|
|
* Get line items. |
|
335
|
|
|
* |
|
336
|
|
|
* @return LineItems|null |
|
337
|
|
|
*/ |
|
338
|
1 |
|
public function get_line_items() { |
|
339
|
1 |
|
return $this->line_items; |
|
340
|
|
|
} |
|
341
|
|
|
|
|
342
|
|
|
/** |
|
343
|
|
|
* Set line items. |
|
344
|
|
|
* |
|
345
|
|
|
* @param LineItems|null $line_items Line items. |
|
346
|
|
|
* @return void |
|
347
|
|
|
*/ |
|
348
|
1 |
|
public function set_line_items( $line_items ) { |
|
349
|
1 |
|
$this->line_items = $line_items; |
|
350
|
1 |
|
} |
|
351
|
|
|
|
|
352
|
|
|
/** |
|
353
|
|
|
* Create and set new line items. |
|
354
|
|
|
* |
|
355
|
|
|
* @return LineItems |
|
356
|
|
|
*/ |
|
357
|
1 |
|
public function new_line_items() { |
|
358
|
1 |
|
$this->line_items = new LineItems(); |
|
359
|
|
|
|
|
360
|
1 |
|
return $this->line_items; |
|
361
|
|
|
} |
|
362
|
|
|
|
|
363
|
|
|
/** |
|
364
|
|
|
* Get merchant account. |
|
365
|
|
|
* |
|
366
|
|
|
* @return string |
|
367
|
|
|
*/ |
|
368
|
6 |
|
public function get_merchant_account() { |
|
369
|
6 |
|
return $this->merchant_account; |
|
370
|
|
|
} |
|
371
|
|
|
|
|
372
|
|
|
|
|
373
|
|
|
/** |
|
374
|
|
|
* Get merchant order reference. |
|
375
|
|
|
* |
|
376
|
|
|
* @return mixed |
|
377
|
|
|
*/ |
|
378
|
5 |
|
public function get_merchant_order_reference() { |
|
379
|
5 |
|
return $this->merchant_order_reference; |
|
380
|
|
|
} |
|
381
|
|
|
|
|
382
|
|
|
/** |
|
383
|
|
|
* Set merchant order reference. |
|
384
|
|
|
* |
|
385
|
|
|
* @param mixed $merchant_order_reference Merchant order reference. |
|
386
|
|
|
* @return void |
|
387
|
|
|
*/ |
|
388
|
|
|
public function set_merchant_order_reference( $merchant_order_reference ) { |
|
389
|
|
|
$this->merchant_order_reference = $merchant_order_reference; |
|
390
|
|
|
} |
|
391
|
|
|
|
|
392
|
|
|
/** |
|
393
|
|
|
* Get metadata. |
|
394
|
|
|
* |
|
395
|
|
|
* @return array<string,int|string>|null |
|
396
|
|
|
*/ |
|
397
|
5 |
|
public function get_metadata() { |
|
398
|
5 |
|
return $this->metadata; |
|
399
|
|
|
} |
|
400
|
|
|
|
|
401
|
|
|
/** |
|
402
|
|
|
* Set metadata. |
|
403
|
|
|
* |
|
404
|
|
|
* @param array<string,int|string>|null $metadata Metadata. |
|
405
|
|
|
* @return void |
|
406
|
|
|
*/ |
|
407
|
1 |
|
public function set_metadata( $metadata ) { |
|
408
|
1 |
|
$this->metadata = $metadata; |
|
409
|
1 |
|
} |
|
410
|
|
|
|
|
411
|
|
|
/** |
|
412
|
|
|
* Get reference. |
|
413
|
|
|
* |
|
414
|
|
|
* @return string |
|
415
|
|
|
*/ |
|
416
|
6 |
|
public function get_reference() { |
|
417
|
6 |
|
return $this->reference; |
|
418
|
|
|
} |
|
419
|
|
|
|
|
420
|
|
|
/** |
|
421
|
|
|
* Get return URL. |
|
422
|
|
|
* |
|
423
|
|
|
* @return string |
|
424
|
|
|
*/ |
|
425
|
6 |
|
public function get_return_url() { |
|
426
|
6 |
|
return $this->return_url; |
|
427
|
|
|
} |
|
428
|
|
|
|
|
429
|
|
|
/** |
|
430
|
|
|
* Get shopper IP. |
|
431
|
|
|
* |
|
432
|
|
|
* @return string|null |
|
433
|
|
|
*/ |
|
434
|
2 |
|
public function get_shopper_ip() { |
|
435
|
2 |
|
return $this->shopper_ip; |
|
436
|
|
|
} |
|
437
|
|
|
|
|
438
|
|
|
/** |
|
439
|
|
|
* Set shopper IP. |
|
440
|
|
|
* |
|
441
|
|
|
* @param string|null $shopper_ip Shopper IP. |
|
442
|
|
|
* @return void |
|
443
|
|
|
*/ |
|
444
|
2 |
|
public function set_shopper_ip( $shopper_ip ) { |
|
445
|
2 |
|
$this->shopper_ip = $shopper_ip; |
|
446
|
2 |
|
} |
|
447
|
|
|
|
|
448
|
|
|
/** |
|
449
|
|
|
* Get shopper locale. |
|
450
|
|
|
* |
|
451
|
|
|
* @return string|null |
|
452
|
|
|
*/ |
|
453
|
2 |
|
public function get_shopper_locale() { |
|
454
|
2 |
|
return $this->shopper_locale; |
|
455
|
|
|
} |
|
456
|
|
|
|
|
457
|
|
|
/** |
|
458
|
|
|
* Set shopper locale. |
|
459
|
|
|
* |
|
460
|
|
|
* @param string|null $shopper_locale Shopper locale. |
|
461
|
|
|
* @return void |
|
462
|
|
|
*/ |
|
463
|
2 |
|
public function set_shopper_locale( $shopper_locale ) { |
|
464
|
2 |
|
$this->shopper_locale = $shopper_locale; |
|
465
|
2 |
|
} |
|
466
|
|
|
|
|
467
|
|
|
/** |
|
468
|
|
|
* Get shopper name. |
|
469
|
|
|
* |
|
470
|
|
|
* @return Name|null |
|
471
|
|
|
*/ |
|
472
|
1 |
|
public function get_shopper_name() { |
|
473
|
1 |
|
return $this->shopper_name; |
|
474
|
|
|
} |
|
475
|
|
|
|
|
476
|
|
|
/** |
|
477
|
|
|
* Set shopper name. |
|
478
|
|
|
* |
|
479
|
|
|
* @param Name|null $shopper_name Shopper name. |
|
480
|
|
|
* @return void |
|
481
|
|
|
*/ |
|
482
|
1 |
|
public function set_shopper_name( Name $shopper_name = null ) { |
|
483
|
1 |
|
$this->shopper_name = $shopper_name; |
|
484
|
1 |
|
} |
|
485
|
|
|
|
|
486
|
|
|
/** |
|
487
|
|
|
* Get shopper email. |
|
488
|
|
|
* |
|
489
|
|
|
* @return string|null |
|
490
|
|
|
*/ |
|
491
|
|
|
public function get_shopper_email() { |
|
492
|
|
|
return $this->shopper_email; |
|
493
|
|
|
} |
|
494
|
|
|
|
|
495
|
|
|
/** |
|
496
|
|
|
* Set shopper email. |
|
497
|
|
|
* |
|
498
|
|
|
* @param string|null $shopper_email Shopper email. |
|
499
|
|
|
* |
|
500
|
|
|
* @return void |
|
501
|
|
|
*/ |
|
502
|
1 |
|
public function set_shopper_email( $shopper_email = null ) { |
|
503
|
1 |
|
$this->shopper_email = $shopper_email; |
|
504
|
1 |
|
} |
|
505
|
|
|
|
|
506
|
|
|
/** |
|
507
|
|
|
* Get shopper reference. |
|
508
|
|
|
* |
|
509
|
|
|
* @return string|null |
|
510
|
|
|
*/ |
|
511
|
1 |
|
public function get_shopper_reference() { |
|
512
|
1 |
|
return $this->shopper_reference; |
|
513
|
|
|
} |
|
514
|
|
|
|
|
515
|
|
|
/** |
|
516
|
|
|
* Set shopper reference. |
|
517
|
|
|
* |
|
518
|
|
|
* @param string|null $shopper_reference Shopper reference. |
|
519
|
|
|
* @return void |
|
520
|
|
|
*/ |
|
521
|
1 |
|
public function set_shopper_reference( $shopper_reference ) { |
|
522
|
1 |
|
$this->shopper_reference = $shopper_reference; |
|
523
|
1 |
|
} |
|
524
|
|
|
|
|
525
|
|
|
/** |
|
526
|
|
|
* Get shopper statement. |
|
527
|
|
|
* |
|
528
|
|
|
* @return string|null |
|
529
|
|
|
*/ |
|
530
|
2 |
|
public function get_shopper_statement() { |
|
531
|
2 |
|
return $this->shopper_statement; |
|
532
|
|
|
} |
|
533
|
|
|
|
|
534
|
|
|
/** |
|
535
|
|
|
* Set shopper statement. |
|
536
|
|
|
* |
|
537
|
|
|
* @param string|null $shopper_statement Shopper statement. |
|
538
|
|
|
* @return void |
|
539
|
|
|
*/ |
|
540
|
2 |
|
public function set_shopper_statement( $shopper_statement ) { |
|
541
|
2 |
|
$this->shopper_statement = $shopper_statement; |
|
542
|
2 |
|
} |
|
543
|
|
|
|
|
544
|
|
|
/** |
|
545
|
|
|
* Get telephone number. |
|
546
|
|
|
* |
|
547
|
|
|
* @return string|null |
|
548
|
|
|
*/ |
|
549
|
2 |
|
public function get_telephone_number() { |
|
550
|
2 |
|
return $this->telephone_number; |
|
551
|
|
|
} |
|
552
|
|
|
|
|
553
|
|
|
/** |
|
554
|
|
|
* Set shopper statement. |
|
555
|
|
|
* |
|
556
|
|
|
* @param string|null $telephone_number Telephone number. |
|
557
|
|
|
* @return void |
|
558
|
|
|
*/ |
|
559
|
2 |
|
public function set_telephone_number( $telephone_number ) { |
|
560
|
2 |
|
$this->telephone_number = $telephone_number; |
|
561
|
2 |
|
} |
|
562
|
|
|
|
|
563
|
|
|
/** |
|
564
|
|
|
* Get JSON. |
|
565
|
|
|
* |
|
566
|
|
|
* @return object |
|
567
|
|
|
*/ |
|
568
|
5 |
|
public function get_json() { |
|
569
|
5 |
|
$metadata = $this->get_metadata(); |
|
570
|
|
|
|
|
571
|
5 |
|
$properties = Util::filter_null( |
|
572
|
|
|
array( |
|
573
|
5 |
|
'amount' => $this->get_amount()->get_json(), |
|
574
|
5 |
|
'applicationInfo' => $this->application_info, |
|
575
|
5 |
|
'billingAddress' => is_null( $this->billing_address ) ? null : $this->billing_address->get_json(), |
|
576
|
5 |
|
'channel' => $this->channel, |
|
577
|
5 |
|
'countryCode' => $this->country_code, |
|
578
|
5 |
|
'dateOfBirth' => is_null( $this->date_of_birth ) ? null : $this->date_of_birth->format( 'Y-m-d' ), |
|
579
|
5 |
|
'deliveryAddress' => is_null( $this->delivery_address ) ? null : $this->delivery_address->get_json(), |
|
580
|
5 |
|
'lineItems' => is_null( $this->line_items ) ? null : $this->line_items->get_json(), |
|
581
|
5 |
|
'merchantAccount' => $this->get_merchant_account(), |
|
582
|
5 |
|
'merchantOrderReference' => $this->get_merchant_order_reference(), |
|
583
|
5 |
|
'metadata' => empty( $metadata ) ? null : (object) $metadata, |
|
584
|
5 |
|
'reference' => $this->get_reference(), |
|
585
|
5 |
|
'returnUrl' => $this->get_return_url(), |
|
586
|
5 |
|
'shopperIP' => $this->shopper_ip, |
|
587
|
5 |
|
'shopperLocale' => $this->shopper_locale, |
|
588
|
5 |
|
'shopperName' => is_null( $this->shopper_name ) ? null : $this->shopper_name->get_json(), |
|
589
|
5 |
|
'shopperEmail' => $this->shopper_email, |
|
590
|
5 |
|
'shopperReference' => $this->shopper_reference, |
|
591
|
5 |
|
'shopperStatement' => $this->shopper_statement, |
|
592
|
5 |
|
'telephoneNumber' => $this->telephone_number, |
|
593
|
|
|
) |
|
594
|
|
|
); |
|
595
|
|
|
|
|
596
|
5 |
|
$object = (object) $properties; |
|
597
|
|
|
|
|
598
|
5 |
|
return $object; |
|
599
|
|
|
} |
|
600
|
|
|
} |
|
601
|
|
|
|