Completed
Pull Request — master (#5)
by Leith
08:28
created

PurchaseRequest::getHomePhone()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Omnipay\Redsys\Message;
4
5
use DateTime;
6
use DateTimeZone;
7
use Omnipay\Common\Message\AbstractRequest;
8
use Omnipay\Common\Exception\InvalidRequestException;
9
10
/**
11
 * Redsys Purchase Request
12
 *
13
 * @todo consider shifting date formatters out of getData() and into parameter setters so that request->all() has sensible values
14
 */
15
class PurchaseRequest extends AbstractRequest
16
{
17
    /** @var string */
18
    protected $liveEndpoint = 'https://sis.redsys.es/sis/realizarPago';
19
    /** @var string */
20
    protected $testEndpoint = 'https://sis-t.redsys.es:25443/sis/realizarPago';
21
    /** @var array */
22
    protected static $consumerLanguages = array(
23
        'es' => '001', // Spanish
24
        'en' => '002', // English
25
        'ca' => '003', // Catalan - same as Valencian (010)
26
        'fr' => '004', // French
27
        'de' => '005', // German
28
        'nl' => '006', // Dutch
29
        'it' => '007', // Italian
30
        'sv' => '008', // Swedish
31
        'pt' => '009', // Portuguese
32 2
        'pl' => '011', // Polish
33
        'gl' => '012', // Galician
34 2
        'eu' => '013', // Basque
35
    );
36
37 4
    /** @var string 250x400 */
38
    const CHALLENGE_WINDOW_SIZE_250_400 = "01";
39 4
    /** @var string 390x400 */
40
    const CHALLENGE_WINDOW_SIZE_390_400 = "02";
41
    /** @var string 500x600 */
42 8
    const CHALLENGE_WINDOW_SIZE_500_600 = "03";
43
    /** @var string 600x400 */
44 8
    const CHALLENGE_WINDOW_SIZE_600_400 = "04";
45
    /** @var string Fullscreen window (default) */
46
    const CHALLENGE_WINDOW_SIZE_FULLSCREEN = "05";
47
48
    /** @var string No 3DS Requestor authentication occurred (i.e. cardholder logged in as guest) */
49
    const ACCOUNT_AUTHENTICATION_METHOD_NONE = "01";
50
    /** @var string Login to the cardholder account at the 3DS Requestor system using 3DS Requestor's own credentials */
51
    const ACCOUNT_AUTHENTICATION_METHOD_OWN_CREDENTIALS = "02";
52 7
    /** @var string Login to the cardholder account at the 3DS Requestor system using federated ID */
53
    const ACCOUNT_AUTHENTICATION_METHOD_FEDERATED_ID = "03";
54 7
    /** @var string Login to the cardholder account at the 3DS Requestor system using issuer credentials */
55 1
    const ACCOUNT_AUTHENTICATION_METHOD_ISSUER_CREDENTIALS = "04";
56 1
    /** @var string Login to the cardholder account at the 3DS Requestor system using third-party authentication */
57 1
    const ACCOUNT_AUTHENTICATION_METHOD_THIRD_PARTY_AUTHENTICATION = "05";
58 1
    /** @var string Login to the cardholder account at the 3DS Requestor system using FIDO Authenticator */
59 7
    const ACCOUNT_AUTHENTICATION_METHOD_FIDO = "06";
60 7
61 7
    /** @var string No account (guest check-out) */
62
    const CUSTOMER_ACCOUNT_CREATED_NONE = "01";
63 7
    /** @var string Created during this transaction */
64
    const CUSTOMER_ACCOUNT_CREATED_THIS_TRANSACTION = "02";
65
    /** @var string Less than 30 days */
66 15
    const CUSTOMER_ACCOUNT_CREATED_LAST_30_DAYS = "03";
67
    /** @var string Between 30 and 60 days */
68 15
    const CUSTOMER_ACCOUNT_CREATED_LAST_60_DAYS = "04";
69
    /** @var string More than 60 day */
70
    const CUSTOMER_ACCOUNT_CREATED_MORE_THAN_60_DAYS = "05";
71 23
72
    /** @var string Modified in this session */
73 23
    const CUSTOMER_ACCOUNT_MODIFIED_THIS_TRANSACTION = "01";
74
    /** @var string Less than 30 days */
75
    const CUSTOMER_ACCOUNT_MODIFIED_LAST_30_DAYS = "02";
76 7
    /** @var string Between 30 and 60 days */
77
    const CUSTOMER_ACCOUNT_MODIFIED_LAST_60_DAYS = "03";
78 7
    /** @var string More than 60 day */
79
    const CUSTOMER_ACCOUNT_MODIFIED_MORE_THAN_60_DAYS = "04";
80
81 7
    /** @var string Unchanged */
82
    const CUSTOMER_ACCOUNT_PASSWORD_MODIFIED_NONE = "01";
83 7
    /** @var string Modified in this session */
84
    const CUSTOMER_ACCOUNT_PASSWORD_MODIFIED_THIS_TRANSACTION = "02";
85
    /** @var string Less than 30 days */
86 11
    const CUSTOMER_ACCOUNT_PASSWORD_MODIFIED_LAST_30_DAYS = "03";
87
    /** @var string Between 30 and 60 days */
88 11
    const CUSTOMER_ACCOUNT_PASSWORD_MODIFIED_LAST_60_DAYS = "04";
89
    /** @var string More than 60 day */
90
    const CUSTOMER_ACCOUNT_PASSWORD_MODIFIED_MORE_THAN_60_DAYS = "05";
91 23
92
    /** @var string No account (guest check-out) */
93 23
    const PAYMENT_METHOD_CREATED_NONE = "01";
94
    /** @var string Created during this transaction */
95
    const PAYMENT_METHOD_CREATED_THIS_TRANSACTION = "02";
96 11
    /** @var string Less than 30 days */
97
    const PAYMENT_METHOD_CREATED_LAST_30_DAYS = "03";
98 11
    /** @var string Between 30 and 60 days */
99
    const PAYMENT_METHOD_CREATED_LAST_60_DAYS = "04";
100
    /** @var string More than 60 day */
101 23
    const PAYMENT_METHOD_CREATED_MORE_THAN_60_DAYS = "05";
102
103 23
    /** @var string For the first time */
104
    const SHIPPING_ADDRESS_USAGE_THIS_TRANSACTION = "01";
105
    /** @var string Less than 30 days */
106 11
    const SHIPPING_ADDRESS_USAGE_LAST_30_DAYS = "02";
107
    /** @var string Between 30 and 60 days */
108 11
    const SHIPPING_ADDRESS_USAGE_LAST_60_DAYS = "03";
109
    /** @var string More than 60 day */
110
    const SHIPPING_ADDRESS_USAGE_MORE_THAN_60_DAYS = "04";
111 23
112
    /** @var string Electronic delivery */
113 23
    const DELIVERY_TIMEFRAME_ELECTRONIC_DELIVERY = "01";
114
    /** @var string Same day shipping */
115
    const DELIVERY_TIMEFRAME_SAME_DAY = "02";
116
    /** @var string Next day shipping */
117
    const DELIVERY_TIMEFRAME_NEXT_DAY = "03";
118
    /** @var string Shipping in 2 or more days */
119
    const DELIVERY_TIMEFRAME_2_OR_MORE_DAYS = "04";
120
121 15
    /** @var string Ship to cardholder's billing address */
122
    const SHIPPING_TO_BILLING_ADDRESS = "01";
123 15
    /** @var string Ship to another verified address on file with merchant */
124 15
    const SHIPPING_TO_ANOTHER_VERIFIED_ADDRESS = "02";
125 15
    /** @var string Ship to address that is different than the cardholder's billing address */
126 15
    const SHIPPING_DIFFERENT_BILLING_ADDRESS = "03";
127 15
    /** @var string Pick-up at local store (Store address shall be populated in shipping address fields) */
128 15
    const SHIPPING_PICK_UP = "04";
129 15
    /** @var string Digital goods (includes online services, electronic gift cards and redemption codes) */
130
    const SHIPPING_DIGITAL = "05";
131 15
    /** @var string Travel and Event tickets, not shipped */
132 15
    const SHIPPING_TRAVEL = "06";
133
    /** @var string Other (for example, Gaming, digital services not shipped, emedia subscriptions, etc.) */
134 15
    const SHIPPING_OTHER = "07";
135 15
136
    /** @var string Exemption due to low amount (transactions up to € 30) */
137 2
    const SCA_EXEMPTION_LOW_AMOUNT = 'LMV';
138
    /** @var string Exemption due to low risk */
139 2
    const SCA_EXEMPTION_LOW_RISK = 'TRA';
140
    /** @var string Exemption for payments identified as corporate. */
141
    const SCA_EXEMPTION_CORPORATE = 'COR';
142
    /**
143 2
     * @var string Transactions initiated by the merchant, in which there is no intervention by the customer. They are
144 2
     *             outside the scope of PSD2.
145 2
     */
146 2
    const SCA_EXEMPTION_MERCHANT_INITIATED = 'MIT';
147 2
148 2
    public function getCardholder()
149 2
    {
150
        return $this->getParameter('cardholder');
151 2
    }
152 2
153 2
    public function setCardholder($value)
154 2
    {
155 2
        return $this->setParameter('cardholder', $value);
156 2
    }
157 2
158 2
    public function getConsumerLanguage()
159
    {
160
        return $this->getParameter('consumerLanguage');
161 1
    }
162
163 1
    /**
164
     * Set the language presented to the consumer
165 1
     *
166
     * @param null|string|int Either the ISO 639-1 code to be converted, or the gateway's own numeric language code
167
     */
168 1
    public function setConsumerLanguage($value)
169 1
    {
170 1
        if (is_int($value)) {
171 1
            if ($value < 0 || $value > 13) {
172 1
                $value = 1;
173 1
            }
174 1
            $value = str_pad($value, 3, '0', STR_PAD_LEFT);
175 1
        } elseif (!is_numeric($value)) {
176
            $value = isset(self::$consumerLanguages[$value]) ? self::$consumerLanguages[$value] : '001';
177 1
        }
178
179
        return $this->setParameter('consumerLanguage', $value);
180 7
    }
181
182 7
    public function getHmacKey()
183
    {
184
        return $this->getParameter('hmacKey');
185 1
    }
186
187
    public function setHmacKey($value)
188
    {
189
        return $this->setParameter('hmacKey', $value);
190
    }
191
192
    public function getMerchantData()
193
    {
194
        return $this->getParameter('merchantData');
195
    }
196
197
    public function setMerchantData($value)
198
    {
199
        return $this->setParameter('merchantData', $value);
200
    }
201
202
    public function getMerchantId()
203
    {
204
        return $this->getParameter('merchantId');
205
    }
206
207
    public function setMerchantId($value)
208
    {
209
        return $this->setParameter('merchantId', $value);
210
    }
211
212
    public function getMerchantName()
213
    {
214
        return $this->getParameter('merchantName');
215
    }
216
217
    public function setMerchantName($value)
218
    {
219
        return $this->setParameter('merchantName', $value);
220
    }
221
222
    public function getTerminalId()
223
    {
224
        return $this->getParameter('terminalId');
225
    }
226
227
    public function setTerminalId($value)
228
    {
229
        return $this->setParameter('terminalId', $value);
230
    }
231
232
    /**
233
     * Get the use3ds field
234
     *
235
     * Controls the presence of the Ds_Merchant_Emv3Ds structure
236
     *
237
     * @return bool
238
     */
239
    public function getUse3DS()
240
    {
241
        return (bool) $this->getParameter('use3ds');
242
    }
243
244
    /**
245
     * Set the use3ds field
246
     *
247
     * Controls the presence of the Ds_Merchant_Emv3Ds structure
248
     *
249
     * @param bool $value
250
     * @return self
251
     */
252
    public function setUse3DS($value)
253
    {
254
        return $this->setParameter('use3ds', $value);
255
    }
256
257
    /**
258
     * Get the homePhoneCountryPrefix field
259
     *
260
     * Corresponds to the Ds_Merchant_Emv3Ds.homePhone.cc field
261
     *
262
     * @return null|string
263
     */
264
    public function getHomePhoneCountryPrefix()
265
    {
266
        return $this->getParameter('homePhoneCountryPrefix');
267
    }
268
269
    /**
270
     * Set the homePhoneCountryPrefix field
271
     *
272
     * Corresponds to the Ds_Merchant_Emv3Ds.homePhone.cc field
273
     *
274
     * @param null|string $value
275
     * @return self
276
     */
277
    public function setHomePhoneCountryPrefix($value)
278
    {
279
        return $this->setParameter('homePhoneCountryPrefix', $value);
280
    }
281
282
    /**
283
     * Get the homePhone field
284
     *
285
     * Corresponds to the Ds_Merchant_Emv3Ds.homePhone.subscriber field
286
     *
287
     * @return null|string
288
     */
289
    public function getHomePhone()
290
    {
291
        return $this->getParameter('homePhone');
292
    }
293
294
    /**
295
     * Set the homePhone field
296
     *
297
     * Corresponds to the Ds_Merchant_Emv3Ds.homePhone.subscriber field
298
     *
299
     * @param null|string $value
300
     * @return self
301
     */
302
    public function setHomePhone($value)
303
    {
304
        return $this->setParameter('homePhone', $value);
305
    }
306
307
    /**
308
     * Get the mobilePhoneCountryPrefix field
309
     *
310
     * Corresponds to the Ds_Merchant_Emv3Ds.mobilePhone.cc field
311
     *
312
     * @return null|string
313
     */
314
    public function getMobilePhoneCountryPrefix()
315
    {
316
        return $this->getParameter('mobilePhoneCountryPrefix');
317
    }
318
319
    /**
320
     * Set the mobilePhoneCountryPrefix field
321
     *
322
     * Corresponds to the Ds_Merchant_Emv3Ds.mobilePhone.cc field
323
     *
324
     * @param null|string $value
325
     * @return self
326
     */
327
    public function setMobilePhoneCountryPrefix($value)
328
    {
329
        return $this->setParameter('mobilePhoneCountryPrefix', $value);
330
    }
331
332
    /**
333
     * Get the mobilePhone field
334
     *
335
     * Corresponds to the Ds_Merchant_Emv3Ds.mobilePhone.subscriber field
336
     *
337
     * @return null|string
338
     */
339
    public function getMobilePhone()
340
    {
341
        return $this->getParameter('mobilePhone');
342
    }
343
344
    /**
345
     * Set the mobilePhone field
346
     *
347
     * Corresponds to the Ds_Merchant_Emv3Ds.mobilePhone.subscriber field
348
     *
349
     * @param null|string $value
350
     * @return self
351
     */
352
    public function setMobilePhone($value)
353
    {
354
        return $this->setParameter('mobilePhone', $value);
355
    }
356
357
    /**
358
     * Get the workPhoneCountryPrefix field
359
     *
360
     * Corresponds to the Ds_Merchant_Emv3Ds.workPhone.cc field
361
     *
362
     * @return null|string
363
     */
364
    public function getWorkPhoneCountryPrefix()
365
    {
366
        return $this->getParameter('workPhoneCountryPrefix');
367
    }
368
369
    /**
370
     * Set the workPhoneCountryPrefix field
371
     *
372
     * Corresponds to the Ds_Merchant_Emv3Ds.workPhone.cc field
373
     *
374
     * @param null|string $value
375
     * @return self
376
     */
377
    public function setWorkPhoneCountryPrefix($value)
378
    {
379
        return $this->setParameter('workPhoneCountryPrefix', $value);
380
    }
381
382
    /**
383
     * Get the workPhone field
384
     *
385
     * Corresponds to the Ds_Merchant_Emv3Ds.workPhone.subscriber field
386
     *
387
     * @return null|string
388
     */
389
    public function getWorkPhone()
390
    {
391
        return $this->getParameter('workPhone');
392
    }
393
394
    /**
395
     * Set the workPhone field
396
     *
397
     * Corresponds to the Ds_Merchant_Emv3Ds.workPhone.subscriber field
398
     *
399
     * @param null|string $value
400
     * @return self
401
     */
402
    public function setWorkPhone($value)
403
    {
404
        return $this->setParameter('workPhone', $value);
405
    }
406
407
    /**
408
     * Get the addressMatch field
409
     *
410
     * Corresponds to the Ds_Merchant_Emv3Ds.addrMatch field
411
     *
412
     * @return string  Either 'Y' or 'N'
413
     */
414
    public function getAddressMatch()
415
    {
416
        $match = $this->getParameter('addressMatch');
417
418
        if ($match === null) {
419
            $match = false;
420
            $card = $this->getCard();
421
            if ($card !== null) {
422
                $match = $card->getShippingAddress1() === $card->getBillingAddress1()
423
                    && $card->getShippingAddress2() === $card->getBillingAddress2()
424
                    && $card->getShippingAddress3() === $card->getBillingAddress3()
425
                    && $card->getShippingCity() === $card->getBillingCity()
426
                    && $card->getShippingPostcode() === $card->getBillingPostcode()
427
                    && $card->getShippingState() === $card->getBillingState()
428
                    && $card->getShippingCountry() === $card->getBillingCountry();
429
            }
430
        }
431
432
        return $match ? "Y" : "N";
433
    }
434
435
    /**
436
     * Set the addressMatch field
437
     *
438
     * Corresponds to the Ds_Merchant_Emv3Ds.addrMatch field
439
     *
440
     * @param null|boolean $value
441
     * @return self
442
     */
443
    public function setAddressMatch($value)
444
    {
445
        return $this->setParameter('addressMatch', $value);
446
    }
447
448
    /**
449
     * Get the challengeWindowSize field
450
     *
451
     * Corresponds to the Ds_Merchant_Emv3Ds.challengeWindowSize field
452
     *
453
     * @return null|string One of the self::CHALLENGE_WINDOW_SIZE_* constants
454
     */
455
    public function getChallengeWindowSize()
456
    {
457
        return $this->getParameter('challengeWindowSize');
458
    }
459
460
    /**
461
     * Set the challengeWindowSize field
462
     *
463
     * Corresponds to the Ds_Merchant_Emv3Ds.challengeWindowSize field
464
     *
465
     * @param null|string $value One of the self::CHALLENGE_WINDOW_SIZE_* constants
466
     * @return self
467
     * @throws InvalidRequestException if $value is invalid.
468
     */
469
    public function setChallengeWindowSize($value)
470
    {
471
        if (in_array(
472
            $value,
473
            [
474
                null,
475
                self::CHALLENGE_WINDOW_SIZE_250_400,
476
                self::CHALLENGE_WINDOW_SIZE_390_400,
477
                self::CHALLENGE_WINDOW_SIZE_500_600,
478
                self::CHALLENGE_WINDOW_SIZE_600_400,
479
                self::CHALLENGE_WINDOW_SIZE_FULLSCREEN,
480
            ]
481
        )) {
482
            return $this->setParameter('challengeWindowSize', $value);
483
        }
484
        throw new InvalidRequestException("Invalid challengeWindowSize parameter");
485
    }
486
487
    /**
488
     * Get the customerAdditionalInformation field
489
     *
490
     * Corresponds to the Ds_Merchant_Emv3Ds.acctID field
491
     *
492
     * @return null|string
493
     */
494
    public function getCustomerAdditionalInformation()
495
    {
496
        return $this->getParameter('customerAdditionalInformation');
497
    }
498
499
    /**
500
     * Set the customerAdditionalInformation field
501
     *
502
     * Corresponds to the Ds_Merchant_Emv3Ds.acctID field
503
     *
504
     * @param null|string $value
505
     * @return self
506
     */
507
    public function setCustomerAdditionalInformation($value)
508
    {
509
        return $this->setParameter('customerAdditionalInformation', $value);
510
    }
511
512
    /**
513
     * Get the 3DsRequestAuthenticationMethodData field
514
     *
515
     * Corresponds to the Ds_Merchant_Emv3Ds.threeDSRequestorAuthenticationInfo.threeDSReqAuthData field in Redsys
516
     * documentation.
517
     *
518
     * @return null|string
519
     */
520
    public function get3DsRequestAuthenticationMethodData()
521
    {
522
        return $this->getParameter('3DsRequestAuthenticationMethodData');
523
    }
524
525
    /**
526
     * Set the 3DsRequestAuthenticationMethodData field
527
     *
528
     * Corresponds to the Ds_Merchant_Emv3Ds.threeDSRequestorAuthenticationInfo.threeDSReqAuthData field in the Redsys
529
     * documentation.
530
     *
531
     * @param null|string $value
532
     * @return self
533
     */
534
    public function set3DsRequestAuthenticationMethodData($value)
535
    {
536
        return $this->setParameter('3DsRequestAuthenticationMethodData', $value);
537
    }
538
539
    /**
540
     * Get the 3DsRequestAuthenticationMethod field
541
     *
542
     * Corresponds to the Ds_Merchant_Emv3Ds.threeDSRequestorAuthenticationInfo.threeDSReqAuthMethod field in Redsys
543
     * documentation.
544
     *
545
     * @return null|string One of the self::ACCOUNT_AUTHENTICATION_METHOD_* constants.
546
     */
547
    public function get3DsRequestAuthenticationMethod()
548
    {
549
        return $this->getParameter('3DsRequestAuthenticationMethod');
550
    }
551
552
    /**
553
     * Set the 3DsRequestAuthenticationMethod field
554
     *
555
     * Corresponds to the Ds_Merchant_Emv3Ds.threeDSRequestorAuthenticationInfo.threeDSReqAuthMethod field in the Redsys
556
     * documentation.
557
     *
558
     * @param null|string $value One of the self::ACCOUNT_AUTHENTICATION_METHOD_* constants.
559
     * @return self
560
     * @throws InvalidRequestException if $value is invalid.
561
     */
562 View Code Duplication
    public function set3DsRequestAuthenticationMethod($value)
1 ignored issue
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
563
    {
564
        if (in_array(
565
            $value,
566
            [
567
                null,
568
                self::ACCOUNT_AUTHENTICATION_METHOD_NONE,
569
                self::ACCOUNT_AUTHENTICATION_METHOD_OWN_CREDENTIALS,
570
                self::ACCOUNT_AUTHENTICATION_METHOD_FEDERATED_ID,
571
                self::ACCOUNT_AUTHENTICATION_METHOD_ISSUER_CREDENTIALS,
572
                self::ACCOUNT_AUTHENTICATION_METHOD_THIRD_PARTY_AUTHENTICATION,
573
                self::ACCOUNT_AUTHENTICATION_METHOD_FIDO,
574
            ]
575
        )) {
576
            return $this->setParameter('3DsRequestAuthenticationMethod', $value);
577
        }
578
        throw new InvalidRequestException("Invalid 3DsRequestAuthenticationMethod parameter");
579
    }
580
581
    /**
582
     * Get the 3DsRequestAuthenticationTime field
583
     *
584
     * Corresponds to the Ds_Merchant_Emv3Ds.threeDSRequestorAuthenticationInfo.threeDSReqAuthTimestamp field
585
     *
586
     * @return null|string
587
     */
588
    public function get3DsRequestAuthenticationTime()
589
    {
590
        return $this->getParameter('3DsRequestAuthenticationTime');
591
    }
592
593
    /**
594
     * Set the 3DsRequestAuthenticationTime field
595
     *
596
     * Corresponds to the Ds_Merchant_Emv3Ds.threeDSRequestorAuthenticationInfo.threeDSReqAuthTimestamp field
597
     *
598
     * @param null|DateTime|int $value
599
     * @return self
600
     */
601
    public function set3DsRequestAuthenticationTime($value)
602
    {
603
        return $this->setParameter('3DsRequestAuthenticationTime', $this->formatDateTime($value, "YmdHi"));
604
    }
605
606
    /**
607
     * Get the customerAccountCreatedIndicator field
608
     *
609
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.chAccAgeInd field
610
     *
611
     * @return null|string One of the CUSTOMER_ACCOUNT_CREATED_* constants
612
     */
613
    public function getCustomerAccountCreatedIndicator()
614
    {
615
        return $this->getParameter('customerAccountCreatedIndicator');
616
    }
617
618
    /**
619
     * Set the customerAccountCreatedIndicator field
620
     *
621
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.chAccAgeInd field
622
     *
623
     * @param null|string $value One of the CUSTOMER_ACCOUNT_CREATED_* constants
624
     * @return self
625
     * @throws InvalidRequestException if $value is invalid.
626
     */
627
    public function setCustomerAccountCreatedIndicator($value)
628
    {
629
        if (in_array(
630
            $value,
631
            [
632
                null,
633
                self::CUSTOMER_ACCOUNT_CREATED_NONE,
634
                self::CUSTOMER_ACCOUNT_CREATED_THIS_TRANSACTION,
635
                self::CUSTOMER_ACCOUNT_CREATED_LAST_30_DAYS,
636
                self::CUSTOMER_ACCOUNT_CREATED_LAST_60_DAYS,
637
                self::CUSTOMER_ACCOUNT_CREATED_MORE_THAN_60_DAYS,
638
            ]
639
        )) {
640
            return $this->setParameter('customerAccountCreatedIndicator', $value);
641
        }
642
        throw new InvalidRequestException("Invalid customerAccountCreatedIndicator parameter");
643
    }
644
645
    /**
646
     * Get the customerAccountCreatedDate field
647
     *
648
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.chAccDate field
649
     *
650
     * @return null|string
651
     */
652
    public function getCustomerAccountCreatedDate()
653
    {
654
        return $this->getParameter('customerAccountCreatedDate');
655
    }
656
657
    /**
658
     * Set the customerAccountCreatedDate field
659
     *
660
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.chAccDate field
661
     *
662
     * @param null|DateTime|int $value
663
     * @return self
664
     */
665
    public function setCustomerAccountCreatedDate($value)
666
    {
667
        return $this->setParameter('customerAccountCreatedDate', $this->formatDateTime($value, "Ymd"));
668
    }
669
670
    /**
671
     * Get the customerAccountChangedIndicator field
672
     *
673
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.chAccChangeInd field
674
     *
675
     * @return null|string One of the CUSTOMER_ACCOUNT_MODIFIED_* constants
676
     */
677
    public function getCustomerAccountChangedIndicator()
678
    {
679
        return $this->getParameter('customerAccountChangedIndicator');
680
    }
681
682
    /**
683
     * Set the customerAccountChangedIndicator field
684
     *
685
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.chAccChangeInd field
686
     *
687
     * @param null|string $value One of the CUSTOMER_ACCOUNT_MODIFIED_* constants
688
     * @return self
689
     * @throws InvalidRequestException if $value is invalid.
690
     */
691
    public function setCustomerAccountChangedIndicator($value)
692
    {
693
        if (in_array(
694
            $value,
695
            [
696
                null,
697
                self::CUSTOMER_ACCOUNT_MODIFIED_THIS_TRANSACTION,
698
                self::CUSTOMER_ACCOUNT_MODIFIED_LAST_30_DAYS,
699
                self::CUSTOMER_ACCOUNT_MODIFIED_LAST_60_DAYS,
700
                self::CUSTOMER_ACCOUNT_MODIFIED_MORE_THAN_60_DAYS,
701
            ]
702
        )) {
703
            return $this->setParameter('customerAccountChangedIndicator', $value);
704
        }
705
        throw new InvalidRequestException("Invalid customerAccountChangedIndicator parameter");
706
    }
707
708
    /**
709
     * Get the customerAccountChangedDate field
710
     *
711
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.chAccChange field
712
     *
713
     * @return null|string
714
     */
715
    public function getCustomerAccountChangedDate()
716
    {
717
        return $this->getParameter('customerAccountChangedDate');
718
    }
719
720
    /**
721
     * Set the customerAccountChangedDate field
722
     *
723
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.chAccChange field
724
     *
725
     * @param null|DateTime|int $value
726
     * @return self
727
     */
728
    public function setCustomerAccountChangedDate($value)
729
    {
730
        return $this->setParameter('customerAccountChangedDate', $this->formatDateTime($value, "Ymd"));
731
    }
732
733
    /**
734
     * Get the customerPasswordAgeIndicator field
735
     *
736
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.chAccPwChangeInd field
737
     *
738
     * @return null|string One of the CUSTOMER_ACCOUNT_PASSWORD_MODIFIED_* constants
739
     */
740
    public function getCustomerPasswordChangedIndicator()
741
    {
742
        return $this->getParameter('customerPasswordAgeIndicator');
743
    }
744
745
    /**
746
     * Set the customerPasswordAgeIndicator field
747
     *
748
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.chAccPwChangeInd field
749
     *
750
     * @param null|string $value One of the CUSTOMER_ACCOUNT_PASSWORD_MODIFIED_* constants
751
     * @return self
752
     * @throws InvalidRequestException if $value is invalid.
753
     */
754
    public function setCustomerPasswordChangedIndicator($value)
755
    {
756
        if (in_array(
757
            $value,
758
            [
759
                null,
760
                self::CUSTOMER_ACCOUNT_PASSWORD_MODIFIED_NONE,
761
                self::CUSTOMER_ACCOUNT_PASSWORD_MODIFIED_THIS_TRANSACTION,
762
                self::CUSTOMER_ACCOUNT_PASSWORD_MODIFIED_LAST_30_DAYS,
763
                self::CUSTOMER_ACCOUNT_PASSWORD_MODIFIED_LAST_60_DAYS,
764
                self::CUSTOMER_ACCOUNT_PASSWORD_MODIFIED_MORE_THAN_60_DAYS,
765
            ]
766
        )) {
767
            return $this->setParameter('customerPasswordAgeIndicator', $value);
768
        }
769
        throw new InvalidRequestException("Invalid customerPasswordAgeIndicator parameter");
770
    }
771
772
    /**
773
     * Get the customerPasswordChangedDate field
774
     *
775
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.chAccPwChange field
776
     *
777
     * @return null|string
778
     */
779
    public function getCustomerPasswordChangedDate()
780
    {
781
        return $this->getParameter('customerPasswordChangedDate');
782
    }
783
784
    /**
785
     * Set the customerPasswordChangedDate field
786
     *
787
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.chAccPwChange field
788
     *
789
     * @param null|DateTime|int $value
790
     * @return self
791
     */
792
    public function setCustomerPasswordChangedDate($value)
793
    {
794
        return $this->setParameter('customerPasswordChangedDate', $this->formatDateTime($value, "Ymd"));
795
    }
796
797
    /**
798
     * Get the customerPurchasesInLast6Months field
799
     *
800
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.nbPurchaseAccount field
801
     *
802
     * @return null|int
803
     */
804
    public function getCustomerPurchasesInLast6Months()
805
    {
806
        return $this->getParameter('customerPurchasesInLast6Months');
807
    }
808
809
    /**
810
     * Set the customerPurchasesInLast6Months field
811
     *
812
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.nbPurchaseAccount field
813
     *
814
     * @param null|int $value
815
     * @return self
816
     */
817
    public function setCustomerPurchasesInLast6Months($value)
818
    {
819
        return $this->setParameter('customerPurchasesInLast6Months', $value);
820
    }
821
822
    /**
823
     * Get the customerAccountCardProvisionsLast24Hours field
824
     *
825
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.provisionAttemptsDay field
826
     *
827
     * @return null|int
828
     */
829
    public function getCustomerAccountCardProvisionsLast24Hours()
830
    {
831
        return $this->getParameter('customerAccountCardProvisionsLast24Hours');
832
    }
833
834
    /**
835
     * Set the customerAccountCardProvisionsLast24Hours field
836
     *
837
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.provisionAttemptsDay field
838
     *
839
     * @param null|int $value
840
     * @return self
841
     */
842
    public function setCustomerAccountCardProvisionsLast24Hours($value)
843
    {
844
        return $this->setParameter('customerAccountCardProvisionsLast24Hours', $value);
845
    }
846
847
    /**
848
     * Get the customerAccountTransactionsLast24Hours field
849
     *
850
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.txnActivityDay field
851
     *
852
     * @return null|int
853
     */
854
    public function getCustomerAccountTransactionsLast24Hours()
855
    {
856
        return $this->getParameter('customerAccountTransactionsLast24Hours');
857
    }
858
859
    /**
860
     * Set the customerAccountTransactionsLast24Hours field
861
     *
862
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.txnActivityDay field
863
     *
864
     * @param null|int $value
865
     * @return self
866
     */
867
    public function setCustomerAccountTransactionsLast24Hours($value)
868
    {
869
        return $this->setParameter('customerAccountTransactionsLast24Hours', $value);
870
    }
871
872
    /**
873
     * Get the customerAccountTransactionsLastYear field
874
     *
875
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.txnActivityYear field
876
     *
877
     * @return null|int
878
     */
879
    public function getCustomerAccountTransactionsLastYear()
880
    {
881
        return $this->getParameter('customerAccountTransactionsLastYear');
882
    }
883
884
    /**
885
     * Set the customerAccountTransactionsLastYear field
886
     *
887
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.txnActivityYear field
888
     *
889
     * @param null|int $value
890
     * @return self
891
     */
892
    public function setCustomerAccountTransactionsLastYear($value)
893
    {
894
        return $this->setParameter('customerAccountTransactionsLastYear', $value);
895
    }
896
897
    /**
898
     * Get the customerPaymentMethodCreatedIndicator field
899
     *
900
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.paymentAccInd field
901
     *
902
     * @return null|string One of the PAYMENT_METHOD_CREATED_* constants
903
     */
904
    public function getCustomerPaymentMethodCreatedIndicator()
905
    {
906
        return $this->getParameter('customerPaymentMethodCreatedIndicator');
907
    }
908
909
    /**
910
     * Set the customerPaymentMethodCreatedIndicator field
911
     *
912
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.paymentAccInd field
913
     *
914
     * @param null|string $value One of the PAYMENT_METHOD_CREATED_* constants
915
     * @return self
916
     * @throws InvalidRequestException if $value is invalid.
917
     */
918
    public function setCustomerPaymentMethodCreatedIndicator($value)
919
    {
920
        if (in_array(
921
            $value,
922
            [
923
                null,
924
                self::PAYMENT_METHOD_CREATED_NONE,
925
                self::PAYMENT_METHOD_CREATED_THIS_TRANSACTION,
926
                self::PAYMENT_METHOD_CREATED_LAST_30_DAYS,
927
                self::PAYMENT_METHOD_CREATED_LAST_60_DAYS,
928
                self::PAYMENT_METHOD_CREATED_MORE_THAN_60_DAYS,
929
            ]
930
        )) {
931
            return $this->setParameter('customerPaymentMethodCreatedIndicator', $value);
932
        }
933
        throw new InvalidRequestException("Invalid customerPaymentMethodCreatedIndicator parameter");
934
    }
935
936
    /**
937
     * Get the customerPaymentMethodCreatedDate field
938
     *
939
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.paymentAccAge field
940
     *
941
     * @return null|string
942
     */
943
    public function getCustomerPaymentMethodCreatedDate()
944
    {
945
        return $this->getParameter('customerPaymentMethodCreatedDate');
946
    }
947
948
    /**
949
     * Set the customerPaymentMethodCreatedDate field
950
     *
951
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.paymentAccAge field
952
     *
953
     * @param null|DateTime|int $value
954
     * @return self
955
     */
956
    public function setCustomerPaymentMethodCreatedDate($value)
957
    {
958
        return $this->setParameter('customerPaymentMethodCreatedDate', $this->formatDateTime($value, "Ymd"));
959
    }
960
961
    /**
962
     * Get the shippingAddressFirstUsedIndicator field
963
     *
964
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.shipAddressUsageInd field
965
     *
966
     * @return null|string One of the SHIPPING_ADDRESS_USAGE_* constants
967
     */
968
    public function getShippingAddressFirstUsedIndicator()
969
    {
970
        return $this->getParameter('shippingAddressFirstUsedIndicator');
971
    }
972
973
    /**
974
     * Set the shippingAddressFirstUsedIndicator field
975
     *
976
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.shipAddressUsageInd field
977
     *
978
     * @param null|string $value One of the SHIPPING_ADDRESS_USAGE_* constants
979
     * @return self
980
     * @throws InvalidRequestException if $value is invalid.
981
     */
982
    public function setShippingAddressFirstUsedIndicator($value)
983
    {
984
        if (in_array(
985
            $value,
986
            [
987
                null,
988
                self::SHIPPING_ADDRESS_USAGE_THIS_TRANSACTION,
989
                self::SHIPPING_ADDRESS_USAGE_LAST_30_DAYS,
990
                self::SHIPPING_ADDRESS_USAGE_LAST_60_DAYS,
991
                self::SHIPPING_ADDRESS_USAGE_MORE_THAN_60_DAYS,
992
            ]
993
        )) {
994
            return $this->setParameter('shippingAddressFirstUsedIndicator', $value);
995
        }
996
        throw new InvalidRequestException("Invalid shippingAddressFirstUsedIndicator parameter");
997
    }
998
999
    /**
1000
     * Get the shippingAddressFirstUsedDate field
1001
     *
1002
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.shipAddressUsage field
1003
     *
1004
     * @return null|string
1005
     */
1006
    public function getShippingAddressFirstUsedDate()
1007
    {
1008
        return $this->getParameter('shippingAddressFirstUsedDate');
1009
    }
1010
1011
    /**
1012
     * Set the shippingAddressFirstUsedDate field
1013
     *
1014
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.shipAddressUsage field
1015
     *
1016
     * @param null|DateTime|int $value
1017
     * @return self
1018
     */
1019
    public function setShippingAddressFirstUsedDate($value)
1020
    {
1021
        return $this->setParameter('shippingAddressFirstUsedDate', $this->formatDateTime($value, "Ymd"));
1022
    }
1023
1024
    /**
1025
     * Get the shippingNameCustomerNameMatch field
1026
     *
1027
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.shipNameIndicator field
1028
     *
1029
     * @return null|boolean
1030
     */
1031
    public function getShippingNameCustomerNameMatch()
1032
    {
1033
        return $this->getParameter('shippingNameCustomerNameMatch');
1034
    }
1035
1036
    /**
1037
     * Set the shippingNameCustomerNameMatch field
1038
     *
1039
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.shipNameIndicator field
1040
     *
1041
     * @param null|boolean $value
1042
     * @return self
1043
     */
1044
    public function setShippingNameCustomerNameMatch($value)
1045
    {
1046
        return $this->setParameter('shippingNameCustomerNameMatch', $value);
1047
    }
1048
1049
    /**
1050
     * Get the customerHasSuspiciousActivity field
1051
     *
1052
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.suspiciousAccActivity field
1053
     *
1054
     * @return null|boolean
1055
     */
1056
    public function getCustomerHasSuspiciousActivity()
1057
    {
1058
        return $this->getParameter('customerHasSuspiciousActivity');
1059
    }
1060
1061
    /**
1062
     * Set the customerHasSuspiciousActivity field
1063
     *
1064
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.suspiciousAccActivity field
1065
     *
1066
     * @param null|boolean $value
1067
     * @return self
1068
     */
1069
    public function setCustomerHasSuspiciousActivity($value)
1070
    {
1071
        return $this->setParameter('customerHasSuspiciousActivity', $value);
1072
    }
1073
1074
    /**
1075
     * Get the deliveryEmail field
1076
     *
1077
     * Corresponds to the Ds_Merchant_Emv3Ds.MerchantRiskIndicator.deliveryEmailAddress field
1078
     *
1079
     * @return null|string
1080
     */
1081
    public function getDeliveryEmail()
1082
    {
1083
        return $this->getParameter('deliveryEmail');
1084
    }
1085
1086
    /**
1087
     * Set the deliveryEmail field
1088
     *
1089
     * Corresponds to the Ds_Merchant_Emv3Ds.MerchantRiskIndicator.deliveryEmailAddress field
1090
     *
1091
     * @param null|string $value
1092
     * @return self
1093
     */
1094
    public function setDeliveryEmail($value)
1095
    {
1096
        return $this->setParameter('deliveryEmail', $value);
1097
    }
1098
1099
    /**
1100
     * Get the deliveryTimeframeIndicator field
1101
     *
1102
     * Corresponds to the Ds_Merchant_Emv3Ds.MerchantRiskIndicator.deliveryTimeframe field
1103
     *
1104
     * @return null|string One of the DELIVERY_TIMEFRAME_* constants
1105
     */
1106
    public function getDeliveryTimeframeIndicator()
1107
    {
1108
        return $this->getParameter('deliveryTimeframeIndicator');
1109
    }
1110
1111
    /**
1112
     * Set the deliveryTimeframeIndicator field
1113
     *
1114
     * Corresponds to the Ds_Merchant_Emv3Ds.MerchantRiskIndicator.deliveryTimeframe field
1115
     *
1116
     * @param null|string $value One of the DELIVERY_TIMEFRAME_* constants
1117
     * @return self
1118
     * @throws InvalidRequestException if $value is invalid.
1119
     */
1120
    public function setDeliveryTimeframeIndicator($value)
1121
    {
1122
        if (in_array(
1123
            $value,
1124
            [
1125
                null,
1126
                self::DELIVERY_TIMEFRAME_ELECTRONIC_DELIVERY,
1127
                self::DELIVERY_TIMEFRAME_SAME_DAY,
1128
                self::DELIVERY_TIMEFRAME_NEXT_DAY,
1129
                self::DELIVERY_TIMEFRAME_2_OR_MORE_DAYS,
1130
            ]
1131
        )) {
1132
            return $this->setParameter('deliveryTimeframeIndicator', $value);
1133
        }
1134
        throw new InvalidRequestException("Invalid deliveryTimeframeIndicator parameter");
1135
    }
1136
1137
    /**
1138
     * Get the giftCardAmount field
1139
     *
1140
     * Corresponds to the Ds_Merchant_Emv3Ds.MerchantRiskIndicator.giftCardAmount field
1141
     *
1142
     * @return null|int
1143
     */
1144
    public function getGiftCardAmount()
1145
    {
1146
        return $this->getParameter('giftCardAmount');
1147
    }
1148
1149
    /**
1150
     * Set the giftCardAmount field
1151
     *
1152
     * Corresponds to the Ds_Merchant_Emv3Ds.MerchantRiskIndicator.giftCardAmount field
1153
     *
1154
     * @param null|int $value
1155
     * @return self
1156
     */
1157
    public function setGiftCardAmount($value)
1158
    {
1159
        return $this->setParameter('giftCardAmount', $value);
1160
    }
1161
1162
    /**
1163
     * Get the giftCardCount field
1164
     *
1165
     * Corresponds to the Ds_Merchant_Emv3Ds.MerchantRiskIndicator.giftCardCount field
1166
     *
1167
     * @return null|int
1168
     */
1169
    public function getGiftCardCount()
1170
    {
1171
        return $this->getParameter('giftCardCount');
1172
    }
1173
1174
    /**
1175
     * Set the giftCardCount field
1176
     *
1177
     * Corresponds to the Ds_Merchant_Emv3Ds.MerchantRiskIndicator.giftCardCount field
1178
     *
1179
     * @param null|int $value
1180
     * @return self
1181
     */
1182
    public function setGiftCardCount($value)
1183
    {
1184
        return $this->setParameter('giftCardCount', $value);
1185
    }
1186
1187
    /**
1188
     * Get the giftCardCurrency field
1189
     *
1190
     * Corresponds to the Ds_Merchant_Emv3Ds.MerchantRiskIndicator.giftCardCurr field
1191
     *
1192
     * @return null|string ISO-4217 currency code
1193
     */
1194
    public function getGiftCardCurrency()
1195
    {
1196
        return $this->getParameter('giftCardCurrency');
1197
    }
1198
1199
    /**
1200
     * Set the giftCardCurrency field
1201
     *
1202
     * Corresponds to the Ds_Merchant_Emv3Ds.MerchantRiskIndicator.giftCardCurr field
1203
     *
1204
     * @param null|string $value ISO-4217 currency code
1205
     * @return self
1206
     */
1207
    public function setGiftCardCurrency($value)
1208
    {
1209
        return $this->setParameter('giftCardCurrency', $value);
1210
    }
1211
1212
    /**
1213
     * Get the purchasingPreOrder field
1214
     *
1215
     * Corresponds to the Ds_Merchant_Emv3Ds.MerchantRiskIndicator.preOrderPurchaseInd field
1216
     *
1217
     * @return null|boolean True if the customer is purchasing a preorder
1218
     */
1219
    public function getPurchasingPreOrder()
1220
    {
1221
        return $this->getParameter('purchasingPreOrder');
1222
    }
1223
1224
    /**
1225
     * Set the purchasingPreOrder field
1226
     *
1227
     * Corresponds to the Ds_Merchant_Emv3Ds.MerchantRiskIndicator.preOrderPurchaseInd field
1228
     *
1229
     * @param null|boolean $value True if the customer is purchasing a preorder
1230
     * @return self
1231
     */
1232
    public function setPurchasingPreOrder($value)
1233
    {
1234
        return $this->setParameter('purchasingPreOrder', $value);
1235
    }
1236
1237
    /**
1238
     * Get the preOrderDate field
1239
     *
1240
     * Corresponds to the Ds_Merchant_Emv3Ds.MerchantRiskIndicator.preOrderDate field
1241
     *
1242
     * @return null|string
1243
     */
1244
    public function getPreOrderDate()
1245
    {
1246
        return $this->getParameter('preOrderDate');
1247
    }
1248
1249
    /**
1250
     * Set the preOrderDate field
1251
     *
1252
     * Corresponds to the Ds_Merchant_Emv3Ds.MerchantRiskIndicator.preOrderDate field
1253
     *
1254
     * @param null|DateTime|int $value
1255
     * @return self
1256
     */
1257
    public function setPreOrderDate($value)
1258
    {
1259
        return $this->setParameter('preOrderDate', $this->formatDateTime($value, "Ymd"));
1260
    }
1261
1262
    /**
1263
     * Get the customerHasPurchasedProductBefore field
1264
     *
1265
     * Corresponds to the Ds_Merchant_Emv3Ds.MerchantRiskIndicator.reorderItemsInd field
1266
     *
1267
     * @return null|boolean
1268
     */
1269
    public function getCustomerHasPurchasedProductBefore()
1270
    {
1271
        return $this->getParameter('customerHasPurchasedProductBefore');
1272
    }
1273
1274
    /**
1275
     * Set the customerHasPurchasedProductBefore field
1276
     *
1277
     * Corresponds to the Ds_Merchant_Emv3Ds.MerchantRiskIndicator.reorderItemsInd field
1278
     *
1279
     * @param null|boolean $value
1280
     * @return self
1281
     */
1282
    public function setCustomerHasPurchasedProductBefore($value)
1283
    {
1284
        return $this->setParameter('customerHasPurchasedProductBefore', $value);
1285
    }
1286
1287
    /**
1288
     * Get the shippingAddressIndicator field
1289
     *
1290
     * Corresponds to the Ds_Merchant_Emv3Ds.MerchantRiskIndicator.shipIndicator field
1291
     *
1292
     * @return null|string One of the self::SHIPPING_* constants
1293
     */
1294
    public function getShippingAddressIndicator()
1295
    {
1296
        return $this->getParameter('shippingAddressIndicator');
1297
    }
1298
1299
    /**
1300
     * Set the shippingAddressIndicator field
1301
     *
1302
     * Corresponds to the Ds_Merchant_Emv3Ds.MerchantRiskIndicator.shipIndicator field
1303
     *
1304
     * @param null|string $value One of the self::SHIPPING_* constants
1305
     * @return self
1306
     * @throws InvalidRequestException if $value is invalid.
1307
     */
1308 View Code Duplication
    public function setShippingAddressIndicator($value)
1 ignored issue
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1309
    {
1310
        if (in_array(
1311
            $value,
1312
            [
1313
                null,
1314
                self::SHIPPING_TO_BILLING_ADDRESS,
1315
                self::SHIPPING_TO_ANOTHER_VERIFIED_ADDRESS,
1316
                self::SHIPPING_DIFFERENT_BILLING_ADDRESS,
1317
                self::SHIPPING_PICK_UP,
1318
                self::SHIPPING_DIGITAL,
1319
                self::SHIPPING_TRAVEL,
1320
                self::SHIPPING_OTHER,
1321
            ]
1322
        )) {
1323
            return $this->setParameter('shippingAddressIndicator', $value);
1324
        }
1325
        throw new InvalidRequestException("Invalid shippingAddressIndicator parameter");
1326
    }
1327
1328
    /**
1329
     * Get the SCA exemption field
1330
     *
1331
     * Corresponds to the Ds_Merchant_Excep_Sca field
1332
     *
1333
     * @return null|string One of the self::SCA_EXEMPTION_* constants
1334
     */
1335
    public function getScaExemptionIndicator()
1336
    {
1337
        return $this->getParameter('scaExemptionIndicator');
1338
    }
1339
1340
    /**
1341
     * Set the SCA exemption field
1342
     *
1343
     * Corresponds to the Ds_Merchant_Emv3Ds.MerchantRiskIndicator.shipIndicator field
1344
     *
1345
     * @param null|string $value One of the self::SCA_EXEMPTION_* constants
1346
     * @return self
1347
     * @throws InvalidRequestException if $value is invalid.
1348
     */
1349
    public function setScaExemptionIndicator($value)
1350
    {
1351
        if (in_array(
1352
            $value,
1353
            [
1354
                null,
1355
                self::SCA_EXEMPTION_LOW_AMOUNT,
1356
                self::SCA_EXEMPTION_LOW_RISK,
1357
                self::SCA_EXEMPTION_CORPORATE,
1358
                self::SCA_EXEMPTION_MERCHANT_INITIATED,
1359
            ]
1360
        )) {
1361
            return $this->setParameter('scaExemptionIndicator', $value);
1362
        }
1363
        throw new InvalidRequestException("Invalid scaExemptionIndicator parameter");
1364
    }
1365
1366
    /**
1367
     * Override the abstract method to add requirement that it must start with 4 numeric characters
1368
     *
1369
     * @param string|int $value The transaction ID (merchant order) to set for the transaction
1370
     */
1371
    public function setTransactionId($value)
1372
    {
1373
        $start = substr($value, 0, 4);
1374
        $numerics = 0;
1375
        foreach (str_split($start) as $char) {
1376
            if (is_numeric($char)) {
1377
                $numerics++;
1378
            } else {
1379
                break;
1380
            }
1381
        }
1382
        $value = str_pad(substr($start, 0, $numerics), 4, 0, STR_PAD_LEFT).substr($value, $numerics);
1383
1384
        parent::setTransactionId($value);
1385
    }
1386
1387
    /**
1388
     * Get the basic data fields that don't require any 3DS/SCA fields
1389
     */
1390
    public function getBaseData()
1391
    {
1392
        $this->validate('merchantId', 'terminalId', 'amount', 'currency');
1393
1394
        return [
1395
            // mandatory fields
1396
            'Ds_Merchant_MerchantCode'       => $this->getMerchantId(),
1397
            'Ds_Merchant_Terminal'           => $this->getTerminalId(),
1398
            'Ds_Merchant_TransactionType'    => '0',                          // Authorisation
1399
            'Ds_Merchant_Amount'             => $this->getAmountInteger(),
1400
            'Ds_Merchant_Currency'           => $this->getCurrencyNumeric(),  // uses ISO-4217 codes
1401
            'Ds_Merchant_Order'              => $this->getTransactionId(),
1402
            'Ds_Merchant_MerchantUrl'        => $this->getNotifyUrl(),
1403
            // optional fields
1404
            'Ds_Merchant_ProductDescription' => $this->getDescription(),
1405
            'Ds_Merchant_Cardholder'         => $this->getCardholder(),
1406
            'Ds_Merchant_UrlOK'              => $this->getReturnUrl(),
1407
            'Ds_Merchant_UrlKO'              => $this->getReturnUrl(),
1408
            'Ds_Merchant_MerchantName'       => $this->getMerchantName(),
1409
            'Ds_Merchant_ConsumerLanguage'   => $this->getConsumerLanguage(),
1410
            'Ds_Merchant_MerchantData'       => $this->getMerchantData(),
1411
        ];
1412
    }
1413
1414
    public function get3DSAccountInfoData()
1415
    {
1416
        $data = array_filter([
1417
            'chAccAgeInd'           => $this->getCustomerAccountCreatedIndicator(),
1418
            'chAccDate'             => $this->getCustomerAccountCreatedDate(),
1419
            'chAccChangeInd'        => $this->getCustomerAccountChangedIndicator(),
1420
            'chAccChange'           => $this->getCustomerAccountChangedDate(),
1421
            'chAccPwChangeInd'      => $this->getCustomerPasswordChangedIndicator(),
1422
            'chAccPwChange'         => $this->getCustomerPasswordChangedDate(),
1423
            'paymentAccInd'         => $this->getCustomerPaymentMethodCreatedIndicator(),
1424
            'paymentAccAge'         => $this->getCustomerPaymentMethodCreatedDate(),
1425
            'shipAddressUsageInd'   => $this->getShippingAddressFirstUsedIndicator(),
1426
            'shipAddressUsage'      => $this->getShippingAddressFirstUsedDate(),
1427
        ]);
1428
        // checks that can't rely on a simple filter (which could remove or add values unintentionally)
1429
        if ($this->getShippingNameCustomerNameMatch() !== null) {
1430
            $data['shipNameIndicator'] = $this->getShippingNameCustomerNameMatch() ? "01" : "02";
1431
        }
1432
        if ($this->getCustomerHasSuspiciousActivity() !== null) {
1433
            $data['suspiciousAccActivity'] = $this->getCustomerHasSuspiciousActivity() ? "02" : "01";
1434
        }
1435
        if ($this->getCustomerPurchasesInLast6Months() !== null) {
1436
            $data['nbPurchaseAccount'] = $this->getCustomerPurchasesInLast6Months();
1437
        }
1438
        if ($this->getCustomerAccountCardProvisionsLast24Hours() !== null) {
1439
            $data['provisionAttemptsDay'] = $this->getCustomerAccountCardProvisionsLast24Hours();
1440
        }
1441
        if ($this->getCustomerAccountTransactionsLast24Hours() !== null) {
1442
            $data['txnActivityDay'] = $this->getCustomerAccountTransactionsLast24Hours();
1443
        }
1444
        if ($this->getCustomerAccountTransactionsLastYear() !== null) {
1445
            $data['txnActivityYear'] = $this->getCustomerAccountTransactionsLastYear();
1446
        }
1447
1448
        return $data;
1449
    }
1450
1451
    public function getMerchantRiskData()
1452
    {
1453
        $data = array_filter([
1454
            'deliveryEmailAddress' => $this->getDeliveryEmail(),
1455
            'deliveryTimeframe'    => $this->getDeliveryTimeframeIndicator(),
1456
            'giftCardCount'        => $this->getGiftCardCount(),
1457
            'giftCardCurr'         => $this->getGiftCardCurrency(),
1458
            'preOrderDate'         => $this->getPreOrderDate(),
1459
            'shipIndicator'        => $this->getShippingAddressIndicator(),
1460
        ]);
1461
        if ($this->getGiftCardAmount() !== null) {
1462
            $data['giftCardAmount'] = (int) $this->getGiftCardAmount();
1463
        }
1464
        if ($this->getPurchasingPreOrder() !== null) {
1465
            $data['preOrderPurchaseInd'] = $this->getPurchasingPreOrder() ? "02" : "01";
1466
        }
1467
        if ($this->getCustomerHasPurchasedProductBefore() !== null) {
1468
            $data['reorderItemsInd'] = $this->getCustomerHasPurchasedProductBefore() ? "02" : "01";
1469
        }
1470
1471
        return $data;
1472
    }
1473
1474
    public function getData()
1475
    {
1476
        $data = $this->getBaseData();
1477
        if ($this->getScaExemptionIndicator() !== null) {
1478
            $data['Ds_Merchant_Excep_Sca'] = $this->getScaExemptionIndicator();
1479
        }
1480
1481
        // only generate an EMV 3DS request if requested to
1482
        if ($this->getUse3DS()) {
1483
            // Validating the presence of the card under the assumption that at least an address is required
1484
            // NOTE: normally would validate() for other submission params, but the minimum depends on bank contract
1485
            $this->validate('card');
1486
            $card = $this->getCard();
1487
1488
            $homePhone = array_filter([
1489
                'cc'         => $this->getHomePhoneCountryPrefix(),
1490
                'subscriber' => $this->getHomePhone(),
1491
            ]);
1492
            $mobilePhone = array_filter([
1493
                'cc'         => $this->getMobilePhoneCountryPrefix(),
1494
                'subscriber' => $this->getMobilePhone(),
1495
            ]);
1496
            $workPhone = array_filter([
1497
                'cc'         => $this->getWorkPhoneCountryPrefix(),
1498
                'subscriber' => $this->getWorkPhone(),
1499
            ]);
1500
            $threeDSAuthInfo = array_filter([
1501
                'threeDSReqAuthData'      => $this->get3DsRequestAuthenticationMethodData(),
1502
                'threeDSReqAuthMethod'    => $this->get3DsRequestAuthenticationMethod(),
1503
                'threeDSReqAuthTimestamp' => $this->get3DsRequestAuthenticationTime(),
1504
            ]);
1505
            $emv3DsParameters = array_filter([
1506
                'cardholderName'                     => $this->getCardholder(),
1507
                'email'                              => $card->getEmail(),
1508
                'homePhone'                          => $homePhone,
1509
                'mobilePhone'                        => $mobilePhone,
1510
                'workPhone'                          => $workPhone,
1511
                'shipAddrLine1'                      => $card->getShippingAddress1(),
1512
                'shipAddrLine2'                      => $card->getShippingAddress2(),
1513
                'shipAddrLine3'                      => $card->getShippingAddress3(),
1514
                'shipAddrCity'                       => $card->getShippingCity(),
1515
                'shipAddrPostCode'                   => $card->getShippingPostcode(),
1516
                'shipAddrState'                      => $card->getShippingState(),
1517
                'shipAddrCountry'                    => $card->getShippingCountry(),
1518
                'billAddrLine1'                      => $card->getBillingAddress1(),
1519
                'billAddrLine2'                      => $card->getBillingAddress2(),
1520
                'billAddrLine3'                      => $card->getBillingAddress3(),
1521
                'billAddrCity'                       => $card->getBillingCity(),
1522
                'billAddrPostCode'                   => $card->getBillingPostcode(),
1523
                'billAddrState'                      => $card->getBillingState(),
1524
                'billAddrCountry'                    => $card->getBillingCountry(),
1525
                'addrMatch'                          => $this->getAddressMatch(),
1526
                'challengeWindowSize'                => $this->getChallengeWindowSize(),
1527
                'acctID'                             => $this->getCustomerAdditionalInformation(),
1528
                'threeDSRequestorAuthenticationInfo' => $threeDSAuthInfo,
1529
            ]);
1530
1531
            $acctInfo = $this->get3DSAccountInfoData();
1532
            if ($acctInfo !== []) {
1533
                $emv3DsParameters['acctInfo'] = $acctInfo;
1534
            }
1535
1536
            $merchantRiskIndicator = $this->getMerchantRiskData();
1537
            if ($merchantRiskIndicator !== []) {
1538
                $emv3DsParameters['merchantRiskIndicator'] = $merchantRiskIndicator;
1539
            }
1540
1541
            if ($emv3DsParameters !== []) {
1542
                $data['Ds_Merchant_Emv3Ds'] = $emv3DsParameters;
1543
            }
1544
        }
1545
1546
        return $data;
1547
    }
1548
1549
    public function sendData($data)
1550
    {
1551
        $security = new Security;
1552
1553
        $encoded_data = $security->encodeMerchantParameters($data);
1554
1555
        $response_data = array(
1556
            'Ds_SignatureVersion'   => Security::VERSION,
1557
            'Ds_MerchantParameters' => $encoded_data,
1558
            'Ds_Signature'          => $security->createSignature(
1559
                $encoded_data,
1560
                $data['Ds_Merchant_Order'],
1561
                $this->getHmacKey()
1562
            ),
1563
        );
1564
1565
        return $this->response = new PurchaseResponse($this, $response_data);
1566
    }
1567
1568
    public function getEndpoint()
1569
    {
1570
        return $this->getTestMode() ? $this->testEndpoint : $this->liveEndpoint;
1571
    }
1572
1573
    /**
1574
     * Convert a DateTime or timestamp to a formatted date.
1575
     *
1576
     * @param DateTime|int|null $date   The date to format.
1577
     * @param string            $format The format to use.
1578
     *
1579
     * @return string|null The formatted date, or null if date isn't a timestamp or DateTime object.
1580
     */
1581
    protected function formatDateTime($date, $format)
1582
    {
1583
        if (is_int($date)) {
1584
            return (new DateTime('@'.$date))->format($format);
1585
        } elseif ($date instanceof DateTime) {
1586
            return $date->setTimezone(new DateTimeZone('UTC'))->format($format);
1587
        }
1588
    }
1589
}
1590