1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace CMPayments\PaymentSdk\Entities; |
4
|
|
|
|
5
|
|
|
use Money\Money; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class DirectDebitPayment |
9
|
|
|
* @package CMPayments\PaymentSdk\Entities |
10
|
|
|
* @author Jory Geerts <[email protected]> |
11
|
|
|
*/ |
12
|
|
|
class DirectDebitPayment extends Payment |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* @var string |
16
|
|
|
*/ |
17
|
|
|
private $description; |
18
|
|
|
/** |
19
|
|
|
* @var string |
20
|
|
|
*/ |
21
|
|
|
private $iban; |
22
|
|
|
/** |
23
|
|
|
* @var string |
24
|
|
|
*/ |
25
|
|
|
private $name; |
26
|
|
|
/** |
27
|
|
|
* @var string |
28
|
|
|
*/ |
29
|
|
|
private $mandateId; |
30
|
|
|
/** |
31
|
|
|
* @var \DateTime |
32
|
|
|
*/ |
33
|
|
|
private $mandateStartDate; |
34
|
|
|
/** |
35
|
|
|
* @var null|string |
36
|
|
|
*/ |
37
|
|
|
private $transactionDescription; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* IdealPayment constructor. |
41
|
|
|
* @param Money $money |
42
|
|
|
* @param string $purchaseId |
43
|
|
|
* @param string $iban |
44
|
|
|
* @param string $name |
45
|
|
|
* @param string $mandateId |
46
|
|
|
* @param \DateTime $mandateStartDate |
47
|
|
|
* @param string $description |
48
|
|
|
* @param string $transactionDescription = null |
49
|
|
|
* @internal param string $bic |
50
|
|
|
*/ |
51
|
1 |
|
public function __construct( |
52
|
|
|
Money $money, |
53
|
|
|
$purchaseId, |
54
|
|
|
$iban, |
55
|
|
|
$name, |
56
|
|
|
$mandateId, |
57
|
|
|
\DateTime $mandateStartDate, |
58
|
|
|
$description, |
59
|
|
|
$transactionDescription = null |
60
|
|
|
) { |
61
|
1 |
|
parent::__construct($money, 'DirectDebit', $purchaseId); |
62
|
|
|
|
63
|
1 |
|
$this->description = $description; |
64
|
1 |
|
$this->iban = $iban; |
65
|
1 |
|
$this->name = $name; |
66
|
1 |
|
$this->mandateId = $mandateId; |
67
|
1 |
|
$this->mandateStartDate = $mandateStartDate; |
68
|
1 |
|
$this->transactionDescription = $transactionDescription; |
69
|
1 |
|
} |
70
|
|
|
|
71
|
|
|
/** @inheritdoc */ |
72
|
1 |
|
public function toArray() |
73
|
|
|
{ |
74
|
1 |
|
$array = parent::toArray(); |
75
|
1 |
|
$array['payment_details']['bank_account_number'] = $this->iban; |
76
|
1 |
|
$array['payment_details']['name'] = $this->name; |
77
|
1 |
|
$array['payment_details']['mandate_id'] = $this->mandateId; |
78
|
1 |
|
$array['payment_details']['mandate_start_date'] = $this->mandateStartDate->format('Y-m-d'); |
79
|
1 |
|
$array['payment_details']['description'] = $this->description; |
80
|
|
|
|
81
|
1 |
|
if ($this->transactionDescription) { |
|
|
|
|
82
|
1 |
|
$array['payment_details']['transaction_description'] = $this->transactionDescription; |
83
|
1 |
|
} |
84
|
|
|
|
85
|
1 |
|
return $array; |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: