Completed
Push — master ( e1cfbf...f5d5d5 )
by Joachim
04:22
created

Payment::createFromDandomainPayment()   C

Complexity

Conditions 7
Paths 16

Size

Total Lines 35
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 35
rs 6.7272
cc 7
eloc 21
nc 16
nop 1
1
<?php
2
3
namespace Loevgaard\DandomainAltapayBundle\Entity;
4
5
use Brick\Math\BigDecimal;
6
use Doctrine\Common\Collections\ArrayCollection;
7
use Doctrine\ORM\Mapping as ORM;
8
use Symfony\Component\Validator\Constraints as Assert;
9
use Loevgaard\Dandomain\Pay\Model\Payment as BasePayment;
10
use Loevgaard\Dandomain\Pay\Model\Payment as DandomainPayment;
11
12
/**
13
 * The Payment entity is a special entity since it maps a payment from the Dandomain Payment API
14
 * This is also the reason why it doesn't implement an interface but extends the PaymentRequest
15
 * from the Dandomain Pay PHP SDK.
16
 *
17
 * Also it doesn't relate to any other entities other than PaymentLine since the Dandomain Payment API
18
 * POST request is not complete with all information needed to populate all the related entities, i.e. customers,
19
 * deliveries etc.
20
 *
21
 * @ORM\Table(name="dandomain_altapay_payments")
22
 * @ORM\Entity()
23
 */
