Completed
Push — master ( e16295...10cfb1 )
by Joachim
09:10
created

Payment::getTotalAmount()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 3
nop 0
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 Loevgaard\Dandomain\Pay\Model\Payment as BasePayment;
9
use Loevgaard\Dandomain\Pay\Model\Payment as DandomainPayment;
10
use Money\Currency;
11
use Money\Money;
12
use Symfony\Component\Validator\Constraints as Assert;
13
14
/**
15
 * The Payment entity is a special entity since it maps a payment from the Dandomain Payment API
16
 * This is also the reason why it doesn't implement an interface but extends the PaymentRequest
17
 * from the Dandomain Pay PHP SDK.
18
 *
19
 * Also it doesn't relate to any other entities other than PaymentLine since the Dandomain Payment API
20
 * POST request is not complete with all information needed to populate all the related entities, i.e. customers,
21
 * deliveries etc.
22
 *
23
 * @ORM\Table(name="dandomain_altapay_payments")
24
 * @ORM\Entity()
25
 */
26
class Payment extends BasePayment
27
{
28
    /**
29
     * @var int
30
     *
31
     * @ORM\Id
32
     * @ORM\Column(name="id", type="integer")
33
     * @ORM\GeneratedValue(strategy="AUTO")
34
     */
35
    protected $id;
36
37
    /**
38
     * @Assert\NotBlank()
39
     * @Assert\Length(max="191")
40
     *
41
     * @ORM\Column(type="string", length=191)
42
     */
43
    protected $apiKey;
44
45
    /**
46
     * @Assert\NotBlank()
47
     * @Assert\Length(max="191")
48
     *
49
     * @ORM\Column(type="string", length=191)
50
     */
51
    protected $merchant;
52
53
    /**
54
     * @ORM\Column(type="integer")
55
     */
56
    protected $orderId;
57
58
    /**
59
     * @ORM\Column(type="text")
60
     */
61
    protected $sessionId;
62
63
    /**
64
     * @Assert\NotBlank()
65
     * @Assert\Length(max="191")
66
     *
67
     * @ORM\Column(type="string", length=191)
68
     */
69
    protected $currencySymbol;
70
71
    /**
72
     * @Assert\NotBlank()
73
     *
74
     * @ORM\Column(type="integer")
75
     */
76
    protected $totalAmountAmount;
77
78
    /**
79
     * @Assert\NotBlank()
80
     *
81
     * @ORM\Column(type="string")
82
     */
83
    protected $totalAmountCurrency;
84
85
    /**
86
     * @Assert\NotBlank()
87
     * @Assert\Length(max="191")
88
     *
89
     * @ORM\Column(type="string", length=191)
90
     */
91
    protected $callBackUrl;
92
93
    /**
94
     * @Assert\NotBlank()
95
     * @Assert\Length(max="191")
96
     *
97
     * @ORM\Column(type="string", length=191)
98
     */
99
    protected $fullCallBackOkUrl;
100
101
    /**
102
     * @Assert\NotBlank()
103
     * @Assert\Length(max="191")
104
     *
105
     * @ORM\Column(type="string", length=191)
106
     */
107
    protected $callBackOkUrl;
108
109
    /**
110
     * @Assert\NotBlank()
111
     * @Assert\Length(max="191")
112
     *
113
     * @ORM\Column(type="string", length=191)
114
     */
115
    protected $callBackServerUrl;
116
117
    /**
118
     * @Assert\NotBlank()
119
     *
120
     * @ORM\Column(type="integer")
121
     */
122
    protected $languageId;
123
124
    /**
125
     * @Assert\NotBlank()
126
     * @Assert\Length(max="191")
127
     *
128
     * @ORM\Column(type="string", length=191)
129
     */
130
    protected $testMode;
131
132
    /**
133
     * @Assert\NotBlank()
134
     *
135
     * @ORM\Column(type="integer")
136
     */
137
    protected $paymentGatewayCurrencyCode;
138
139
    /**
140
     * @Assert\NotBlank()
141
     *
142
     * @ORM\Column(type="integer")
143
     */
144
    protected $cardTypeId;
145
146
    /**
147
     * @Assert\NotBlank()
148
     * @Assert\Length(max="191")
149
     *
150
     * @ORM\Column(type="string", length=191)
151
     */
152
    protected $customerRekvNr;
153
154
    /**
155
     * @Assert\NotBlank()
156
     * @Assert\Length(max="191")
157
     *
158
     * @ORM\Column(type="string", length=191)
159
     */
160
    protected $customerName;
161
162
    /**
163
     * @ORM\Column(type="string", nullable=true)
164
     */
165
    protected $customerCompany;
166
167
    /**
168
     * @Assert\NotBlank()
169
     * @Assert\Length(max="191")
170
     *
171
     * @ORM\Column(type="string", length=191)
172
     */
173
    protected $customerAddress;
174
175
    /**
176
     * @ORM\Column(type="string", nullable=true)
177
     */
178
    protected $customerAddress2;
179
180
    /**
181
     * @Assert\NotBlank()
182
     * @Assert\Length(max="191")
183
     *
184
     * @ORM\Column(type="string", length=191)
185
     */
186
    protected $customerZipCode;
187
188
    /**
189
     * @Assert\NotBlank()
190
     * @Assert\Length(max="191")
191
     *
192
     * @ORM\Column(type="string", length=191)
193
     */
194
    protected $customerCity;
195
196
    /**
197
     * @Assert\NotBlank()
198
     *
199
     * @ORM\Column(type="integer")
200
     */
201
    protected $customerCountryId;
202
203
    /**
204
     * @Assert\NotBlank()
205
     * @Assert\Length(max="191")
206
     *
207
     * @ORM\Column(type="string", length=191)
208
     */
209
    protected $customerCountry;
210
211
    /**
212
     * @Assert\NotBlank()
213
     * @Assert\Length(max="191")
214
     *
215
     * @ORM\Column(type="string", length=191)
216
     */
217
    protected $customerPhone;
218
219
    /**
220
     * @ORM\Column(type="string", nullable=true)
221
     */
222
    protected $customerFax;
223
224
    /**
225
     * @Assert\NotBlank()
226
     * @Assert\Length(max="191")
227
     *
228
     * @ORM\Column(type="string", length=191)
229
     */
230
    protected $customerEmail;
231
232
    /**
233
     * @ORM\Column(type="text", nullable=true)
234
     */
235
    protected $customerNote;
236
237
    /**
238
     * @ORM\Column(type="string", nullable=true, length=191)
239
     */
240
    protected $customerCvrnr;
241
242
    /**
243
     * @Assert\NotBlank()
244
     *
245
     * @ORM\Column(type="integer")
246
     */
247
    protected $customerCustTypeId;
248
249
    /**
250
     * @ORM\Column(type="string", nullable=true, length=191)
251
     */
252
    protected $customerEan;
253
254
    /**
255
     * @ORM\Column(type="string", nullable=true, length=191)
256
     */
257
    protected $customerRes1;
258
259
    /**
260
     * @ORM\Column(type="string", nullable=true, length=191)
261
     */
262
    protected $customerRes2;
263
264
    /**
265
     * @ORM\Column(type="string", nullable=true, length=191)
266
     */
267
    protected $customerRes3;
268
269
    /**
270
     * @ORM\Column(type="string", nullable=true, length=191)
271
     */
272
    protected $customerRes4;
273
274
    /**
275
     * @ORM\Column(type="string", nullable=true, length=191)
276
     */
277
    protected $customerRes5;
278
279
    /**
280
     * @Assert\NotBlank()
281
     * @Assert\Length(max="191")
282
     *
283
     * @ORM\Column(type="string", length=191)
284
     */
285
    protected $customerIp;
286
287
    /**
288
     * @ORM\Column(type="string", nullable=true, length=191)
289
     */
290
    protected $deliveryName;
291
292
    /**
293
     * @ORM\Column(type="string", nullable=true, length=191)
294
     */
295
    protected $deliveryCompany;
296
297
    /**
298
     * @ORM\Column(type="string", nullable=true, length=191)
299
     */
300
    protected $deliveryAddress;
301
302
    /**
303
     * @ORM\Column(type="string", nullable=true, length=191)
304
     */
305
    protected $deliveryAddress2;
306
307
    /**
308
     * @ORM\Column(type="string", nullable=true, length=191)
309
     */
310
    protected $deliveryZipCode;
311
312
    /**
313
     * @ORM\Column(type="string", nullable=true, length=191)
314
     */
315
    protected $deliveryCity;
316
317
    /**
318
     * @ORM\Column(type="integer", nullable=true)
319
     */
320
    protected $deliveryCountryID;
321
322
    /**
323
     * @ORM\Column(type="string", nullable=true, length=191)
324
     */
325
    protected $deliveryCountry;
326
327
    /**
328
     * @ORM\Column(type="string", nullable=true, length=191)
329
     */
330
    protected $deliveryPhone;
331
332
    /**
333
     * @ORM\Column(type="string", nullable=true, length=191)
334
     */
335
    protected $deliveryFax;
336
337
    /**
338
     * @ORM\Column(type="string", nullable=true, length=191)
339
     */
340
    protected $deliveryEmail;
341
342
    /**
343
     * @ORM\Column(type="string", nullable=true, length=191)
344
     */
345
    protected $deliveryEan;
346
347
    /**
348
     * @Assert\NotBlank()
349
     * @Assert\Length(max="191")
350
     *
351
     * @ORM\Column(type="string", length=191)
352
     */
353
    protected $shippingMethod;
354
355
    /**
356
     * @Assert\NotBlank()
357
     *
358
     * @ORM\Column(type="integer")
359
     */
360
    protected $shippingFeeAmount;
361
362
    /**
363
     * @Assert\NotBlank()
364
     *
365
     * @ORM\Column(type="string")
366
     */
367
    protected $shippingFeeCurrency;
368
369
    /**
370
     * @Assert\NotBlank()
371
     * @Assert\Length(max="191")
372
     *
373
     * @ORM\Column(type="string", length=191)
374
     */
375
    protected $paymentMethod;
376
377
    /**
378
     * @Assert\NotBlank()
379
     *
380
     * @ORM\Column(type="integer")
381
     */
382
    protected $paymentFeeAmount;
383
384
    /**
385
     * @Assert\NotBlank()
386
     *
387
     * @ORM\Column(type="string")
388
     */
389
    protected $paymentFeeCurrency;
390
391
    /**
392
     * @ORM\Column(type="string", nullable=true, length=191)
393
     */
394
    protected $loadBalancerRealIp;
395
396
    /**
397
     * @var string
398
     *
399
     * @ORM\Column(type="string", nullable=true, length=191)
400
     */
401
    protected $referrer;
402
403
    /**
404
     * @ORM\OneToMany(targetEntity="PaymentLine", mappedBy="payment", cascade={"persist", "remove"}, fetch="EAGER")
405
     */
406
    protected $paymentLines;
407
408
    /**********************************
409
     * Properties specific to Altapay *
410
     *********************************/
411
412
    /**
413
     * @var string|null
414
     *
415
     * @ORM\Column(type="string", nullable=true, unique=true, length=191)
416
     */
417
    protected $altapayId;
418
419
    /**
420
     * @var string|null
421
     *
422
     * @ORM\Column(type="string", nullable=true, length=191)
423
     */
424
    protected $cardStatus;
425
426
    /**
427
     * @var string|null
428
     *
429
     * @ORM\Column(type="string", nullable=true, length=191)
430
     */
431
    protected $creditCardToken;
432
433
    /**
434
     * @var string|null
435
     *
436
     * @ORM\Column(type="string", nullable=true, length=191)
437
     */
438
    protected $creditCardMaskedPan;
439
440
    /**
441
     * @var string|null
442
     *
443
     * @ORM\Column(type="string", nullable=true, length=191)
444
     */
445
    protected $threeDSecureResult;
446
447
    /**
448
     * @var string|null
449
     *
450
     * @ORM\Column(type="string", nullable=true, length=191)
451
     */
452
    protected $liableForChargeback;
453
454
    /**
455
     * @var string|null
456
     *
457
     * @ORM\Column(type="string", nullable=true, length=191)
458
     */
459
    protected $blacklistToken;
460
461
    /**
462
     * @var string|null
463
     *
464
     * @ORM\Column(type="string", nullable=true, length=191)
465
     */
466
    protected $shop;
467
468
    /**
469
     * @var string|null
470
     *
471
     * @ORM\Column(type="string", nullable=true, length=191)
472
     */
473
    protected $terminal;
474
475
    /**
476
     * @var string|null
477
     *
478
     * @ORM\Column(type="string", nullable=true, length=191)
479
     */
480
    protected $transactionStatus;
481
482
    /**
483
     * @var string|null
484
     *
485
     * @ORM\Column(type="string", nullable=true, length=191)
486
     */
487
    protected $reasonCode;
488
489
    /**
490
     * @var int|null
491
     *
492
     * @ORM\Column(type="integer", nullable=true)
493
     */
494
    protected $merchantCurrency;
495
496
    /**
497
     * @var string|null
498
     *
499
     * @ORM\Column(type="string", nullable=true, length=191)
500
     */
501
    protected $merchantCurrencyAlpha;
502
503
    /**
504
     * @var int|null
505
     *
506
     * @ORM\Column(type="integer", nullable=true)
507
     */
508
    protected $cardHolderCurrency;
509
510
    /**
511
     * @var string|null
512
     *
513
     * @ORM\Column(type="string", nullable=true, length=191)
514
     */
515
    protected $cardHolderCurrencyAlpha;
516
517
    /**
518
     * @var float|null
519
     *
520
     * @ORM\Column(type="decimal", precision=10, scale=2)
521
     */
522
    protected $reservedAmount;
523
524
    /**
525
     * @var float|null
526
     *
527
     * @ORM\Column(type="decimal", precision=10, scale=2)
528
     */
529
    protected $capturedAmount;
530
531
    /**
532
     * @var float|null
533
     *
534
     * @ORM\Column(type="decimal", precision=10, scale=2)
535
     */
536
    protected $refundedAmount;
537
538
    /**
539
     * @var float|null
540
     *
541
     * @ORM\Column(type="decimal", precision=10, scale=2)
542
     */
543
    protected $recurringDefaultAmount;
544
545
    /**
546
     * @var \DateTime|null
547
     *
548
     * @ORM\Column(type="datetime", nullable=true)
549
     */
550
    protected $createdDate;
551
552
    /**
553
     * @var \DateTime|null
554
     *
555
     * @ORM\Column(type="datetime", nullable=true)
556
     */
557
    protected $updatedDate;
558
559
    /**
560
     * @var string|null
561
     *
562
     * @ORM\Column(type="string", nullable=true, length=191)
563
     */
564
    protected $paymentNature;
565
566
    /**
567
     * @var bool|null
568
     *
569
     * @ORM\Column(type="boolean", nullable=true)
570
     */
571
    protected $supportsRefunds;
572
573
    /**
574
     * @var bool|null
575
     *
576
     * @ORM\Column(type="boolean", nullable=true)
577
     */
578
    protected $supportsRelease;
579
580
    /**
581
     * @var bool|null
582
     *
583
     * @ORM\Column(type="boolean", nullable=true)
584
     */
585
    protected $supportsMultipleCaptures;
586
587
    /**
588
     * @var bool|null
589
     *
590
     * @ORM\Column(type="boolean", nullable=true)
591
     */
592
    protected $supportsMultipleRefunds;
593
594
    /**
595
     * @var float|null
596
     *
597
     * @ORM\Column(type="float", nullable=true)
598
     */
599
    protected $fraudRiskScore;
600
601
    /**
602
     * @var string|null
603
     *
604
     * @ORM\Column(type="string", nullable=true, length=191)
605
     */
606
    protected $fraudExplanation;
607
608
    public function __construct()
609
    {
610
        parent::__construct();
611
612
        $this->paymentLines = new ArrayCollection();
613
        $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...
614
        $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...
615
        $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...
616
        $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...
617
    }
618
619
    /**
620
     * This will transform a Dandomain Payment (parent) to a Payment (child).
621
     *
622
     * @param DandomainPayment $dandomainPayment
623
     *
624
     * @return Payment
625
     */
626
    public static function createFromDandomainPayment(DandomainPayment $dandomainPayment)
627
    {
628
        $payment = new self();
629
630
        $methods = get_class_methods($dandomainPayment);
631
632
        foreach ($methods as $method) {
633
            if ('get' === substr($method, 0, 3)) {
634
                $val = $dandomainPayment->{$method}();
635
                $property = substr($method, 3);
636
            } elseif ('is' === substr($method, 0, 2)) {
637
                $val = $dandomainPayment->{$method}();
638
                $property = substr($method, 2);
639
            } else {
640
                continue;
641
            }
642
643
            if (!is_scalar($val)) {
644
                continue;
645
            }
646
647
            $setter = 'set'.$property;
648
649
            if (method_exists($payment, $setter)) {
650
                $payment->{$setter}($val);
651
            }
652
        }
653
654
        foreach ($dandomainPayment->getPaymentLines() as $paymentLine) {
655
            $newPaymentLine = PaymentLine::createFromDandomainPaymentLine($paymentLine);
656
            $payment->addPaymentLine($newPaymentLine);
657
        }
658
659
        return $payment;
660
    }
661
662
    /**
663
     * Returns true if the payment can be captured.
664
     *
665
     * @return bool
666
     */
667
    public function isCaptureable(): bool
668
    {
669
        if ($this->capturableAmount() <= 0) {
670
            return false;
671
        }
672
673
        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...
674
            return false;
675
        }
676
677
        return true;
678
    }
