|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Address |
|
4
|
|
|
* |
|
5
|
|
|
* @author Pronamic <[email protected]> |
|
6
|
|
|
* @copyright 2005-2018 Pronamic |
|
7
|
|
|
* @license GPL-3.0-or-later |
|
8
|
|
|
* @package Pronamic\WordPress\Pay\Gateways\OmniKassa2 |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace Pronamic\WordPress\Pay\Gateways\OmniKassa2; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Address |
|
15
|
|
|
* |
|
16
|
|
|
* @author Remco Tolsma |
|
17
|
|
|
* @version 2.1.0 |
|
18
|
|
|
* @since 2.0.2 |
|
19
|
|
|
*/ |
|
20
|
|
|
class Address { |
|
21
|
|
|
/** |
|
22
|
|
|
* First name. |
|
23
|
|
|
* |
|
24
|
|
|
* @var string |
|
25
|
|
|
*/ |
|
26
|
|
|
private $first_name; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Insert or second name. |
|
30
|
|
|
* |
|
31
|
|
|
* @var string |
|
32
|
|
|
*/ |
|
33
|
|
|
private $middle_name; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Surname. |
|
37
|
|
|
* |
|
38
|
|
|
* @var string |
|
39
|
|
|
*/ |
|
40
|
|
|
private $last_name; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Street. |
|
44
|
|
|
* |
|
45
|
|
|
* Note: In case of payment via Visa, Mastercard, V PAY, |
|
46
|
|
|
* Bancontact and Maestro the street name will be |
|
47
|
|
|
* truncated to 50 characters. |
|
48
|
|
|
* |
|
49
|
|
|
* @var string |
|
50
|
|
|
*/ |
|
51
|
|
|
private $street; |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* House number. |
|
55
|
|
|
* |
|
56
|
|
|
* Note: In case of payment via Visa, Mastercard, V PAY, |
|
57
|
|
|
* Bancontact and Maestro the houseNumber concatenated |
|
58
|
|
|
* with houseNumberAddition (see below) will be |
|
59
|
|
|
* truncated to 10 characters. |
|
60
|
|
|
* |
|
61
|
|
|
* @var string|null |
|
62
|
|
|
*/ |
|
63
|
|
|
private $house_number; |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* House number additions. |
|
67
|
|
|
* |
|
68
|
|
|
* @var string|null |
|
69
|
|
|
*/ |
|
70
|
|
|
private $house_number_addition; |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Postal code. |
|
74
|
|
|
* |
|
75
|
|
|
* @var string |
|
76
|
|
|
*/ |
|
77
|
|
|
private $postal_code; |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* City. |
|
81
|
|
|
* |
|
82
|
|
|
* @var string |
|
83
|
|
|
*/ |
|
84
|
|
|
private $city; |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* Country code, ISO 3166-1 alpha-2. |
|
88
|
|
|
* |
|
89
|
|
|
* @var string |
|
90
|
|
|
*/ |
|
91
|
|
|
private $country_code; |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* Construct address. |
|
95
|
|
|
* |
|
96
|
|
|
* @param string $last_name Last name. |
|
97
|
|
|
* @param string $street Street. |
|
98
|
|
|
* @param string $postal_code Postal code. |
|
99
|
|
|
* @param string $city City. |
|
100
|
|
|
* @param string $country_code Country code. |
|
101
|
|
|
*/ |
|
102
|
1 |
|
public function __construct( $last_name, $street, $postal_code, $city, $country_code ) { |
|
103
|
1 |
|
$this->last_name = $last_name; |
|
104
|
1 |
|
$this->street = $street; |
|
105
|
1 |
|
$this->postal_code = $postal_code; |
|
106
|
1 |
|
$this->city = $city; |
|
107
|
1 |
|
$this->country_code = $country_code; |
|
108
|
1 |
|
} |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* Get first name. |
|
112
|
|
|
* |
|
113
|
|
|
* @return string |
|
114
|
|
|
*/ |
|
115
|
|
|
public function get_first_name() { |
|
116
|
|
|
return $this->first_name; |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
/** |
|
120
|
|
|
* Set first name. |
|
121
|
|
|
* |
|
122
|
|
|
* @param string $first_name First name. |
|
123
|
|
|
*/ |
|
124
|
1 |
|
public function set_first_name( $first_name ) { |
|
125
|
1 |
|
$this->first_name = $first_name; |
|
126
|
1 |
|
} |
|
127
|
|
|
|
|
128
|
|
|
/** |
|
129
|
|
|
* Get middle name. |
|
130
|
|
|
* |
|
131
|
|
|
* @return string |
|
132
|
|
|
*/ |
|
133
|
|
|
public function get_middle_name() { |
|
134
|
|
|
return $this->middle_name; |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
/** |
|
138
|
|
|
* Set middle name. |
|
139
|
|
|
* |
|
140
|
|
|
* @param string $middle_name Middle name. |
|
141
|
|
|
*/ |
|
142
|
1 |
|
public function set_middle_name( $middle_name ) { |
|
143
|
1 |
|
$this->middle_name = $middle_name; |
|
144
|
1 |
|
} |
|
145
|
|
|
|
|
146
|
|
|
/** |
|
147
|
|
|
* Get last name. |
|
148
|
|
|
* |
|
149
|
|
|
* @return string |
|
150
|
|
|
*/ |
|
151
|
|
|
public function get_last_name() { |
|
152
|
|
|
return $this->last_name; |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
/** |
|
156
|
|
|
* Set last name. |
|
157
|
|
|
* |
|
158
|
|
|
* @param string $last_name Last name. |
|
159
|
|
|
*/ |
|
160
|
|
|
public function set_last_name( $last_name ) { |
|
161
|
|
|
$this->last_name = $last_name; |
|
162
|
|
|
} |
|
163
|
|
|
|
|
164
|
|
|
/** |
|
165
|
|
|
* Get street. |
|
166
|
|
|
* |
|
167
|
|
|
* @return string |
|
168
|
|
|
*/ |
|
169
|
|
|
public function get_street() { |
|
170
|
|
|
return $this->street; |
|
171
|
|
|
} |
|
172
|
|
|
|
|
173
|
|
|
/** |
|
174
|
|
|
* Set street. |
|
175
|
|
|
* |
|
176
|
|
|
* @param string $street Street. |
|
177
|
|
|
*/ |
|
178
|
|
|
public function set_street( $street ) { |
|
179
|
|
|
$this->street = $street; |
|
180
|
|
|
} |
|
181
|
|
|
|
|
182
|
|
|
/** |
|
183
|
|
|
* Get house number. |
|
184
|
|
|
* |
|
185
|
|
|
* @return string|null |
|
186
|
|
|
*/ |
|
187
|
|
|
public function get_house_number() { |
|
188
|
|
|
return $this->house_number; |
|
189
|
|
|
} |
|
190
|
|
|
|
|
191
|
|
|
/** |
|
192
|
|
|
* Set house number. |
|
193
|
|
|
* |
|
194
|
|
|
* @param string|null $house_number House number. |
|
195
|
|
|
*/ |
|
196
|
1 |
|
public function set_house_number( $house_number ) { |
|
197
|
1 |
|
$this->house_number = $house_number; |
|
198
|
1 |
|
} |
|
199
|
|
|
|
|
200
|
|
|
/** |
|
201
|
|
|
* Get house number addition. |
|
202
|
|
|
* |
|
203
|
|
|
* @return string|null |
|
204
|
|
|
*/ |
|
205
|
|
|
public function get_house_number_addition() { |
|
206
|
|
|
return $this->house_number_addition; |
|
207
|
|
|
} |
|
208
|
|
|
|
|
209
|
|
|
/** |
|
210
|
|
|
* Set house number addition. |
|
211
|
|
|
* |
|
212
|
|
|
* @param string|null $house_number_addition House number addition. |
|
213
|
|
|
*/ |
|
214
|
1 |
|
public function set_house_number_addition( $house_number_addition ) { |
|
215
|
1 |
|
$this->house_number_addition = $house_number_addition; |
|
216
|
1 |
|
} |
|
217
|
|
|
|
|
218
|
|
|
/** |
|
219
|
|
|
* Get postal code. |
|
220
|
|
|
* |
|
221
|
|
|
* @return string |
|
222
|
|
|
*/ |
|
223
|
|
|
public function get_postal_code() { |
|
224
|
|
|
return $this->postal_code; |
|
225
|
|
|
} |
|
226
|
|
|
|
|
227
|
|
|
/** |
|
228
|
|
|
* Set postal code. |
|
229
|
|
|
* |
|
230
|
|
|
* @param string $postal_code Postal code. |
|
231
|
|
|
*/ |
|
232
|
|
|
public function set_postal_code( $postal_code ) { |
|
233
|
|
|
$this->postal_code = $postal_code; |
|
234
|
|
|
} |
|
235
|
|
|
|
|
236
|
|
|
/** |
|
237
|
|
|
* Get city. |
|
238
|
|
|
* |
|
239
|
|
|
* @return string |
|
240
|
|
|
*/ |
|
241
|
|
|
public function get_city() { |
|
242
|
|
|
return $this->city; |
|
243
|
|
|
} |
|
244
|
|
|
|
|
245
|
|
|
/** |
|
246
|
|
|
* Set city. |
|
247
|
|
|
* |
|
248
|
|
|
* @param string $city City. |
|
249
|
|
|
*/ |
|
250
|
|
|
public function set_city( $city ) { |
|
251
|
|
|
$this->city = $city; |
|
252
|
|
|
} |
|
253
|
|
|
|
|
254
|
|
|
/** |
|
255
|
|
|
* Get country code. |
|
256
|
|
|
* |
|
257
|
|
|
* @return string |
|
258
|
|
|
*/ |
|
259
|
|
|
public function get_country_code() { |
|
260
|
|
|
return $this->country_code; |
|
261
|
|
|
} |
|
262
|
|
|
|
|
263
|
|
|
/** |
|
264
|
|
|
* Set country code. |
|
265
|
|
|
* |
|
266
|
|
|
* @param string $country_code Country code. |
|
267
|
|
|
*/ |
|
268
|
|
|
public function set_country_code( $country_code ) { |
|
269
|
|
|
$this->country_code = $country_code; |
|
270
|
|
|
} |
|
271
|
|
|
|
|
272
|
|
|
/** |
|
273
|
|
|
* Get JSON. |
|
274
|
|
|
* |
|
275
|
|
|
* @return object|null |
|
276
|
|
|
*/ |
|
277
|
|
|
public function get_json() { |
|
278
|
|
|
$object = (object) array(); |
|
279
|
|
|
|
|
280
|
|
|
$object->firstName = $this->first_name; |
|
281
|
|
|
$object->middleName = $this->middle_name; |
|
282
|
|
|
$object->lastName = $this->last_name; |
|
283
|
|
|
$object->street = $this->street; |
|
284
|
|
|
|
|
285
|
|
|
if ( null !== $this->house_number ) { |
|
286
|
|
|
$object->houseNumber = $this->house_number; |
|
287
|
|
|
} |
|
288
|
|
|
|
|
289
|
|
|
if ( null !== $this->house_number_addition ) { |
|
290
|
|
|
$object->houseNumberAddition = $this->house_number_addition; |
|
291
|
|
|
} |
|
292
|
|
|
|
|
293
|
|
|
$object->postalCode = $this->postal_code; |
|
294
|
|
|
$object->city = $this->city; |
|
295
|
|
|
$object->countryCode = $this->country_code; |
|
296
|
|
|
|
|
297
|
|
|
return $object; |
|
298
|
|
|
} |
|
299
|
|
|
|
|
300
|
|
|
/** |
|
301
|
|
|
* Get signature fields. |
|
302
|
|
|
* |
|
303
|
|
|
* @param array $fields Fields. |
|
304
|
|
|
* @return array |
|
305
|
|
|
*/ |
|
306
|
1 |
|
public function get_signature_fields( $fields = array() ) { |
|
307
|
1 |
|
$fields[] = $this->first_name; |
|
308
|
1 |
|
$fields[] = $this->middle_name; |
|
309
|
1 |
|
$fields[] = $this->last_name; |
|
310
|
1 |
|
$fields[] = $this->street; |
|
311
|
|
|
|
|
312
|
1 |
|
if ( null !== $this->house_number ) { |
|
313
|
1 |
|
$fields[] = $this->house_number; |
|
314
|
|
|
} |
|
315
|
|
|
|
|
316
|
1 |
|
if ( null !== $this->house_number_addition ) { |
|
317
|
1 |
|
$fields[] = $this->house_number_addition; |
|
318
|
|
|
} |
|
319
|
|
|
|
|
320
|
1 |
|
$fields[] = $this->postal_code; |
|
321
|
1 |
|
$fields[] = $this->city; |
|
322
|
1 |
|
$fields[] = $this->country_code; |
|
323
|
|
|
|
|
324
|
1 |
|
return $fields; |
|
325
|
|
|
} |
|
326
|
|
|
} |
|
327
|
|
|
|