24
class Payment extends BasePayment
25
{
26
    /**
27
     * @var int
28
     *
29
     * @ORM\Id
30
     * @ORM\Column(name="id", type="integer")
31
     * @ORM\GeneratedValue(strategy="AUTO")
32
     */
33
    protected $id;
34
35
    /**
36
     * @Assert\NotBlank()
37
     * @Assert\Length(max="191")
38
     *
39
     * @ORM\Column(type="string", length=191)
40
     */
41
    protected $apiKey;
42
43
    /**
44
     * @Assert\NotBlank()
45
     * @Assert\Length(max="191")
46
     *
47
     * @ORM\Column(type="string", length=191)
48
     */
49
    protected $merchant;
50
51
    /**
52
     * @ORM\Column(type="integer")
53
     */
54
    protected $orderId;
55
56
    /**
57
     * @ORM\Column(type="text")
58
     */
59
    protected $sessionId;
60
61
    /**
62
     * @Assert\NotBlank()
63
     * @Assert\Length(max="191")
64
     *
65
     * @ORM\Column(type="string", length=191)
66
     */
67
    protected $currencySymbol;
68
69
    /**
70
     * @Assert\NotBlank()
71
     *
72
     * @ORM\Column(type="decimal", precision=12, scale=2)
73
     */
74
    protected $totalAmount;
75
76
    /**
77
     * @Assert\NotBlank()
78
     * @Assert\Length(max="191")
79
     *
80
     * @ORM\Column(type="string", length=191)
81
     */
82
    protected $callBackUrl;
83
84
    /**
85
     * @Assert\NotBlank()
86
     * @Assert\Length(max="191")
87
     *
88
     * @ORM\Column(type="string", length=191)
89
     */
90
    protected $fullCallBackOkUrl;
91
92
    /**
93
     * @Assert\NotBlank()
94
     * @Assert\Length(max="191")
95
     *
96
     * @ORM\Column(type="string", length=191)
97
     */
98
    protected $callBackOkUrl;
99
100
    /**
101
     * @Assert\NotBlank()
102
     * @Assert\Length(max="191")
103
     *
104
     * @ORM\Column(type="string", length=191)
105
     */
106
    protected $callBackServerUrl;
107
108
    /**
109
     * @Assert\NotBlank()
110
     *
111
     * @ORM\Column(type="integer")
112
     */
113
    protected $languageId;
114
115
    /**
116
     * @Assert\NotBlank()
117
     * @Assert\Length(max="191")
118
     *
119
     * @ORM\Column(type="string", length=191)
120
     */
121
    protected $testMode;
122
123
    /**
124
     * @Assert\NotBlank()
125
     *
126
     * @ORM\Column(type="integer")
127
     */
128
    protected $paymentGatewayCurrencyCode;
129
130
    /**
131
     * @Assert\NotBlank()
132
     *
133
     * @ORM\Column(type="integer")
134
     */
135
    protected $cardTypeId;
136
137
    /**
138
     * @Assert\NotBlank()
139
     * @Assert\Length(max="191")
140
     *
141
     * @ORM\Column(type="string", length=191)
142
     */
143
    protected $customerRekvNr;
144
145
    /**
146
     * @Assert\NotBlank()
147
     * @Assert\Length(max="191")
148
     *
149
     * @ORM\Column(type="string", length=191)
150
     */
151
    protected $customerName;
152
153
    /**
154
     * @ORM\Column(type="string", nullable=true)
155
     */
156
    protected $customerCompany;
157
158
    /**
159
     * @Assert\NotBlank()
160
     * @Assert\Length(max="191")
161
     *
162
     * @ORM\Column(type="string", length=191)
163
     */
164
    protected $customerAddress;
165
166
    /**
167
     * @ORM\Column(type="string", nullable=true)
168
     */
169
    protected $customerAddress2;
170
171
    /**
172
     * @Assert\NotBlank()
173
     * @Assert\Length(max="191")
174
     *
175
     * @ORM\Column(type="string", length=191)
176
     */
177
    protected $customerZipCode;
178
179
    /**
180
     * @Assert\NotBlank()
181
     * @Assert\Length(max="191")
182
     *
183
     * @ORM\Column(type="string", length=191)
184
     */
185
    protected $customerCity;
186
187
    /**
188
     * @Assert\NotBlank()
189
     *
190
     * @ORM\Column(type="integer")
191
     */
192
    protected $customerCountryId;
193
194
    /**
195
     * @Assert\NotBlank()
196
     * @Assert\Length(max="191")
197
     *
198
     * @ORM\Column(type="string", length=191)
199
     */
200
    protected $customerCountry;
201
202
    /**
203
     * @Assert\NotBlank()
204
     * @Assert\Length(max="191")
205
     *
206
     * @ORM\Column(type="string", length=191)
207
     */
208
    protected $customerPhone;
209
210
    /**
211
     * @ORM\Column(type="string", nullable=true)
212
     */
213
    protected $customerFax;
214
215
    /**
216
     * @Assert\NotBlank()
217
     * @Assert\Length(max="191")
218
     *
219
     * @ORM\Column(type="string", length=191)
220
     */
221
    protected $customerEmail;
222
223
    /**
224
     * @ORM\Column(type="text", nullable=true)
225
     */
226
    protected $customerNote;
227
228
    /**
229
     * @ORM\Column(type="string", nullable=true, length=191)
230
     */
231
    protected $customerCvrnr;
232
233
    /**
234
     * @Assert\NotBlank()
235
     *
236
     * @ORM\Column(type="integer")
237
     */
238
    protected $customerCustTypeId;
239
240
    /**
241
     * @ORM\Column(type="string", nullable=true, length=191)
242
     */
243
    protected $customerEan;
244
245
    /**
246
     * @ORM\Column(type="string", nullable=true, length=191)
247
     */
248
    protected $customerRes1;
249
250
    /**
251
     * @ORM\Column(type="string", nullable=true, length=191)
252
     */
253
    protected $customerRes2;
254
255
    /**
256
     * @ORM\Column(type="string", nullable=true, length=191)
257
     */
258
    protected $customerRes3;
259
260
    /**
261
     * @ORM\Column(type="string", nullable=true, length=191)
262
     */
263
    protected $customerRes4;
264
265
    /**
266
     * @ORM\Column(type="string", nullable=true, length=191)
267
     */
268
    protected $customerRes5;
269
270
    /**
271
     * @Assert\NotBlank()
272
     * @Assert\Length(max="191")
273
     *
274
     * @ORM\Column(type="string", length=191)
275
     */
276
    protected $customerIp;
277
278
    /**
279
     * @ORM\Column(type="string", nullable=true, length=191)
280
     */
281
    protected $deliveryName;
282
283
    /**
284
     * @ORM\Column(type="string", nullable=true, length=191)
285
     */
286
    protected $deliveryCompany;
287
288
    /**
289
     * @ORM\Column(type="string", nullable=true, length=191)
290
     */
291
    protected $deliveryAddress;
292
293
    /**
294
     * @ORM\Column(type="string", nullable=true, length=191)
295
     */
296
    protected $deliveryAddress2;
297
298
    /**
299
     * @ORM\Column(type="string", nullable=true, length=191)
300
     */
301
    protected $deliveryZipCode;
302
303
    /**
304
     * @ORM\Column(type="string", nullable=true, length=191)
305
     */
306
    protected $deliveryCity;
307
308
    /**
309
     * @ORM\Column(type="integer", nullable=true)
310
     */
311
    protected $deliveryCountryID;
312
313
    /**
314
     * @ORM\Column(type="string", nullable=true, length=191)
315
     */
316
    protected $deliveryCountry;
317
318
    /**
319
     * @ORM\Column(type="string", nullable=true, length=191)
320
     */
321
    protected $deliveryPhone;
322
323
    /**
324
     * @ORM\Column(type="string", nullable=true, length=191)
325
     */
326
    protected $deliveryFax;
327
328
    /**
329
     * @ORM\Column(type="string", nullable=true, length=191)
330
     */
331
    protected $deliveryEmail;
332
333
    /**
334
     * @ORM\Column(type="string", nullable=true, length=191)
335
     */
336
    protected $deliveryEan;
337
338
    /**
339
     * @Assert\NotBlank()
340
     * @Assert\Length(max="191")
341
     *
342
     * @ORM\Column(type="string", length=191)
343
     */
344
    protected $shippingMethod;
345
346
    /**
347
     * @Assert\NotBlank()
348
     *
349
     * @ORM\Column(type="decimal", precision=12, scale=2)
350
     */
351
    protected $shippingFee;
352
353
    /**
354
     * @Assert\NotBlank()
355
     * @Assert\Length(max="191")
356
     *
357
     * @ORM\Column(type="string", length=191)
358
     */
359
    protected $paymentMethod;
360
361
    /**
362
     * @Assert\NotBlank()
363
     *
364
     * @ORM\Column(type="decimal", precision=12, scale=2)
365
     */
366
    protected $paymentFee;
367
368
    /**
369
     * @ORM\Column(type="string", nullable=true, length=191)
370
     */
371
    protected $loadBalancerRealIp;
372
373
    /**
374
     * @var string
375
     *
376
     * @ORM\Column(type="string", nullable=true, length=191)
377
     */
378
    protected $referrer;
379
380
    /**
381
     * @ORM\OneToMany(targetEntity="PaymentLine", mappedBy="payment", cascade={"persist", "remove"}, fetch="EAGER")
382
     */
383
    protected $paymentLines;
384
385
    /**********************************
386
     * Properties specific to Altapay *
387
     *********************************/
388
389
    /**
390
     * @var string|null
391
     *
392
     * @ORM\Column(type="string", nullable=true, unique=true, length=191)
393
     */
394
    protected $altapayId;
395
396
    /**
397
     * @var string|null
398
     *
399
     * @ORM\Column(type="string", nullable=true, length=191)
400
     */
401
    protected $cardStatus;
402
403
    /**
404
     * @var string|null
405
     *
406
     * @ORM\Column(type="string", nullable=true, length=191)
407
     */
408
    protected $creditCardToken;
409
410
    /**
411
     * @var string|null
412
     *
413
     * @ORM\Column(type="string", nullable=true, length=191)
414
     */
415
    protected $creditCardMaskedPan;
416
417
    /**
418
     * @var string|null
419
     *
420
     * @ORM\Column(type="string", nullable=true, length=191)
421
     */
422
    protected $threeDSecureResult;
423
424
    /**
425
     * @var string|null
426
     *
427
     * @ORM\Column(type="string", nullable=true, length=191)
428
     */
429
    protected $liableForChargeback;
430
431
    /**
432
     * @var string|null
433
     *
434
     * @ORM\Column(type="string", nullable=true, length=191)
435
     */
436
    protected $blacklistToken;
437
438
    /**
439
     * @var string|null
440
     *
441
     * @ORM\Column(type="string", nullable=true, length=191)
442
     */
443
    protected $shop;
444
445
    /**
446
     * @var string|null
447
     *
448
     * @ORM\Column(type="string", nullable=true, length=191)
449
     */
450
    protected $terminal;
451
452
    /**
453
     * @var string|null
454
     *
455
     * @ORM\Column(type="string", nullable=true, length=191)
456
     */
457
    protected $transactionStatus;
458
459
    /**
460
     * @var string|null
461
     *
462
     * @ORM\Column(type="string", nullable=true, length=191)
463
     */
464
    protected $reasonCode;
465
466
    /**
467
     * @var int|null
468
     *
469
     * @ORM\Column(type="integer", nullable=true)
470
     */
471
    protected $merchantCurrency;
472
473
    /**
474
     * @var string|null
475
     *
476
     * @ORM\Column(type="string", nullable=true, length=191)
477
     */
478
    protected $merchantCurrencyAlpha;
479
480
    /**
481
     * @var int|null
482
     *
483
     * @ORM\Column(type="integer", nullable=true)
484
     */
485
    protected $cardHolderCurrency;
486
487
    /**
488
     * @var string|null
489
     *
490
     * @ORM\Column(type="string", nullable=true, length=191)
491
     */
492
    protected $cardHolderCurrencyAlpha;
493
494
    /**
495
     * @var float|null
496
     *
497
     * @ORM\Column(type="decimal", precision=10, scale=2)
498
     */
499
    protected $reservedAmount;
500
501
    /**
502
     * @var float|null
503
     *
504
     * @ORM\Column(type="decimal", precision=10, scale=2)
505
     */
506
    protected $capturedAmount;
507
508
    /**
509
     * @var float|null
510
     *
511
     * @ORM\Column(type="decimal", precision=10, scale=2)
512
     */
513
    protected $refundedAmount;
514
515
    /**
516
     * @var float|null
517
     *
518
     * @ORM\Column(type="decimal", precision=10, scale=2)
519
     */
520
    protected $recurringDefaultAmount;
521
522
    /**
523
     * @var \DateTime|null
524
     *
525
     * @ORM\Column(type="datetime", nullable=true)
526
     */
527
    protected $createdDate;
528
529
    /**
530
     * @var \DateTime|null
531
     *
532
     * @ORM\Column(type="datetime", nullable=true)
533
     */
534
    protected $updatedDate;
535
536
    /**
537
     * @var string|null
538
     *
539
     * @ORM\Column(type="string", nullable=true, length=191)
540
     */
541
    protected $paymentNature;
542
543
    /**
544
     * @var bool|null
545
     *
546
     * @ORM\Column(type="boolean", nullable=true)
547
     */
548
    protected $supportsRefunds;
549
550
    /**
551
     * @var bool|null
552
     *
553
     * @ORM\Column(type="boolean", nullable=true)
554
     */
555
    protected $supportsRelease;
556
557
    /**
558
     * @var bool|null
559
     *
560
     * @ORM\Column(type="boolean", nullable=true)
561
     */
562
    protected $supportsMultipleCaptures;
563
564
    /**
565
     * @var bool|null
566
     *
567
     * @ORM\Column(type="boolean", nullable=true)
568
     */
569
    protected $supportsMultipleRefunds;
570
571
    /**
572
     * @var float|null
573
     *
574
     * @ORM\Column(type="float", nullable=true)
575
     */
576
    protected $fraudRiskScore;
577
578
    /**
579
     * @var string|null
580
     *
581
     * @ORM\Column(type="string", nullable=true, length=191)
582
     */
583
    protected $fraudExplanation;
584
585
    public function __construct()
586
    {
587
        parent::__construct();
588
589
        $this->paymentLines = new ArrayCollection();
590
        $this->reservedAmount = 0;
0 ignored issues
show
Documentation Bug introduced by
It seems like 0 of type integer is incompatible with the declared type double|null of property $reservedAmount.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
591
        $this->capturedAmount = 0;
0 ignored issues
show
Documentation Bug introduced by
It seems like 0 of type integer is incompatible with the declared type double|null of property $capturedAmount.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
592
        $this->refundedAmount = 0;
0 ignored issues
show
Documentation Bug introduced by
It seems like 0 of type integer is incompatible with the declared type double|null of property $refundedAmount.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
593
        $this->recurringDefaultAmount = 0;
0 ignored issues
show
Documentation Bug introduced by
It seems like 0 of type integer is incompatible with the declared type double|null of property $recurringDefaultAmount.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
594
    }
595
596
    /**
597
     * This will transform a Dandomain Payment (parent) to a Payment (child).
598
     *
599
     * @param DandomainPayment $dandomainPayment
600
     *
601
     * @return Payment
602
     */
603
    public static function createFromDandomainPayment(DandomainPayment $dandomainPayment)
604
    {
605
        $payment = new self();
606
607
        $methods = get_class_methods($dandomainPayment);
608
609
        foreach ($methods as $method) {
610
            if ('get' === substr($method, 0, 3)) {
611
                $val = $dandomainPayment->{$method}();
612
                $property = substr($method, 3);
613
            } elseif ('is' === substr($method, 0, 2)) {
614
                $val = $dandomainPayment->{$method}();
615
                $property = substr($method, 2);
616
            } else {
617
                continue;
618
            }
619
620
            if (!is_scalar($val)) {
621
                continue;
622
            }
623
624
            $setter = 'set'.$property;
625
626
            if (method_exists($payment, $setter)) {
627
                $payment->{$setter}($val);
628
            }
629
        }
630
631
        foreach ($dandomainPayment->getPaymentLines() as $paymentLine) {
632
            $newPaymentLine = PaymentLine::createFromDandomainPaymentLine($paymentLine);
633
            $payment->addPaymentLine($newPaymentLine);
634
        }
635
636
        return $payment;
637
    }
638
639
    /**
640
     * Returns true if the payment can be captured.
641
     *
642
     * @return bool
643
     */
644
    public function isCaptureable(): bool
645
    {
646
        if ($this->capturableAmount() <= 0) {
647
            return false;
648
        }
649
650
        if ($this->capturedAmount > 0 && !$this->supportsMultipleCaptures) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->supportsMultipleCaptures of type boolean|null is loosely compared to false; this is ambiguous if the boolean can be false. You might want to explicitly use !== null instead.

If an expression can have both false, and null as possible values. It is generally a good practice to always use strict comparison to clearly distinguish between those two values.

$a = canBeFalseAndNull();

// Instead of
if ( ! $a) { }

// Better use one of the explicit versions:
if ($a !== null) { }
if ($a !== false) { }
if ($a !== null && $a !== false) { }
Loading history...
651
            return false;
652
        }
653
654
        return true;
655
    }