679
680
    /**
681
     * Returns true if the payment can be refunded.
682
     *
683
     * @return bool
684
     */
685
    public function isRefundable(): bool
686
    {
687
        if ($this->refundableAmount() <= 0) {
688
            return false;
689
        }
690
691
        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...
692
            return false;
693
        }
694
695
        return true;
696
    }
697
698
    /**
699
     * @return float
700
     */
701
    public function refundableAmount()
702
    {
703
        $capturedAmount = BigDecimal::of($this->capturedAmount);
704
705
        return $capturedAmount->minus($this->refundedAmount)->toFloat();
706
    }
707
708
    /**
709
     * @return float
710
     */
711
    public function capturableAmount()
712
    {
713
        $reservedAmount = BigDecimal::of($this->reservedAmount);
714
        $realCapturedAmount = BigDecimal::of($this->capturedAmount)->minus($this->refundedAmount);
715
716
        return $reservedAmount->minus($realCapturedAmount)->toFloat();
717
    }
718
719
    // @todo create type hints for getters and setters
720
721
    public function setTotalAmount(Money $totalAmount): DandomainPayment
722
    {
723
        parent::setTotalAmount($totalAmount);
724
725
        $this->totalAmountAmount = $totalAmount->getAmount();
726
        $this->totalAmountCurrency = $totalAmount->getCurrency()->getCode();
727
728
        return $this;
729
    }
