|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Payment methods 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
|
|
|
/** |
|
14
|
|
|
* Payment methods request |
|
15
|
|
|
* |
|
16
|
|
|
* @link https://docs.adyen.com/api-explorer/#/PaymentSetupAndVerificationService/v51/paymentMethods |
|
17
|
|
|
* |
|
18
|
|
|
* @author Remco Tolsma |
|
19
|
|
|
* @version 1.0.0 |
|
20
|
|
|
* @since 1.0.0 |
|
21
|
|
|
*/ |
|
22
|
|
|
class PaymentMethodsRequest extends Request { |
|
23
|
|
|
/** |
|
24
|
|
|
* The merchant account identifier, with which you want to process the transaction. |
|
25
|
|
|
* |
|
26
|
|
|
* @var string |
|
27
|
|
|
*/ |
|
28
|
|
|
private $merchant_account; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* The shopper's country code. |
|
32
|
|
|
* |
|
33
|
|
|
* @var string|null |
|
34
|
|
|
*/ |
|
35
|
7 |
|
private $country_code; |
|
36
|
7 |
|
|
|
37
|
7 |
|
/** |
|
38
|
|
|
* The amount information for the transaction. |
|
39
|
|
|
* |
|
40
|
|
|
* @var Amount|null |
|
41
|
|
|
*/ |
|
42
|
|
|
private $amount; |
|
43
|
|
|
|
|
44
|
6 |
|
/** |
|
45
|
|
|
* Construct a payment request object. |
|
46
|
6 |
|
* |
|
47
|
|
|
* @param string $merchant_account The merchant account identifier. |
|
48
|
|
|
*/ |
|
49
|
|
|
public function __construct( $merchant_account ) { |
|
50
|
6 |
|
$this->merchant_account = $merchant_account; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Set the shopper's country code. |
|
55
|
|
|
* |
|
56
|
|
|
* @param string|null $country_code The shopper's country code. |
|
57
|
|
|
*/ |
|
58
|
|
|
public function set_country_code( $country_code ) { |
|
59
|
|
|
$this->country_code = $country_code; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Set the amount information for the transaction. |
|
64
|
|
|
* |
|
65
|
|
|
* @param Amount|null $amount The amount information for the transaction. |
|
66
|
|
|
*/ |
|
67
|
|
|
public function set_amount( Amount $amount = null ) { |
|
68
|
|
|
$this->amount = $amount; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Get JSON. |
|
73
|
|
|
* |
|
74
|
|
|
* @return object |
|
75
|
|
|
*/ |
|
76
|
|
|
public function get_json() { |
|
77
|
|
|
$properties = array( |
|
78
|
|
|
'merchantAccount' => $this->merchant_account, |
|
79
|
|
|
); |
|
80
|
|
|
|
|
81
|
|
|
if ( null !== $this->country_code ) { |
|
82
|
|
|
$properties['countryCode'] = $this->country_code; |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
if ( null !== $this->amount ) { |
|
86
|
|
|
$properties['amount'] = $this->amount->get_json(); |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
// Return object. |
|
90
|
|
|
$object = (object) $properties; |
|
91
|
|
|
|
|
92
|
|
|
return $object; |
|
93
|
|
|
} |
|
94
|
|
|
} |
|
95
|
|
|
|