656
657
    /**
658
     * Returns true if the payment can be refunded.
659
     *
660
     * @return bool
661
     */
662
    public function isRefundable(): bool
663
    {
664
        if ($this->refundableAmount() <= 0) {
665
            return false;
666
        }
667
668
        if ($this->refundedAmount > 0 && !$this->supportsMultipleRefunds) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->supportsMultipleRefunds of type boolean|null is loosely compared to false; this is ambiguous if the boolean can be false. You might want to explicitly use !== null instead.

If an expression can have both false, and null as possible values. It is generally a good practice to always use strict comparison to clearly distinguish between those two values.

$a = canBeFalseAndNull();

// Instead of
if ( ! $a) { }

// Better use one of the explicit versions:
if ($a !== null) { }
if ($a !== false) { }
if ($a !== null && $a !== false) { }
Loading history...
669
            return false;
670
        }
671
672
        return true;
673
    }
674
675
    /**
676
     * @return float
677
     */
678
    public function refundableAmount()
679
    {
680
        $capturedAmount = BigDecimal::of($this->capturedAmount);
681
682
        return $capturedAmount->minus($this->refundedAmount)->toFloat();
683
    }
684
685
    /**
686
     * @return float
687
     */
688
    public function capturableAmount()
689
    {
690
        $reservedAmount = BigDecimal::of($this->reservedAmount);
691
        $realCapturedAmount = BigDecimal::of($this->capturedAmount)->minus($this->refundedAmount);
692
693
        return $reservedAmount->minus($realCapturedAmount)->toFloat();
694
    }