730
731
    public function getTotalAmount(): ?Money
732
    {
733
        if (!$this->totalAmountCurrency) {
734
            return null;
735
        }
736
737
        $amount = $this->totalAmountAmount;
738
        if (!$amount) {
739
            $amount = 0;
740
        }
741
742
        return new Money($amount, new Currency($this->totalAmountCurrency));
743
    }
744
745
    public function setShippingFee(Money $shippingFee): DandomainPayment
746
    {
747
        parent::setShippingFee($shippingFee);
748
749
        $this->shippingFeeAmount = $shippingFee->getAmount();
750
        $this->shippingFeeCurrency = $shippingFee->getCurrency()->getCode();
751
752
        return $this;
753
    }
754
755
    public function getShippingFee(): ?Money
756
    {
757
        if (!$this->shippingFeeCurrency) {
758
            return null;
759
        }
760
761
        $amount = $this->shippingFeeAmount;
762
        if (!$amount) {
763
            $amount = 0;
764
        }
765
766
        return new Money($amount, new Currency($this->shippingFeeCurrency));
767
    }
768
769
    public function setPaymentFee(Money $paymentFee): DandomainPayment
770
    {
771
        parent::setPaymentFee($paymentFee);
772
773
        $this->paymentFeeAmount = $paymentFee->getAmount();
774
        $this->paymentFeeCurrency = $paymentFee->getCurrency()->getCode();
775
776
        return $this;
777
    }
