1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Payment request |
4
|
|
|
* |
5
|
|
|
* @author Pronamic <[email protected]> |
6
|
|
|
* @copyright 2005-2019 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
|
|
|
* Title: Adyen payment request |
15
|
|
|
* Description: |
16
|
|
|
* Copyright: 2005-2019 Pronamic |
17
|
|
|
* Company: Pronamic |
18
|
|
|
* |
19
|
|
|
* @link https://docs.adyen.com/api-explorer/#/PaymentSetupAndVerificationService/v40/payments |
20
|
|
|
* |
21
|
|
|
* @author Reüel van der Steege |
22
|
|
|
* @version 1.0.0 |
23
|
|
|
* @since 1.0.0 |
24
|
|
|
*/ |
25
|
|
|
class PaymentRequest { |
26
|
|
|
/** |
27
|
|
|
* The transaction amount needs to be represented in minor units according to the table below. |
28
|
|
|
* |
29
|
|
|
* Some currencies do not have decimal points, such as JPY, and some have 3 decimal points, such as BHD. |
30
|
|
|
* For example, 10 GBP is submitted as 1000, whereas 10 JPY is submitted as 10. |
31
|
|
|
* |
32
|
|
|
* @link https://docs.adyen.com/developers/development-resources/currency-codes |
33
|
|
|
* |
34
|
|
|
* @var int |
35
|
|
|
*/ |
36
|
|
|
public $amount_value; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Currency code. |
40
|
|
|
* |
41
|
|
|
* @link https://docs.adyen.com/developers/development-resources/currency-codes |
42
|
|
|
* |
43
|
|
|
* @var string |
44
|
|
|
*/ |
45
|
|
|
public $currency; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* The merchant account identifier, with which you want to process the transaction. |
49
|
|
|
* |
50
|
|
|
* @var string |
51
|
|
|
*/ |
52
|
|
|
public $merchant_account; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* The collection that contains the type of the payment method and its |
56
|
|
|
* specific information (e.g. idealIssuer). |
57
|
|
|
* |
58
|
|
|
* @var array |
59
|
|
|
*/ |
60
|
|
|
public $payment_method; |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* The reference to uniquely identify a payment. This reference is used in all communication |
64
|
|
|
* with you about the payment status. We recommend using a unique value per payment; |
65
|
|
|
* however, it is not a requirement. If you need to provide multiple references for |
66
|
|
|
* a transaction, separate them with hyphens ("-"). Maximum length: 80 characters. |
67
|
|
|
* |
68
|
|
|
* @var string |
69
|
|
|
*/ |
70
|
|
|
public $reference; |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* The URL to return to. |
74
|
|
|
* |
75
|
|
|
* @var string |
76
|
|
|
*/ |
77
|
|
|
public $return_url; |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* The shopper IP. |
81
|
|
|
* |
82
|
|
|
* @var string |
83
|
|
|
*/ |
84
|
|
|
public $shopper_ip; |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* The shopper gender. |
88
|
|
|
* |
89
|
|
|
* @var string |
90
|
|
|
*/ |
91
|
|
|
public $shopper_gender; |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* The shopper first name. |
95
|
|
|
* |
96
|
|
|
* @var string |
97
|
|
|
*/ |
98
|
|
|
public $shopper_first_name; |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* The name's infix, if applicable. A maximum length of twenty (20) characters is imposed. |
102
|
|
|
* |
103
|
|
|
* @var string |
104
|
|
|
*/ |
105
|
|
|
public $shopper_name_infix; |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* The shopper last name. |
109
|
|
|
* |
110
|
|
|
* @var string |
111
|
|
|
*/ |
112
|
|
|
public $shopper_last_name; |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* The combination of a language code and a country code to specify the language to be used in the payment. |
116
|
|
|
* |
117
|
|
|
* @var string |
118
|
|
|
*/ |
119
|
|
|
public $shopper_locale; |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* The shopper's reference to uniquely identify this shopper (e.g. user ID or account ID). This field is |
123
|
|
|
* required for recurring payments |
124
|
|
|
* |
125
|
|
|
* @var string |
126
|
|
|
*/ |
127
|
|
|
public $shopper_reference; |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* The text to appear on the shopper's bank statement. |
131
|
|
|
* |
132
|
|
|
* @var string |
133
|
|
|
*/ |
134
|
|
|
public $shopper_statement; |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* The shopper's telephone number. |
138
|
|
|
* |
139
|
|
|
* @var string |
140
|
|
|
*/ |
141
|
|
|
public $shopper_telephone_number; |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* Get array of this Adyen payment request object. |
145
|
|
|
* |
146
|
|
|
* @return array |
147
|
|
|
*/ |
148
|
|
|
public function get_array() { |
149
|
|
|
$array = array( |
150
|
|
|
'amount' => array( |
151
|
|
|
'currency' => $this->currency, |
152
|
|
|
'value' => $this->amount_value, |
153
|
|
|
), |
154
|
|
|
'merchantAccount' => $this->merchant_account, |
155
|
|
|
'paymentMethod' => $this->payment_method, |
156
|
|
|
'reference' => $this->reference, |
157
|
|
|
'returnUrl' => $this->return_url, |
158
|
|
|
'shopperIp' => $this->shopper_ip, |
159
|
|
|
'shopperName' => array( |
160
|
|
|
'firstName' => $this->shopper_first_name, |
161
|
|
|
'gender' => $this->shopper_gender, |
162
|
|
|
'infix' => $this->shopper_name_infix, |
163
|
|
|
'lastName' => $this->shopper_last_name, |
164
|
|
|
), |
165
|
|
|
'shopperLocale' => $this->shopper_locale, |
166
|
|
|
'shopperReference' => $this->shopper_reference, |
167
|
|
|
'shopperStatement' => $this->shopper_statement, |
168
|
|
|
'telephoneNumber' => $this->shopper_telephone_number, |
169
|
|
|
); |
170
|
|
|
|
171
|
|
|
/* |
172
|
|
|
* Array filter will remove values NULL, FALSE and empty strings ('') |
173
|
|
|
*/ |
174
|
|
|
$array['paymentMethod'] = (object) array_filter( $array['paymentMethod'] ); |
175
|
|
|
$array['shopperName'] = (object) array_filter( $array['shopperName'] ); |
176
|
|
|
$array = array_filter( $array ); |
177
|
|
|
|
178
|
|
|
return $array; |
179
|
|
|
} |
180
|
|
|
} |
181
|
|
|
|