695
696
    // @todo create type hints for getters and setters
697
698
    /**
699
     * @return int
700
     */
701
    public function getId(): ?int
702
    {
703
        return $this->id;
704
    }
705
706
    /**
707
     * @param int $id
708
     *
709
     * @return Payment
710
     */
711
    public function setId(int $id): self
712
    {
713
        $this->id = $id;
714
715
        return $this;
716
    }
717
718
    /**
719
     * @return null|string
720
     */
721
    public function getAltapayId()
722
    {
723
        return $this->altapayId;
724
    }
725
726
    /**
727
     * @param null|string $altapayId
728
     *
729
     * @return Payment
730
     */
731
    public function setAltapayId($altapayId)
732
    {
733
        $this->altapayId = $altapayId;
734
735
        return $this;
736
    }
737
738
    /**
739
     * @return null|string
740
     */
741
    public function getCardStatus()
742
    {
743
        return $this->cardStatus;
744
    }
745
746
    /**
747
     * @param null|string $cardStatus
748
     *
749
     * @return Payment
750
     */
751
    public function setCardStatus($cardStatus)
752
    {
753
        $this->cardStatus = $cardStatus;
754
755
        return $this;
756
    }
757
758
    /**
759
     * @return null|string
760
     */
761
    public function getCreditCardToken()