778
779
    public function getPaymentFee(): ?Money
780
    {
781
        if (!$this->paymentFeeCurrency) {
782
            return null;
783
        }
784
785
        $amount = $this->paymentFeeAmount;
786
        if (!$amount) {
787
            $amount = 0;
788
        }
789
790
        return new Money($amount, new Currency($this->paymentFeeCurrency));
791
    }
792
793
    /**
794
     * @return int
795
     */
796
    public function getId(): ?int
797
    {
798
        return $this->id;
799
    }
800
801
    /**
802
     * @param int $id
803
     *
804
     * @return Payment
805
     */
806
    public function setId(int $id): self
807
    {
808
        $this->id = $id;
809
810
        return $this;
811
    }
812
813
    /**
814
     * @return null|string
815
     */
816
    public function getAltapayId()
817
    {
818
        return $this->altapayId;
819
    }
820
821
    /**
822
     * @param null|string $altapayId
823
     *
824
     * @return Payment
825
     */
826
    public function setAltapayId($altapayId)
827
    {
828
        $this->altapayId = $altapayId;
829
830
        return $this;
831
    }
832
833
    /**
834
     * @return null|string
835
     */
836
    public function getCardStatus()
837
    {
838
        return $this->cardStatus;
839
    }
840
841
    /**
842
     * @param null|string $cardStatus
843
     *
844
     * @return Payment
845
     */
