1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Credit Card class |
4
|
|
|
*/ |
5
|
|
|
|
6
|
|
|
namespace Omnipay\Common; |
7
|
|
|
|
8
|
|
|
use DateTime; |
9
|
|
|
use DateTimeZone; |
10
|
|
|
use Omnipay\Common\Exception\InvalidCreditCardException; |
11
|
|
|
use Symfony\Component\HttpFoundation\ParameterBag; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Credit Card class |
15
|
|
|
* |
16
|
|
|
* This class defines and abstracts all of the credit card types used |
17
|
|
|
* throughout the Omnipay system. |
18
|
|
|
* |
19
|
|
|
* Example: |
20
|
|
|
* |
21
|
|
|
* <code> |
22
|
|
|
* // Define credit card parameters, which should look like this |
23
|
|
|
* $parameters = [ |
24
|
|
|
* 'firstName' => 'Bobby', |
25
|
|
|
* 'lastName' => 'Tables', |
26
|
|
|
* 'number' => '4444333322221111', |
27
|
|
|
* 'cvv' => '123', |
28
|
|
|
* 'expiryMonth' => '12', |
29
|
|
|
* 'expiryYear' => '2017', |
30
|
|
|
* 'email' => '[email protected]', |
31
|
|
|
* ]; |
32
|
|
|
* |
33
|
|
|
* // Create a credit card object |
34
|
|
|
* $card = new CreditCard($parameters); |
35
|
|
|
* </code> |
36
|
|
|
* |
37
|
|
|
* The full list of card attributes that may be set via the parameter to |
38
|
|
|
* *new* is as follows: |
39
|
|
|
* |
40
|
|
|
* * title |
41
|
|
|
* * firstName |
42
|
|
|
* * lastName |
43
|
|
|
* * name |
44
|
|
|
* * company |
45
|
|
|
* * address1 |
46
|
|
|
* * address2 |
47
|
|
|
* * city |
48
|
|
|
* * postcode |
49
|
|
|
* * state |
50
|
|
|
* * country |
51
|
|
|
* * phone |
52
|
|
|
* * phoneExtension |
53
|
|
|
* * fax |
54
|
|
|
* * number |
55
|
|
|
* * expiryMonth |
56
|
|
|
* * expiryYear |
57
|
|
|
* * startMonth |
58
|
|
|
* * startYear |
59
|
|
|
* * cvv |
60
|
|
|
* * tracks |
61
|
|
|
* * issueNumber |
62
|
|
|
* * billingTitle |
63
|
|
|
* * billingName |
64
|
|
|
* * billingFirstName |
65
|
|
|
* * billingLastName |
66
|
|
|
* * billingCompany |
67
|
|
|
* * billingAddress1 |
68
|
|
|
* * billingAddress2 |
69
|
|
|
* * billingCity |
70
|
|
|
* * billingPostcode |
71
|
|
|
* * billingState |
72
|
|
|
* * billingCountry |
73
|
|
|
* * billingPhone |
74
|
|
|
* * billingFax |
75
|
|
|
* * shippingTitle |
76
|
|
|
* * shippingName |
77
|
|
|
* * shippingFirstName |
78
|
|
|
* * shippingLastName |
79
|
|
|
* * shippingCompany |
80
|
|
|
* * shippingAddress1 |
81
|
|
|
* * shippingAddress2 |
82
|
|
|
* * shippingCity |
83
|
|
|
* * shippingPostcode |
84
|
|
|
* * shippingState |
85
|
|
|
* * shippingCountry |
86
|
|
|
* * shippingPhone |
87
|
|
|
* * shippingFax |
88
|
|
|
* * email |
89
|
|
|
* * birthday |
90
|
|
|
* * gender |
91
|
|
|
* |
92
|
|
|
* If any unknown parameters are passed in, they will be ignored. No error is thrown. |
93
|
|
|
*/ |
94
|
|
|
class CreditCard |
95
|
|
|
{ |
96
|
|
|
use ParametersTrait; |
97
|
|
|
|
98
|
|
|
const BRAND_VISA = 'visa'; |
99
|
|
|
const BRAND_MASTERCARD = 'mastercard'; |
100
|
|
|
const BRAND_DISCOVER = 'discover'; |
101
|
|
|
const BRAND_AMEX = 'amex'; |
102
|
|
|
const BRAND_DINERS_CLUB = 'diners_club'; |
103
|
|
|
const BRAND_JCB = 'jcb'; |
104
|
|
|
const BRAND_SWITCH = 'switch'; |
105
|
|
|
const BRAND_SOLO = 'solo'; |
106
|
|
|
const BRAND_DANKORT = 'dankort'; |
107
|
|
|
const BRAND_MAESTRO = 'maestro'; |
108
|
|
|
const BRAND_FORBRUGSFORENINGEN = 'forbrugsforeningen'; |
109
|
|
|
const BRAND_LASER = 'laser'; |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* All known/supported card brands, and a regular expression to match them. |
113
|
|
|
* |
114
|
|
|
* The order of the card brands is important, as some of the regular expressions overlap. |
115
|
|
|
* |
116
|
|
|
* Note: The fact that a particular card brand has been added to this array does not imply |
117
|
|
|
* that a selected gateway will support the card. |
118
|
|
|
* |
119
|
|
|
* @link https://github.com/Shopify/active_merchant/blob/master/lib/active_merchant/billing/credit_card_methods.rb |
120
|
|
|
* @var array |
121
|
|
|
*/ |
122
|
|
|
const REGEX_MASTERCARD = '/^(5[1-5]\d{4}|677189)\d{10}$|^2(?:2(?:2[1-9]|[3-9]\d)|[3-6]\d\d|7(?:[01]\d|20))\d{12}$/'; |
123
|
|
|
protected $supported_cards = array( |
124
|
|
|
self::BRAND_VISA => '/^4\d{12}(\d{3})?$/', |
125
|
|
|
self::BRAND_MASTERCARD => self::REGEX_MASTERCARD, |
126
|
|
|
self::BRAND_DISCOVER => '/^(6011|65\d{2}|64[4-9]\d)\d{12}|(62\d{14})$/', |
127
|
|
|
self::BRAND_AMEX => '/^3[47]\d{13}$/', |
128
|
|
|
self::BRAND_DINERS_CLUB => '/^3(0[0-5]|[68]\d)\d{11}$/', |
129
|
|
|
self::BRAND_JCB => '/^35(28|29|[3-8]\d)\d{12}$/', |
130
|
|
|
self::BRAND_SWITCH => '/^6759\d{12}(\d{2,3})?$/', |
131
|
|
|
self::BRAND_SOLO => '/^6767\d{12}(\d{2,3})?$/', |
132
|
|
|
self::BRAND_DANKORT => '/^5019\d{12}$/', |
133
|
|
|
self::BRAND_MAESTRO => '/^(5[06-8]|6\d)\d{10,17}$/', |
134
|
|
|
self::BRAND_FORBRUGSFORENINGEN => '/^600722\d{10}$/', |
135
|
|
|
self::BRAND_LASER => '/^(6304|6706|6709|6771(?!89))\d{8}(\d{4}|\d{6,7})?$/', |
136
|
|
|
); |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* Create a new CreditCard object using the specified parameters |
140
|
|
|
* |
141
|
|
|
* @param array $parameters An array of parameters to set on the new object |
142
|
|
|
*/ |
143
|
285 |
|
public function __construct($parameters = null) |
144
|
|
|
{ |
145
|
285 |
|
$this->initialize($parameters); |
146
|
285 |
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* All known/supported card brands, and a regular expression to match them. |
150
|
|
|
* |
151
|
|
|
* Note: The fact that this class knows about a particular card brand does not imply |
152
|
|
|
* that your gateway supports it. |
153
|
|
|
* |
154
|
|
|
* @return array |
155
|
|
|
*/ |
156
|
33 |
|
public function getSupportedBrands() |
157
|
|
|
{ |
158
|
33 |
|
return $this->supported_cards; |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* Set a custom supported card brand with a regular expression to match it. |
163
|
|
|
* |
164
|
|
|
* Note: The fact that a particular card is known does not imply that your |
165
|
|
|
* gateway supports it. |
166
|
|
|
* |
167
|
|
|
* Set $add_to_front to true if the key should be added to the front of the array |
168
|
|
|
* |
169
|
|
|
* @param string $name The name of the new supported brand. |
170
|
|
|
* @param string $expression The regular expression to check if a card is supported. |
171
|
|
|
* @return boolean success |
172
|
|
|
*/ |
173
|
9 |
|
public function addSupportedBrand($name, $expression) |
174
|
|
|
{ |
175
|
9 |
|
$known_brands = array_keys($this->supported_cards); |
176
|
|
|
|
177
|
9 |
|
if (in_array($name, $known_brands)) { |
178
|
3 |
|
return false; |
179
|
|
|
} |
180
|
|
|
|
181
|
9 |
|
$this->supported_cards[$name] = $expression; |
182
|
9 |
|
return true; |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
/** |
186
|
|
|
* Initialize the object with parameters. |
187
|
|
|
* |
188
|
|
|
* If any unknown parameters passed, they will be ignored. |
189
|
|
|
* |
190
|
|
|
* @param array $parameters An associative array of parameters |
191
|
|
|
* @return $this |
192
|
|
|
*/ |
193
|
285 |
|
public function initialize(array $parameters = null) |
194
|
|
|
{ |
195
|
285 |
|
$this->parameters = new ParameterBag; |
196
|
|
|
|
197
|
285 |
|
Helper::initialize($this, $parameters); |
198
|
|
|
|
199
|
285 |
|
return $this; |
200
|
|
|
} |
201
|
|
|
|
202
|
|
|
/** |
203
|
|
|
* Set the credit card year. |
204
|
|
|
* |
205
|
|
|
* The input value is normalised to a 4 digit number. |
206
|
|
|
* |
207
|
|
|
* @param string $key Parameter key, e.g. 'expiryYear' |
208
|
|
|
* @param mixed $value Parameter value |
209
|
|
|
* @return $this |
210
|
|
|
*/ |
211
|
279 |
|
protected function setYearParameter($key, $value) |
212
|
|
|
{ |
213
|
|
|
// normalize year to four digits |
214
|
279 |
|
if (null === $value || '' === $value) { |
215
|
3 |
|
$value = null; |
216
|
|
|
} else { |
217
|
279 |
|
$value = (int) gmdate('Y', gmmktime(0, 0, 0, 1, 1, (int) $value)); |
218
|
|
|
} |
219
|
|
|
|
220
|
279 |
|
return $this->setParameter($key, $value); |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
/** |
224
|
|
|
* Validate this credit card. If the card is invalid, InvalidCreditCardException is thrown. |
225
|
|
|
* |
226
|
|
|
* This method is called internally by gateways to avoid wasting time with an API call |
227
|
|
|
* when the credit card is clearly invalid. |
228
|
|
|
* |
229
|
|
|
* Generally if you want to validate the credit card yourself with custom error |
230
|
|
|
* messages, you should use your framework's validation library, not this method. |
231
|
|
|
* |
232
|
|
|
* @return void |
233
|
|
|
* @throws Exception\InvalidRequestException |
234
|
|
|
* @throws InvalidCreditCardException |
235
|
|
|
*/ |
236
|
24 |
|
public function validate() |
237
|
|
|
{ |
238
|
|
|
$requiredParameters = array( |
239
|
24 |
|
'number' => 'credit card number', |
240
|
|
|
'expiryMonth' => 'expiration month', |
241
|
|
|
'expiryYear' => 'expiration year' |
242
|
|
|
); |
243
|
|
|
|
244
|
24 |
|
foreach ($requiredParameters as $key => $val) { |
245
|
24 |
|
if (!$this->getParameter($key)) { |
246
|
19 |
|
throw new InvalidCreditCardException("The $val is required"); |
247
|
|
|
} |
248
|
|
|
} |
249
|
|
|
|
250
|
15 |
|
if ($this->getExpiryDate('Ym') < gmdate('Ym')) { |
251
|
3 |
|
throw new InvalidCreditCardException('Card has expired'); |
252
|
|
|
} |
253
|
|
|
|
254
|
12 |
|
if (!Helper::validateLuhn($this->getNumber())) { |
255
|
6 |
|
throw new InvalidCreditCardException('Card number is invalid'); |
256
|
|
|
} |
257
|
|
|
|
258
|
6 |
|
if (!is_null($this->getNumber()) && !preg_match('/^\d{12,19}$/i', $this->getNumber())) { |
259
|
3 |
|
throw new InvalidCreditCardException('Card number should have 12 to 19 digits'); |
260
|
|
|
} |
261
|
3 |
|
} |
262
|
|
|
/** |
263
|
|
|
* Get Card Title. |
264
|
|
|
* |
265
|
|
|
* @return string |
266
|
|
|
*/ |
267
|
6 |
|
public function getTitle() |
268
|
|
|
{ |
269
|
6 |
|
return $this->getBillingTitle(); |
270
|
|
|
} |
271
|
|
|
|
272
|
|
|
/** |
273
|
|
|
* Set Card Title. |
274
|
|
|
* |
275
|
|
|
* @param string $value Parameter value |
276
|
|
|
* @return $this |
277
|
|
|
*/ |
278
|
3 |
|
public function setTitle($value) |
279
|
|
|
{ |
280
|
3 |
|
$this->setBillingTitle($value); |
281
|
3 |
|
$this->setShippingTitle($value); |
282
|
|
|
|
283
|
3 |
|
return $this; |
284
|
|
|
} |
285
|
|
|
|
286
|
|
|
/** |
287
|
|
|
* Get Card First Name. |
288
|
|
|
* |
289
|
|
|
* @return string |
290
|
|
|
*/ |
291
|
15 |
|
public function getFirstName() |
292
|
|
|
{ |
293
|
15 |
|
return $this->getBillingFirstName(); |
294
|
|
|
} |
295
|
|
|
|
296
|
|
|
/** |
297
|
|
|
* Set Card First Name (Billing and Shipping). |
298
|
|
|
* |
299
|
|
|
* @param string $value Parameter value |
300
|
|
|
* @return $this |
301
|
|
|
*/ |
302
|
279 |
|
public function setFirstName($value) |
303
|
|
|
{ |
304
|
279 |
|
$this->setBillingFirstName($value); |
305
|
279 |
|
$this->setShippingFirstName($value); |
306
|
|
|
|
307
|
279 |
|
return $this; |
308
|
|
|
} |
309
|
|
|
|
310
|
|
|
/** |
311
|
|
|
* Get Card Last Name. |
312
|
|
|
* |
313
|
|
|
* @return string |
314
|
|
|
*/ |
315
|
15 |
|
public function getLastName() |
316
|
|
|
{ |
317
|
15 |
|
return $this->getBillingLastName(); |
318
|
|
|
} |
319
|
|
|
|
320
|
|
|
/** |
321
|
|
|
* Set Card Last Name (Billing and Shipping). |
322
|
|
|
* |
323
|
|
|
* @param string $value Parameter value |
324
|
|
|
* @return $this |
325
|
|
|
*/ |
326
|
279 |
|
public function setLastName($value) |
327
|
|
|
{ |
328
|
279 |
|
$this->setBillingLastName($value); |
329
|
279 |
|
$this->setShippingLastName($value); |
330
|
|
|
|
331
|
279 |
|
return $this; |
332
|
|
|
} |
333
|
|
|
|
334
|
|
|
/** |
335
|
|
|
* Get Card Name. |
336
|
|
|
* |
337
|
|
|
* @return string |
338
|
|
|
*/ |
339
|
9 |
|
public function getName() |
340
|
|
|
{ |
341
|
9 |
|
return $this->getBillingName(); |
342
|
|
|
} |
343
|
|
|
|
344
|
|
|
/** |
345
|
|
|
* Set Card Name (Billing and Shipping). |
346
|
|
|
* |
347
|
|
|
* @param string $value Parameter value |
348
|
|
|
* @return $this |
349
|
|
|
*/ |
350
|
18 |
|
public function setName($value) |
351
|
|
|
{ |
352
|
18 |
|
$this->setBillingName($value); |
353
|
18 |
|
$this->setShippingName($value); |
354
|
|
|
|
355
|
18 |
|
return $this; |
356
|
|
|
} |
357
|
|
|
|
358
|
|
|
/** |
359
|
|
|
* Get Card Number. |
360
|
|
|
* |
361
|
|
|
* @return string |
362
|
|
|
*/ |
363
|
57 |
|
public function getNumber() |
364
|
|
|
{ |
365
|
57 |
|
return $this->getParameter('number'); |
366
|
|
|
} |
367
|
|
|
|
368
|
|
|
/** |
369
|
|
|
* Set Card Number |
370
|
|
|
* |
371
|
|
|
* Non-numeric characters are stripped out of the card number, so |
372
|
|
|
* it's safe to pass in strings such as "4444-3333 2222 1111" etc. |
373
|
|
|
* |
374
|
|
|
* @param string $value Parameter value |
375
|
|
|
* @return $this |
376
|
|
|
*/ |
377
|
282 |
|
public function setNumber($value) |
378
|
|
|
{ |
379
|
|
|
// strip non-numeric characters |
380
|
282 |
|
return $this->setParameter('number', preg_replace('/\D/', '', $value)); |
381
|
|
|
} |
382
|
|
|
|
383
|
|
|
/** |
384
|
|
|
* Get the last 4 digits of the card number. |
385
|
|
|
* |
386
|
|
|
* @return string |
387
|
|
|
*/ |
388
|
15 |
|
public function getNumberLastFour() |
389
|
|
|
{ |
390
|
15 |
|
return substr($this->getNumber(), -4, 4) ?: null; |
391
|
|
|
} |
392
|
|
|
|
393
|
|
|
/** |
394
|
|
|
* Returns a masked credit card number with only the last 4 chars visible |
395
|
|
|
* |
396
|
|
|
* @param string $mask Character to use in place of numbers |
397
|
|
|
* @return string |
398
|
|
|
*/ |
399
|
6 |
|
public function getNumberMasked($mask = 'X') |
400
|
|
|
{ |
401
|
6 |
|
$maskLength = strlen($this->getNumber()) - 4; |
402
|
|
|
|
403
|
6 |
|
return str_repeat($mask, $maskLength) . $this->getNumberLastFour(); |
404
|
|
|
} |
405
|
|
|
|
406
|
|
|
/** |
407
|
|
|
* Credit Card Brand |
408
|
|
|
* |
409
|
|
|
* Iterates through known/supported card brands to determine the brand of this card |
410
|
|
|
* |
411
|
|
|
* @return string |
412
|
|
|
*/ |
413
|
24 |
|
public function getBrand() |
414
|
|
|
{ |
415
|
24 |
|
foreach ($this->getSupportedBrands() as $brand => $val) { |
416
|
24 |
|
if (preg_match($val, $this->getNumber())) { |
417
|
23 |
|
return $brand; |
418
|
|
|
} |
419
|
|
|
} |
420
|
3 |
|
} |
421
|
|
|
|
422
|
|
|
/** |
423
|
|
|
* Get the card expiry month. |
424
|
|
|
* |
425
|
|
|
* @return int |
426
|
|
|
*/ |
427
|
24 |
|
public function getExpiryMonth() |
428
|
|
|
{ |
429
|
24 |
|
return $this->getParameter('expiryMonth'); |
430
|
|
|
} |
431
|
|
|
|
432
|
|
|
/** |
433
|
|
|
* Sets the card expiry month. |
434
|
|
|
* |
435
|
|
|
* @param string $value |
436
|
|
|
* @return $this |
437
|
|
|
*/ |
438
|
279 |
|
public function setExpiryMonth($value) |
439
|
|
|
{ |
440
|
279 |
|
return $this->setParameter('expiryMonth', (int) $value); |
441
|
|
|
} |
442
|
|
|
|
443
|
|
|
/** |
444
|
|
|
* Get the card expiry year. |
445
|
|
|
* |
446
|
|
|
* @return int |
447
|
|
|
*/ |
448
|
24 |
|
public function getExpiryYear() |
449
|
|
|
{ |
450
|
24 |
|
return $this->getParameter('expiryYear'); |
451
|
|
|
} |
452
|
|
|
|
453
|
|
|
/** |
454
|
|
|
* Sets the card expiry year. |
455
|
|
|
* |
456
|
|
|
* @param string $value |
457
|
|
|
* @return $this |
458
|
|
|
*/ |
459
|
279 |
|
public function setExpiryYear($value) |
460
|
|
|
{ |
461
|
279 |
|
return $this->setYearParameter('expiryYear', $value); |
462
|
|
|
} |
463
|
|
|
|
464
|
|
|
/** |
465
|
|
|
* Get the card expiry date, using the specified date format string. |
466
|
|
|
* |
467
|
|
|
* @param string $format |
468
|
|
|
* |
469
|
|
|
* @return string |
470
|
|
|
*/ |
471
|
18 |
|
public function getExpiryDate($format) |
472
|
|
|
{ |
473
|
18 |
|
return gmdate($format, gmmktime(0, 0, 0, $this->getExpiryMonth(), 1, $this->getExpiryYear())); |
474
|
|
|
} |
475
|
|
|
|
476
|
|
|
/** |
477
|
|
|
* Get the card start month. |
478
|
|
|
* |
479
|
|
|
* @return string |
480
|
|
|
*/ |
481
|
9 |
|
public function getStartMonth() |
482
|
|
|
{ |
483
|
9 |
|
return $this->getParameter('startMonth'); |
484
|
|
|
} |
485
|
|
|
|
486
|
|
|
/** |
487
|
|
|
* Sets the card start month. |
488
|
|
|
* |
489
|
|
|
* @param string $value |
490
|
|
|
* @return $this |
491
|
|
|
*/ |
492
|
9 |
|
public function setStartMonth($value) |
493
|
|
|
{ |
494
|
9 |
|
return $this->setParameter('startMonth', (int) $value); |
495
|
|
|
} |
496
|
|
|
|
497
|
|
|
/** |
498
|
|
|
* Get the card start year. |
499
|
|
|
* |
500
|
|
|
* @return int |
501
|
|
|
*/ |
502
|
9 |
|
public function getStartYear() |
503
|
|
|
{ |
504
|
9 |
|
return $this->getParameter('startYear'); |
505
|
|
|
} |
506
|
|
|
|
507
|
|
|
/** |
508
|
|
|
* Sets the card start year. |
509
|
|
|
* |
510
|
|
|
* @param string $value |
511
|
|
|
* @return $this |
512
|
|
|
*/ |
513
|
9 |
|
public function setStartYear($value) |
514
|
|
|
{ |
515
|
9 |
|
return $this->setYearParameter('startYear', $value); |
516
|
|
|
} |
517
|
|
|
|
518
|
|
|
/** |
519
|
|
|
* Get the card start date, using the specified date format string |
520
|
|
|
* |
521
|
|
|
* @param string $format |
522
|
|
|
* |
523
|
|
|
* @return string |
524
|
|
|
*/ |
525
|
3 |
|
public function getStartDate($format) |
526
|
|
|
{ |
527
|
3 |
|
return gmdate($format, gmmktime(0, 0, 0, $this->getStartMonth(), 1, $this->getStartYear())); |
528
|
|
|
} |
529
|
|
|
|
530
|
|
|
/** |
531
|
|
|
* Get the card CVV. |
532
|
|
|
* |
533
|
|
|
* @return string |
534
|
|
|
*/ |
535
|
3 |
|
public function getCvv() |
536
|
|
|
{ |
537
|
3 |
|
return $this->getParameter('cvv'); |
538
|
|
|
} |
539
|
|
|
|
540
|
|
|
/** |
541
|
|
|
* Sets the card CVV. |
542
|
|
|
* |
543
|
|
|
* @param string $value |
544
|
|
|
* @return $this |
545
|
|
|
*/ |
546
|
279 |
|
public function setCvv($value) |
547
|
|
|
{ |
548
|
279 |
|
return $this->setParameter('cvv', $value); |
549
|
|
|
} |
550
|
|
|
|
551
|
|
|
/** |
552
|
|
|
* Get raw data for all tracks on the credit card magnetic strip. |
553
|
|
|
* |
554
|
|
|
* @return string |
555
|
|
|
*/ |
556
|
12 |
|
public function getTracks() |
557
|
|
|
{ |
558
|
12 |
|
return $this->getParameter('tracks'); |
559
|
|
|
} |
560
|
|
|
|
561
|
|
|
/** |
562
|
|
|
* Get raw data for track 1 on the credit card magnetic strip. |
563
|
|
|
* |
564
|
|
|
* @return string|null |
565
|
|
|
*/ |
566
|
3 |
|
public function getTrack1() |
567
|
|
|
{ |
568
|
3 |
|
return $this->getTrackByPattern('/\%B\d{1,19}\^.{2,26}\^\d{4}\d*\?/'); |
569
|
|
|
} |
570
|
|
|
|
571
|
|
|
/** |
572
|
|
|
* Get raw data for track 2 on the credit card magnetic strip. |
573
|
|
|
* |
574
|
|
|
* @return string|null |
575
|
|
|
*/ |
576
|
6 |
|
public function getTrack2() |
577
|
|
|
{ |
578
|
6 |
|
return $this->getTrackByPattern('/;\d{1,19}=\d{4}\d*\?/'); |
579
|
|
|
} |
580
|
|
|
|
581
|
|
|
/** |
582
|
|
|
* Get raw data for a track on the credit card magnetic strip based on the pattern for track 1 or 2. |
583
|
|
|
* |
584
|
|
|
* @param $pattern |
585
|
|
|
* @return string|null |
586
|
|
|
*/ |
587
|
9 |
|
protected function getTrackByPattern($pattern) |
588
|
|
|
{ |
589
|
9 |
|
if ($tracks = $this->getTracks()) { |
590
|
6 |
|
if (preg_match($pattern, $tracks, $matches) === 1) { |
591
|
6 |
|
return $matches[0]; |
592
|
|
|
} |
593
|
|
|
} |
594
|
3 |
|
} |
595
|
|
|
|
596
|
|
|
/** |
597
|
|
|
* Sets raw data from all tracks on the credit card magnetic strip. Used by gateways that support card-present |
598
|
|
|
* transactions. |
599
|
|
|
* |
600
|
|
|
* @param $value |
601
|
|
|
* @return $this |
602
|
|
|
*/ |
603
|
12 |
|
public function setTracks($value) |
604
|
|
|
{ |
605
|
12 |
|
return $this->setParameter('tracks', $value); |
606
|
|
|
} |
607
|
|
|
|
608
|
|
|
/** |
609
|
|
|
* Get the card issue number. |
610
|
|
|
* |
611
|
|
|
* @return string |
612
|
|
|
*/ |
613
|
3 |
|
public function getIssueNumber() |
614
|
|
|
{ |
615
|
3 |
|
return $this->getParameter('issueNumber'); |
616
|
|
|
} |
617
|
|
|
|
618
|
|
|
/** |
619
|
|
|
* Sets the card issue number. |
620
|
|
|
* |
621
|
|
|
* @param string $value |
622
|
|
|
* @return $this |
623
|
|
|
*/ |
624
|
3 |
|
public function setIssueNumber($value) |
625
|
|
|
{ |
626
|
3 |
|
return $this->setParameter('issueNumber', $value); |
627
|
|
|
} |
628
|
|
|
|
629
|
|
|
/** |
630
|
|
|
* Get the card billing title. |
631
|
|
|
* |
632
|
|
|
* @return string |
633
|
|
|
*/ |
634
|
6 |
|
public function getBillingTitle() |
635
|
|
|
{ |
636
|
6 |
|
return $this->getParameter('billingTitle'); |
637
|
|
|
} |
638
|
|
|
|
639
|
|
|
/** |
640
|
|
|
* Sets the card billing title. |
641
|
|
|
* |
642
|
|
|
* @param string $value |
643
|
|
|
* @return $this |
644
|
|
|
*/ |
645
|
6 |
|
public function setBillingTitle($value) |
646
|
|
|
{ |
647
|
6 |
|
return $this->setParameter('billingTitle', $value); |
648
|
|
|
} |
649
|
|
|
|
650
|
|
|
/** |
651
|
|
|
* Get the card billing name. |
652
|
|
|
* |
653
|
|
|
* @return string |
654
|
|
|
*/ |
655
|
12 |
|
public function getBillingName() |
656
|
|
|
{ |
657
|
12 |
|
return trim($this->getBillingFirstName() . ' ' . $this->getBillingLastName()); |
658
|
|
|
} |
659
|
|
|
|
660
|
|
|
/** |
661
|
|
|
* Split the full name in the first and last name. |
662
|
|
|
* |
663
|
|
|
* @param $fullName |
664
|
|
|
* @return array with first and lastname |
665
|
|
|
*/ |
666
|
24 |
|
protected function listFirstLastName($fullName) |
667
|
|
|
{ |
668
|
24 |
|
$names = explode(' ', $fullName, 2); |
669
|
|
|
|
670
|
24 |
|
return [$names[0], isset($names[1]) ? $names[1] : null]; |
671
|
|
|
} |
672
|
|
|
|
673
|
|
|
/** |
674
|
|
|
* Sets the card billing name. |
675
|
|
|
* |
676
|
|
|
* @param string $value |
677
|
|
|
* @return $this |
678
|
|
|
*/ |
679
|
21 |
|
public function setBillingName($value) |
680
|
|
|
{ |
681
|
21 |
|
$names = $this->listFirstLastName($value); |
682
|
|
|
|
683
|
21 |
|
$this->setBillingFirstName($names[0]); |
684
|
21 |
|
$this->setBillingLastName($names[1]); |
685
|
|
|
|
686
|
21 |
|
return $this; |
687
|
|
|
} |
688
|
|
|
|
689
|
|
|
/** |
690
|
|
|
* Get the first part of the card billing name. |
691
|
|
|
* |
692
|
|
|
* @return string |
693
|
|
|
*/ |
694
|
27 |
|
public function getBillingFirstName() |
695
|
|
|
{ |
696
|
27 |
|
return $this->getParameter('billingFirstName'); |
697
|
|
|
} |
698
|
|
|
|
699
|
|
|
/** |
700
|
|
|
* Sets the first part of the card billing name. |
701
|
|
|
* |
702
|
|
|
* @param string $value |
703
|
|
|
* @return $this |
704
|
|
|
*/ |
705
|
279 |
|
public function setBillingFirstName($value) |
706
|
|
|
{ |
707
|
279 |
|
return $this->setParameter('billingFirstName', $value); |
708
|
|
|
} |
709
|
|
|
|
710
|
|
|
/** |
711
|
|
|
* Get the last part of the card billing name. |
712
|
|
|
* |
713
|
|
|
* @return string |
714
|
|
|
*/ |
715
|
27 |
|
public function getBillingLastName() |
716
|
|
|
{ |
717
|
27 |
|
return $this->getParameter('billingLastName'); |
718
|
|
|
} |
719
|
|
|
|
720
|
|
|
/** |
721
|
|
|
* Sets the last part of the card billing name. |
722
|
|
|
* |
723
|
|
|
* @param string $value |
724
|
|
|
* @return $this |
725
|
|
|
*/ |
726
|
279 |
|
public function setBillingLastName($value) |
727
|
|
|
{ |
728
|
279 |
|
return $this->setParameter('billingLastName', $value); |
729
|
|
|
} |
730
|
|
|
|
731
|
|
|
/** |
732
|
|
|
* Get the billing company name. |
733
|
|
|
* |
734
|
|
|
* @return string |
735
|
|
|
*/ |
736
|
6 |
|
public function getBillingCompany() |
737
|
|
|
{ |
738
|
6 |
|
return $this->getParameter('billingCompany'); |
739
|
|
|
} |
740
|
|
|
|
741
|
|
|
/** |
742
|
|
|
* Sets the billing company name. |
743
|
|
|
* |
744
|
|
|
* @param string $value |
745
|
|
|
* @return $this |
746
|
|
|
*/ |
747
|
3 |
|
public function setBillingCompany($value) |
748
|
|
|
{ |
749
|
3 |
|
return $this->setParameter('billingCompany', $value); |
750
|
|
|
} |
751
|
|
|
|
752
|
|
|
/** |
753
|
|
|
* Get the billing address, line 1. |
754
|
|
|
* |
755
|
|
|
* @return string |
756
|
|
|
*/ |
757
|
6 |
|
public function getBillingAddress1() |
758
|
|
|
{ |
759
|
6 |
|
return $this->getParameter('billingAddress1'); |
760
|
|
|
} |
761
|
|
|
|
762
|
|
|
/** |
763
|
|
|
* Sets the billing address, line 1. |
764
|
|
|
* |
765
|
|
|
* @param string $value |
766
|
|
|
* @return $this |
767
|
|
|
*/ |
768
|
3 |
|
public function setBillingAddress1($value) |
769
|
|
|
{ |
770
|
3 |
|
return $this->setParameter('billingAddress1', $value); |
771
|
|
|
} |
772
|
|
|
|
773
|
|
|
/** |
774
|
|
|
* Get the billing address, line 2. |
775
|
|
|
* |
776
|
|
|
* @return string |
777
|
|
|
*/ |
778
|
6 |
|
public function getBillingAddress2() |
779
|
|
|
{ |
780
|
6 |
|
return $this->getParameter('billingAddress2'); |
781
|
|
|
} |
782
|
|
|
|
783
|
|
|
/** |
784
|
|
|
* Sets the billing address, line 2. |
785
|
|
|
* |
786
|
|
|
* @param string $value |
787
|
|
|
* @return $this |
788
|
|
|
*/ |
789
|
3 |
|
public function setBillingAddress2($value) |
790
|
|
|
{ |
791
|
3 |
|
return $this->setParameter('billingAddress2', $value); |
792
|
|
|
} |
793
|
|
|
|
794
|
|
|
/** |
795
|
|
|
* Get the billing city. |
796
|
|
|
* |
797
|
|
|
* @return string |
798
|
|
|
*/ |
799
|
6 |
|
public function getBillingCity() |
800
|
|
|
{ |
801
|
6 |
|
return $this->getParameter('billingCity'); |
802
|
|
|
} |
803
|
|
|
|
804
|
|
|
/** |
805
|
|
|
* Sets billing city. |
806
|
|
|
* |
807
|
|
|
* @param string $value |
808
|
|
|
* @return $this |
809
|
|
|
*/ |
810
|
3 |
|
public function setBillingCity($value) |
811
|
|
|
{ |
812
|
3 |
|
return $this->setParameter('billingCity', $value); |
813
|
|
|
} |
814
|
|
|
|
815
|
|
|
/** |
816
|
|
|
* Get the billing postcode. |
817
|
|
|
* |
818
|
|
|
* @return string |
819
|
|
|
*/ |
820
|
6 |
|
public function getBillingPostcode() |
821
|
|
|
{ |
822
|
6 |
|
return $this->getParameter('billingPostcode'); |
823
|
|
|
} |
824
|
|
|
|
825
|
|
|
/** |
826
|
|
|
* Sets the billing postcode. |
827
|
|
|
* |
828
|
|
|
* @param string $value |
829
|
|
|
* @return $this |
830
|
|
|
*/ |
831
|
3 |
|
public function setBillingPostcode($value) |
832
|
|
|
{ |
833
|
3 |
|
return $this->setParameter('billingPostcode', $value); |
834
|
|
|
} |
835
|
|
|
|
836
|
|
|
/** |
837
|
|
|
* Get the billing state. |
838
|
|
|
* |
839
|
|
|
* @return string |
840
|
|
|
*/ |
841
|
6 |
|
public function getBillingState() |
842
|
|
|
{ |
843
|
6 |
|
return $this->getParameter('billingState'); |
844
|
|
|
} |
845
|
|
|
|
846
|
|
|
/** |
847
|
|
|
* Sets the billing state. |
848
|
|
|
* |
849
|
|
|
* @param string $value |
850
|
|
|
* @return $this |
851
|
|
|
*/ |
852
|
3 |
|
public function setBillingState($value) |
853
|
|
|
{ |
854
|
3 |
|
return $this->setParameter('billingState', $value); |
855
|
|
|
} |
856
|
|
|
|
857
|
|
|
/** |
858
|
|
|
* Get the billing country name. |
859
|
|
|
* |
860
|
|
|
* @return string |
861
|
|
|
*/ |
862
|
6 |
|
public function getBillingCountry() |
863
|
|
|
{ |
864
|
6 |
|
return $this->getParameter('billingCountry'); |
865
|
|
|
} |
866
|
|
|
|
867
|
|
|
/** |
868
|
|
|
* Sets the billing country name. |
869
|
|
|
* |
870
|
|
|
* @param string $value |
871
|
|
|
* @return $this |
872
|
|
|
*/ |
873
|
3 |
|
public function setBillingCountry($value) |
874
|
|
|
{ |
875
|
3 |
|
return $this->setParameter('billingCountry', $value); |
876
|
|
|
} |
877
|
|
|
|
878
|
|
|
/** |
879
|
|
|
* Get the billing phone number. |
880
|
|
|
* |
881
|
|
|
* @return string |
882
|
|
|
*/ |
883
|
6 |
|
public function getBillingPhone() |
884
|
|
|
{ |
885
|
6 |
|
return $this->getParameter('billingPhone'); |
886
|
|
|
} |
887
|
|
|
|
888
|
|
|
/** |
889
|
|
|
* Sets the billing phone number. |
890
|
|
|
* |
891
|
|
|
* @param string $value |
892
|
|
|
* @return $this |
893
|
|
|
*/ |
894
|
3 |
|
public function setBillingPhone($value) |
895
|
|
|
{ |
896
|
3 |
|
return $this->setParameter('billingPhone', $value); |
897
|
|
|
} |
898
|
|
|
|
899
|
|
|
/** |
900
|
|
|
* Get the billing phone number extension. |
901
|
|
|
* |
902
|
|
|
* @return string |
903
|
|
|
*/ |
904
|
6 |
|
public function getBillingPhoneExtension() |
905
|
|
|
{ |
906
|
6 |
|
return $this->getParameter('billingPhoneExtension'); |
907
|
|
|
} |
908
|
|
|
|
909
|
|
|
/** |
910
|
|
|
* Sets the billing phone number extension. |
911
|
|
|
* |
912
|
|
|
* @param string $value |
913
|
|
|
* @return $this |
914
|
|
|
*/ |
915
|
3 |
|
public function setBillingPhoneExtension($value) |
916
|
|
|
{ |
917
|
3 |
|
return $this->setParameter('billingPhoneExtension', $value); |
918
|
|
|
} |
919
|
|
|
|
920
|
|
|
/** |
921
|
|
|
* Get the billing fax number. |
922
|
|
|
* |
923
|
|
|
* @return string |
924
|
|
|
*/ |
925
|
6 |
|
public function getBillingFax() |
926
|
|
|
{ |
927
|
6 |
|
return $this->getParameter('billingFax'); |
928
|
|
|
} |
929
|
|
|
|
930
|
|
|
/** |
931
|
|
|
* Sets the billing fax number. |
932
|
|
|
* |
933
|
|
|
* @param string $value |
934
|
|
|
* @return $this |
935
|
|
|
*/ |
936
|
3 |
|
public function setBillingFax($value) |
937
|
|
|
{ |
938
|
3 |
|
return $this->setParameter('billingFax', $value); |
939
|
|
|
} |
940
|
|
|
|
941
|
|
|
/** |
942
|
|
|
* Get the title of the card shipping name. |
943
|
|
|
* |
944
|
|
|
* @return string |
945
|
|
|
*/ |
946
|
3 |
|
public function getShippingTitle() |
947
|
|
|
{ |
948
|
3 |
|
return $this->getParameter('shippingTitle'); |
949
|
|
|
} |
950
|
|
|
|
951
|
|
|
/** |
952
|
|
|
* Sets the title of the card shipping name. |
953
|
|
|
* |
954
|
|
|
* @param string $value |
955
|
|
|
* @return $this |
956
|
|
|
*/ |
957
|
6 |
|
public function setShippingTitle($value) |
958
|
|
|
{ |
959
|
6 |
|
return $this->setParameter('shippingTitle', $value); |
960
|
|
|
} |
961
|
|
|
|
962
|
|
|
/** |
963
|
|
|
* Get the card shipping name. |
964
|
|
|
* |
965
|
|
|
* @return string |
966
|
|
|
*/ |
967
|
3 |
|
public function getShippingName() |
968
|
|
|
{ |
969
|
3 |
|
return trim($this->getShippingFirstName() . ' ' . $this->getShippingLastName()); |
970
|
|
|
} |
971
|
|
|
|
972
|
|
|
/** |
973
|
|
|
* Sets the card shipping name. |
974
|
|
|
* |
975
|
|
|
* @param string $value |
976
|
|
|
* @return $this |
977
|
|
|
*/ |
978
|
21 |
|
public function setShippingName($value) |
979
|
|
|
{ |
980
|
21 |
|
$names = $this->listFirstLastName($value); |
981
|
|
|
|
982
|
21 |
|
$this->setShippingFirstName($names[0]); |
983
|
21 |
|
$this->setShippingLastName($names[1]); |
984
|
|
|
|
985
|
21 |
|
return $this; |
986
|
|
|
} |
987
|
|
|
|
988
|
|
|
/** |
989
|
|
|
* Get the first part of the card shipping name. |
990
|
|
|
* |
991
|
|
|
* @return string |
992
|
|
|
*/ |
993
|
6 |
|
public function getShippingFirstName() |
994
|
|
|
{ |
995
|
6 |
|
return $this->getParameter('shippingFirstName'); |
996
|
|
|
} |
997
|
|
|
|
998
|
|
|
/** |
999
|
|
|
* Sets the first part of the card shipping name. |
1000
|
|
|
* |
1001
|
|
|
* @param string $value |
1002
|
|
|
* @return $this |
1003
|
|
|
*/ |
1004
|
279 |
|
public function setShippingFirstName($value) |
1005
|
|
|
{ |
1006
|
279 |
|
return $this->setParameter('shippingFirstName', $value); |
1007
|
|
|
} |
1008
|
|
|
|
1009
|
|
|
/** |
1010
|
|
|
* Get the last part of the card shipping name. |
1011
|
|
|
* |
1012
|
|
|
* @return string |
1013
|
|
|
*/ |
1014
|
6 |
|
public function getShippingLastName() |
1015
|
|
|
{ |
1016
|
6 |
|
return $this->getParameter('shippingLastName'); |
1017
|
|
|
} |
1018
|
|
|
|
1019
|
|
|
/** |
1020
|
|
|
* Sets the last part of the card shipping name. |
1021
|
|
|
* |
1022
|
|
|
* @param string $value |
1023
|
|
|
* @return $this |
1024
|
|
|
*/ |
1025
|
279 |
|
public function setShippingLastName($value) |
1026
|
|
|
{ |
1027
|
279 |
|
return $this->setParameter('shippingLastName', $value); |
1028
|
|
|
} |
1029
|
|
|
|
1030
|
|
|
/** |
1031
|
|
|
* Get the shipping company name. |
1032
|
|
|
* |
1033
|
|
|
* @return string |
1034
|
|
|
*/ |
1035
|
6 |
|
public function getShippingCompany() |
1036
|
|
|
{ |
1037
|
6 |
|
return $this->getParameter('shippingCompany'); |
1038
|
|
|
} |
1039
|
|
|
|
1040
|
|
|
/** |
1041
|
|
|
* Sets the shipping company name. |
1042
|
|
|
* |
1043
|
|
|
* @param string $value |
1044
|
|
|
* @return $this |
1045
|
|
|
*/ |
1046
|
3 |
|
public function setShippingCompany($value) |
1047
|
|
|
{ |
1048
|
3 |
|
return $this->setParameter('shippingCompany', $value); |
1049
|
|
|
} |
1050
|
|
|
|
1051
|
|
|
/** |
1052
|
|
|
* Get the shipping address, line 1. |
1053
|
|
|
* |
1054
|
|
|
* @return string |
1055
|
|
|
*/ |
1056
|
6 |
|
public function getShippingAddress1() |
1057
|
|
|
{ |
1058
|
6 |
|
return $this->getParameter('shippingAddress1'); |
1059
|
|
|
} |
1060
|
|
|
|
1061
|
|
|
/** |
1062
|
|
|
* Sets the shipping address, line 1. |
1063
|
|
|
* |
1064
|
|
|
* @param string $value |
1065
|
|
|
* @return $this |
1066
|
|
|
*/ |
1067
|
3 |
|
public function setShippingAddress1($value) |
1068
|
|
|
{ |
1069
|
3 |
|
return $this->setParameter('shippingAddress1', $value); |
1070
|
|
|
} |
1071
|
|
|
|
1072
|
|
|
/** |
1073
|
|
|
* Get the shipping address, line 2. |
1074
|
|
|
* |
1075
|
|
|
* @return string |
1076
|
|
|
*/ |
1077
|
6 |
|
public function getShippingAddress2() |
1078
|
|
|
{ |
1079
|
6 |
|
return $this->getParameter('shippingAddress2'); |
1080
|
|
|
} |
1081
|
|
|
|
1082
|
|
|
/** |
1083
|
|
|
* Sets the shipping address, line 2. |
1084
|
|
|
* |
1085
|
|
|
* @param string $value |
1086
|
|
|
* @return $this |
1087
|
|
|
*/ |
1088
|
3 |
|
public function setShippingAddress2($value) |
1089
|
|
|
{ |
1090
|
3 |
|
return $this->setParameter('shippingAddress2', $value); |
1091
|
|
|
} |
1092
|
|
|
|
1093
|
|
|
/** |
1094
|
|
|
* Get the shipping city. |
1095
|
|
|
* |
1096
|
|
|
* @return string |
1097
|
|
|
*/ |
1098
|
6 |
|
public function getShippingCity() |
1099
|
|
|
{ |
1100
|
6 |
|
return $this->getParameter('shippingCity'); |
1101
|
|
|
} |
1102
|
|
|
|
1103
|
|
|
/** |
1104
|
|
|
* Sets the shipping city. |
1105
|
|
|
* |
1106
|
|
|
* @param string $value |
1107
|
|
|
* @return $this |
1108
|
|
|
*/ |
1109
|
3 |
|
public function setShippingCity($value) |
1110
|
|
|
{ |
1111
|
3 |
|
return $this->setParameter('shippingCity', $value); |
1112
|
|
|
} |
1113
|
|
|
|
1114
|
|
|
/** |
1115
|
|
|
* Get the shipping postcode. |
1116
|
|
|
* |
1117
|
|
|
* @return string |
1118
|
|
|
*/ |
1119
|
6 |
|
public function getShippingPostcode() |
1120
|
|
|
{ |
1121
|
6 |
|
return $this->getParameter('shippingPostcode'); |
1122
|
|
|
} |
1123
|
|
|
|
1124
|
|
|
/** |
1125
|
|
|
* Sets the shipping postcode. |
1126
|
|
|
* |
1127
|
|
|
* @param string $value |
1128
|
|
|
* @return $this |
1129
|
|
|
*/ |
1130
|
3 |
|
public function setShippingPostcode($value) |
1131
|
|
|
{ |
1132
|
3 |
|
return $this->setParameter('shippingPostcode', $value); |
1133
|
|
|
} |
1134
|
|
|
|
1135
|
|
|
/** |
1136
|
|
|
* Get the shipping state. |
1137
|
|
|
* |
1138
|
|
|
* @return string |
1139
|
|
|
*/ |
1140
|
6 |
|
public function getShippingState() |
1141
|
|
|
{ |
1142
|
6 |
|
return $this->getParameter('shippingState'); |
1143
|
|
|
} |
1144
|
|
|
|
1145
|
|
|
/** |
1146
|
|
|
* Sets the shipping state. |
1147
|
|
|
* |
1148
|
|
|
* @param string $value |
1149
|
|
|
* @return $this |
1150
|
|
|
*/ |
1151
|
3 |
|
public function setShippingState($value) |
1152
|
|
|
{ |
1153
|
3 |
|
return $this->setParameter('shippingState', $value); |
1154
|
|
|
} |
1155
|
|
|
|
1156
|
|
|
/** |
1157
|
|
|
* Get the shipping country. |
1158
|
|
|
* |
1159
|
|
|
* @return string |
1160
|
|
|
*/ |
1161
|
6 |
|
public function getShippingCountry() |
1162
|
|
|
{ |
1163
|
6 |
|
return $this->getParameter('shippingCountry'); |
1164
|
|
|
} |
1165
|
|
|
|
1166
|
|
|
/** |
1167
|
|
|
* Sets the shipping country. |
1168
|
|
|
* |
1169
|
|
|
* @param string $value |
1170
|
|
|
* @return $this |
1171
|
|
|
*/ |
1172
|
3 |
|
public function setShippingCountry($value) |
1173
|
|
|
{ |
1174
|
3 |
|
return $this->setParameter('shippingCountry', $value); |
1175
|
|
|
} |
1176
|
|
|
|
1177
|
|
|
/** |
1178
|
|
|
* Get the shipping phone number. |
1179
|
|
|
* |
1180
|
|
|
* @return string |
1181
|
|
|
*/ |
1182
|
6 |
|
public function getShippingPhone() |
1183
|
|
|
{ |
1184
|
6 |
|
return $this->getParameter('shippingPhone'); |
1185
|
|
|
} |
1186
|
|
|
|
1187
|
|
|
/** |
1188
|
|
|
* Sets the shipping phone number. |
1189
|
|
|
* |
1190
|
|
|
* @param string $value |
1191
|
|
|
* @return $this |
1192
|
|
|
*/ |
1193
|
3 |
|
public function setShippingPhone($value) |
1194
|
|
|
{ |
1195
|
3 |
|
return $this->setParameter('shippingPhone', $value); |
1196
|
|
|
} |
1197
|
|
|
|
1198
|
|
|
/** |
1199
|
|
|
* Get the shipping phone number extension. |
1200
|
|
|
* |
1201
|
|
|
* @return string |
1202
|
|
|
*/ |
1203
|
6 |
|
public function getShippingPhoneExtension() |
1204
|
|
|
{ |
1205
|
6 |
|
return $this->getParameter('shippingPhoneExtension'); |
1206
|
|
|
} |
1207
|
|
|
|
1208
|
|
|
/** |
1209
|
|
|
* Sets the shipping phone number extension. |
1210
|
|
|
* |
1211
|
|
|
* @param string $value |
1212
|
|
|
* @return $this |
1213
|
|
|
*/ |
1214
|
3 |
|
public function setShippingPhoneExtension($value) |
1215
|
|
|
{ |
1216
|
3 |
|
return $this->setParameter('shippingPhoneExtension', $value); |
1217
|
|
|
} |
1218
|
|
|
|
1219
|
|
|
/** |
1220
|
|
|
* Get the shipping fax number. |
1221
|
|
|
* |
1222
|
|
|
* @return string |
1223
|
|
|
*/ |
1224
|
6 |
|
public function getShippingFax() |
1225
|
|
|
{ |
1226
|
6 |
|
return $this->getParameter('shippingFax'); |
1227
|
|
|
} |
1228
|
|
|
|
1229
|
|
|
/** |
1230
|
|
|
* Sets the shipping fax number. |
1231
|
|
|
* |
1232
|
|
|
* @param string $value |
1233
|
|
|
* @return $this |
1234
|
|
|
*/ |
1235
|
3 |
|
public function setShippingFax($value) |
1236
|
|
|
{ |
1237
|
3 |
|
return $this->setParameter('shippingFax', $value); |
1238
|
|
|
} |
1239
|
|
|
|
1240
|
|
|
/** |
1241
|
|
|
* Get the billing address, line 1. |
1242
|
|
|
* |
1243
|
|
|
* @return string |
1244
|
|
|
*/ |
1245
|
6 |
|
public function getAddress1() |
1246
|
|
|
{ |
1247
|
6 |
|
return $this->getParameter('billingAddress1'); |
1248
|
|
|
} |
1249
|
|
|
|
1250
|
|
|
/** |
1251
|
|
|
* Sets the billing and shipping address, line 1. |
1252
|
|
|
* |
1253
|
|
|
* @param string $value |
1254
|
|
|
* @return $this |
1255
|
|
|
*/ |
1256
|
3 |
|
public function setAddress1($value) |
1257
|
|
|
{ |
1258
|
3 |
|
$this->setParameter('billingAddress1', $value); |
1259
|
3 |
|
$this->setParameter('shippingAddress1', $value); |
1260
|
|
|
|
1261
|
3 |
|
return $this; |
1262
|
|
|
} |
1263
|
|
|
|
1264
|
|
|
/** |
1265
|
|
|
* Get the billing address, line 2. |
1266
|
|
|
* |
1267
|
|
|
* @return string |
1268
|
|
|
*/ |
1269
|
6 |
|
public function getAddress2() |
1270
|
|
|
{ |
1271
|
6 |
|
return $this->getParameter('billingAddress2'); |
1272
|
|
|
} |
1273
|
|
|
|
1274
|
|
|
/** |
1275
|
|
|
* Sets the billing and shipping address, line 2. |
1276
|
|
|
* |
1277
|
|
|
* @param string $value |
1278
|
|
|
* @return $this |
1279
|
|
|
*/ |
1280
|
3 |
|
public function setAddress2($value) |
1281
|
|
|
{ |
1282
|
3 |
|
$this->setParameter('billingAddress2', $value); |
1283
|
3 |
|
$this->setParameter('shippingAddress2', $value); |
1284
|
|
|
|
1285
|
3 |
|
return $this; |
1286
|
|
|
} |
1287
|
|
|
|
1288
|
|
|
/** |
1289
|
|
|
* Get the billing city. |
1290
|
|
|
* |
1291
|
|
|
* @return string |
1292
|
|
|
*/ |
1293
|
6 |
|
public function getCity() |
1294
|
|
|
{ |
1295
|
6 |
|
return $this->getParameter('billingCity'); |
1296
|
|
|
} |
1297
|
|
|
|
1298
|
|
|
/** |
1299
|
|
|
* Sets the billing and shipping city. |
1300
|
|
|
* |
1301
|
|
|
* @param string $value |
1302
|
|
|
* @return $this |
1303
|
|
|
*/ |
1304
|
3 |
|
public function setCity($value) |
1305
|
|
|
{ |
1306
|
3 |
|
$this->setParameter('billingCity', $value); |
1307
|
3 |
|
$this->setParameter('shippingCity', $value); |
1308
|
|
|
|
1309
|
3 |
|
return $this; |
1310
|
|
|
} |
1311
|
|
|
|
1312
|
|
|
/** |
1313
|
|
|
* Get the billing postcode. |
1314
|
|
|
* |
1315
|
|
|
* @return string |
1316
|
|
|
*/ |
1317
|
6 |
|
public function getPostcode() |
1318
|
|
|
{ |
1319
|
6 |
|
return $this->getParameter('billingPostcode'); |
1320
|
|
|
} |
1321
|
|
|
|
1322
|
|
|
/** |
1323
|
|
|
* Sets the billing and shipping postcode. |
1324
|
|
|
* |
1325
|
|
|
* @param string $value |
1326
|
|
|
* @return $this |
1327
|
|
|
*/ |
1328
|
3 |
|
public function setPostcode($value) |
1329
|
|
|
{ |
1330
|
3 |
|
$this->setParameter('billingPostcode', $value); |
1331
|
3 |
|
$this->setParameter('shippingPostcode', $value); |
1332
|
|
|
|
1333
|
3 |
|
return $this; |
1334
|
|
|
} |
1335
|
|
|
|
1336
|
|
|
/** |
1337
|
|
|
* Get the billing state. |
1338
|
|
|
* |
1339
|
|
|
* @return string |
1340
|
|
|
*/ |
1341
|
6 |
|
public function getState() |
1342
|
|
|
{ |
1343
|
6 |
|
return $this->getParameter('billingState'); |
1344
|
|
|
} |
1345
|
|
|
|
1346
|
|
|
/** |
1347
|
|
|
* Sets the billing and shipping state. |
1348
|
|
|
* |
1349
|
|
|
* @param string $value |
1350
|
|
|
* @return $this |
1351
|
|
|
*/ |
1352
|
3 |
|
public function setState($value) |
1353
|
|
|
{ |
1354
|
3 |
|
$this->setParameter('billingState', $value); |
1355
|
3 |
|
$this->setParameter('shippingState', $value); |
1356
|
|
|
|
1357
|
3 |
|
return $this; |
1358
|
|
|
} |
1359
|
|
|
|
1360
|
|
|
/** |
1361
|
|
|
* Get the billing country. |
1362
|
|
|
* |
1363
|
|
|
* @return string |
1364
|
|
|
*/ |
1365
|
6 |
|
public function getCountry() |
1366
|
|
|
{ |
1367
|
6 |
|
return $this->getParameter('billingCountry'); |
1368
|
|
|
} |
1369
|
|
|
|
1370
|
|
|
/** |
1371
|
|
|
* Sets the billing and shipping country. |
1372
|
|
|
* |
1373
|
|
|
* @param string $value |
1374
|
|
|
* @return $this |
1375
|
|
|
*/ |
1376
|
3 |
|
public function setCountry($value) |
1377
|
|
|
{ |
1378
|
3 |
|
$this->setParameter('billingCountry', $value); |
1379
|
3 |
|
$this->setParameter('shippingCountry', $value); |
1380
|
|
|
|
1381
|
3 |
|
return $this; |
1382
|
|
|
} |
1383
|
|
|
|
1384
|
|
|
/** |
1385
|
|
|
* Get the billing phone number. |
1386
|
|
|
* |
1387
|
|
|
* @return string |
1388
|
|
|
*/ |
1389
|
6 |
|
public function getPhone() |
1390
|
|
|
{ |
1391
|
6 |
|
return $this->getParameter('billingPhone'); |
1392
|
|
|
} |
1393
|
|
|
|
1394
|
|
|
/** |
1395
|
|
|
* Sets the billing and shipping phone number. |
1396
|
|
|
* |
1397
|
|
|
* @param string $value |
1398
|
|
|
* @return $this |
1399
|
|
|
*/ |
1400
|
3 |
|
public function setPhone($value) |
1401
|
|
|
{ |
1402
|
3 |
|
$this->setParameter('billingPhone', $value); |
1403
|
3 |
|
$this->setParameter('shippingPhone', $value); |
1404
|
|
|
|
1405
|
3 |
|
return $this; |
1406
|
|
|
} |
1407
|
|
|
|
1408
|
|
|
/** |
1409
|
|
|
* Get the billing phone number extension. |
1410
|
|
|
* |
1411
|
|
|
* @return string |
1412
|
|
|
*/ |
1413
|
6 |
|
public function getPhoneExtension() |
1414
|
|
|
{ |
1415
|
6 |
|
return $this->getParameter('billingPhoneExtension'); |
1416
|
|
|
} |
1417
|
|
|
|
1418
|
|
|
/** |
1419
|
|
|
* Sets the billing and shipping phone number extension. |
1420
|
|
|
* |
1421
|
|
|
* @param string $value |
1422
|
|
|
* @return $this |
1423
|
|
|
*/ |
1424
|
3 |
|
public function setPhoneExtension($value) |
1425
|
|
|
{ |
1426
|
3 |
|
$this->setParameter('billingPhoneExtension', $value); |
1427
|
3 |
|
$this->setParameter('shippingPhoneExtension', $value); |
1428
|
|
|
|
1429
|
3 |
|
return $this; |
1430
|
|
|
} |
1431
|
|
|
|
1432
|
|
|
/** |
1433
|
|
|
* Get the billing fax number.. |
1434
|
|
|
* |
1435
|
|
|
* @return string |
1436
|
|
|
*/ |
1437
|
6 |
|
public function getFax() |
1438
|
|
|
{ |
1439
|
6 |
|
return $this->getParameter('billingFax'); |
1440
|
|
|
} |
1441
|
|
|
|
1442
|
|
|
/** |
1443
|
|
|
* Sets the billing and shipping fax number. |
1444
|
|
|
* |
1445
|
|
|
* @param string $value |
1446
|
|
|
* @return $this |
1447
|
|
|
*/ |
1448
|
3 |
|
public function setFax($value) |
1449
|
|
|
{ |
1450
|
3 |
|
$this->setParameter('billingFax', $value); |
1451
|
3 |
|
$this->setParameter('shippingFax', $value); |
1452
|
|
|
|
1453
|
3 |
|
return $this; |
1454
|
|
|
} |
1455
|
|
|
|
1456
|
|
|
/** |
1457
|
|
|
* Get the card billing company name. |
1458
|
|
|
* |
1459
|
|
|
* @return string |
1460
|
|
|
*/ |
1461
|
6 |
|
public function getCompany() |
1462
|
|
|
{ |
1463
|
6 |
|
return $this->getParameter('billingCompany'); |
1464
|
|
|
} |
1465
|
|
|
|
1466
|
|
|
/** |
1467
|
|
|
* Sets the billing and shipping company name. |
1468
|
|
|
* |
1469
|
|
|
* @param string $value |
1470
|
|
|
* @return $this |
1471
|
|
|
*/ |
1472
|
3 |
|
public function setCompany($value) |
1473
|
|
|
{ |
1474
|
3 |
|
$this->setParameter('billingCompany', $value); |
1475
|
3 |
|
$this->setParameter('shippingCompany', $value); |
1476
|
|
|
|
1477
|
3 |
|
return $this; |
1478
|
|
|
} |
1479
|
|
|
|
1480
|
|
|
/** |
1481
|
|
|
* Get the cardholder's email address. |
1482
|
|
|
* |
1483
|
|
|
* @return string |
1484
|
|
|
*/ |
1485
|
3 |
|
public function getEmail() |
1486
|
|
|
{ |
1487
|
3 |
|
return $this->getParameter('email'); |
1488
|
|
|
} |
1489
|
|
|
|
1490
|
|
|
/** |
1491
|
|
|
* Sets the cardholder's email address. |
1492
|
|
|
* |
1493
|
|
|
* @param string $value |
1494
|
|
|
* @return $this |
1495
|
|
|
*/ |
1496
|
3 |
|
public function setEmail($value) |
1497
|
|
|
{ |
1498
|
3 |
|
return $this->setParameter('email', $value); |
1499
|
|
|
} |
1500
|
|
|
|
1501
|
|
|
/** |
1502
|
|
|
* Get the cardholder's birthday. |
1503
|
|
|
* |
1504
|
|
|
* @return string |
1505
|
|
|
*/ |
1506
|
6 |
|
public function getBirthday($format = 'Y-m-d') |
1507
|
|
|
{ |
1508
|
6 |
|
$value = $this->getParameter('birthday'); |
1509
|
|
|
|
1510
|
6 |
|
return $value ? $value->format($format) : null; |
1511
|
|
|
} |
1512
|
|
|
|
1513
|
|
|
/** |
1514
|
|
|
* Sets the cardholder's birthday. |
1515
|
|
|
* |
1516
|
|
|
* @param string $value |
1517
|
|
|
* @return $this |
1518
|
|
|
*/ |
1519
|
6 |
|
public function setBirthday($value) |
1520
|
|
|
{ |
1521
|
6 |
|
if ($value) { |
1522
|
3 |
|
$value = new DateTime($value, new DateTimeZone('UTC')); |
1523
|
|
|
} else { |
1524
|
3 |
|
$value = null; |
1525
|
|
|
} |
1526
|
|
|
|
1527
|
6 |
|
return $this->setParameter('birthday', $value); |
1528
|
|
|
} |
1529
|
|
|
|
1530
|
|
|
/** |
1531
|
|
|
* Get the cardholder's gender. |
1532
|
|
|
* |
1533
|
|
|
* @return string |
1534
|
|
|
*/ |
1535
|
3 |
|
public function getGender() |
1536
|
|
|
{ |
1537
|
3 |
|
return $this->getParameter('gender'); |
1538
|
|
|
} |
1539
|
|
|
|
1540
|
|
|
/** |
1541
|
|
|
* Sets the cardholder's gender. |
1542
|
|
|
* |
1543
|
|
|
* @param string $value |
1544
|
|
|
* @return $this |
1545
|
|
|
*/ |
1546
|
3 |
|
public function setGender($value) |
1547
|
|
|
{ |
1548
|
3 |
|
return $this->setParameter('gender', $value); |
1549
|
|
|
} |
1550
|
|
|
} |
1551
|
|
|
|