762
    {
763
        return $this->creditCardToken;
764
    }
765
766
    /**
767
     * @param null|string $creditCardToken
768
     *
769
     * @return Payment
770
     */
771
    public function setCreditCardToken($creditCardToken)
772
    {
773
        $this->creditCardToken = $creditCardToken;
774
775
        return $this;
776
    }
777
778
    /**
779
     * @return null|string
780
     */
781
    public function getCreditCardMaskedPan()
782
    {
783
        return $this->creditCardMaskedPan;
784
    }
785
786
    /**
787
     * @param null|string $creditCardMaskedPan
788
     *
789
     * @return Payment
790
     */
791
    public function setCreditCardMaskedPan($creditCardMaskedPan)
792
    {
793
        $this->creditCardMaskedPan = $creditCardMaskedPan;
794
795
        return $this;
796
    }
797
798
    /**
799
     * @return null|string
800
     */
801
    public function getThreeDSecureResult()
802
    {
803
        return $this->threeDSecureResult;
804
    }
805
806
    /**
807
     * @param null|string $threeDSecureResult
808
     *
809
     * @return Payment
810
     */
811
    public function setThreeDSecureResult($threeDSecureResult)
812
    {
813
        $this->threeDSecureResult = $threeDSecureResult;
814
815
        return $this;
816
    }