846
    public function setCardStatus($cardStatus)
847
    {
848
        $this->cardStatus = $cardStatus;
849
850
        return $this;
851
    }
852
853
    /**
854
     * @return null|string
855
     */
856
    public function getCreditCardToken()
857
    {
858
        return $this->creditCardToken;
859
    }
860
861
    /**
862
     * @param null|string $creditCardToken
863
     *
864
     * @return Payment
865
     */
866
    public function setCreditCardToken($creditCardToken)
867
    {
868
        $this->creditCardToken = $creditCardToken;
869
870
        return $this;
871
    }
872
873
    /**
874
     * @return null|string
875
     */
876
    public function getCreditCardMaskedPan()
877
    {
878
        return $this->creditCardMaskedPan;
879
    }
880
881
    /**
882
     * @param null|string $creditCardMaskedPan
883
     *
884
     * @return Payment
885
     */
886
    public function setCreditCardMaskedPan($creditCardMaskedPan)
887
    {
888
        $this->creditCardMaskedPan = $creditCardMaskedPan;
889
890
        return $this;
891
    }
892
893
    /**
894
     * @return null|string
895
     */
896
    public function getThreeDSecureResult()
897
    {
898
        return $this->threeDSecureResult;
899
    }
900
901
    /**
902
     * @param null|string $threeDSecureResult
903
     *
904
     * @return Payment
905
     */
906
    public function setThreeDSecureResult($threeDSecureResult)
907
    {
908
        $this->threeDSecureResult = $threeDSecureResult;
909
910
        return $this;
911
    }
912
913
    /**
914
     * @return null|string
915
     */
916
    public function getLiableForChargeback()
917
    {
918
        return $this->liableForChargeback;
919
    }
920
921
    /**
922
     * @param null|string $liableForChargeback
923
     *
924
     * @return Payment
925
     */
926
    public function setLiableForChargeback($liableForChargeback)
927
    {
928
        $this->liableForChargeback = $liableForChargeback;
929
930
        return $this;
931
    }
932
933
    /**
934
     * @return null|string
935
     */
936
    public function getBlacklistToken()
937
    {
938
        return $this->blacklistToken;
939
    }
940
941
    /**
942
     * @param null|string $blacklistToken
943
     *
944
     * @return Payment
945
     */
946
    public function setBlacklistToken($blacklistToken)
947
    {
948
        $this->blacklistToken = $blacklistToken;
949
950
        return $this;
951
    }
952
953
    /**
954
     * @return null|string
955
     */
956
    public function getShop()
957
    {
958
        return $this->shop;
959
    }
960
961
    /**
962
     * @param null|string $shop
963
     *
964
     * @return Payment
965
     */
966
    public function setShop($shop)
967
    {
968
        $this->shop = $shop;
969
970
        return $this;
971
    }
972
973
    /**
974
     * @return null|string
975
     */
976
    public function getTerminal()
977
    {
978
        return $this->terminal;
979
    }
980
981
    /**
982
     * @param null|string $terminal
983
     *
984
     * @return Payment
985
     */
986
    public function setTerminal($terminal)
987
    {
988
        $this->terminal = $terminal;
989
990
        return $this;
991
    }
992
993
    /**
994
     * @return null|string
995
     */
996
    public function getTransactionStatus()
997
    {
998
        return $this->transactionStatus;
999
    }
1000
1001
    /**
1002
     * @param null|string $transactionStatus
1003
     *
1004
     * @return Payment
1005
     */
1006
    public function setTransactionStatus($transactionStatus)
1007
    {
1008
        $this->transactionStatus = $transactionStatus;
1009
1010
        return $this;
1011
    }
1012
1013
    /**
1014
     * @return null|string
1015
     */
1016
    public function getReasonCode()
1017
    {
1018
        return $this->reasonCode;
1019
    }
1020
1021
    /**
1022
     * @param null|string $reasonCode
1023
     *
1024
     * @return Payment
1025
     */
1026
    public function setReasonCode($reasonCode)
1027
    {
1028
        $this->reasonCode = $reasonCode;
1029
1030
        return $this;
1031
    }
1032
1033
    /**
1034
     * @return int|null
1035
     */
1036
    public function getMerchantCurrency()
1037
    {
1038
        return $this->merchantCurrency;
1039
    }
1040
1041
    /**
1042
     * @param int|null $merchantCurrency
1043
     *
1044
     * @return Payment
1045
     */
1046
    public function setMerchantCurrency($merchantCurrency)
1047
    {
1048
        $this->merchantCurrency = $merchantCurrency;
1049
1050
        return $this;
1051
    }
1052
1053
    /**
1054
     * @return null|string
1055
     */
1056
    public function getMerchantCurrencyAlpha()
1057
    {
1058
        return $this->merchantCurrencyAlpha;
1059
    }
1060
1061
    /**
1062
     * @param null|string $merchantCurrencyAlpha
1063
     *
1064
     * @return Payment
1065
     */
1066
    public function setMerchantCurrencyAlpha($merchantCurrencyAlpha)
1067
    {
1068
        $this->merchantCurrencyAlpha = $merchantCurrencyAlpha;
1069
1070
        return $this;
1071
    }
1072
1073
    /**
1074
     * @return int|null
1075
     */
1076
    public function getCardHolderCurrency()
1077
    {
1078
        return $this->cardHolderCurrency;
1079
    }
1080
1081
    /**
1082
     * @param int|null $cardHolderCurrency
1083
     *
1084
     * @return Payment
1085
     */
1086
    public function setCardHolderCurrency($cardHolderCurrency)
1087
    {
1088
        $this->cardHolderCurrency = $cardHolderCurrency;
1089
1090
        return $this;
1091
    }
1092
1093
    /**
1094
     * @return null|string
1095
     */
1096
    public function getCardHolderCurrencyAlpha()
1097
    {
1098
        return $this->cardHolderCurrencyAlpha;
1099
    }
1100
1101
    /**
1102
     * @param null|string $cardHolderCurrencyAlpha
1103
     *
1104
     * @return Payment
1105
     */
1106
    public function setCardHolderCurrencyAlpha($cardHolderCurrencyAlpha)
1107
    {
1108
        $this->cardHolderCurrencyAlpha = $cardHolderCurrencyAlpha;
1109
1110
        return $this;
1111
    }
1112
1113
    /**
1114
     * @return float|null
1115
     */
1116
    public function getReservedAmount()
1117
    {
1118
        return $this->reservedAmount;
1119
    }
1120
1121
    /**
1122
     * @param float|null $reservedAmount
1123
     *
1124
     * @return Payment
1125
     */
1126
    public function setReservedAmount($reservedAmount)
1127
    {
1128
        $this->reservedAmount = $reservedAmount;
1129
1130
        return $this;
1131
    }
1132
1133
    /**
1134
     * @return float|null
1135
     */
1136
    public function getCapturedAmount()
1137
    {
1138
        return $this->capturedAmount;
1139
    }
1140
1141
    /**
1142
     * @param float|null $capturedAmount
1143
     *
1144
     * @return Payment
1145
     */
1146
    public function setCapturedAmount($capturedAmount)
1147
    {
1148
        $this->capturedAmount = $capturedAmount;
1149
1150
        return $this;
1151
    }
1152
1153
    /**
1154
     * @return float|null
1155
     */
1156
    public function getRefundedAmount()
1157
    {
1158
        return $this->refundedAmount;
1159
    }
1160
1161
    /**
1162
     * @param float|null $refundedAmount
1163
     *
1164
     * @return Payment
1165
     */
1166
    public function setRefundedAmount($refundedAmount)
1167
    {
1168
        $this->refundedAmount = $refundedAmount;
1169
1170
        return $this;
1171
    }
1172
1173
    /**
1174
     * @return float|null
1175
     */
1176
    public function getRecurringDefaultAmount()
1177
    {
1178
        return $this->recurringDefaultAmount;
1179
    }
1180
1181
    /**
1182
     * @param float|null $recurringDefaultAmount
1183
     *
1184
     * @return Payment
1185
     */
1186
    public function setRecurringDefaultAmount($recurringDefaultAmount)
1187
    {
1188
        $this->recurringDefaultAmount = $recurringDefaultAmount;
1189
1190
        return $this;
1191
    }
1192
1193
    /**
1194
     * @return \DateTime|null
1195
     */
1196
    public function getCreatedDate()
1197
    {
1198
        return $this->createdDate;
1199
    }
