Completed
Pull Request — master (#5)
by Michael
05:20
created

PurchaseRequest::getHomePhoneCountryPrefix()   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\CreditCard;
8
use Omnipay\Common\Message\AbstractRequest;
9
use Omnipay\Redsys\Exception\InvalidParameterException;
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
    /**
148 2
     * Get the card field
149 2
     *
150
     * @return OmniPay::CreditCard
0 ignored issues
show
Documentation introduced by
The doc-type OmniPay::CreditCard could not be parsed: Unknown type name "OmniPay::CreditCard" at position 0. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
151 2
     */
152 2
    public function getCard()
153 2
    {
154 2
        return $this->getParameter('card');
155 2
    }
156 2
157 2
    /**
158 2
     * Set the card field
159
     *
160
     * @param OmniPay::CreditCard $value
0 ignored issues
show
Documentation introduced by
The doc-type OmniPay::CreditCard could not be parsed: Unknown type name "OmniPay::CreditCard" at position 0. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

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