817
818
    /**
819
     * @return null|string
820
     */
821
    public function getLiableForChargeback()
822
    {
823
        return $this->liableForChargeback;
824
    }
825
826
    /**
827
     * @param null|string $liableForChargeback
828
     *
829
     * @return Payment
830
     */
831
    public function setLiableForChargeback($liableForChargeback)
832
    {
833
        $this->liableForChargeback = $liableForChargeback;
834
835
        return $this;
836
    }
837
838
    /**
839
     * @return null|string
840
     */
841
    public function getBlacklistToken()
842
    {
843
        return $this->blacklistToken;
844
    }
845
846
    /**
847
     * @param null|string $blacklistToken
848
     *
849
     * @return Payment
850
     */
851
    public function setBlacklistToken($blacklistToken)
852
    {
853
        $this->blacklistToken = $blacklistToken;
854
855
        return $this;
856
    }
857
858
    /**
859
     * @return null|string
860
     */
861
    public function getShop()
862
    {
863
        return $this->shop;
864
    }
865
866
    /**
867
     * @param null|string $shop
868
     *
869
     * @return Payment
870
     */
871
    public function setShop($shop)
872
    {
873
        $this->shop = $shop;
874
875
        return $this;
876
    }
877
878
    /**
879
     * @return null|string
880
     */
881
    public function getTerminal()
882
    {
883
        return $this->terminal;
884
    }
885
886
    /**
887
     * @param null|string $terminal
888
     *
889
     * @return Payment
890
     */
891
    public function setTerminal($terminal)
892
    {
893
        $this->terminal = $terminal;
894
895
        return $this;
896
    }
897
898
    /**
899
     * @return null|string
900
     */
901
    public function getTransactionStatus()
902
    {
903
        return $this->transactionStatus;
904
    }
905
906
    /**
907
     * @param null|string $transactionStatus
908
     *
909
     * @return Payment
910
     */
911
    public function setTransactionStatus($transactionStatus)
912
    {
913
        $this->transactionStatus = $transactionStatus;
914
915
        return $this;
916
    }
917
918
    /**
919
     * @return null|string
920
     */
921
    public function getReasonCode()
922
    {
923
        return $this->reasonCode;
924
    }
925
926
    /**
927
     * @param null|string $reasonCode
928
     *
929
     * @return Payment
930
     */
931
    public function setReasonCode($reasonCode)
932
    {
933
        $this->reasonCode = $reasonCode;
934
935
        return $this;
936
    }
937
938
    /**
939
     * @return int|null
940
     */
941
    public function getMerchantCurrency()
942
    {
943
        return $this->merchantCurrency;
944
    }
945
946
    /**
947
     * @param int|null $merchantCurrency
948
     *
949
     * @return Payment
950
     */
951
    public function setMerchantCurrency($merchantCurrency)
