1 | <?php |
||
17 | trait BankAccountTrait |
||
18 | { |
||
19 | /** |
||
20 | * Get the payment issuer. |
||
21 | * |
||
22 | * @return string |
||
23 | * |
||
24 | * @codeCoverageIgnore |
||
25 | */ |
||
26 | abstract public function getPaymentMethod(); |
||
27 | |||
28 | /** |
||
29 | * Gets the account holder. |
||
30 | * |
||
31 | * @return string|null Account holder name. |
||
32 | */ |
||
33 | 3 | public function getAccountHolder() |
|
34 | { |
||
35 | 3 | return $this->getParameter('accountHolder'); |
|
36 | } |
||
37 | |||
38 | /** |
||
39 | * Gets the account number. |
||
40 | * |
||
41 | * @return string|null Account number, generally IBAN for euro countries |
||
42 | */ |
||
43 | 3 | public function getAccountNumber() |
|
44 | { |
||
45 | 3 | return $this->getParameter('accountNumber'); |
|
46 | } |
||
47 | |||
48 | /** |
||
49 | * Gets the account sort code |
||
50 | * |
||
51 | * @return string|null Sort code, generally the BIC |
||
52 | */ |
||
53 | 3 | public function getSortCode() |
|
54 | { |
||
55 | 3 | return $this->getParameter('sortCode'); |
|
56 | } |
||
57 | |||
58 | /** |
||
59 | * Sets the account holder. |
||
60 | * |
||
61 | * @param string $value Account Holder |
||
62 | * |
||
63 | * @return AuthorizeRequest |
||
64 | */ |
||
65 | 11 | public function setAccountHolder($value) |
|
66 | { |
||
67 | 11 | return $this->setParameter('accountHolder', $value); |
|
68 | } |
||
69 | |||
70 | /** |
||
71 | * Sets the account number. |
||
72 | * |
||
73 | * @param string $value Account number, generally IBAN number |
||
74 | * |
||
75 | * @return AuthorizeRequest |
||
76 | */ |
||
77 | 11 | public function setAccountNumber($value) |
|
78 | { |
||
79 | 11 | return $this->setParameter('accountNumber', $value); |
|
80 | } |
||
81 | |||
82 | /** |
||
83 | * Sets the sort code. |
||
84 | * |
||
85 | * @param string $value Sort code, generally the BIC |
||
86 | * |
||
87 | * @return AuthorizeRequest |
||
88 | */ |
||
89 | 11 | public function setSortCode($value) |
|
90 | { |
||
91 | 11 | return $this->setParameter('sortCode', $value); |
|
92 | } |
||
93 | |||
94 | /** |
||
95 | * Appends the bank account information to the SimpleXMLElement. |
||
96 | * |
||
97 | * @param SimpleXMLElement $data |
||
98 | * |
||
99 | * @throws InvalidRequestException |
||
100 | */ |
||
101 | 9 | protected function appendBankAccount(SimpleXMLElement $data) |
|
102 | { |
||
103 | 9 | if ($this->getPaymentMethod() === 'invoice') { |
|
104 | 7 | return; |
|
105 | } |
||
106 | |||
107 | 2 | $data->addChild('bank_account'); |
|
108 | 2 | $data->bank_account[0]['accountholder'] = $this->getAccountHolder(); |
|
109 | 2 | $data->bank_account[0]['accountnumber'] = $this->getAccountNumber(); |
|
110 | 2 | $data->bank_account[0]['sortcode'] = $this->getSortCode(); |
|
111 | 2 | } |
|
112 | |||
113 | /** |
||
114 | * Get a single parameter. |
||
115 | * |
||
116 | * @param string $key The parameter key |
||
117 | * |
||
118 | * @return mixed |
||
119 | * |
||
120 | * @codeCoverageIgnore |
||
121 | */ |
||
122 | abstract protected function getParameter($key); |
||
123 | |||
124 | /** |
||
125 | * Set a single parameter. |
||
126 | * |
||
127 | * @param string $key The parameter key |
||
128 | * @param mixed $value The value to set |
||
129 | * |
||
130 | * @return AbstractRequest Provides a fluent interface |
||
131 | * |
||
132 | * @codeCoverageIgnore |
||
133 | */ |
||
134 | abstract protected function setParameter($key, $value); |
||
135 | } |
||
136 |