• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mlocati / PayWay / 5272005549

pending completion
5272005549

Pull #4

github

web-flow
Merge d20a1048f into ada68d889
Pull Request #4: Multiple fixes

51 of 51 new or added lines in 8 files covered. (100.0%)

1603 of 2134 relevant lines covered (75.12%)

1.54 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

67.32
/src/Init/Request.php
1
<?php
2

3
namespace MLocati\PayWay\Init;
4

5
use DateTime;
6
use DateTimeInterface;
7
use JsonSerializable;
8
use MLocati\PayWay\Dictionary;
9
use MLocati\PayWay\Exception;
10
use MLocati\PayWay\Service;
11

12
class Request implements JsonSerializable
13
{
14
    use Service\BasePaymentInitRequestTrait {
15
        jsonSerialize as jsonSerializeBasePaymentInitRequest;
16
    }
17

18
    /**
19
     * The customer ID (eg. email address).
20
     * If it's an email address, a notification email will be sent to it.
21
     *
22
     * @var string
23
     */
24
    private $shopUserRef = '';
25

26
    /**
27
     * The customer last and first name, separated by a comma.
28
     *
29
     * @var string
30
     *
31
     * @example doe,john
32
     */
33
    private $shopUserName = '';
34

35
    /**
36
     * The customer account from the merchant portal.
37
     *
38
     * @var string
39
     */
40
    private $shopUserAccount = '';
41

42
    /**
43
     * The customer mobile phone.
44
     *
45
     * @var string
46
     */
47
    private $shopUserMobilePhone = '';
48

49
    /**
50
     * Undocumented.
51
     *
52
     * @var string
53
     */
54
    private $shopUserIMEI = '';
55

56
    /**
57
     * The type of the request.
58
     *
59
     * @var string
60
     *
61
     * @see \MLocati\PayWay\Dictionary\TrType
62
     */
63
    private $trType = Dictionary\TrType::CODE_PURCHASE;
64

65
    /**
66
     * The virtual amount in decimal.
67
     * Mandatory with trType PURCHASE o AUTH.
68
     * Optional with trType VERIFY.
69
     *
70
     * @var int|null
71
     *
72
     * @example 0.07 EUR = 7
73
     * @example 1.00 EUR = 100
74
     * @example 12.05 EUR = 1205
75
     */
76
    private $amount;
77

78
    /**
79
     * The currency ISO code.
80
     * Mandatory with trType PURCHASE o AUTH.
81
     * Optional with trType VERIFY.
82
     *
83
     * @var string
84
     *
85
     * @see \MLocati\PayWay\Dictionary\Currency
86
     *
87
     * @example 'EUR'
88
     * @example 'USD'
89
     */
90
    private $currencyCode = Dictionary\Currency::CODE_EUR;
91

92
    /**
93
     * The ISO 639—2 code of the language used for the data entry payment page.
94
     *
95
     * @var string
96
     *
97
     * @see \MLocati\PayWay\Dictionary\Language
98
     *
99
     * @example 'IT'
100
     * @example 'EN'
101
     */
102
    private $langID = Dictionary\Language::CODE_ITALIAN;
103

104
    /**
105
     * The URL relating to the request outcome notification page.
106
     *
107
     * @var string
108
     */
109
    private $notifyURL = '';
110

111
    /**
112
     * The URL relating to the error page associated with a request.
113
     * The error cause is returned by the addition query string parameter rc.
114
     * This URL will be called only incase of technical problems: if the transaction has a negative outcome (eg lack of funds) it is redirected to the notifyURL.
115
     *
116
     * @var string
117
     */
118
    private $errorURL = '';
119

120
    /**
121
     * The URL for Server2Server notifications.
122
     *
123
     * @var string
124
     *
125
     * @see \MLocati\PayWay\Server2Server\RequestData
126
     */
127
    private $callbackURL = '';
128

129
    /**
130
     * The field #1 available to merchant.
131
     *
132
     * @var string
133
     */
134
    private $addInfo1 = '';
135

136
    /**
137
     * The field #2 available to merchant.
138
     *
139
     * @var string
140
     */
141
    private $addInfo2 = '';
142

143
    /**
144
     * The field #3 available to merchant.
145
     *
146
     * @var string
147
     */
148
    private $addInfo3 = '';
149

150
    /**
151
     * The field #4 available to merchant.
152
     *
153
     * @var string
154
     */
155
    private $addInfo4 = '';
156

157
    /**
158
     * The field #5 available to merchant.
159
     *
160
     * @var string
161
     */
162
    private $addInfo5 = '';
163

164
    /**
165
     * The token ID associated to the payment instrument.
166
     * Used when the card number tokenization is set to EXTERNAL instead of AUTOGEN.
167
     *
168
     * @var string
169
     */
170
    private $payInstrToken = '';
171

172
    /**
173
     * Undocumented.
174
     *
175
     * @var string
176
     */
177
    private $billingID = '';
178

179
    /**
180
     * Should a new token be generated?
181
     *
182
     * @var bool|null
183
     */
184
    private $regenPayInstrToken;
185

186
    /**
187
     * Undocumented.
188
     *
189
     * @var bool|null
190
     */
191
    private $keepOnRegenPayInstrToken;
192

193
    /**
194
     * Undocumented.
195
     *
196
     * @var \DateTimeInterface|null
197
     */
198
    private $payInstrTokenExpire;
199

200
    /**
201
     * Undocumented.
202
     *
203
     * @var int|null
204
     */
205
    private $payInstrTokenUsageLimit;
206

207
    /**
208
     * Undocumented.
209
     *
210
     * @var string
211
     */
212
    private $payInstrTokenAlg = '';
213

214
    /**
215
     * The holder last and first name, separated by a comma, for prefilling respective fields.
216
     *
217
     * @var string
218
     *
219
     * @example doe,john
220
     */
221
    private $accountName = '';
222

223
    /**
224
     * Undocumented.
225
     *
226
     * @var \MLocati\PayWay\Service\Level3Info|null
227
     */
228
    private $level3Info;
229

230
    /**
231
     * Undocumented.
232
     *
233
     * @var \MLocati\PayWay\Service\MandateInfo|null
234
     */
235
    private $mandateInfo;
236

237
    /**
238
     * The payment description.
239
     *
240
     * @var string
241
     */
242
    private $description = '';
243

244
    /**
245
     * The payment reason.
246
     *
247
     * @var string
248
     */
249
    private $paymentReason = '';
250

251
    /**
252
     * Undocumented.
253
     *
254
     * @var string
255
     */
256
    private $freeText = '';
257

258
    /**
259
     * Undocumented.
260
     *
261
     * @var string
262
     */
263
    private $topUpID = '';
264

265
    /**
266
     * Undocumented.
267
     *
268
     * @var bool|null
269
     */
270
    private $firstTopUp;
271

272
    /**
273
     * Undocumented.
274
     *
275
     * @var bool|null
276
     */
277
    private $payInstrTokenAsTopUpID;
278

279
    /**
280
     * @deprecated Use txIndicatorType
281
     *
282
     * @var bool|null
283
     */
284
    private $recurrentIndicator;
285

286
    /**
287
     * The transaction indicator type.
288
     *
289
     * @var string
290
     *
291
     * @see \MLocati\PayWay\Dictionary\TxIndicatorType
292
     */
293
    private $txIndicatorType = '';
294

295
    /**
296
     * The transaction identifier for recurrent/unscheduled payments.
297
     *
298
     * @var string
299
     */
300
    private $traceChainId = '';
301

302
    /**
303
     * The SCA exemption type reguested by merchant.
304
     *
305
     * @var string
306
     *
307
     * @see \MLocati\PayWay\Dictionary\ScaExemptionType
308
     */
309
    private $scaExemptionType = '';
310

311
    /**
312
     * The transaction validity date/time limit (valid only for external payment instrument).
313
     *
314
     * @var \DateTimeInterface|null
315
     */
316
    private $validityExpire;
317

318
    /**
319
     * Undocumented.
320
     *
321
     * @var int|null
322
     */
323
    private $minExpireMonth;
324

325
    /**
326
     * Undocumented.
327
     *
328
     * @var int|null
329
     */
330
    private $minExpireYear;
331

332
    /**
333
     * Undocumented.
334
     *
335
     * @var \MLocati\PayWay\Service\TermInfo[]
336
     */
337
    private $termInfos = [];
338

339
    /**
340
     * Undocumented.
341
     *
342
     * @var array
343
     */
344
    private $payInstrAddData = [];
345

346
    /**
347
     * Get the customer ID (eg. email address).
348
     * If it's an email address, a notification email will be sent to it.
349
     *
350
     * @return string
351
     */
352
    public function getShopUserRef()
353
    {
354
        return $this->shopUserRef;
4✔
355
    }
356

357
    /**
358
     * Set the customer ID (eg. email address).
359
     * If it's an email address, a notification email will be sent to it.
360
     *
361
     * @param string $value
362
     *
363
     * @return $this
364
     */
365
    public function setShopUserRef($value)
366
    {
367
        $this->shopUserRef = (string) $value;
1✔
368

369
        return $this;
1✔
370
    }
371

372
    /**
373
     * Get the customer last and first name, separated by a comma.
374
     *
375
     * @return string
376
     *
377
     * @example doe,john
378
     */
379
    public function getShopUserName()
380
    {
381
        return $this->shopUserName;
4✔
382
    }
383

384
    /**
385
     * Set the customer last and first name, separated by a comma.
386
     *
387
     * @param string $value
388
     *
389
     * @return $this
390
     *
391
     * @example doe,john
392
     */
393
    public function setShopUserName($value)
394
    {
395
        $this->shopUserName = (string) $value;
×
396

397
        return $this;
×
398
    }
399

400
    /**
401
     * Get the customer account from the merchant portal.
402
     *
403
     * @return string
404
     */
405
    public function getShopUserAccount()
406
    {
407
        return $this->shopUserAccount;
4✔
408
    }
409

410
    /**
411
     * Set the customer account from the merchant portal.
412
     *
413
     * @param string $value
414
     *
415
     * @return $this
416
     */
417
    public function setShopUserAccount($value)
418
    {
419
        $this->shopUserAccount = (string) $value;
×
420

421
        return $this;
×
422
    }
423

424
    /**
425
     * Get the customer mobile phone.
426
     *
427
     * @return string
428
     */
429
    public function getShopUserMobilePhone()
430
    {
431
        return $this->shopUserMobilePhone;
4✔
432
    }
433

434
    /**
435
     * Set the customer mobile phone.
436
     *
437
     * @param string $value
438
     *
439
     * @return $this
440
     */
441
    public function setShopUserMobilePhone($value)
442
    {
443
        $this->shopUserMobilePhone = (string) $value;
×
444

445
        return $this;
×
446
    }
447

448
    /**
449
     * Undocumented.
450
     *
451
     * @return string
452
     */
453
    public function getShopUserIMEI()
454
    {
455
        return $this->shopUserIMEI;
4✔
456
    }
457

458
    /**
459
     * Undocumented.
460
     *
461
     * @param string $value
462
     *
463
     * @return $this
464
     */
465
    public function setShopUserIMEI($value)
466
    {
467
        $this->shopUserIMEI = (string) $value;
×
468

469
        return $this;
×
470
    }
471

472
    /**
473
     * Get the type of the request.
474
     *
475
     * @return string
476
     *
477
     * @see \MLocati\PayWay\Dictionary\TrType
478
     */
479
    public function getTrType()
480
    {
481
        return $this->trType;
4✔
482
    }
483

484
    /**
485
     * Set the type of the request.
486
     *
487
     * @param string $value
488
     *
489
     * @return $this
490
     *
491
     * @see \MLocati\PayWay\Dictionary\TrType
492
     */
493
    public function setTrType($value)
494
    {
495
        $this->trType = (string) $value;
1✔
496

497
        return $this;
1✔
498
    }
499

500
    /**
501
     * Get the virtual amount (as a floating number).
502
     *
503
     * @return float|int|null
504
     *
505
     * @example 0.07 EUR = 0.07
506
     * @example 1.00 EUR = 1
507
     * @example 12.05 EUR = 12.05
508
     *
509
     * @see \MLocati\PayWay\Init\Request::getAmountAsCents()
510
     */
511
    public function getAmountAsFloat()
512
    {
513
        return $this->amount === null ? null : ((float) $this->amount) / 100.;
×
514
    }
515

516
    /**
517
     * Set the virtual amount (as a floating number).
518
     *
519
     * @param float|int|null $value
520
     *
521
     * @return $this
522
     *
523
     * @example 0.07 EUR = 0.07
524
     * @example 1.00 EUR = 1
525
     * @example 12.05 EUR = 12.05
526
     *
527
     * @see \MLocati\PayWay\Init\Request::setAmountAsCents()
528
     */
529
    public function setAmountAsFloat($value)
530
    {
531
        return $this->setAmountAsCents(empty($value) ? $value : round((float) $value * 100.));
1✔
532
    }
533

534
    /**
535
     * Get the virtual amount (in decimal).
536
     *
537
     * @var int|null
538
     *
539
     * @example 0.07 EUR = 7
540
     * @example 1.00 EUR = 100
541
     * @example 12.05 EUR = 1205
542
     *
543
     * @see \MLocati\PayWay\Init\Request::getAmountAsFloat()
544
     */
545
    public function getAmountAsCents()
546
    {
547
        return $this->amount;
4✔
548
    }
549

550
    /**
551
     * Set the virtual amount (as a floating number).
552
     *
553
     * @param int|null $value
554
     *
555
     * @return $this
556
     *
557
     * @example 0.07 EUR = 7
558
     * @example 1.00 EUR = 100
559
     * @example 12.05 EUR = 1205
560
     *
561
     * @see \MLocati\PayWay\Init\Request::setAmountAsFloat()
562
     */
563
    public function setAmountAsCents($value)
564
    {
565
        $this->amount = $value === null || $value === '' ? null : (int) $value;
1✔
566

567
        return $this;
1✔
568
    }
569

570
    /**
571
     * Get the currency ISO code.
572
     * Mandatory with trType PURCHASE o AUTH.
573
     * Optional with trType VERIFY.
574
     *
575
     * @return string
576
     *
577
     * @example 'EUR'
578
     * @example 'USD'
579
     *
580
     * @see \MLocati\PayWay\Dictionary\Currency
581
     */
582
    public function getCurrencyCode()
583
    {
584
        return $this->currencyCode;
4✔
585
    }
586

587
    /**
588
     * Set the currency ISO code.
589
     * Mandatory with trType PURCHASE o AUTH.
590
     * Optional with trType VERIFY.
591
     *
592
     * @param string $value
593
     *
594
     * @return $this
595
     *
596
     * @example 'EUR'
597
     * @example 'USD'
598
     *
599
     * @see \MLocati\PayWay\Dictionary\Currency
600
     */
601
    public function setCurrencyCode($value)
602
    {
603
        $this->currencyCode = strtoupper((string) $value);
1✔
604

605
        return $this;
1✔
606
    }
607

608
    /**
609
     * Get the ISO 639—2 code of the language used for the data entry payment page.
610
     *
611
     * @return string
612
     *
613
     * @see \MLocati\PayWay\Dictionary\Language
614
     *
615
     * @example 'IT'
616
     * @example 'EN'
617
     */
618
    public function getLangID()
619
    {
620
        return $this->langID;
4✔
621
    }
622

623
    /**
624
     * Set the ISO 639—2 code of the language used for the data entry payment page.
625
     *
626
     * @param string $value
627
     *
628
     * @return $this
629
     *
630
     * @see \MLocati\PayWay\Dictionary\Language
631
     *
632
     * @example 'IT'
633
     * @example 'EN'
634
     */
635
    public function setLangID($value)
636
    {
637
        $this->langID = (string) $value;
1✔
638

639
        return $this;
1✔
640
    }
641

642
    /**
643
     * Get the URL relating to the request outcome notification page.
644
     *
645
     * @return string
646
     */
647
    public function getNotifyURL()
648
    {
649
        return $this->notifyURL;
4✔
650
    }
651

652
    /**
653
     * Set the URL relating to the request outcome notification page.
654
     *
655
     * @param string $value
656
     *
657
     * @return $this
658
     */
659
    public function setNotifyURL($value)
660
    {
661
        $this->notifyURL = (string) $value;
1✔
662

663
        return $this;
1✔
664
    }
665

666
    /**
667
     * Get the URL relating to the error page associated with a request.
668
     * The error cause is returned by the addition query string parameter rc.
669
     * This URL will be called only incase of technical problems: if the transaction has a negative outcome (eg lack of funds) it is redirected to the notifyURL.
670
     *
671
     * @return string
672
     */
673
    public function getErrorURL()
674
    {
675
        return $this->errorURL;
4✔
676
    }
677

678
    /**
679
     * Set the URL relating to the error page associated with a request.
680
     * The error cause is returned by the addition query string parameter rc.
681
     * This URL will be called only incase of technical problems: if the transaction has a negative outcome (eg lack of funds) it is redirected to the notifyURL.
682
     *
683
     * @param string $value
684
     *
685
     * @return $this
686
     */
687
    public function setErrorURL($value)
688
    {
689
        $this->errorURL = (string) $value;
1✔
690

691
        return $this;
1✔
692
    }
693

694
    /**
695
     * Get the URL for Server2Server notifications.
696
     *
697
     * @return string
698
     *
699
     * @see \MLocati\PayWay\Server2Server\RequestData
700
     */
701
    public function getCallbackURL()
702
    {
703
        return $this->callbackURL;
4✔
704
    }
705

706
    /**
707
     * Set the URL for Server2Server notifications.
708
     *
709
     * @param string $value
710
     *
711
     * @return $this
712
     *
713
     * @see \MLocati\PayWay\Server2Server\RequestData
714
     */
715
    public function setCallbackURL($value)
716
    {
717
        $this->callbackURL = (string) $value;
×
718

719
        return $this;
×
720
    }
721

722
    /**
723
     * Get the field #1 available to merchant.
724
     *
725
     * @return string
726
     */
727
    public function getAddInfo1()
728
    {
729
        return $this->addInfo1;
4✔
730
    }
731

732
    /**
733
     * Set the field #1 available to merchant.
734
     *
735
     * @param string $value
736
     *
737
     * @return $this
738
     */
739
    public function setAddInfo1($value)
740
    {
741
        $this->addInfo1 = (string) $value;
×
742

743
        return $this;
×
744
    }
745

746
    /**
747
     * Get the field #2 available to merchant.
748
     *
749
     * @return string
750
     */
751
    public function getAddInfo2()
752
    {
753
        return $this->addInfo2;
4✔
754
    }
755

756
    /**
757
     * Set the field #2 available to merchant.
758
     *
759
     * @param string $value
760
     *
761
     * @return $this
762
     */
763
    public function setAddInfo2($value)
764
    {
765
        $this->addInfo2 = (string) $value;
×
766

767
        return $this;
×
768
    }
769

770
    /**
771
     * Get the field #3 available to merchant.
772
     *
773
     * @return string
774
     */
775
    public function getAddInfo3()
776
    {
777
        return $this->addInfo3;
4✔
778
    }
779

780
    /**
781
     * Set the field #3 available to merchant.
782
     *
783
     * @param string $value
784
     *
785
     * @return $this
786
     */
787
    public function setAddInfo3($value)
788
    {
789
        $this->addInfo3 = (string) $value;
×
790

791
        return $this;
×
792
    }
793

794
    /**
795
     * Get the field #4 available to merchant.
796
     *
797
     * @return string
798
     */
799
    public function getAddInfo4()
800
    {
801
        return $this->addInfo4;
4✔
802
    }
803

804
    /**
805
     * Set the field #4 available to merchant.
806
     *
807
     * @param string $value
808
     *
809
     * @return $this
810
     */
811
    public function setAddInfo4($value)
812
    {
813
        $this->addInfo4 = (string) $value;
×
814

815
        return $this;
×
816
    }
817

818
    /**
819
     * Get the field #5 available to merchant.
820
     *
821
     * @return string
822
     */
823
    public function getAddInfo5()
824
    {
825
        return $this->addInfo5;
4✔
826
    }
827

828
    /**
829
     * Set the field #5 available to merchant.
830
     *
831
     * @param string $value
832
     *
833
     * @return $this
834
     */
835
    public function setAddInfo5($value)
836
    {
837
        $this->addInfo5 = (string) $value;
×
838

839
        return $this;
×
840
    }
841

842
    /**
843
     * Get the token ID associated to the payment instrument.
844
     * Used when the card number tokenization is set to EXTERNAL instead of AUTOGEN.
845
     *
846
     * @return string
847
     */
848
    public function getPayInstrToken()
849
    {
850
        return $this->payInstrToken;
4✔
851
    }
852

853
    /**
854
     * Set the token ID associated to the payment instrument.
855
     * Used when the card number tokenization is set to EXTERNAL instead of AUTOGEN.
856
     *
857
     * @param string $value
858
     *
859
     * @return $this
860
     */
861
    public function setPayInstrToken($value)
862
    {
863
        $this->payInstrToken = (string) $value;
×
864

865
        return $this;
×
866
    }
867

868
    /**
869
     * Undocumented.
870
     *
871
     * @return string
872
     */
873
    public function getBillingID()
874
    {
875
        return $this->billingID;
4✔
876
    }
877

878
    /**
879
     * Undocumented.
880
     *
881
     * @param string $value
882
     *
883
     * @return $this
884
     */
885
    public function setBillingID($value)
886
    {
887
        $this->billingID = (string) $value;
×
888

889
        return $this;
×
890
    }
891

892
    /**
893
     * Should a new token be generated?
894
     *
895
     * @return bool|null
896
     */
897
    public function isRegenPayInstrToken()
898
    {
899
        return $this->regenPayInstrToken;
4✔
900
    }
901

902
    /**
903
     * Should a new token be generated?
904
     *
905
     * @param bool|null $value
906
     *
907
     * @return $this
908
     */
909
    public function setRegenPayInstrToken($value)
910
    {
911
        $this->regenPayInstrToken = $value === null || $value === '' ? null : (bool) $value;
×
912

913
        return $this;
×
914
    }
915

916
    /**
917
     * Undocumented.
918
     *
919
     * @return bool|null
920
     */
921
    public function isKeepOnRegenPayInstrToken()
922
    {
923
        return $this->keepOnRegenPayInstrToken;
4✔
924
    }
925

926
    /**
927
     * Undocumented.
928
     *
929
     * @param bool|null $value
930
     *
931
     * @return $this
932
     */
933
    public function setKeepOnRegenPayInstrToken($value)
934
    {
935
        $this->keepOnRegenPayInstrToken = $value === null || $value === '' ? null : (bool) $value;
×
936

937
        return $this;
×
938
    }
939

940
    /**
941
     * Undocumented.
942
     *
943
     * @return \DateTimeInterface|null
944
     */
945
    public function getPayInstrTokenExpire()
946
    {
947
        return $this->payInstrTokenExpire;
4✔
948
    }
949

950
    /**
951
     * Undocumented.
952
     *
953
     * @return $this
954
     */
955
    public function setPayInstrTokenExpire(DateTimeInterface $value = null)
956
    {
957
        $this->payInstrTokenExpire = (string) $value;
×
958

959
        return $this;
×
960
    }
961

962
    /**
963
     * Undocumented.
964
     *
965
     * @return int|null
966
     */
967
    public function getPayInstrTokenUsageLimit()
968
    {
969
        return $this->payInstrTokenUsageLimit;
4✔
970
    }
971

972
    /**
973
     * Undocumented.
974
     *
975
     * @param int|null $value
976
     *
977
     * @return $this
978
     */
979
    public function setPayInstrTokenUsageLimit($value)
980
    {
981
        $this->payInstrTokenUsageLimit = $value === null || $value === '' ? null : (int) $value;
×
982

983
        return $this;
×
984
    }
985

986
    /**
987
     * Undocumented.
988
     *
989
     * @return string
990
     */
991
    public function getPayInstrTokenAlg()
992
    {
993
        return $this->payInstrTokenAlg;
4✔
994
    }
995

996
    /**
997
     * Undocumented.
998
     *
999
     * @param string $value
1000
     *
1001
     * @return $this
1002
     */
1003
    public function setPayInstrTokenAlg($value)
1004
    {
1005
        $this->payInstrTokenAlg = (string) $value;
×
1006

1007
        return $this;
×
1008
    }
1009

1010
    /**
1011
     * Get the holder last and first name, separated by a comma, for prefilling respective fields.
1012
     *
1013
     * @return string
1014
     *
1015
     * @example doe,john
1016
     */
1017
    public function getAccountName()
1018
    {
1019
        return $this->accountName;
4✔
1020
    }
1021

1022
    /**
1023
     * Set the holder last and first name, separated by a comma, for prefilling respective fields.
1024
     *
1025
     * @param string $value
1026
     *
1027
     * @return $this
1028
     *
1029
     * @example doe,john
1030
     */
1031
    public function setAccountName($value)
1032
    {
1033
        $this->accountName = (string) $value;
×
1034

1035
        return $this;
×
1036
    }
1037

1038
    /**
1039
     * Undocumented.
1040
     *
1041
     * @return \MLocati\PayWay\Service\Level3Info
1042
     */
1043
    public function getLevel3Info()
1044
    {
1045
        if ($this->level3Info === null) {
4✔
1046
            $this->level3Info = new Service\Level3Info();
2✔
1047
        }
1048

1049
        return $this->level3Info;
4✔
1050
    }
1051

1052
    /**
1053
     * @return $this
1054
     */
1055
    public function setLevel3Info(Service\Level3Info $value)
1056
    {
1057
        $this->level3Info = $value;
×
1058

1059
        return $this;
×
1060
    }
1061

1062
    /**
1063
     * Undocumented.
1064
     *
1065
     * @return \MLocati\PayWay\Service\MandateInfo
1066
     */
1067
    public function getMandateInfo()
1068
    {
1069
        if ($this->mandateInfo === null) {
4✔
1070
            $this->mandateInfo = new Service\MandateInfo();
2✔
1071
        }
1072

1073
        return $this->mandateInfo;
4✔
1074
    }
1075

1076
    /**
1077
     * @return $this
1078
     */
1079
    public function setMandateInfo(Service\MandateInfo $value)
1080
    {
1081
        $this->mandateInfo = $value;
×
1082

1083
        return $this;
×
1084
    }
1085

1086
    /**
1087
     * Get payment description.
1088
     *
1089
     * @return string
1090
     */
1091
    public function getDescription()
1092
    {
1093
        return $this->description;
4✔
1094
    }
1095

1096
    /**
1097
     * Set payment description.
1098
     *
1099
     * @param string $value
1100
     *
1101
     * @return $this
1102
     */
1103
    public function setDescription($value)
1104
    {
1105
        $this->description = (string) $value;
1✔
1106

1107
        return $this;
1✔
1108
    }
1109

1110
    /**
1111
     * Get the payment reason.
1112
     *
1113
     * @return string
1114
     */
1115
    public function getPaymentReason()
1116
    {
1117
        return $this->paymentReason;
4✔
1118
    }
1119

1120
    /**
1121
     * Set the payment reason.
1122
     *
1123
     * @param string $value
1124
     *
1125
     * @return $this
1126
     */
1127
    public function setPaymentReason($value)
1128
    {
1129
        $this->paymentReason = (string) $value;
×
1130

1131
        return $this;
×
1132
    }
1133

1134
    /**
1135
     * Undocumented.
1136
     *
1137
     * @return string
1138
     */
1139
    public function getFreeText()
1140
    {
1141
        return $this->freeText;
4✔
1142
    }
1143

1144
    /**
1145
     * Undocumented.
1146
     *
1147
     * @param string $value
1148
     *
1149
     * @return $this
1150
     */
1151
    public function setFreeText($value)
1152
    {
1153
        $this->freeText = (string) $value;
×
1154

1155
        return $this;
×
1156
    }
1157

1158
    /**
1159
     * Undocumented.
1160
     *
1161
     * @return string
1162
     */
1163
    public function getTopUpID()
1164
    {
1165
        return $this->topUpID;
4✔
1166
    }
1167

1168
    /**
1169
     * Undocumented.
1170
     *
1171
     * @param string $value
1172
     *
1173
     * @return $this
1174
     */
1175
    public function setTopUpID($value)
1176
    {
1177
        $this->topUpID = (string) $value;
×
1178

1179
        return $this;
×
1180
    }
1181

1182
    /**
1183
     * Undocumented.
1184
     *
1185
     * @return bool|null
1186
     */
1187
    public function isFirstTopUp()
1188
    {
1189
        return $this->firstTopUp;
4✔
1190
    }
1191

1192
    /**
1193
     * Undocumented.
1194
     *
1195
     * @param bool|null $value
1196
     *
1197
     * @return $this
1198
     */
1199
    public function setFirstTopUp($value)
1200
    {
1201
        $this->firstTopUp = $value === null || $value === '' ? null : (bool) $value;
×
1202

1203
        return $this;
×
1204
    }
1205

1206
    /**
1207
     * Undocumented.
1208
     *
1209
     * @return bool|null
1210
     */
1211
    public function isPayInstrTokenAsTopUpID()
1212
    {
1213
        return $this->payInstrTokenAsTopUpID;
4✔
1214
    }
1215

1216
    /**
1217
     * Undocumented.
1218
     *
1219
     * @param bool|null $value
1220
     *
1221
     * @return $this
1222
     */
1223
    public function setPayInstrTokenAsTopUpID($value)
1224
    {
1225
        $this->payInstrTokenAsTopUpID = $value === null || $value === '' ? null : (bool) $value;
×
1226

1227
        return $this;
×
1228
    }
1229

1230
    /**
1231
     * @deprecated Use txIndicatorType
1232
     *
1233
     * @return bool|null
1234
     */
1235
    public function isRecurrentIndicator()
1236
    {
1237
        return $this->recurrentIndicator;
4✔
1238
    }
1239

1240
    /**
1241
     * @deprecated Use txIndicatorType
1242
     *
1243
     * @param bool|null $value
1244
     *
1245
     * @return $this
1246
     */
1247
    public function setRecurrentIndicator($value)
1248
    {
1249
        $this->recurrentIndicator = $value === null || $value === '' ? null : (bool) $value;
×
1250

1251
        return $this;
×
1252
    }
1253

1254
    /**
1255
     * Get the transaction indicator type.
1256
     *
1257
     * @return string
1258
     *
1259
     * @see \MLocati\PayWay\Dictionary\TxIndicatorType
1260
     */
1261
    public function getTxIndicatorType()
1262
    {
1263
        return $this->txIndicatorType;
4✔
1264
    }
1265

1266
    /**
1267
     * Set the transaction indicator type.
1268
     *
1269
     * @param string $value
1270
     *
1271
     * @return $this
1272
     *
1273
     * @see \MLocati\PayWay\Dictionary\TxIndicatorType
1274
     */
1275
    public function setTxIndicatorType($value)
1276
    {
1277
        $this->txIndicatorType = (string) $value;
×
1278

1279
        return $this;
×
1280
    }
1281

1282
    /**
1283
     * Get the transaction identifier for recurrent/unscheduled payments.
1284
     *
1285
     * @return string
1286
     */
1287
    public function getTraceChainId()
1288
    {
1289
        return $this->traceChainId;
4✔
1290
    }
1291

1292
    /**
1293
     * Set the transaction identifier for recurrent/unscheduled payments.
1294
     *
1295
     * @param string $value
1296
     *
1297
     * @return $this
1298
     */
1299
    public function setTraceChainId($value)
1300
    {
1301
        $this->traceChainId = (string) $value;
×
1302

1303
        return $this;
×
1304
    }
1305

1306
    /**
1307
     * Get the SCA exemption type reguested by merchant.
1308
     *
1309
     * @return string
1310
     *
1311
     * @see \MLocati\PayWay\Dictionary\ScaExemptionType
1312
     */
1313
    public function getScaExemptionType()
1314
    {
1315
        return $this->scaExemptionType;
4✔
1316
    }
1317

1318
    /**
1319
     * Set the SCA exemption type reguested by merchant.
1320
     *
1321
     * @param string $value
1322
     *
1323
     * @return $this
1324
     *
1325
     * @see \MLocati\PayWay\Dictionary\ScaExemptionType
1326
     */
1327
    public function setScaExemptionType($value)
1328
    {
1329
        $this->scaExemptionType = (string) $value;
×
1330

1331
        return $this;
×
1332
    }
1333

1334
    /**
1335
     * Get the transaction validity date/time limit (valid only for external payment instrument).
1336
     *
1337
     * @return \DateTimeInterface|null
1338
     */
1339
    public function getValidityExpire()
1340
    {
1341
        return $this->validityExpire;
4✔
1342
    }
1343

1344
    /**
1345
     * Set the transaction validity date/time limit (valid only for external payment instrument).
1346
     *
1347
     * @return $this
1348
     */
1349
    public function setValidityExpire(DateTimeInterface $value = null)
1350
    {
1351
        $this->validityExpire = (string) $value;
×
1352

1353
        return $this;
×
1354
    }
1355

1356
    /**
1357
     * Undocumented.
1358
     *
1359
     * @return int|null
1360
     */
1361
    public function getMinExpireMonth()
1362
    {
1363
        return $this->minExpireMonth;
4✔
1364
    }
1365

1366
    /**
1367
     * Undocumented.
1368
     *
1369
     * @param int|null $value
1370
     *
1371
     * @return $this
1372
     */
1373
    public function setMinExpireMonth($value)
1374
    {
1375
        return $this->minExpireMonth = $value === null || $value === '' ? null : (int) $value;
×
1376

1377
        return $this;
1378
    }
1379

1380
    /**
1381
     * Undocumented.
1382
     *
1383
     * @return int|null
1384
     */
1385
    public function getMinExpireYear()
1386
    {
1387
        return $this->minExpireYear;
4✔
1388
    }
1389

1390
    /**
1391
     * Undocumented.
1392
     *
1393
     * @param int|null $value
1394
     *
1395
     * @return $this
1396
     */
1397
    public function setMinExpireYear($value)
1398
    {
1399
        return $this->minExpireYear = $value === null || $value === '' ? null : (int) $value;
×
1400

1401
        return $this;
1402
    }
1403

1404
    /**
1405
     * Undocumented.
1406
     *
1407
     * @return \MLocati\PayWay\Service\TermInfo[]
1408
     */
1409
    public function getTermInfos()
1410
    {
1411
        return $this->termInfos;
4✔
1412
    }
1413

1414
    /**
1415
     * Undocumented.
1416
     *
1417
     * @param \MLocati\PayWay\Service\TermInfo[] $value
1418
     *
1419
     * @return $this
1420
     */
1421
    public function setTermInfos(array $value)
1422
    {
1423
        $this->termInfos = [];
×
1424
        foreach ($value as $item) {
×
1425
            $this->addTermInfo($item);
×
1426
        }
1427

1428
        return $this;
×
1429
    }
1430

1431
    /**
1432
     * @return $this
1433
     */
1434
    public function addTermInfo(Service\TermInfo $value)
1435
    {
1436
        $this->termInfos[] = $value;
×
1437

1438
        return $this;
×
1439
    }
1440

1441
    /**
1442
     * Undocumented.
1443
     *
1444
     * @return array
1445
     */
1446
    public function getPayInstrAddData()
1447
    {
1448
        return $this->payInstrAddData;
4✔
1449
    }
1450

1451
    /**
1452
     * Undocumented.
1453
     *
1454
     * @return $this
1455
     */
1456
    public function setPayInstrAddData(array $value)
1457
    {
1458
        $this->payInstrAddData = [];
×
1459
        foreach ($value as $key => $item) {
×
1460
            $this->addPayInstrAddData($key, $item);
×
1461
        }
1462

1463
        return $this;
×
1464
    }
1465

1466
    /**
1467
     * Undocumented.
1468
     *
1469
     * @param string $key
1470
     * @param string $value
1471
     *
1472
     * @return $this
1473
     */
1474
    public function addPayInstrAddData($key, $value)
1475
    {
1476
        $this->payInstrAddData[(string) $key] = (string) $value;
×
1477

1478
        return $this;
×
1479
    }
1480

1481
    /**
1482
     * @throws \MLocati\PayWay\Exception\MissingRequiredField
1483
     * @throws \MLocati\PayWay\Exception\FieldValueTooLong
1484
     * @throws \MLocati\PayWay\Exception\FieldValueOutOfRange
1485
     * @throws \MLocati\PayWay\Exception\InvalidFieldUrl
1486
     */
1487
    public function check()
1488
    {
1489
        $this->checkBasePaymentInitRequest();
4✔
1490
        $this->checkStringField('shopUserRef', false, 256);
4✔
1491
        $this->checkStringField('shopUserName', false, 256);
4✔
1492
        $this->checkStringField('shopUserAccount', false, 64);
4✔
1493
        $this->checkStringField('shopUserMobilePhone', false, 32);
4✔
1494
        $this->checkEnumField('trType', true, Dictionary\TrType::getList());
4✔
1495
        switch ($this->trType) {
4✔
1496
            case Dictionary\TrType::CODE_PURCHASE:
4✔
1497
            case Dictionary\TrType::CODE_AUTH:
1✔
1498
                if ($this->amount === null) {
4✔
1499
                    throw new Exception\MissingRequiredField('amount');
×
1500
                }
1501
                break;
4✔
1502
        }
1503
        $this->checkEnumField('currencyCode', $this->amount !== null, Dictionary\Currency::getAvailableCodes());
4✔
1504
        $this->checkEnumField('langID', true, Dictionary\Language::getAvailableCodes());
4✔
1505
        $this->checkUrlField('notifyURL', true, 512);
4✔
1506
        $this->checkUrlField('errorURL', true, 512);
4✔
1507
        $this->checkUrlField('callbackURL', false, 512);
4✔
1508
        $this->checkStringField('addInfo1', false, 256);
4✔
1509
        $this->checkStringField('addInfo2', false, 256);
4✔
1510
        $this->checkStringField('addInfo3', false, 256);
4✔
1511
        $this->checkStringField('addInfo4', false, 256);
4✔
1512
        $this->checkStringField('addInfo5', false, 256);
4✔
1513
        $this->checkStringField('payInstrToken', false, 256);
4✔
1514
        $this->checkStringField('accountName', false, 36);
4✔
1515
        if ($this->level3Info !== null) {
4✔
1516
            if ($this->level3Info->getSenderCountryCode() !== '' && !in_array($this->level3Info->getSenderCountryCode(), Dictionary\Country::getAvailableCodes(), true)) {
3✔
1517
                throw new Exception\FieldValueOutOfRange('level3Info.senderCountryCode', Dictionary\Country::getAvailableCodes());
×
1518
            }
1519
            if ($this->level3Info->getDestinationCountryCode() !== '' && !in_array($this->level3Info->getDestinationCountryCode(), Dictionary\Country::getAvailableCodes(), true)) {
3✔
1520
                throw new Exception\FieldValueOutOfRange('level3Info.destinationCountryCode', Dictionary\Country::getAvailableCodes());
×
1521
            }
1522
            if ($this->level3Info->getBillingCountryCode() !== '' && !in_array($this->level3Info->getBillingCountryCode(), Dictionary\Country::getAvailableCodes(), true)) {
3✔
1523
                throw new Exception\FieldValueOutOfRange('level3Info.billingCountryCode', Dictionary\Country::getAvailableCodes());
×
1524
            }
1525
            $num = 0;
3✔
1526
            foreach ($this->level3Info->getProducts() as $product) {
3✔
1527
                if ($product->getProductCode() === '') {
1✔
1528
                    throw new Exception\MissingRequiredField("level3Info.product[{$num}].productCode");
×
1529
                }
1530
                if ($product->getProductDescription() === '') {
1✔
1531
                    throw new Exception\MissingRequiredField("level3Info.product[{$num}].productDescription");
×
1532
                }
1533
            }
1534
            if ($num > 10) {
3✔
1535
                throw new Exception\FieldValueTooLong('level3Info.product', 10);
×
1536
            }
1537
        }
1538
        $this->checkStringField('description', false, 100);
4✔
1539
        $this->checkStringField('paymentReason', false, 99);
4✔
1540
        $this->checkEnumField('txIndicatorType', false, Dictionary\TxIndicatorType::getList());
4✔
1541
        $this->checkStringField('traceChainId', false, 36);
4✔
1542
        $this->checkEnumField('scaExemptionType', false, Dictionary\ScaExemptionType::getList());
4✔
1543
    }
1544

1545
    /**
1546
     * {@inheritdoc}
1547
     *
1548
     * @see \JsonSerializable::jsonSerialize()
1549
     */
1550
    #[\ReturnTypeWillChange]
1551
    public function jsonSerialize()
1552
    {
1553
        return $this->jsonSerializeBasePaymentInitRequest() + $this->cleanupJson([
1✔
1554
            'shopUserRef' => $this->shopUserRef,
1✔
1555
            'shopUserName' => $this->shopUserName,
1✔
1556
            'shopUserAccount' => $this->shopUserAccount,
1✔
1557
            'shopUserMobilePhone' => $this->shopUserMobilePhone,
1✔
1558
            'shopUserIMEI' => $this->shopUserIMEI,
1✔
1559
            'trType' => $this->trType,
1✔
1560
            'amount' => $this->amount,
1✔
1561
            'currencyCode' => $this->currencyCode,
1✔
1562
            'langID' => $this->langID,
1✔
1563
            'notifyURL' => $this->notifyURL,
1✔
1564
            'errorURL' => $this->errorURL,
1✔
1565
            'callbackURL' => $this->callbackURL,
1✔
1566
            'addInfo1' => $this->addInfo1,
1✔
1567
            'addInfo2' => $this->addInfo2,
1✔
1568
            'addInfo3' => $this->addInfo3,
1✔
1569
            'addInfo4' => $this->addInfo4,
1✔
1570
            'addInfo5' => $this->addInfo5,
1✔
1571
            'payInstrToken' => $this->payInstrToken,
1✔
1572
            'billingID' => $this->billingID,
1✔
1573
            'regenPayInstrToken' => $this->regenPayInstrToken,
1✔
1574
            'keepOnRegenPayInstrToken' => $this->keepOnRegenPayInstrToken,
1✔
1575
            'payInstrTokenExpire' => $this->payInstrTokenExpire === null ? '' : $this->payInstrTokenExpire->format(DateTime::RFC3339),
1✔
1576
            'payInstrTokenUsageLimit' => $this->payInstrTokenUsageLimit,
1✔
1577
            'payInstrTokenAlg' => $this->payInstrTokenAlg,
1✔
1578
            'accountName' => $this->accountName,
1✔
1579
            'level3Info' => $this->level3Info === null ? null : $this->level3Info->jsonSerialize(),
1✔
1580
            'mandateInfo' => $this->mandateInfo === null ? null : $this->mandateInfo->jsonSerialize(),
1✔
1581
            'description' => $this->description,
1✔
1582
            'paymentReason' => $this->paymentReason,
1✔
1583
            'freeText' => $this->freeText,
1✔
1584
            'topUpID' => $this->topUpID,
1✔
1585
            'firstTopUp' => $this->firstTopUp,
1✔
1586
            'payInstrTokenAsTopUpID' => $this->payInstrTokenAsTopUpID,
1✔
1587
            'recurrentIndicator' => $this->recurrentIndicator,
1✔
1588
            'txIndicatorType' => $this->txIndicatorType,
1✔
1589
            'traceChainId' => $this->traceChainId,
1✔
1590
            'scaExemptionType' => $this->scaExemptionType,
1✔
1591
            'validityExpire' => $this->validityExpire === null ? null : $this->validityExpire->format(DateTime::RFC3339),
1✔
1592
            'minExpireMonth' => $this->minExpireMonth,
1✔
1593
            'minExpireYear' => $this->minExpireYear,
1✔
1594
            'termInfo' => array_map(static function (Service\TermInfo $termInfo) {
1✔
1595
                return $termInfo->jsonSerialize();
×
1596
            }, $this->termInfos),
1✔
1597
            'payInstrAddData' => $this->payInstrAddData,
1✔
1598
        ]);
1✔
1599
    }
1600

1601
    protected function getSignatureFields()
1602
    {
1603
        return [
4✔
1604
            $this->apiVersion,
4✔
1605
            $this->tid,
4✔
1606
            $this->merID,
4✔
1607
            $this->payInstr,
4✔
1608
            $this->shopID,
4✔
1609
            $this->shopUserRef,
4✔
1610
            $this->shopUserName,
4✔
1611
            $this->shopUserAccount,
4✔
1612
            $this->shopUserMobilePhone,
4✔
1613
            $this->shopUserIMEI,
4✔
1614
            $this->trType,
4✔
1615
            (string) $this->amount,
4✔
1616
            $this->currencyCode,
4✔
1617
            $this->langID,
4✔
1618
            $this->notifyURL,
4✔
1619
            $this->errorURL,
4✔
1620
            $this->callbackURL,
4✔
1621
            $this->addInfo1,
4✔
1622
            $this->addInfo2,
4✔
1623
            $this->addInfo3,
4✔
1624
            $this->addInfo4,
4✔
1625
            $this->addInfo5,
4✔
1626
            $this->payInstrToken,
4✔
1627
            $this->topUpID,
4✔
1628
        ];
4✔
1629
    }
1630
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc