Completed
Pull Request — master (#5)
by Leith
06:30
created

setCustomerAccountTransactionsLastYear()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 6
1
<?php
2
3
namespace Omnipay\Redsys\Message;
4
5
use DateTime;
6
use DateTimeZone;
7
use OmniPay\CreditCard;
8
use Omnipay\Common\Message\AbstractRequest;
9
use Omnipay\Common\Exception\InvalidRequestException;
10
11
/**
12
 * Redsys Purchase Request
13
 */
14
class PurchaseRequest extends AbstractRequest
15
{
16
    /** @var string */
17
    protected $liveEndpoint = 'https://sis.redsys.es/sis/realizarPago';
18
    /** @var string */
19
    protected $testEndpoint = 'https://sis-t.redsys.es:25443/sis/realizarPago';
20
    /** @var array */
21
    protected static $consumerLanguages = array(
22
        'es' => '001', // Spanish
23
        'en' => '002', // English
24
        'ca' => '003', // Catalan - same as Valencian (010)
25
        'fr' => '004', // French
26
        'de' => '005', // German
27
        'nl' => '006', // Dutch
28
        'it' => '007', // Italian
29
        'sv' => '008', // Swedish
30
        'pt' => '009', // Portuguese
31
        'pl' => '011', // Polish
32 2
        'gl' => '012', // Galician
33
        'eu' => '013', // Basque
34 2
    );
35
36
    /** @var string 250x400 */
37 4
    const CHALLENGE_WINDOW_SIZE_250_400 = "01";
38
    /** @var string 390x400 */
39 4
    const CHALLENGE_WINDOW_SIZE_390_400 = "02";
40
    /** @var string 500x600 */
41
    const CHALLENGE_WINDOW_SIZE_500_600 = "03";
42 8
    /** @var string 600x400 */
43
    const CHALLENGE_WINDOW_SIZE_600_400 = "04";
44 8
    /** @var string Fullscreen window (default) */
45
    const CHALLENGE_WINDOW_SIZE_FULLSCREEN = "05";
46
47
    /** @var string No 3DS Requestor authentication occurred (i.e. cardholder logged in as guest) */
48
    const ACCOUNT_AUTHENTICATION_METHOD_NONE = "01";
49
    /** @var string Login to the cardholder account at the 3DS Requestor system using 3DS Requestor's own credentials */
50
    const ACCOUNT_AUTHENTICATION_METHOD_OWN_CREDENTIALS = "02";
51
    /** @var string Login to the cardholder account at the 3DS Requestor system using federated ID */
52 7
    const ACCOUNT_AUTHENTICATION_METHOD_FEDERATED_ID = "03";
53
    /** @var string Login to the cardholder account at the 3DS Requestor system using issuer credentials */
54 7
    const ACCOUNT_AUTHENTICATION_METHOD_ISSUER_CREDENTIALS = "04";
55 1
    /** @var string Login to the cardholder account at the 3DS Requestor system using third-party authentication */
56 1
    const ACCOUNT_AUTHENTICATION_METHOD_THIRD_PARTY_AUTHENTICATION = "05";
57 1
    /** @var string Login to the cardholder account at the 3DS Requestor system using FIDO Authenticator */
58 1
    const ACCOUNT_AUTHENTICATION_METHOD_FIDO = "06";
59 7
60 7
    /** @var string No account (guest check-out) */
61 7
    const CUSTOMER_ACCOUNT_CREATED_NONE = "01";
62
    /** @var string Created during this transaction */
63 7
    const CUSTOMER_ACCOUNT_CREATED_THIS_TRANSACTION = "02";
64
    /** @var string Less than 30 days */
65
    const CUSTOMER_ACCOUNT_CREATED_LAST_30_DAYS = "03";
66 15
    /** @var string Between 30 and 60 days */
67
    const CUSTOMER_ACCOUNT_CREATED_LAST_60_DAYS = "04";
68 15
    /** @var string More than 60 day */
69
    const CUSTOMER_ACCOUNT_CREATED_MORE_THAN_60_DAYS = "05";
70
71 23
    /** @var string Modified in this session */
72
    const CUSTOMER_ACCOUNT_MODIFIED_THIS_TRANSACTION = "01";
73 23
    /** @var string Less than 30 days */
74
    const CUSTOMER_ACCOUNT_MODIFIED_LAST_30_DAYS = "02";
75
    /** @var string Between 30 and 60 days */
76 7
    const CUSTOMER_ACCOUNT_MODIFIED_LAST_60_DAYS = "03";
77
    /** @var string More than 60 day */
78 7
    const CUSTOMER_ACCOUNT_MODIFIED_MORE_THAN_60_DAYS = "04";
79
80
    /** @var string Unchanged */
81 7
    const CUSTOMER_ACCOUNT_PASSWORD_MODIFIED_NONE = "01";
82
    /** @var string Modified in this session */
83 7
    const CUSTOMER_ACCOUNT_PASSWORD_MODIFIED_THIS_TRANSACTION = "02";
84
    /** @var string Less than 30 days */
85
    const CUSTOMER_ACCOUNT_PASSWORD_MODIFIED_LAST_30_DAYS = "03";
86 11
    /** @var string Between 30 and 60 days */
87
    const CUSTOMER_ACCOUNT_PASSWORD_MODIFIED_LAST_60_DAYS = "04";
88 11
    /** @var string More than 60 day */
89
    const CUSTOMER_ACCOUNT_PASSWORD_MODIFIED_MORE_THAN_60_DAYS = "05";
90
91 23
    /** @var string No account (guest check-out) */
92
    const PAYMENT_METHOD_CREATED_NONE = "01";
93 23
    /** @var string Created during this transaction */
94
    const PAYMENT_METHOD_CREATED_THIS_TRANSACTION = "02";
95
    /** @var string Less than 30 days */
96 11
    const PAYMENT_METHOD_CREATED_LAST_30_DAYS = "03";
97
    /** @var string Between 30 and 60 days */
98 11
    const PAYMENT_METHOD_CREATED_LAST_60_DAYS = "04";
99
    /** @var string More than 60 day */
100
    const PAYMENT_METHOD_CREATED_MORE_THAN_60_DAYS = "05";
101 23
102
    /** @var string For the first time */
103 23
    const SHIPPING_ADDRESS_USAGE_THIS_TRANSACTION = "01";
104
    /** @var string Less than 30 days */
105
    const SHIPPING_ADDRESS_USAGE_LAST_30_DAYS = "02";
106 11
    /** @var string Between 30 and 60 days */
107
    const SHIPPING_ADDRESS_USAGE_LAST_60_DAYS = "03";
108 11
    /** @var string More than 60 day */
109
    const SHIPPING_ADDRESS_USAGE_MORE_THAN_60_DAYS = "04";
110
111 23
    /** @var string Electronic delivery */
112
    const DELIVERY_TIMEFRAME_ELECTRONIC_DELIVERY = "01";
113 23
    /** @var string Same day shipping */
114
    const DELIVERY_TIMEFRAME_SAME_DAY = "02";
115
    /** @var string Next day shipping */
116
    const DELIVERY_TIMEFRAME_NEXT_DAY = "03";
117
    /** @var string Shipping in 2 or more days */
118
    const DELIVERY_TIMEFRAME_2_OR_MORE_DAYS = "04";
119
120
    /** @var string Ship to cardholder's billing address */
121 15
    const SHIPPING_TO_BILLING_ADDRESS = "01";
122
    /** @var string Ship to another verified address on file with merchant */
123 15
    const SHIPPING_TO_ANOTHER_VERIFIED_ADDRESS = "02";
124 15
    /** @var string Ship to address that is different than the cardholder's billing address */
125 15
    const SHIPPING_DIFFERENT_BILLING_ADDRESS = "03";
126 15
    /** @var string Pick-up at local store (Store address shall be populated in shipping address fields) */
127 15
    const SHIPPING_PICK_UP = "04";
128 15
    /** @var string Digital goods (includes online services, electronic gift cards and redemption codes) */
129 15
    const SHIPPING_DIGITAL = "05";
130
    /** @var string Travel and Event tickets, not shipped */
131 15
    const SHIPPING_TRAVEL = "06";
132 15
    /** @var string Other (for example, Gaming, digital services not shipped, emedia subscriptions, etc.) */
133
    const SHIPPING_OTHER = "07";
134 15
135 15
    /** @var string Exemption due to low amount (transactions up to € 30) */
136
    const SCA_EXCEMPTION_LOW_AMOUNT = 'LMV';
137 2
    /** @var string Exemption due to low risk */
138
    const SCA_EXCEMPTION_LOW_RISK = 'TRA';
139 2
    /** @var string Exemption for payments identified as corporate. */
140
    const SCA_EXCEMPTION_CORPORATE = 'COR';
141
    /**
142
     * @var string Transactions initiated by the merchant, in which there is no intervention by the customer. They are
143 2
     *             outside the scope of PSD2.
144 2
     */
145 2
    const SCA_EXCEMPTION_MERCHANT_INITIATED = 'MIT';
146 2
147 2
    public function getCardholder()
148 2
    {
149 2
        return $this->getParameter('cardholder');
150
    }
151 2
152 2
    public function setCardholder($value)
153 2
    {
154 2
        return $this->setParameter('cardholder', $value);
155 2
    }
156 2
157 2
    public function getConsumerLanguage()
158 2
    {
159
        return $this->getParameter('consumerLanguage');
160
    }
161 1
162
    /**
163 1
     * Set the language presented to the consumer
164
     *
165 1
     * @param null|string|int Either the ISO 639-1 code to be converted, or the gateway's own numeric language code
166
     */
167
    public function setConsumerLanguage($value)
168 1
    {
169 1
        if (is_int($value)) {
170 1
            if ($value < 0 || $value > 13) {
171 1
                $value = 1;
172 1
            }
173 1
            $value = str_pad($value, 3, '0', STR_PAD_LEFT);
174 1
        } elseif (!is_numeric($value)) {
175 1
            $value = isset(self::$consumerLanguages[$value]) ? self::$consumerLanguages[$value] : '001';
176
        }
177 1
178
        return $this->setParameter('consumerLanguage', $value);
179
    }
180 7
181
    public function getHmacKey()
182 7
    {
183
        return $this->getParameter('hmacKey');
184
    }
185 1
186
    public function setHmacKey($value)
187
    {
188
        return $this->setParameter('hmacKey', $value);
189
    }
190
191
    public function getMerchantData()
192
    {
193
        return $this->getParameter('merchantData');
194
    }
195
196
    public function setMerchantData($value)
197
    {
198
        return $this->setParameter('merchantData', $value);
199
    }
200
201
    public function getMerchantId()
202
    {
203
        return $this->getParameter('merchantId');
204
    }
205
206
    public function setMerchantId($value)
207
    {
208
        return $this->setParameter('merchantId', $value);
209
    }
210
211
    public function getMerchantName()
212
    {
213
        return $this->getParameter('merchantName');
214
    }
215
216
    public function setMerchantName($value)
217
    {
218
        return $this->setParameter('merchantName', $value);
219
    }
220
221
    public function getTerminalId()
222
    {
223
        return $this->getParameter('terminalId');
224
    }
225
226
    public function setTerminalId($value)
227
    {
228
        return $this->setParameter('terminalId', $value);
229
    }
230
231
    /**
232
     * Get the use3ds field
233
     *
234
     * Controls the presence of the Ds_Merchant_Emv3Ds structure in Redsys documentation.
235
     *
236
     * @return null|bool
237
     */
238
    public function getUse3DS()
239
    {
240
        return $this->getParameter('use3ds');
241
    }
242
243
    /**
244
     * Set the use3ds field
245
     *
246
     * Controls the presence of the Ds_Merchant_Emv3Ds structure in Redsys documentation.
247
     *
248
     * @param null|bool $value
249
     * @return self
250
     */
251
    public function setUse3DS($value)
252
    {
253
        return $this->setParameter('use3ds', $value);
254
    }
255
256
    /**
257
     * Get the email field
258
     *
259
     * Corresponds to the Ds_Merchant_Emv3Ds.email field in Redsys documentation.
260
     *
261
     * @return null|string
262
     */
263
    public function getEmail()
264
    {
265
        return $this->getParameter('email');
266
    }
267
268
    /**
269
     * Set the email field
270
     *
271
     * Corresponds to the Ds_Merchant_Emv3Ds.email field in Redsys documentation.
272
     *
273
     * @param null|string $value
274
     * @return self
275
     */
276
    public function setEmail($value)
277
    {
278
        if ($value !== null) {
279
            $this->setUse3DS(true);
280
        }
281
        return $this->setParameter('email', $value);
282
    }
283
284
    /**
285
     * Get the homePhoneCountryPrefix field
286
     *
287
     * Corresponds to the Ds_Merchant_Emv3Ds.homePhone.cc field in Redsys documentation.
288
     *
289
     * @return null|string
290
     */
291
    public function getHomePhoneCountryPrefix()
292
    {
293
        return $this->getParameter('homePhoneCountryPrefix');
294
    }
295
296
    /**
297
     * Set the homePhoneCountryPrefix field
298
     *
299
     * Corresponds to the Ds_Merchant_Emv3Ds.homePhone.cc field in the Redsys documentation.
300
     *
301
     * @param null|string $value
302
     * @return self
303
     */
304
    public function setHomePhoneCountryPrefix($value)
305
    {
306
        if ($value !== null) {
307
            $this->setUse3DS(true);
308
        }
309
        return $this->setParameter('homePhoneCountryPrefix', $value);
310
    }
311
312
    /**
313
     * Get the homePhone field
314
     *
315
     * Corresponds to the Ds_Merchant_Emv3Ds.homePhone.subscriber field in Redsys documentation.
316
     *
317
     * @return null|string
318
     */
319
    public function getHomePhone()
320
    {
321
        return $this->getParameter('homePhone');
322
    }
323
324
    /**
325
     * Set the homePhone field
326
     *
327
     * Corresponds to the Ds_Merchant_Emv3Ds.homePhone.subscriber field in the Redsys documentation.
328
     *
329
     * @param null|string $value
330
     * @return self
331
     */
332
    public function setHomePhone($value)
333
    {
334
        if ($value !== null) {
335
            $this->setUse3DS(true);
336
        }
337
        return $this->setParameter('homePhone', $value);
338
    }
339
340
    /**
341
     * Get the mobilePhoneCountryPrefix field
342
     *
343
     * Corresponds to the Ds_Merchant_Emv3Ds.mobilePhone.cc field in Redsys documentation.
344
     *
345
     * @return null|string
346
     */
347
    public function getMobilePhoneCountryPrefix()
348
    {
349
        return $this->getParameter('mobilePhoneCountryPrefix');
350
    }
351
352
    /**
353
     * Set the mobilePhoneCountryPrefix field
354
     *
355
     * Corresponds to the Ds_Merchant_Emv3Ds.mobilePhone.cc field in the Redsys documentation.
356
     *
357
     * @param null|string $value
358
     * @return self
359
     */
360
    public function setMobilePhoneCountryPrefix($value)
361
    {
362
        if ($value !== null) {
363
            $this->setUse3DS(true);
364
        }
365
        return $this->setParameter('mobilePhoneCountryPrefix', $value);
366
    }
367
368
    /**
369
     * Get the mobilePhone field
370
     *
371
     * Corresponds to the Ds_Merchant_Emv3Ds.mobilePhone.subscriber field in Redsys documentation.
372
     *
373
     * @return null|string
374
     */
375
    public function getMobilePhone()
376
    {
377
        return $this->getParameter('mobilePhone');
378
    }
379
380
    /**
381
     * Set the mobilePhone field
382
     *
383
     * Corresponds to the Ds_Merchant_Emv3Ds.mobilePhone.subscriber field in the Redsys documentation.
384
     *
385
     * @param null|string $value
386
     * @return self
387
     */
388
    public function setMobilePhone($value)
389
    {
390
        if ($value !== null) {
391
            $this->setUse3DS(true);
392
        }
393
        return $this->setParameter('mobilePhone', $value);
394
    }
395
396
    /**
397
     * Get the workPhoneCountryPrefix field
398
     *
399
     * Corresponds to the Ds_Merchant_Emv3Ds.workPhone.cc field in Redsys documentation.
400
     *
401
     * @return null|string
402
     */
403
    public function getWorkPhoneCountryPrefix()
404
    {
405
        return $this->getParameter('workPhoneCountryPrefix');
406
    }
407
408
    /**
409
     * Set the workPhoneCountryPrefix field
410
     *
411
     * Corresponds to the Ds_Merchant_Emv3Ds.workPhone.cc field in the Redsys documentation.
412
     *
413
     * @param null|string $value
414
     * @return self
415
     */
416
    public function setWorkPhoneCountryPrefix($value)
417
    {
418
        if ($value !== null) {
419
            $this->setUse3DS(true);
420
        }
421
        return $this->setParameter('workPhoneCountryPrefix', $value);
422
    }
423
424
    /**
425
     * Get the workPhone field
426
     *
427
     * Corresponds to the Ds_Merchant_Emv3Ds.workPhone.subscriber field in Redsys documentation.
428
     *
429
     * @return null|string
430
     */
431
    public function getWorkPhone()
432
    {
433
        return $this->getParameter('workPhone');
434
    }
435
436
    /**
437
     * Set the workPhone field
438
     *
439
     * Corresponds to the Ds_Merchant_Emv3Ds.workPhone.subscriber field in the Redsys documentation.
440
     *
441
     * @param null|string $value
442
     * @return self
443
     */
444
    public function setWorkPhone($value)
445
    {
446
        if ($value !== null) {
447
            $this->setUse3DS(true);
448
        }
449
        return $this->setParameter('workPhone', $value);
450
    }
451
452
    /**
453
     * Get the addressMatch field
454
     *
455
     * Corresponds to the Ds_Merchant_Emv3Ds.addrMatch field in Redsys documentation.
456
     *
457
     * @return null|boolean
458
     */
459
    public function getAddressMatch()
460
    {
461
        return $this->getParameter('addressMatch');
462
    }
463
464
    /**
465
     * Set the addressMatch field
466
     *
467
     * Corresponds to the Ds_Merchant_Emv3Ds.addrMatch field in the Redsys documentation.
468
     *
469
     * @param null|boolean $value
470
     * @return self
471
     */
472
    public function setAddressMatch($value)
473
    {
474
        if ($value !== null) {
475
            $this->setUse3DS(true);
476
        }
477
        return $this->setParameter('addressMatch', $value);
478
    }
479
480
    /**
481
     * Get the challengeWindowSize field
482
     *
483
     * Corresponds to the Ds_Merchant_Emv3Ds.challengeWindowSize field in Redsys documentation.
484
     *
485
     * @return null|string One of the self::CHALLENGE_WINDOW_SIZE_* constants
486
     */
487
    public function getChallengeWindowSize()
488
    {
489
        return $this->getParameter('challengeWindowSize');
490
    }
491
492
    /**
493
     * Set the challengeWindowSize field
494
     *
495
     * Corresponds to the Ds_Merchant_Emv3Ds.challengeWindowSize field in the Redsys documentation.
496
     *
497
     * @param null|string $value One of the self::CHALLENGE_WINDOW_SIZE_* constants
498
     * @return self
499
     * @throws InvalidRequestException if $value is invalid.
500
     */
501
    public function setChallengeWindowSize($value)
502
    {
503
        if (in_array(
504
            $value,
505
            [
506
                null,
507
                self::CHALLENGE_WINDOW_SIZE_250_400,
508
                self::CHALLENGE_WINDOW_SIZE_390_400,
509
                self::CHALLENGE_WINDOW_SIZE_500_600,
510
                self::CHALLENGE_WINDOW_SIZE_600_400,
511
                self::CHALLENGE_WINDOW_SIZE_FULLSCREEN,
512
            ]
513
        )) {
514
            if ($value !== null) {
515
                $this->setUse3DS(true);
516
            }
517
            return $this->setParameter('challengeWindowSize', $value);
518
        }
519
        throw new InvalidRequestException("Invalid challengeWindowSize parameter");
520
    }
521
522
    /**
523
     * Get the customerAdditionalInformation field
524
     *
525
     * Corresponds to the Ds_Merchant_Emv3Ds.acctID field in Redsys documentation.
526
     *
527
     * @return null|string
528
     */
529
    public function getCustomerAdditionalInformation()
530
    {
531
        return $this->getParameter('customerAdditionalInformation');
532
    }
533
534
    /**
535
     * Set the customerAdditionalInformation field
536
     *
537
     * Corresponds to the Ds_Merchant_Emv3Ds.acctID field in the Redsys documentation.
538
     *
539
     * @param null|string $value
540
     * @return self
541
     */
542
    public function setCustomerAdditionalInformation($value)
543
    {
544
        if ($value !== null) {
545
            $this->setUse3DS(true);
546
        }
547
        return $this->setParameter('customerAdditionalInformation', $value);
548
    }
549
550
    /**
551
     * Get the 3DsRequestAuthenticationMethodData field
552
     *
553
     * Corresponds to the Ds_Merchant_Emv3Ds.threeDSRequestorAuthenticationInfo.threeDSReqAuthData field in Redsys
554
     * documentation.
555
     *
556
     * @return null|string
557
     */
558
    public function get3DsRequestAuthenticationMethodData()
559
    {
560
        return $this->getParameter('3DsRequestAuthenticationMethodData');
561
    }
562
563
    /**
564
     * Set the 3DsRequestAuthenticationMethodData field
565
     *
566
     * Corresponds to the Ds_Merchant_Emv3Ds.threeDSRequestorAuthenticationInfo.threeDSReqAuthData field in the Redsys
567
     * documentation.
568
     *
569
     * @param null|string $value
570
     * @return self
571
     */
572
    public function set3DsRequestAuthenticationMethodData($value)
573
    {
574
        if ($value !== null) {
575
            $this->setUse3DS(true);
576
        }
577
        return $this->setParameter('3DsRequestAuthenticationMethodData', $value);
578
    }
579
580
    /**
581
     * Get the 3DsRequestAuthenticationMethod field
582
     *
583
     * Corresponds to the Ds_Merchant_Emv3Ds.threeDSRequestorAuthenticationInfo.threeDSReqAuthMethod field in Redsys
584
     * documentation.
585
     *
586
     * @return null|string One of the self::ACCOUNT_AUTHENTICATION_METHOD_* constants.
587
     */
588
    public function get3DsRequestAuthenticationMethod()
589
    {
590
        return $this->getParameter('3DsRequestAuthenticationMethod');
591
    }
592
593
    /**
594
     * Set the 3DsRequestAuthenticationMethod field
595
     *
596
     * Corresponds to the Ds_Merchant_Emv3Ds.threeDSRequestorAuthenticationInfo.threeDSReqAuthMethod field in the Redsys
597
     * documentation.
598
     *
599
     * @param null|string $value One of the self::ACCOUNT_AUTHENTICATION_METHOD_* constants.
600
     * @return self
601
     * @throws InvalidRequestException if $value is invalid.
602
     */
603 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...
604
    {
605
        if (in_array(
606
            $value,
607
            [
608
                null,
609
                self::ACCOUNT_AUTHENTICATION_METHOD_NONE,
610
                self::ACCOUNT_AUTHENTICATION_METHOD_OWN_CREDENTIALS,
611
                self::ACCOUNT_AUTHENTICATION_METHOD_FEDERATED_ID,
612
                self::ACCOUNT_AUTHENTICATION_METHOD_ISSUER_CREDENTIALS,
613
                self::ACCOUNT_AUTHENTICATION_METHOD_THIRD_PARTY_AUTHENTICATION,
614
                self::ACCOUNT_AUTHENTICATION_METHOD_FIDO,
615
            ]
616
        )) {
617
            if ($value !== null) {
618
                $this->setUse3DS(true);
619
            }
620
            return $this->setParameter('3DsRequestAuthenticationMethod', $value);
621
        }
622
        throw new InvalidRequestException("Invalid 3DsRequestAuthenticationMethod parameter");
623
    }
624
625
    /**
626
     * Get the 3DsRequestAuthenticationTime field
627
     *
628
     * Corresponds to the Ds_Merchant_Emv3Ds.threeDSRequestorAuthenticationInfo.threeDSReqAuthTimestamp field in Redsys
629
     * documentation.
630
     *
631
     * @return null|DateTime|int
632
     */
633
    public function get3DsRequestAuthenticationTime()
634
    {
635
        return $this->getParameter('3DsRequestAuthenticationTime');
636
    }
637
638
    /**
639
     * Set the 3DsRequestAuthenticationTime field
640
     *
641
     * Corresponds to the Ds_Merchant_Emv3Ds.threeDSRequestorAuthenticationInfo.threeDSReqAuthTimestamp field in the
642
     * Redsys documentation.
643
     *
644
     * @param null|DateTime|int $value
645
     * @return self
646
     */
647
    public function set3DsRequestAuthenticationTime($value)
648
    {
649
        if ($value !== null) {
650
            $this->setUse3DS(true);
651
        }
652
        return $this->setParameter('3DsRequestAuthenticationTime', $value);
653
    }
654
655
    /**
656
     * Get the customerAccountCreatedIndicator field
657
     *
658
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.chAccAgeInd field in Redsys documentation.
659
     *
660
     * @return null|string One of the CUSTOMER_ACCOUNT_CREATED_* constants
661
     */
662
    public function getCustomerAccountCreatedIndicator()
663
    {
664
        return $this->getParameter('customerAccountCreatedIndicator');
665
    }
666
667
    /**
668
     * Set the customerAccountCreatedIndicator field
669
     *
670
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.chAccAgeInd field in the Redsys documentation.
671
     *
672
     * @param null|string $value One of the CUSTOMER_ACCOUNT_CREATED_* constants
673
     * @return self
674
     * @throws InvalidRequestException if $value is invalid.
675
     */
676
    public function setCustomerAccountCreatedIndicator($value)
677
    {
678
        if (in_array(
679
            $value,
680
            [
681
                null,
682
                self::CUSTOMER_ACCOUNT_CREATED_NONE,
683
                self::CUSTOMER_ACCOUNT_CREATED_THIS_TRANSACTION,
684
                self::CUSTOMER_ACCOUNT_CREATED_LAST_30_DAYS,
685
                self::CUSTOMER_ACCOUNT_CREATED_LAST_60_DAYS,
686
                self::CUSTOMER_ACCOUNT_CREATED_MORE_THAN_60_DAYS,
687
            ]
688
        )) {
689
            if ($value !== null) {
690
                $this->setUse3DS(true);
691
            }
692
            return $this->setParameter('customerAccountCreatedIndicator', $value);
693
        }
694
        throw new InvalidRequestException("Invalid customerAccountCreatedIndicator parameter");
695
    }
696
697
    /**
698
     * Get the customerAccountCreatedDate field
699
     *
700
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.chAccDate field in Redsys documentation.
701
     *
702
     * @return null|DateTime|int
703
     */
704
    public function getCustomerAccountCreatedDate()
705
    {
706
        return $this->getParameter('customerAccountCreatedDate');
707
    }
708
709
    /**
710
     * Set the customerAccountCreatedDate field
711
     *
712
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.chAccDate field in the Redsys documentation.
713
     *
714
     * @param null|DateTime|int $value
715
     * @return self
716
     */
717
    public function setCustomerAccountCreatedDate($value)
718
    {
719
        if ($value !== null) {
720
            $this->setUse3DS(true);
721
        }
722
        return $this->setParameter('customerAccountCreatedDate', $value);
723
    }
724
725
    /**
726
     * Get the customerAccountChangedIndicator field
727
     *
728
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.chAccChangeInd field in Redsys documentation.
729
     *
730
     * @return null|string One of the CUSTOMER_ACCOUNT_MODIFIED_* constants
731
     */
732
    public function getCustomerAccountChangedIndicator()
733
    {
734
        return $this->getParameter('customerAccountChangedIndicator');
735
    }
736
737
    /**
738
     * Set the customerAccountChangedIndicator field
739
     *
740
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.chAccChangeInd field in the Redsys documentation.
741
     *
742
     * @param null|string $value One of the CUSTOMER_ACCOUNT_MODIFIED_* constants
743
     * @return self
744
     * @throws InvalidRequestException if $value is invalid.
745
     */
746
    public function setCustomerAccountChangedIndicator($value)
747
    {
748
        if (in_array(
749
            $value,
750
            [
751
                null,
752
                self::CUSTOMER_ACCOUNT_MODIFIED_THIS_TRANSACTION,
753
                self::CUSTOMER_ACCOUNT_MODIFIED_LAST_30_DAYS,
754
                self::CUSTOMER_ACCOUNT_MODIFIED_LAST_60_DAYS,
755
                self::CUSTOMER_ACCOUNT_MODIFIED_MORE_THAN_60_DAYS,
756
            ]
757
        )) {
758
            if ($value !== null) {
759
                $this->setUse3DS(true);
760
            }
761
            return $this->setParameter('customerAccountChangedIndicator', $value);
762
        }
763
        throw new InvalidRequestException("Invalid customerAccountChangedIndicator parameter");
764
    }
765
766
    /**
767
     * Get the customerAccountChangedDate field
768
     *
769
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.chAccChange field in Redsys documentation.
770
     *
771
     * @return null|DateTime|int
772
     */
773
    public function getCustomerAccountChangedDate()
774
    {
775
        return $this->getParameter('customerAccountChangedDate');
776
    }
777
778
    /**
779
     * Set the customerAccountChangedDate field
780
     *
781
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.chAccChange field in the Redsys documentation.
782
     *
783
     * @param null|DateTime|int $value
784
     * @return self
785
     */
786
    public function setCustomerAccountChangedDate($value)
787
    {
788
        if ($value !== null) {
789
            $this->setUse3DS(true);
790
        }
791
        return $this->setParameter('customerAccountChangedDate', $value);
792
    }
793
794
    /**
795
     * Get the customerPasswordAgeIndicator field
796
     *
797
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.chAccPwChangeInd field in Redsys documentation.
798
     *
799
     * @return null|string One of the CUSTOMER_ACCOUNT_PASSWORD_MODIFIED_* constants
800
     */
801
    public function getCustomerPasswordChangedIndicator()
802
    {
803
        return $this->getParameter('customerPasswordAgeIndicator');
804
    }
805
806
    /**
807
     * Set the customerPasswordAgeIndicator field
808
     *
809
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.chAccPwChangeInd field in the Redsys documentation.
810
     *
811
     * @param null|string $value One of the CUSTOMER_ACCOUNT_PASSWORD_MODIFIED_* constants
812
     * @return self
813
     * @throws InvalidRequestException if $value is invalid.
814
     */
815
    public function setCustomerPasswordChangedIndicator($value)
816
    {
817
        if (in_array(
818
            $value,
819
            [
820
                null,
821
                self::CUSTOMER_ACCOUNT_PASSWORD_MODIFIED_NONE,
822
                self::CUSTOMER_ACCOUNT_PASSWORD_MODIFIED_THIS_TRANSACTION,
823
                self::CUSTOMER_ACCOUNT_PASSWORD_MODIFIED_LAST_30_DAYS,
824
                self::CUSTOMER_ACCOUNT_PASSWORD_MODIFIED_LAST_60_DAYS,
825
                self::CUSTOMER_ACCOUNT_PASSWORD_MODIFIED_MORE_THAN_60_DAYS,
826
            ]
827
        )) {
828
            if ($value !== null) {
829
                $this->setUse3DS(true);
830
            }
831
            return $this->setParameter('customerPasswordAgeIndicator', $value);
832
        }
833
        throw new InvalidRequestException("Invalid customerPasswordAgeIndicator parameter");
834
    }
835
836
    /**
837
     * Get the customerPasswordChangedDate field
838
     *
839
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.chAccPwChange field in Redsys documentation.
840
     *
841
     * @return null|DateTime|int
842
     */
843
    public function getCustomerPasswordChangedDate()
844
    {
845
        return $this->getParameter('customerPasswordChangedDate');
846
    }
847
848
    /**
849
     * Set the customerPasswordChangedDate field
850
     *
851
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.chAccPwChange field in the Redsys documentation.
852
     *
853
     * @param null|DateTime|int $value
854
     * @return self
855
     */
856
    public function setCustomerPasswordChangedDate($value)
857
    {
858
        if ($value !== null) {
859
            $this->setUse3DS(true);
860
        }
861
        return $this->setParameter('customerPasswordChangedDate', $value);
862
    }
863
864
    /**
865
     * Get the customerPurchasesInLast6Months field
866
     *
867
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.nbPurchaseAccount field in Redsys documentation.
868
     *
869
     * @return null|int
870
     */
871
    public function getCustomerPurchasesInLast6Months()
872
    {
873
        return $this->getParameter('customerPurchasesInLast6Months');
874
    }
875
876
    /**
877
     * Set the customerPurchasesInLast6Months field
878
     *
879
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.nbPurchaseAccount field in the Redsys documentation.
880
     *
881
     * @param null|int $value
882
     * @return self
883
     */
884
    public function setCustomerPurchasesInLast6Months($value)
885
    {
886
        if ($value !== null) {
887
            $this->setUse3DS(true);
888
        }
889
        return $this->setParameter('customerPurchasesInLast6Months', $value);
890
    }
891
892
    /**
893
     * Get the customerAccountCardProvisionsLast24Hours field
894
     *
895
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.provisionAttemptsDay field in Redsys documentation.
896
     *
897
     * @return null|int
898
     */
899
    public function getCustomerAccountCardProvisionsLast24Hours()
900
    {
901
        return $this->getParameter('customerAccountCardProvisionsLast24Hours');
902
    }
903
904
    /**
905
     * Set the customerAccountCardProvisionsLast24Hours field
906
     *
907
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.provisionAttemptsDay field in the Redsys documentation.
908
     *
909
     * @param null|int $value
910
     * @return self
911
     */
912
    public function setCustomerAccountCardProvisionsLast24Hours($value)
913
    {
914
        if ($value !== null) {
915
            $this->setUse3DS(true);
916
        }
917
        return $this->setParameter('customerAccountCardProvisionsLast24Hours', $value);
918
    }
919
920
    /**
921
     * Get the customerAccountTransactionsLast24Hours field
922
     *
923
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.txnActivityDay field in Redsys documentation.
924
     *
925
     * @return null|int
926
     */
927
    public function getCustomerAccountTransactionsLast24Hours()
928
    {
929
        return $this->getParameter('customerAccountTransactionsLast24Hours');
930
    }
931
932
    /**
933
     * Set the customerAccountTransactionsLast24Hours field
934
     *
935
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.txnActivityDay field in the Redsys documentation.
936
     *
937
     * @param null|int $value
938
     * @return self
939
     */
940
    public function setCustomerAccountTransactionsLast24Hours($value)
941
    {
942
        if ($value !== null) {
943
            $this->setUse3DS(true);
944
        }
945
        return $this->setParameter('customerAccountTransactionsLast24Hours', $value);
946
    }
947
948
    /**
949
     * Get the customerAccountTransactionsLastYear field
950
     *
951
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.txnActivityYear field in Redsys documentation.
952
     *
953
     * @return null|int
954
     */
955
    public function getCustomerAccountTransactionsLastYear()
956
    {
957
        return $this->getParameter('customerAccountTransactionsLastYear');
958
    }
959
960
    /**
961
     * Set the customerAccountTransactionsLastYear field
962
     *
963
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.txnActivityYear field in the Redsys documentation.
964
     *
965
     * @param null|int $value
966
     * @return self
967
     */
968
    public function setCustomerAccountTransactionsLastYear($value)
969
    {
970
        if ($value !== null) {
971
            $this->setUse3DS(true);
972
        }
973
        return $this->setParameter('customerAccountTransactionsLastYear', $value);
974
    }
975
976
    /**
977
     * Get the customerPaymentMethodCreatedIndicator field
978
     *
979
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.paymentAccInd field in Redsys documentation.
980
     *
981
     * @return null|string One of the PAYMENT_METHOD_CREATED_* constants
982
     */
983
    public function getCustomerPaymentMethodCreatedIndicator()
984
    {
985
        return $this->getParameter('customerPaymentMethodCreatedIndicator');
986
    }
987
988
    /**
989
     * Set the customerPaymentMethodCreatedIndicator field
990
     *
991
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.paymentAccInd field in the Redsys documentation.
992
     *
993
     * @param null|string $value One of the PAYMENT_METHOD_CREATED_* constants
994
     * @return self
995
     * @throws InvalidRequestException if $value is invalid.
996
     */
997
    public function setCustomerPaymentMethodCreatedIndicator($value)
998
    {
999
        if (in_array(
1000
            $value,
1001
            [
1002
                null,
1003
                self::PAYMENT_METHOD_CREATED_NONE,
1004
                self::PAYMENT_METHOD_CREATED_THIS_TRANSACTION,
1005
                self::PAYMENT_METHOD_CREATED_LAST_30_DAYS,
1006
                self::PAYMENT_METHOD_CREATED_LAST_60_DAYS,
1007
                self::PAYMENT_METHOD_CREATED_MORE_THAN_60_DAYS,
1008
            ]
1009
        )) {
1010
            if ($value !== null) {
1011
                $this->setUse3DS(true);
1012
            }
1013
            return $this->setParameter('customerPaymentMethodCreatedIndicator', $value);
1014
        }
1015
        throw new InvalidRequestException("Invalid customerPaymentMethodCreatedIndicator parameter");
1016
    }
1017
1018
    /**
1019
     * Get the customerPaymentMethodCreatedDate field
1020
     *
1021
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.paymentAccAge field in Redsys documentation.
1022
     *
1023
     * @return null|DateTime|int
1024
     */
1025
    public function getCustomerPaymentMethodCreatedDate()
1026
    {
1027
        return $this->getParameter('customerPaymentMethodCreatedDate');
1028
    }
1029
1030
    /**
1031
     * Set the customerPaymentMethodCreatedDate field
1032
     *
1033
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.paymentAccAge field in the Redsys documentation.
1034
     *
1035
     * @param null|DateTime|int $value
1036
     * @return self
1037
     */
1038
    public function setCustomerPaymentMethodCreatedDate($value)
1039
    {
1040
        if ($value !== null) {
1041
            $this->setUse3DS(true);
1042
        }
1043
        return $this->setParameter('customerPaymentMethodCreatedDate', $value);
1044
    }
1045
1046
    /**
1047
     * Get the shippingAddressFirstUsedIndicator field
1048
     *
1049
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.shipAddressUsageInd field in Redsys documentation.
1050
     *
1051
     * @return null|string One of the SHIPPING_ADDRESS_USAGE_* constants
1052
     */
1053
    public function getShippingAddressFirstUsedIndicator()
1054
    {
1055
        return $this->getParameter('shippingAddressFirstUsedIndicator');
1056
    }
1057
1058
    /**
1059
     * Set the shippingAddressFirstUsedIndicator field
1060
     *
1061
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.shipAddressUsageInd field in the Redsys documentation.
1062
     *
1063
     * @param null|string $value One of the SHIPPING_ADDRESS_USAGE_* constants
1064
     * @return self
1065
     * @throws InvalidRequestException if $value is invalid.
1066
     */
1067
    public function setShippingAddressFirstUsedIndicator($value)
1068
    {
1069
        if (in_array(
1070
            $value,
1071
            [
1072
                null,
1073
                self::SHIPPING_ADDRESS_USAGE_THIS_TRANSACTION,
1074
                self::SHIPPING_ADDRESS_USAGE_LAST_30_DAYS,
1075
                self::SHIPPING_ADDRESS_USAGE_LAST_60_DAYS,
1076
                self::SHIPPING_ADDRESS_USAGE_MORE_THAN_60_DAYS,
1077
            ]
1078
        )) {
1079
            if ($value !== null) {
1080
                $this->setUse3DS(true);
1081
            }
1082
            return $this->setParameter('shippingAddressFirstUsedIndicator', $value);
1083
        }
1084
        throw new InvalidRequestException("Invalid shippingAddressFirstUsedIndicator parameter");
1085
    }
1086
1087
    /**
1088
     * Get the shippingAddressFirstUsedDate field
1089
     *
1090
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.shipAddressUsage field in Redsys documentation.
1091
     *
1092
     * @return null|DateTime|int
1093
     */
1094
    public function getShippingAddressFirstUsedDate()
1095
    {
1096
        return $this->getParameter('shippingAddressFirstUsedDate');
1097
    }
1098
1099
    /**
1100
     * Set the shippingAddressFirstUsedDate field
1101
     *
1102
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.shipAddressUsage field in the Redsys documentation.
1103
     *
1104
     * @param null|DateTime|int $value
1105
     * @return self
1106
     */
1107
    public function setShippingAddressFirstUsedDate($value)
1108
    {
1109
        if ($value !== null) {
1110
            $this->setUse3DS(true);
1111
        }
1112
        return $this->setParameter('shippingAddressFirstUsedDate', $value);
1113
    }
1114
1115
    /**
1116
     * Get the shippingNameCustomerNameMatch field
1117
     *
1118
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.shipNameIndicator field in Redsys documentation.
1119
     *
1120
     * @return null|boolean
1121
     */
1122
    public function getShippingNameCustomerNameMatch()
1123
    {
1124
        return $this->getParameter('shippingNameCustomerNameMatch');
1125
    }
1126
1127
    /**
1128
     * Set the shippingNameCustomerNameMatch field
1129
     *
1130
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.shipNameIndicator field in the Redsys documentation.
1131
     *
1132
     * @param null|boolean $value
1133
     * @return self
1134
     */
1135
    public function setShippingNameCustomerNameMatch($value)
1136
    {
1137
        if ($value !== null) {
1138
            $this->setUse3DS(true);
1139
        }
1140
        return $this->setParameter('shippingNameCustomerNameMatch', $value);
1141
    }
1142
1143
    /**
1144
     * Get the customerHasSuspiciousActivity field
1145
     *
1146
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.suspiciousAccActivity field in Redsys documentation.
1147
     *
1148
     * @return null|boolean
1149
     */
1150
    public function getCustomerHasSuspiciousActivity()
1151
    {
1152
        return $this->getParameter('customerHasSuspiciousActivity');
1153
    }
1154
1155
    /**
1156
     * Set the customerHasSuspiciousActivity field
1157
     *
1158
     * Corresponds to the Ds_Merchant_Emv3Ds.acctInfo.suspiciousAccActivity field in the Redsys documentation.
1159
     *
1160
     * @param null|boolean $value
1161
     * @return self
1162
     */
1163
    public function setCustomerHasSuspiciousActivity($value)
1164
    {
1165
        if ($value !== null) {
1166
            $this->setUse3DS(true);
1167
        }
1168
        return $this->setParameter('customerHasSuspiciousActivity', $value);
1169
    }
1170
1171
    /**
1172
     * Get the deliveryEmail field
1173
     *
1174
     * Corresponds to the Ds_Merchant_Emv3Ds.MerchantRiskIndicator.deliveryEmailAddress field in Redsys documentation.
1175
     *
1176
     * @return null|string
1177
     */
1178
    public function getDeliveryEmail()
1179
    {
1180
        return $this->getParameter('deliveryEmail');
1181
    }
1182
1183
    /**
1184
     * Set the deliveryEmail field
1185
     *
1186
     * Corresponds to the Ds_Merchant_Emv3Ds.MerchantRiskIndicator.deliveryEmailAddress field in the Redsys
1187
     * documentation.
1188
     *
1189
     * @param null|string $value
1190
     * @return self
1191
     */
1192
    public function setDeliveryEmail($value)
1193
    {
1194
        if ($value !== null) {
1195
            $this->setUse3DS(true);
1196
        }
1197
        return $this->setParameter('deliveryEmail', $value);
1198
    }
1199
1200
    /**
1201
     * Get the deliveryTimeframeIndicator field
1202
     *
1203
     * Corresponds to the Ds_Merchant_Emv3Ds.MerchantRiskIndicator.deliveryTimeframe field in Redsys documentation.
1204
     *
1205
     * @return null|string One of the DELIVERY_TIMEFRAME_* constants
1206
     */
1207
    public function getDeliveryTimeframeIndicator()
1208
    {
1209
        return $this->getParameter('deliveryTimeframeIndicator');
1210
    }
1211
1212
    /**
1213
     * Set the deliveryTimeframeIndicator field
1214
     *
1215
     * Corresponds to the Ds_Merchant_Emv3Ds.MerchantRiskIndicator.deliveryTimeframe field in the Redsys documentation.
1216
     *
1217
     * @param null|string $value One of the DELIVERY_TIMEFRAME_* constants
1218
     * @return self
1219
     * @throws InvalidRequestException if $value is invalid.
1220
     */
1221
    public function setDeliveryTimeframeIndicator($value)
1222
    {
1223
        if (in_array(
1224
            $value,
1225
            [
1226
                null,
1227
                self::DELIVERY_TIMEFRAME_ELECTRONIC_DELIVERY,
1228
                self::DELIVERY_TIMEFRAME_SAME_DAY,
1229
                self::DELIVERY_TIMEFRAME_NEXT_DAY,
1230
                self::DELIVERY_TIMEFRAME_2_OR_MORE_DAYS,
1231
            ]
1232
        )) {
1233
            if ($value !== null) {
1234
                $this->setUse3DS(true);
1235
            }
1236
            return $this->setParameter('deliveryTimeframeIndicator', $value);
1237
        }
1238
        throw new InvalidRequestException("Invalid deliveryTimeframeIndicator parameter");
1239
    }
1240
1241
    /**
1242
     * Get the giftCardAmount field
1243
     *
1244
     * Corresponds to the Ds_Merchant_Emv3Ds.MerchantRiskIndicator.giftCardAmount field in Redsys documentation.
1245
     *
1246
     * @return null|int
1247
     */
1248
    public function getGiftCardAmount()
1249
    {
1250
        return $this->getParameter('giftCardAmount');
1251
    }
1252
1253
    /**
1254
     * Set the giftCardAmount field
1255
     *
1256
     * Corresponds to the Ds_Merchant_Emv3Ds.MerchantRiskIndicator.giftCardAmount field in the Redsys documentation.
1257
     *
1258
     * @param null|int $value
1259
     * @return self
1260
     */
1261
    public function setGiftCardAmount($value)
1262
    {
1263
        if ($value !== null) {
1264
            $this->setUse3DS(true);
1265
        }
1266
        return $this->setParameter('giftCardAmount', $value);
1267
    }
1268
1269
    /**
1270
     * Get the giftCardCount field
1271
     *
1272
     * Corresponds to the Ds_Merchant_Emv3Ds.MerchantRiskIndicator.giftCardCount field in Redsys documentation.
1273
     *
1274
     * @return null|int
1275
     */
1276
    public function getGiftCardCount()
1277
    {
1278
        return $this->getParameter('giftCardCount');
1279
    }
1280
1281
    /**
1282
     * Set the giftCardCount field
1283
     *
1284
     * Corresponds to the Ds_Merchant_Emv3Ds.MerchantRiskIndicator.giftCardCount field in the Redsys documentation.
1285
     *
1286
     * @param null|int $value
1287
     * @return self
1288
     */
1289
    public function setGiftCardCount($value)
1290
    {
1291
        if ($value !== null) {
1292
            $this->setUse3DS(true);
1293
        }
1294
        return $this->setParameter('giftCardCount', $value);
1295
    }
1296
1297
    /**
1298
     * Get the giftCardCurrency field
1299
     *
1300
     * Corresponds to the Ds_Merchant_Emv3Ds.MerchantRiskIndicator.giftCardCurr field in Redsys documentation.
1301
     *
1302
     * @return null|string ISO-4217 currency code
1303
     */
1304
    public function getGiftCardCurrency()
1305
    {
1306
        return $this->getParameter('giftCardCurrency');
1307
    }
1308
1309
    /**
1310
     * Set the giftCardCurrency field
1311
     *
1312
     * Corresponds to the Ds_Merchant_Emv3Ds.MerchantRiskIndicator.giftCardCurr field in the Redsys documentation.
1313
     *
1314
     * @param null|string $value ISO-4217 currency code
1315
     * @return self
1316
     */
1317
    public function setGiftCardCurrency($value)
1318
    {
1319
        if ($value !== null) {
1320
            $this->setUse3DS(true);
1321
        }
1322
        return $this->setParameter('giftCardCurrency', $value);
1323
    }
1324
1325
    /**
1326
     * Get the purchasingPreOrder field
1327
     *
1328
     * Corresponds to the Ds_Merchant_Emv3Ds.MerchantRiskIndicator.preOrderPurchaseInd field in Redsys documentation.
1329
     *
1330
     * @return null|boolean True if the customer is purchasing a preorder
1331
     */
1332
    public function getPurchasingPreOrder()
1333
    {
1334
        return $this->getParameter('purchasingPreOrder');
1335
    }
1336
1337
    /**
1338
     * Set the purchasingPreOrder field
1339
     *
1340
     * Corresponds to the Ds_Merchant_Emv3Ds.MerchantRiskIndicator.preOrderPurchaseInd field in the Redsys
1341
     * documentation.
1342
     *
1343
     * @param null|boolean $value True if the customer is purchasing a preorder
1344
     * @return self
1345
     */
1346
    public function setPurchasingPreOrder($value)
1347
    {
1348
        if ($value !== null) {
1349
            $this->setUse3DS(true);
1350
        }
1351
        return $this->setParameter('purchasingPreOrder', $value);
1352
    }
1353
1354
    /**
1355
     * Get the preOrderDate field
1356
     *
1357
     * Corresponds to the Ds_Merchant_Emv3Ds.MerchantRiskIndicator.preOrderDate field in Redsys documentation.
1358
     *
1359
     * @return null|DateTime|int
1360
     */
1361
    public function getPreOrderDate()
1362
    {
1363
        return $this->getParameter('preOrderDate');
1364
    }
1365
1366
    /**
1367
     * Set the preOrderDate field
1368
     *
1369
     * Corresponds to the Ds_Merchant_Emv3Ds.MerchantRiskIndicator.preOrderDate field in the Redsys documentation.
1370
     *
1371
     * @param null|DateTime|int $value
1372
     * @return self
1373
     */
1374
    public function setPreOrderDate($value)
1375
    {
1376
        if ($value !== null) {
1377
            $this->setUse3DS(true);
1378
        }
1379
        return $this->setParameter('preOrderDate', $value);
1380
    }
1381
1382
    /**
1383
     * Get the customerHasPurchasedProductBefore field
1384
     *
1385
     * Corresponds to the Ds_Merchant_Emv3Ds.MerchantRiskIndicator.reorderItemsInd field in Redsys documentation.
1386
     *
1387
     * @return null|boolean
1388
     */
1389
    public function getCustomerHasPurchasedProductBefore()
1390
    {
1391
        return $this->getParameter('customerHasPurchasedProductBefore');
1392
    }
1393
1394
    /**
1395
     * Set the customerHasPurchasedProductBefore field
1396
     *
1397
     * Corresponds to the Ds_Merchant_Emv3Ds.MerchantRiskIndicator.reorderItemsInd field in the Redsys documentation.
1398
     *
1399
     * @param null|boolean $value
1400
     * @return self
1401
     */
1402
    public function setCustomerHasPurchasedProductBefore($value)
1403
    {
1404
        if ($value !== null) {
1405
            $this->setUse3DS(true);
1406
        }
1407
        return $this->setParameter('customerHasPurchasedProductBefore', $value);
1408
    }
1409
1410
    /**
1411
     * Get the shippingAddressIndicator field
1412
     *
1413
     * Corresponds to the Ds_Merchant_Emv3Ds.MerchantRiskIndicator.shipIndicator field in Redsys documentation.
1414
     *
1415
     * @return null|string One of the self::SHIPPING_* constants
1416
     */
1417
    public function getShippingAddressIndicator()
1418
    {
1419
        return $this->getParameter('shippingAddressIndicator');
1420
    }
1421
1422
    /**
1423
     * Set the shippingAddressIndicator field
1424
     *
1425
     * Corresponds to the Ds_Merchant_Emv3Ds.MerchantRiskIndicator.shipIndicator field in the Redsys documentation.
1426
     *
1427
     * @param null|string $value One of the self::SHIPPING_* constants
1428
     * @return self
1429
     * @throws InvalidRequestException if $value is invalid.
1430
     */
1431 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...
1432
    {
1433
        if (in_array(
1434
            $value,
1435
            [
1436
                null,
1437
                self::SHIPPING_TO_BILLING_ADDRESS,
1438
                self::SHIPPING_TO_ANOTHER_VERIFIED_ADDRESS,
1439
                self::SHIPPING_DIFFERENT_BILLING_ADDRESS,
1440
                self::SHIPPING_PICK_UP,
1441
                self::SHIPPING_DIGITAL,
1442
                self::SHIPPING_TRAVEL,
1443
                self::SHIPPING_OTHER,
1444
            ]
1445
        )) {
1446
            if ($value !== null) {
1447
                $this->setUse3DS(true);
1448
            }
1449
            return $this->setParameter('shippingAddressIndicator', $value);
1450
        }
1451
        throw new InvalidRequestException("Invalid shippingAddressIndicator parameter");
1452
    }
1453
1454
    /**
1455
     * Get the SCA exemption field
1456
     *
1457
     * Corresponds to the Ds_Merchant_Excep_Sca field in Redsys documentation.
1458
     *
1459
     * @return null|string One of the self::SCA_EXCEMPTION_* constants
1460
     */
1461
    public function getScaExemptionIndicator()
1462
    {
1463
        return $this->getParameter('scaExemptionIndicator');
1464
    }
1465
1466
    /**
1467
     * Set the SCA exemption field
1468
     *
1469
     * Corresponds to the Ds_Merchant_Emv3Ds.MerchantRiskIndicator.shipIndicator field in the Redsys documentation.
1470
     *
1471
     * @param null|string $value One of the self::SCA_EXCEMPTION_* constants
1472
     * @return self
1473
     * @throws InvalidRequestException if $value is invalid.
1474
     */
1475
    public function setScaExemptionIndicator($value)
1476
    {
1477
        if (in_array(
1478
            $value,
1479
            [
1480
                null,
1481
                self::SCA_EXCEMPTION_LOW_AMOUNT,
1482
                self::SCA_EXCEMPTION_LOW_RISK,
1483
                self::SCA_EXCEMPTION_CORPORATE,
1484
                self::SCA_EXCEMPTION_MERCHANT_INITIATED,
1485
            ]
1486
        )) {
1487
            if ($value !== null) {
1488
                $this->setUse3DS(true);
1489
            }
1490
            return $this->setParameter('scaExemptionIndicator', $value);
1491
        }
1492
        throw new InvalidRequestException("Invalid scaExemptionIndicator parameter");
1493
    }
1494
1495
    /**
1496
     * Override the abstract method to add requirement that it must start with 4 numeric characters
1497
     *
1498
     * @param string|int $value The transaction ID (merchant order) to set for the transaction
1499
     */
1500
    public function setTransactionId($value)
1501
    {
1502
        $start = substr($value, 0, 4);
1503
        $numerics = 0;
1504
        foreach (str_split($start) as $char) {
1505
            if (is_numeric($char)) {
1506
                $numerics++;
1507
            } else {
1508
                break;
1509
            }
1510
        }
1511
        $value = str_pad(substr($start, 0, $numerics), 4, 0, STR_PAD_LEFT).substr($value, $numerics);
1512
1513
        parent::setTransactionId($value);
1514
    }
1515
1516
    public function getData()
1517
    {
1518
        $this->validate('merchantId', 'terminalId', 'amount', 'currency');
1519
1520
        // generate EMV 3DS request if any of the EMV parameters are set
1521
        if ($this->getUse3DS() === true || ($this->getUse3DS() === null && (
1522
            $this->getEmail() !== null
1523
            || $this->getHomePhoneCountryPrefix() !== null
1524
            || $this->getHomePhone() !== null
1525
            || $this->getMobilePhoneCountryPrefix() !== null
1526
            || $this->getMobilePhone() !== null
1527
            || $this->getWorkPhoneCountryPrefix() !== null
1528
            || $this->getWorkPhone() !== null
1529
            || ($this->getCard() !== null && (
1530
                $this->getCard()->getEmail() !== null
1531
                || $this->getCard()->getShippingAddress1() !== null
1532
                || $this->getCard()->getShippingAddress2() !== null
1533
                || $this->getCard()->getShippingAddress3() !== null
1534
                || $this->getCard()->getShippingCity() !== null
1535
                || $this->getCard()->getShippingPostcode() !== null
1536
                || $this->getCard()->getShippingState() !== null
1537
                || $this->getCard()->getShippingCountry() !== null
1538
                || $this->getCard()->getBillingAddress1() !== null
1539
                || $this->getCard()->getBillingAddress2() !== null
1540
                || $this->getCard()->getBillingAddress3() !== null
1541
                || $this->getCard()->getBillingCity() !== null
1542
                || $this->getCard()->getBillingPostcode() !== null
1543
                || $this->getCard()->getBillingState() !== null
1544
                || $this->getCard()->getBillingCountry() !== null
1545
            ))
1546
            || $this->getAddressMatch() !== null
1547
            || $this->getChallengeWindowSize() !== null
1548
            || $this->getCustomerAdditionalInformation() !== null
1549
            || $this->get3DsRequestAuthenticationMethodData() !== null
1550
            || $this->get3DsRequestAuthenticationMethod() !== null
1551
            || $this->get3DsRequestAuthenticationTime() !== null
1552
            || $this->getCustomerAccountCreatedIndicator() !== null
1553
            || $this->getCustomerAccountCreatedDate() !== null
1554
            || $this->getCustomerAccountChangedIndicator() !== null
1555
            || $this->getCustomerAccountChangedDate() !== null
1556
            || $this->getCustomerPasswordChangedIndicator() !== null
1557
            || $this->getCustomerPasswordChangedDate() !== null
1558
            || $this->getCustomerPurchasesInLast6Months() !== null
1559
            || $this->getCustomerAccountCardProvisionsLast24Hours() !== null
1560
            || $this->getCustomerAccountTransactionsLast24Hours() !== null
1561
            || $this->getCustomerAccountTransactionsLastYear() !== null
1562
            || $this->getCustomerPaymentMethodCreatedIndicator() !== null
1563
            || $this->getCustomerPaymentMethodCreatedDate() !== null
1564
            || $this->getShippingAddressFirstUsedIndicator() !== null
1565
            || $this->getShippingAddressFirstUsedDate() !== null
1566
            || $this->getShippingNameCustomerNameMatch() !== null
1567
            || $this->getCustomerHasSuspiciousActivity() !== null
1568
            || $this->getDeliveryEmail() !== null
1569
            || $this->getDeliveryTimeframeIndicator() !== null
1570
            || $this->getGiftCardAmount() !== null
1571
            || $this->getGiftCardCount() !== null
1572
            || $this->getGiftCardCurrency() !== null
1573
            || $this->getPurchasingPreOrder() !== null
1574
            || $this->getPreOrderDate() !== null
1575
            || $this->getCustomerHasPurchasedProductBefore() !== null
1576
            || $this->getShippingAddressIndicator() !== null)
1577
        )) {
1578
            $address_matches = (
1579
            $this->getAddressMatch() === null && $this->getCard() !== null
1580
            ? (
1581
                $this->getCard()->getShippingAddress1() === $this->getCard()->getBillingAddress1() &&
1582
                $this->getCard()->getShippingAddress2() === $this->getCard()->getBillingAddress2() &&
1583
                $this->getCard()->getShippingAddress3() === $this->getCard()->getBillingAddress3() &&
1584
                $this->getCard()->getShippingCity() === $this->getCard()->getBillingCity() &&
1585
                $this->getCard()->getShippingPostcode() === $this->getCard()->getBillingPostcode() &&
1586
                $this->getCard()->getShippingState() === $this->getCard()->getBillingState() &&
1587
                $this->getCard()->getShippingCountry() === $this->getCard()->getBillingCountry()
1588
            )
1589
            : $this->getAddressMatch()
1590
            );
1591
            $home_phone = array_filter([
1592
                'cc'         => $this->getHomePhoneCountryPrefix(),
1593
                'subscriber' => $this->getHomePhone(),
1594
            ]);
1595
            $mobile_phone = array_filter([
1596
                'cc'         => $this->getMobilePhoneCountryPrefix(),
1597
                'subscriber' => $this->getMobilePhone(),
1598
            ]);
1599
            $work_phone = array_filter([
1600
                'cc'         => $this->getWorkPhoneCountryPrefix(),
1601
                'subscriber' => $this->getWorkPhone(),
1602
            ]);
1603
            $three_ds_auth_info = array_filter([
1604
                'threeDSReqAuthData'      => $this->get3DsRequestAuthenticationMethodData(),
1605
                'threeDSReqAuthMethod'    => $this->get3DsRequestAuthenticationMethod(),
1606
                'threeDSReqAuthTimestamp' => $this->formatDateTime(
1607
                    $this->get3DsRequestAuthenticationTime(),
1608
                    "YmdHi"
1609
                ),
1610
            ]);
1611
            $acct_info = array_filter([
1612
                'chAccAgeInd'           => $this->getCustomerAccountCreatedIndicator(),
1613
                'chAccDate'             => $this->formatDateTime($this->getCustomerAccountCreatedDate(), "Ymd"),
1614
                'chAccChangeInd'        => $this->getCustomerAccountChangedIndicator(),
1615
                'chAccChange'           => $this->formatDateTime(
1616
                    $this->getCustomerAccountChangedDate(),
1617
                    "Ymd"
1618
                ),
1619
                'chAccPwChangeInd'      => $this->getCustomerPasswordChangedIndicator(),
1620
                'chAccPwChange'         => $this->formatDateTime(
1621
                    $this->getCustomerPasswordChangedDate(),
1622
                    "Ymd"
1623
                ),
1624
                'paymentAccInd'         => $this->getCustomerPaymentMethodCreatedIndicator(),
1625
                'paymentAccAge'         => $this->formatDateTime(
1626
                    $this->getCustomerPaymentMethodCreatedDate(),
1627
                    "Ymd"
1628
                ),
1629
                'shipAddressUsageInd'   => $this->getShippingAddressFirstUsedIndicator(),
1630
                'shipAddressUsage'      => $this->formatDateTime($this->getShippingAddressFirstUsedDate(), "Ymd"),
1631
                'shipNameIndicator'     => $this->getShippingNameCustomerNameMatch() === null
1632
                    ? null
1633
                    : ($this->getShippingNameCustomerNameMatch() ? "01" : "02"),
1634
                'suspiciousAccActivity' => $this->getCustomerHasSuspiciousActivity() === null
1635
                    ? null
1636
                    : ($this->getCustomerHasSuspiciousActivity() ? "02" : "01"),
1637
            ])
1638
            + ($this->getCustomerPurchasesInLast6Months() === null
1639
                ? []
1640
                : ['nbPurchaseAccount' => $this->getCustomerPurchasesInLast6Months()])
1641
            + ($this->getCustomerAccountCardProvisionsLast24Hours() === null
1642
                ? []
1643
                : ['provisionAttemptsDay' => $this->getCustomerAccountCardProvisionsLast24Hours()])
1644
            + ($this->getCustomerAccountTransactionsLast24Hours() === null
1645
                ? []
1646
                : ['txnActivityDay' => $this->getCustomerAccountTransactionsLast24Hours()])
1647
            + ($this->getCustomerAccountTransactionsLastYear() === null
1648
                ? []
1649
                : ['txnActivityYear' => $this->getCustomerAccountTransactionsLastYear()]);
1650
            $merchant_risk_indicator = array_filter([
1651
                'deliveryEmailAddress' => $this->getDeliveryEmail(),
1652
                'deliveryTimeframe'    => $this->getDeliveryTimeframeIndicator(),
1653
                'giftCardAmount'       => $this->getGiftCardAmount() === null
1654
                    ? null
1655
                    : (int) $this->getGiftCardAmount(),
1656
                'giftCardCount'        => $this->getGiftCardCount(),
1657
                'giftCardCurr'         => $this->getGiftCardCurrency(),
1658
                'preOrderPurchaseInd'  => $this->getPurchasingPreOrder() === null
1659
                    ? null
1660
                    : ($this->getPurchasingPreOrder() ? "02" : "01"),
1661
                'preOrderDate'         => $this->formatDateTime($this->getPreOrderDate(), "Ymd"),
1662
                'reorderItemsInd'      => $this->getCustomerHasPurchasedProductBefore() === null
1663
                    ? null
1664
                    : ($this->getCustomerHasPurchasedProductBefore() ? "02" : "01"),
1665
                'shipIndicator'        => $this->getShippingAddressIndicator(),
1666
            ]);
1667
          
1668
            $emv_3ds_parameters = array_filter([
1669
                'cardholderName'      => $this->getCardholder(),
1670
                'email'               => ($this->getEmail() === null
1671
                    ? ($this->getCard() === null ? null : $this->getCard()->getEmail())
1672
                    : $this->getEmail()
1673
                ),
1674
                'addrMatch'           => $address_matches ? "Y" : "N",
1675
                'challengeWindowSize' => $this->getChallengeWindowSize(),
1676
                'acctID'              => $this->getCustomerAdditionalInformation(),
1677
            ]
1678
            + ($this->getCard() === null
1679
                ? []
1680
                : [
1681
                    'shipAddrLine1'       => $this->getCard()->getShippingAddress1(),
1682
                    'shipAddrLine2'       => $this->getCard()->getShippingAddress2(),
1683
                    'shipAddrLine3'       => $this->getCard()->getShippingAddress3(),
1684
                    'shipAddrCity'        => $this->getCard()->getShippingCity(),
1685
                    'shipAddrPostCode'    => $this->getCard()->getShippingPostcode(),
1686
                    'shipAddrState'       => $this->getCard()->getShippingState(),
1687
                    'shipAddrCountry'     => $this->getCard()->getShippingCountry(),
1688
                    'billAddrLine1'       => $this->getCard()->getBillingAddress1(),
1689
                    'billAddrLine2'       => $this->getCard()->getBillingAddress2(),
1690
                    'billAddrLine3'       => $this->getCard()->getBillingAddress3(),
1691
                    'billAddrCity'        => $this->getCard()->getBillingCity(),
1692
                    'billAddrPostCode'    => $this->getCard()->getBillingPostcode(),
1693
                    'billAddrState'       => $this->getCard()->getBillingState(),
1694
                    'billAddrCountry'     => $this->getCard()->getBillingCountry(),
1695
                ]))
1696
            + ($home_phone === []
1697
                ? []
1698
                : ['homePhone' => $home_phone]
1699
            )
1700
            + ($mobile_phone === []
1701
                ? []
1702
                : ['mobilePhone' => $mobile_phone]
1703
            )
1704
            + ($work_phone === []
1705
                ? []
1706
                : ['workPhone' => $work_phone]
1707
            )
1708
            + ($three_ds_auth_info === []
1709
                ? []
1710
                : ['threeDSRequestorAuthenticationInfo' => $three_ds_auth_info]
1711
            )
1712
            + ($acct_info === []
1713
                ? []
1714
                : ['acctInfo' => $acct_info]
1715
            )
1716
            + ($merchant_risk_indicator === []
1717
                ? []
1718
                : ['merchantRiskIndicator' => $merchant_risk_indicator]
1719
            );
1720
        } else {
1721
            $emv_3ds_parameters = null;
1722
        }
1723
1724
        return [
1725
            // mandatory fields
1726
            'Ds_Merchant_MerchantCode'       => $this->getMerchantId(),
1727
            'Ds_Merchant_Terminal'           => $this->getTerminalId(),
1728
            'Ds_Merchant_TransactionType'    => '0',                          // Authorisation
1729
            'Ds_Merchant_Amount'             => $this->getAmountInteger(),
1730
            'Ds_Merchant_Currency'           => $this->getCurrencyNumeric(),  // uses ISO-4217 codes
1731
            'Ds_Merchant_Order'              => $this->getTransactionId(),
1732
            'Ds_Merchant_MerchantUrl'        => $this->getNotifyUrl(),
1733
            // optional fields
1734
            'Ds_Merchant_ProductDescription' => $this->getDescription(),
1735
            'Ds_Merchant_Cardholder'         => $this->getCardholder(),
1736
            'Ds_Merchant_UrlOK'              => $this->getReturnUrl(),
1737
            'Ds_Merchant_UrlKO'              => $this->getReturnUrl(),
1738
            'Ds_Merchant_MerchantName'       => $this->getMerchantName(),
1739
            'Ds_Merchant_ConsumerLanguage'   => $this->getConsumerLanguage(),
1740
            'Ds_Merchant_MerchantData'       => $this->getMerchantData(),
1741
        ]
1742
        + ($this->getScaExemptionIndicator() === null
1743
            ? []
1744
            : ['Ds_Merchant_Excep_Sca' => $this->getScaExemptionIndicator()])
1745
        + ($emv_3ds_parameters === null ? [] : ['Ds_Merchant_Emv3Ds' => $emv_3ds_parameters]);
1746
    }
1747
1748
    public function sendData($data)
1749
    {
1750
        $security = new Security;
1751
1752
        $encoded_data = $security->encodeMerchantParameters($data);
1753
1754
        $response_data = array(
1755
            'Ds_SignatureVersion'   => Security::VERSION,
1756
            'Ds_MerchantParameters' => $encoded_data,
1757
            'Ds_Signature'          => $security->createSignature(
1758
                $encoded_data,
1759
                $data['Ds_Merchant_Order'],
1760
                $this->getHmacKey()
1761
            ),
1762
        );
1763
1764
        return $this->response = new PurchaseResponse($this, $response_data);
1765
    }
1766
1767
    public function getEndpoint()
1768
    {
1769
        return $this->getTestMode() ? $this->testEndpoint : $this->liveEndpoint;
1770
    }
1771
1772
    /**
1773
     * Convert a DateTime or timestamp to a formatted date.
1774
     *
1775
     * @param DateTime|int $date The date to format.
1776
     * @param string $format The format to use.
1777
     *
1778
     * @return string|null The formatted date, or null if date isn't a timestamp or DateTime object.
1779
     */
1780
    protected static function formatDateTime($date, $format)
1781
    {
1782
        if (is_int($date)) {
1783
            return (new DateTime('@'.$date))->format($format);
1784
        } elseif ($date instanceof DateTime) {
1785
            return $date->setTimezone(new DateTimeZone('UTC'))->format($format);
1786
        }
1787
    }
1788
}
1789