1200
1201
    /**
1202
     * @param \DateTimeInterface|null $createdDate
1203
     *
1204
     * @return Payment
1205
     */
1206
    public function setCreatedDate($createdDate)
1207
    {
1208
        $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...
1209
1210
        return $this;
1211
    }
1212
1213
    /**
1214
     * @return \DateTime|null
1215
     */
1216
    public function getUpdatedDate()
1217
    {
1218
        return $this->updatedDate;
1219
    }
1220
1221
    /**
1222
     * @param \DateTimeInterface|null $updatedDate
1223
     *
1224
     * @return Payment
1225
     */
1226
    public function setUpdatedDate($updatedDate)
1227
    {
1228
        $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...
1229
1230
        return $this;
1231
    }
1232
1233
    /**
1234
     * @return null|string
1235
     */
1236
    public function getPaymentNature()
1237
    {
1238
        return $this->paymentNature;
1239
    }
1240
1241
    /**
1242
     * @param null|string $paymentNature
1243
     *
1244
     * @return Payment
1245
     */
1246
    public function setPaymentNature($paymentNature)
1247
    {
1248
        $this->paymentNature = $paymentNature;
1249
1250
        return $this;
1251
    }
1252
1253
    /**
1254
     * @return bool|null
1255
     */
1256
    public function getSupportsRefunds()
1257
    {
1258
        return $this->supportsRefunds;
1259
    }
1260
1261
    /**
1262
     * @param bool|null $supportsRefunds
1263
     *
1264
     * @return Payment
1265
     */
1266
    public function setSupportsRefunds($supportsRefunds)
1267
    {
1268
        $this->supportsRefunds = $supportsRefunds;
1269
1270
        return $this;
1271
    }
1272
1273
    /**
1274
     * @return bool|null
1275
     */
1276
    public function getSupportsRelease()
1277
    {
1278
        return $this->supportsRelease;
1279
    }
1280
1281
    /**
1282
     * @param bool|null $supportsRelease
1283
     *
1284
     * @return Payment
1285
     */
1286
    public function setSupportsRelease($supportsRelease)
1287
    {
1288
        $this->supportsRelease = $supportsRelease;
1289
1290
        return $this;
1291
    }
1292
1293
    /**
1294
     * @return bool|null
1295
     */
1296
    public function getSupportsMultipleCaptures()
1297
    {
1298
        return $this->supportsMultipleCaptures;
1299
    }
1300
1301
    /**
1302
     * @param bool|null $supportsMultipleCaptures
1303
     *
1304
     * @return Payment
1305
     */
1306
    public function setSupportsMultipleCaptures($supportsMultipleCaptures)
1307
    {
1308
        $this->supportsMultipleCaptures = $supportsMultipleCaptures;
1309
1310
        return $this;
1311
    }
1312
1313
    /**
1314
     * @return bool|null
1315
     */
1316
    public function getSupportsMultipleRefunds()
1317
    {
1318
        return $this->supportsMultipleRefunds;
1319
    }
1320
1321
    /**
1322
     * @param bool|null $supportsMultipleRefunds
1323
     *
1324
     * @return Payment
1325
     */
1326
    public function setSupportsMultipleRefunds($supportsMultipleRefunds)
1327
    {
1328
        $this->supportsMultipleRefunds = $supportsMultipleRefunds;
1329
1330
        return $this;
1331
    }
1332
1333
    /**
1334
     * @return float|null
1335
     */
1336
    public function getFraudRiskScore()
1337
    {
1338
        return $this->fraudRiskScore;
1339
    }
1340
1341
    /**
1342
     * @param float|null $fraudRiskScore
1343
     *
1344
     * @return Payment
1345
     */
1346
    public function setFraudRiskScore($fraudRiskScore)
1347
    {
1348
        $this->fraudRiskScore = $fraudRiskScore;
1349
1350
        return $this;
1351
    }
1352
1353
    /**
1354
     * @return null|string
1355
     */
1356
    public function getFraudExplanation()
1357
    {
1358
        return $this->fraudExplanation;
1359
    }
1360
1361
    /**
1362
     * @param null|string $fraudExplanation
1363
     *
1364
     * @return Payment
1365
     */
1366
    public function setFraudExplanation($fraudExplanation)
1367
    {
1368
        $this->fraudExplanation = $fraudExplanation;
1369
1370
        return $this;
1371
    }
1372
}
1373