952
    {
953
        $this->merchantCurrency = $merchantCurrency;
954
955
        return $this;
956
    }
957
958
    /**
959
     * @return null|string
960
     */
961
    public function getMerchantCurrencyAlpha()
962
    {
963
        return $this->merchantCurrencyAlpha;
964
    }
965
966
    /**
967
     * @param null|string $merchantCurrencyAlpha
968
     *
969
     * @return Payment
970
     */
971
    public function setMerchantCurrencyAlpha($merchantCurrencyAlpha)
972
    {
973
        $this->merchantCurrencyAlpha = $merchantCurrencyAlpha;
974
975
        return $this;
976
    }
977
978
    /**
979
     * @return int|null
980
     */
981
    public function getCardHolderCurrency()
982
    {
983
        return $this->cardHolderCurrency;
984
    }
985
986
    /**
987
     * @param int|null $cardHolderCurrency
988
     *
989
     * @return Payment
990
     */
991
    public function setCardHolderCurrency($cardHolderCurrency)
992
    {
993
        $this->cardHolderCurrency = $cardHolderCurrency;
994
995
        return $this;
996
    }
997
998
    /**
999
     * @return null|string
1000
     */
1001
    public function getCardHolderCurrencyAlpha()
1002
    {
1003
        return $this->cardHolderCurrencyAlpha;
1004
    }
1005
1006
    /**
1007
     * @param null|string $cardHolderCurrencyAlpha
1008
     *
1009
     * @return Payment
1010
     */
1011
    public function setCardHolderCurrencyAlpha($cardHolderCurrencyAlpha)
1012
    {
1013
        $this->cardHolderCurrencyAlpha = $cardHolderCurrencyAlpha;
1014
1015
        return $this;
1016
    }
1017
1018
    /**
1019
     * @return float|null
1020
     */
1021
    public function getReservedAmount()
1022
    {
1023
        return $this->reservedAmount;
1024
    }
1025
1026
    /**
1027
     * @param float|null $reservedAmount
1028
     *
1029
     * @return Payment
1030
     */
1031
    public function setReservedAmount($reservedAmount)
1032
    {
1033
        $this->reservedAmount = $reservedAmount;
1034
1035
        return $this;
1036
    }
1037
1038
    /**
1039
     * @return float|null
1040
     */
1041
    public function getCapturedAmount()
1042
    {
1043
        return $this->capturedAmount;
1044
    }
1045
1046
    /**
1047
     * @param float|null $capturedAmount
1048
     *
1049
     * @return Payment
1050
     */
1051
    public function setCapturedAmount($capturedAmount)
1052
    {
1053
        $this->capturedAmount = $capturedAmount;
1054
1055
        return $this;
1056
    }
1057
1058
    /**
1059
     * @return float|null
1060
     */
1061
    public function getRefundedAmount()
1062
    {
1063
        return $this->refundedAmount;
1064
    }
1065
1066
    /**
1067
     * @param float|null $refundedAmount
1068
     *
1069
     * @return Payment
1070
     */
1071
    public function setRefundedAmount($refundedAmount)
1072
    {
1073
        $this->refundedAmount = $refundedAmount;
1074
1075
        return $this;
1076
    }
1077
1078
    /**
1079
     * @return float|null
1080
     */
1081
    public function getRecurringDefaultAmount()
1082
    {
1083
        return $this->recurringDefaultAmount;
1084
    }
1085
1086
    /**
1087
     * @param float|null $recurringDefaultAmount
1088
     *
1089
     * @return Payment
1090
     */
1091
    public function setRecurringDefaultAmount($recurringDefaultAmount)
1092
    {
1093
        $this->recurringDefaultAmount = $recurringDefaultAmount;
1094
1095
        return $this;
1096
    }
1097
1098
    /**
1099
     * @return \DateTime|null
1100
     */
1101
    public function getCreatedDate()
1102
    {
1103
        return $this->createdDate;
1104
    }
1105
1106
    /**
1107
     * @param \DateTimeInterface|null $createdDate
1108
     *
1109
     * @return Payment
1110
     */
1111
    public function setCreatedDate($createdDate)
1112
    {
1113
        $this->createdDate = $createdDate;
0 ignored issues
show
Documentation Bug introduced by
It seems like $createdDate can also be of type object<DateTimeInterface>. However, the property $createdDate is declared as type object<DateTime>|null. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
1114
1115
        return $this;
1116
    }
1117
1118
    /**
1119
     * @return \DateTime|null
1120
     */
1121
    public function getUpdatedDate()
1122
    {
1123
        return $this->updatedDate;
1124
    }
1125
1126
    /**
1127
     * @param \DateTimeInterface|null $updatedDate
1128
     *
1129
     * @return Payment
1130
     */
1131
    public function setUpdatedDate($updatedDate)
1132
    {
1133
        $this->updatedDate = $updatedDate;
0 ignored issues
show
Documentation Bug introduced by
It seems like $updatedDate can also be of type object<DateTimeInterface>. However, the property $updatedDate is declared as type object<DateTime>|null. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
1134
1135
        return $this;
1136
    }
1137
1138
    /**
1139
     * @return null|string
1140
     */
1141
    public function getPaymentNature()
1142
    {
1143
        return $this->paymentNature;
1144
    }
1145
1146
    /**
1147
     * @param null|string $paymentNature
1148
     *
1149
     * @return Payment
1150
     */
1151
    public function setPaymentNature($paymentNature)
1152
    {
1153
        $this->paymentNature = $paymentNature;
1154
1155
        return $this;
1156
    }
1157
1158
    /**
1159
     * @return bool|null
1160
     */
1161
    public function getSupportsRefunds()
1162
    {
1163
        return $this->supportsRefunds;
1164
    }
1165
1166
    /**
1167
     * @param bool|null $supportsRefunds
1168
     *
1169
     * @return Payment
1170
     */
1171
    public function setSupportsRefunds($supportsRefunds)
1172
    {
1173
        $this->supportsRefunds = $supportsRefunds;
1174
1175
        return $this;
1176
    }
1177
1178
    /**
1179
     * @return bool|null
1180
     */
1181
    public function getSupportsRelease()
1182
    {
1183
        return $this->supportsRelease;
1184
    }
1185
1186
    /**
1187
     * @param bool|null $supportsRelease
1188
     *
1189
     * @return Payment
1190
     */
1191
    public function setSupportsRelease($supportsRelease)
1192
    {
1193
        $this->supportsRelease = $supportsRelease;
1194
1195
        return $this;
1196
    }
1197
1198
    /**
1199
     * @return bool|null
1200
     */
1201
    public function getSupportsMultipleCaptures()
1202
    {
1203
        return $this->supportsMultipleCaptures;
1204
    }
1205
1206
    /**
1207
     * @param bool|null $supportsMultipleCaptures
1208
     *
1209
     * @return Payment
1210
     */
1211
    public function setSupportsMultipleCaptures($supportsMultipleCaptures)
1212
    {
1213
        $this->supportsMultipleCaptures = $supportsMultipleCaptures;
1214
1215
        return $this;
1216
    }
1217
1218
    /**
1219
     * @return bool|null
1220
     */
1221
    public function getSupportsMultipleRefunds()
1222
    {
1223
        return $this->supportsMultipleRefunds;
1224
    }
1225
1226
    /**
1227
     * @param bool|null $supportsMultipleRefunds
1228
     *
1229
     * @return Payment
1230
     */
1231
    public function setSupportsMultipleRefunds($supportsMultipleRefunds)
1232
    {
1233
        $this->supportsMultipleRefunds = $supportsMultipleRefunds;
1234
1235
        return $this;
1236
    }
1237
1238
    /**
1239
     * @return float|null
1240
     */
1241
    public function getFraudRiskScore()
1242
    {
1243
        return $this->fraudRiskScore;
1244
    }
1245
1246
    /**
1247
     * @param float|null $fraudRiskScore
1248
     *
1249
     * @return Payment
1250
     */
1251
    public function setFraudRiskScore($fraudRiskScore)
1252
    {
1253
        $this->fraudRiskScore = $fraudRiskScore;
1254
1255
        return $this;
1256
    }
1257
1258
    /**
1259
     * @return null|string
1260
     */
1261
    public function getFraudExplanation()
1262
    {
1263
        return $this->fraudExplanation;
1264
    }
1265
1266
    /**
1267
     * @param null|string $fraudExplanation
1268
     *
1269
     * @return Payment
1270
     */
1271
    public function setFraudExplanation($fraudExplanation)
1272
    {
1273
        $this->fraudExplanation = $fraudExplanation;
1274
1275
        return $this;
1276
    }
1277
}
1278