@@ -12,7 +12,7 @@ |
||
12 | 12 | const SEK = 'SEK'; |
13 | 13 | const USD = 'USD'; |
14 | 14 | |
15 | - static function isValid(string $currency){ |
|
15 | + static function isValid(string $currency) { |
|
16 | 16 | $currencies = self::getCurrencies(); |
17 | 17 | return in_array($currency, $currencies); |
18 | 18 | } |
@@ -2,7 +2,7 @@ |
||
2 | 2 | |
3 | 3 | namespace BPCI\SumUp\Exception; |
4 | 4 | |
5 | -class FileNotFoundException extends \RuntimeException{ |
|
5 | +class FileNotFoundException extends \RuntimeException { |
|
6 | 6 | private $path; |
7 | 7 | public function __construct(string $message, int $code = 0, \Exception $previous = null, string $path = null) |
8 | 8 | { |
@@ -81,14 +81,14 @@ |
||
81 | 81 | */ |
82 | 82 | public static function loadContextFromFile(string $filePath): ContextInterface |
83 | 83 | { |
84 | - if(!file_exists($filePath)){ |
|
85 | - throw new Exception\FileNotFoundException('Context file not found: '.$filePath, 404, null, $filePath); |
|
84 | + if (!file_exists($filePath)) { |
|
85 | + throw new Exception\FileNotFoundException('Context file not found: ' . $filePath, 404, null, $filePath); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | $contents = file_get_contents($filePath); |
89 | 89 | $context_array = json_decode($contents, true); |
90 | 90 | |
91 | - if($context_array === null){ |
|
91 | + if ($context_array === null) { |
|
92 | 92 | throw new Exception\MalformedJsonException('JSON sintax error.'); |
93 | 93 | } |
94 | 94 |
@@ -25,7 +25,7 @@ |
||
25 | 25 | |
26 | 26 | static function getEntrypoint(): string |
27 | 27 | { |
28 | - return self::ENTRYPOINT.self::VERSION.'/'; |
|
28 | + return self::ENTRYPOINT . self::VERSION . '/'; |
|
29 | 29 | } |
30 | 30 | } |
31 | 31 |
@@ -7,29 +7,29 @@ |
||
7 | 7 | |
8 | 8 | class SumUp |
9 | 9 | { |
10 | - const VERSION = 'v0.1'; |
|
11 | - const ENTRYPOINT = 'https://api.sumup.com/'; |
|
10 | + const VERSION = 'v0.1'; |
|
11 | + const ENTRYPOINT = 'https://api.sumup.com/'; |
|
12 | 12 | |
13 | - /** |
|
13 | + /** |
|
14 | 14 | * @param array $options |
15 | 15 | * @return ClientInterface |
16 | - */ |
|
16 | + */ |
|
17 | 17 | static function getClient(array $options = []): ClientInterface |
18 | - { |
|
18 | + { |
|
19 | 19 | $options = array_merge_recursive( |
20 | - [ |
|
21 | - 'base_uri' => self::getEntrypoint(), |
|
22 | - 'timeout' => 2 |
|
20 | + [ |
|
21 | + 'base_uri' => self::getEntrypoint(), |
|
22 | + 'timeout' => 2 |
|
23 | 23 | ], |
24 | 24 | $options |
25 | - ); |
|
25 | + ); |
|
26 | 26 | |
27 | 27 | return new Client($options); |
28 | - } |
|
28 | + } |
|
29 | 29 | |
30 | - static function getEntrypoint(): string |
|
31 | - { |
|
32 | - return self::ENTRYPOINT.self::VERSION.'/'; |
|
33 | - } |
|
30 | + static function getEntrypoint(): string |
|
31 | + { |
|
32 | + return self::ENTRYPOINT.self::VERSION.'/'; |
|
33 | + } |
|
34 | 34 | } |
35 | 35 |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | /** |
98 | 98 | * @inheritDoc |
99 | 99 | */ |
100 | - public function getId():? string { |
|
100 | + public function getId(): ? string { |
|
101 | 101 | return $this->id; |
102 | 102 | } |
103 | 103 | |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | /** |
113 | 113 | * @inheritDoc |
114 | 114 | */ |
115 | - public function getStatus():? string { |
|
115 | + public function getStatus(): ? string { |
|
116 | 116 | return $this->status; |
117 | 117 | } |
118 | 118 | |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | /** |
128 | 128 | * @inheritDoc |
129 | 129 | */ |
130 | - public function getAmount():? float { |
|
130 | + public function getAmount(): ? float { |
|
131 | 131 | return $this->amount; |
132 | 132 | } |
133 | 133 | |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | /** |
143 | 143 | * @inheritDoc |
144 | 144 | */ |
145 | - public function getCurrency():? string { |
|
145 | + public function getCurrency(): ? string { |
|
146 | 146 | return $this->currency; |
147 | 147 | } |
148 | 148 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | /** |
158 | 158 | * @inheritDoc |
159 | 159 | */ |
160 | - public function getPayToEmail():? string { |
|
160 | + public function getPayToEmail(): ? string { |
|
161 | 161 | return $this->payToEmail; |
162 | 162 | } |
163 | 163 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | /** |
173 | 173 | * @inheritDoc |
174 | 174 | */ |
175 | - public function getCheckoutReference():? string { |
|
175 | + public function getCheckoutReference(): ? string { |
|
176 | 176 | return $this->reference; |
177 | 177 | } |
178 | 178 | |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | /** |
188 | 188 | * @inheritDoc |
189 | 189 | */ |
190 | - public function getDescription():? string { |
|
190 | + public function getDescription(): ? string { |
|
191 | 191 | return $this->description; |
192 | 192 | } |
193 | 193 | |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | /** |
203 | 203 | * @inheritDoc |
204 | 204 | */ |
205 | - public function getFeeAmount():? float { |
|
205 | + public function getFeeAmount(): ? float { |
|
206 | 206 | return $this->feeAmount; |
207 | 207 | } |
208 | 208 | |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | /** |
218 | 218 | * @inheritDoc |
219 | 219 | */ |
220 | - public function getPayFromEmail():? string { |
|
220 | + public function getPayFromEmail(): ? string { |
|
221 | 221 | return $this->payFromEmail; |
222 | 222 | } |
223 | 223 | |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | /** |
233 | 233 | * @inheritDoc |
234 | 234 | */ |
235 | - public function getRedirectUrl():? string { |
|
235 | + public function getRedirectUrl(): ? string { |
|
236 | 236 | return $this->redirectUrl; |
237 | 237 | } |
238 | 238 | |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | return $this; |
245 | 245 | } |
246 | 246 | |
247 | - function getValidUntil():? string { |
|
247 | + function getValidUntil(): ? string { |
|
248 | 248 | return $this->validUntil; |
249 | 249 | } |
250 | 250 | |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | return $this; |
254 | 254 | } |
255 | 255 | |
256 | - function getTransactionCode():? string { |
|
256 | + function getTransactionCode(): ? string { |
|
257 | 257 | return $this->transactionCode; |
258 | 258 | } |
259 | 259 | |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | return $this; |
263 | 263 | } |
264 | 264 | |
265 | - function getTransactionId():? string { |
|
265 | + function getTransactionId(): ? string { |
|
266 | 266 | return $this->transactionId; |
267 | 267 | } |
268 | 268 | |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | return $this; |
272 | 272 | } |
273 | 273 | |
274 | - function getTransactions():? array { |
|
274 | + function getTransactions(): ? array { |
|
275 | 275 | // return $this->transactions; |
276 | 276 | //TODO remember myself whats is it. |
277 | 277 | return []; |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | return $this; |
284 | 284 | } |
285 | 285 | |
286 | - function getToken():? string { |
|
286 | + function getToken(): ? string { |
|
287 | 287 | return $this->token; |
288 | 288 | } |
289 | 289 | |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | /** |
367 | 367 | * @return mixed |
368 | 368 | */ |
369 | - public function getType():? string |
|
369 | + public function getType(): ? string |
|
370 | 370 | { |
371 | 371 | return $this->type; |
372 | 372 | } |
@@ -11,378 +11,378 @@ |
||
11 | 11 | |
12 | 12 | class Checkout implements CheckoutInterface, PropertyHandlerInterface |
13 | 13 | { |
14 | - use PropertyHandler; |
|
15 | - |
|
16 | - const PENDING = 'PENDING'; |
|
17 | - const COMPLETED = 'COMPLETED'; |
|
18 | - const FAILED = 'FAILED'; |
|
19 | - |
|
20 | - protected $id; |
|
21 | - protected $status; |
|
22 | - protected $amount; |
|
23 | - protected $feeAmount; |
|
24 | - protected $currency; |
|
25 | - protected $payToEmail; |
|
26 | - protected $payFromEmail; |
|
27 | - protected $description; |
|
28 | - protected $redirectUrl; |
|
29 | - protected $validUntil; |
|
30 | - protected $token; |
|
31 | - protected $transactionId; |
|
32 | - protected $transactionCode; |
|
33 | - protected $type; |
|
34 | - protected $installments; |
|
35 | - |
|
36 | - /** |
|
37 | - * Checkout reference |
|
38 | - * |
|
39 | - * @var string |
|
40 | - */ |
|
41 | - protected $reference; |
|
42 | - |
|
43 | - /** |
|
44 | - * Customer |
|
45 | - * |
|
46 | - * @var null|Customer |
|
47 | - */ |
|
48 | - protected $customer; |
|
49 | - |
|
50 | - /** |
|
14 | + use PropertyHandler; |
|
15 | + |
|
16 | + const PENDING = 'PENDING'; |
|
17 | + const COMPLETED = 'COMPLETED'; |
|
18 | + const FAILED = 'FAILED'; |
|
19 | + |
|
20 | + protected $id; |
|
21 | + protected $status; |
|
22 | + protected $amount; |
|
23 | + protected $feeAmount; |
|
24 | + protected $currency; |
|
25 | + protected $payToEmail; |
|
26 | + protected $payFromEmail; |
|
27 | + protected $description; |
|
28 | + protected $redirectUrl; |
|
29 | + protected $validUntil; |
|
30 | + protected $token; |
|
31 | + protected $transactionId; |
|
32 | + protected $transactionCode; |
|
33 | + protected $type; |
|
34 | + protected $installments; |
|
35 | + |
|
36 | + /** |
|
37 | + * Checkout reference |
|
38 | + * |
|
39 | + * @var string |
|
40 | + */ |
|
41 | + protected $reference; |
|
42 | + |
|
43 | + /** |
|
44 | + * Customer |
|
45 | + * |
|
46 | + * @var null|Customer |
|
47 | + */ |
|
48 | + protected $customer; |
|
49 | + |
|
50 | + /** |
|
51 | 51 | * PaymentInstrument |
52 | - * |
|
53 | - * |
|
52 | + * |
|
53 | + * |
|
54 | 54 | * @var null|PaymentInstrument |
55 | - */ |
|
56 | - protected $card; |
|
55 | + */ |
|
56 | + protected $card; |
|
57 | 57 | |
58 | 58 | |
59 | - /** |
|
60 | - * checkout constructor |
|
61 | - * |
|
62 | - * @param array $data |
|
63 | - */ |
|
64 | - public function __construct(array $data = null) { |
|
65 | - if ($data !== null) { |
|
59 | + /** |
|
60 | + * checkout constructor |
|
61 | + * |
|
62 | + * @param array $data |
|
63 | + */ |
|
64 | + public function __construct(array $data = null) { |
|
65 | + if ($data !== null) { |
|
66 | 66 | $this->setAmount($data['amount']??0); |
67 | 67 | $this->setPayToEmail($data['pay_to_email']??''); |
68 | 68 | $this->setCheckoutReference($data['checkout_reference']??''); |
69 | 69 | $this->setCurrency($data['currency']??''); |
70 | - $this->setDescription($data['description']??null); |
|
71 | - $this->setFeeAmount($data['fee_amount']??null); |
|
72 | - $this->setPayFromEmail($data['pay_from_mail']??null); |
|
73 | - $this->setId($data['id']??null); |
|
74 | - $this->setRedirectUrl($data['redirect_url']??null); |
|
75 | - $this->setStatus($data['status']??null); |
|
76 | - } |
|
77 | - } |
|
78 | - |
|
79 | - /** |
|
80 | - * @inheritDoc |
|
81 | - */ |
|
82 | - public function isValid(): bool { |
|
83 | - return $this->getReference() !== null |
|
84 | - && $this->getAmount() !== null |
|
85 | - && $this->getPayToEmail() !== null |
|
70 | + $this->setDescription($data['description']??null); |
|
71 | + $this->setFeeAmount($data['fee_amount']??null); |
|
72 | + $this->setPayFromEmail($data['pay_from_mail']??null); |
|
73 | + $this->setId($data['id']??null); |
|
74 | + $this->setRedirectUrl($data['redirect_url']??null); |
|
75 | + $this->setStatus($data['status']??null); |
|
76 | + } |
|
77 | + } |
|
78 | + |
|
79 | + /** |
|
80 | + * @inheritDoc |
|
81 | + */ |
|
82 | + public function isValid(): bool { |
|
83 | + return $this->getReference() !== null |
|
84 | + && $this->getAmount() !== null |
|
85 | + && $this->getPayToEmail() !== null |
|
86 | 86 | && $this->getAmount() > 0 |
87 | - && Currency::isValid($this->getCurrency()); |
|
88 | - } |
|
89 | - |
|
90 | - /** |
|
91 | - * @inheritDoc |
|
92 | - */ |
|
93 | - public function getId():? string { |
|
94 | - return $this->id; |
|
95 | - } |
|
96 | - |
|
97 | - /** |
|
98 | - * @inheritDoc |
|
99 | - */ |
|
100 | - public function setId(?string $id): CheckoutInterface { |
|
101 | - $this->id = $id; |
|
102 | - return $this; |
|
103 | - } |
|
104 | - |
|
105 | - /** |
|
106 | - * @inheritDoc |
|
107 | - */ |
|
108 | - public function getStatus():? string { |
|
109 | - return $this->status; |
|
110 | - } |
|
111 | - |
|
112 | - /** |
|
113 | - * @inheritDoc |
|
114 | - */ |
|
115 | - public function setStatus(?string $status): CheckoutInterface { |
|
116 | - $this->status = $status; |
|
117 | - return $this; |
|
118 | - } |
|
119 | - |
|
120 | - /** |
|
121 | - * @inheritDoc |
|
122 | - */ |
|
123 | - public function getAmount():? float { |
|
124 | - return $this->amount; |
|
125 | - } |
|
126 | - |
|
127 | - /** |
|
128 | - * @inheritDoc |
|
129 | - */ |
|
130 | - public function setAmount(float $amount): CheckoutInterface { |
|
131 | - $this->amount = $amount > 0 ? $amount : null; |
|
132 | - return $this; |
|
133 | - } |
|
134 | - |
|
135 | - /** |
|
136 | - * @inheritDoc |
|
137 | - */ |
|
138 | - public function getCurrency():? string { |
|
139 | - return $this->currency; |
|
140 | - } |
|
141 | - |
|
142 | - /** |
|
143 | - * @inheritDoc |
|
144 | - */ |
|
145 | - public function setCurrency(?string $currency): CheckoutInterface { |
|
146 | - $this->currency = $currency; |
|
147 | - return $this; |
|
148 | - } |
|
149 | - |
|
150 | - /** |
|
151 | - * @inheritDoc |
|
152 | - */ |
|
153 | - public function getPayToEmail():? string { |
|
154 | - return $this->payToEmail; |
|
155 | - } |
|
156 | - |
|
157 | - /** |
|
158 | - * @inheritDoc |
|
159 | - */ |
|
160 | - public function setPayToEmail(string $email): CheckoutInterface { |
|
161 | - $this->payToEmail = trim($email) === '' ? null : $email; |
|
162 | - return $this; |
|
163 | - } |
|
164 | - |
|
165 | - /** |
|
166 | - * @inheritDoc |
|
167 | - */ |
|
168 | - public function getCheckoutReference():? string { |
|
169 | - return $this->reference; |
|
170 | - } |
|
171 | - |
|
172 | - /** |
|
173 | - * @inheritDoc |
|
174 | - */ |
|
175 | - public function setCheckoutReference(string $reference): CheckoutInterface { |
|
176 | - $this->reference = trim($reference) === '' ? null : $reference; |
|
177 | - return $this; |
|
178 | - } |
|
179 | - |
|
180 | - /** |
|
181 | - * @inheritDoc |
|
182 | - */ |
|
183 | - public function getDescription():? string { |
|
184 | - return $this->description; |
|
185 | - } |
|
186 | - |
|
187 | - /** |
|
188 | - * @inheritDoc |
|
189 | - */ |
|
190 | - public function setDescription(?string $description): CheckoutInterface { |
|
191 | - $this->description = $description; |
|
192 | - return $this; |
|
193 | - } |
|
194 | - |
|
195 | - /** |
|
196 | - * @inheritDoc |
|
197 | - */ |
|
198 | - public function getFeeAmount():? float { |
|
199 | - return $this->feeAmount; |
|
200 | - } |
|
201 | - |
|
202 | - /** |
|
203 | - * @inheritDoc |
|
204 | - */ |
|
205 | - public function setFeeAmount(?float $fee): CheckoutInterface { |
|
206 | - $this->feeAmount = $fee; |
|
207 | - return $this; |
|
208 | - } |
|
209 | - |
|
210 | - /** |
|
211 | - * @inheritDoc |
|
212 | - */ |
|
213 | - public function getPayFromEmail():? string { |
|
214 | - return $this->payFromEmail; |
|
215 | - } |
|
216 | - |
|
217 | - /** |
|
218 | - * @inheritDoc |
|
219 | - */ |
|
220 | - public function setPayFromEmail(?string $email): CheckoutInterface { |
|
221 | - $this->payFromEmail = $email; |
|
222 | - return $this; |
|
223 | - } |
|
224 | - |
|
225 | - /** |
|
226 | - * @inheritDoc |
|
227 | - */ |
|
228 | - public function getRedirectUrl():? string { |
|
229 | - return $this->redirectUrl; |
|
230 | - } |
|
231 | - |
|
232 | - /** |
|
233 | - * @inheritDoc |
|
234 | - */ |
|
235 | - public function setRedirectUrl(?string $url): CheckoutInterface { |
|
236 | - $this->redirectUrl = $url; |
|
237 | - return $this; |
|
238 | - } |
|
239 | - |
|
240 | - function getValidUntil():? string { |
|
241 | - return $this->validUntil; |
|
242 | - } |
|
243 | - |
|
244 | - function setValidUntil(?string $timestamp): CheckoutInterface { |
|
245 | - $this->validUntil = $timestamp; |
|
246 | - return $this; |
|
247 | - } |
|
248 | - |
|
249 | - function getTransactionCode():? string { |
|
250 | - return $this->transactionCode; |
|
251 | - } |
|
252 | - |
|
253 | - function setTransactionCode(?string $code): CheckoutInterface { |
|
254 | - $this->transactionCode = $code; |
|
255 | - return $this; |
|
256 | - } |
|
257 | - |
|
258 | - function getTransactionId():? string { |
|
259 | - return $this->transactionId; |
|
260 | - } |
|
261 | - |
|
262 | - function setTransactionId(?string $id): CheckoutInterface { |
|
263 | - $this->transactionId = $id; |
|
264 | - return $this; |
|
265 | - } |
|
266 | - |
|
267 | - function getTransactions():? array { |
|
87 | + && Currency::isValid($this->getCurrency()); |
|
88 | + } |
|
89 | + |
|
90 | + /** |
|
91 | + * @inheritDoc |
|
92 | + */ |
|
93 | + public function getId():? string { |
|
94 | + return $this->id; |
|
95 | + } |
|
96 | + |
|
97 | + /** |
|
98 | + * @inheritDoc |
|
99 | + */ |
|
100 | + public function setId(?string $id): CheckoutInterface { |
|
101 | + $this->id = $id; |
|
102 | + return $this; |
|
103 | + } |
|
104 | + |
|
105 | + /** |
|
106 | + * @inheritDoc |
|
107 | + */ |
|
108 | + public function getStatus():? string { |
|
109 | + return $this->status; |
|
110 | + } |
|
111 | + |
|
112 | + /** |
|
113 | + * @inheritDoc |
|
114 | + */ |
|
115 | + public function setStatus(?string $status): CheckoutInterface { |
|
116 | + $this->status = $status; |
|
117 | + return $this; |
|
118 | + } |
|
119 | + |
|
120 | + /** |
|
121 | + * @inheritDoc |
|
122 | + */ |
|
123 | + public function getAmount():? float { |
|
124 | + return $this->amount; |
|
125 | + } |
|
126 | + |
|
127 | + /** |
|
128 | + * @inheritDoc |
|
129 | + */ |
|
130 | + public function setAmount(float $amount): CheckoutInterface { |
|
131 | + $this->amount = $amount > 0 ? $amount : null; |
|
132 | + return $this; |
|
133 | + } |
|
134 | + |
|
135 | + /** |
|
136 | + * @inheritDoc |
|
137 | + */ |
|
138 | + public function getCurrency():? string { |
|
139 | + return $this->currency; |
|
140 | + } |
|
141 | + |
|
142 | + /** |
|
143 | + * @inheritDoc |
|
144 | + */ |
|
145 | + public function setCurrency(?string $currency): CheckoutInterface { |
|
146 | + $this->currency = $currency; |
|
147 | + return $this; |
|
148 | + } |
|
149 | + |
|
150 | + /** |
|
151 | + * @inheritDoc |
|
152 | + */ |
|
153 | + public function getPayToEmail():? string { |
|
154 | + return $this->payToEmail; |
|
155 | + } |
|
156 | + |
|
157 | + /** |
|
158 | + * @inheritDoc |
|
159 | + */ |
|
160 | + public function setPayToEmail(string $email): CheckoutInterface { |
|
161 | + $this->payToEmail = trim($email) === '' ? null : $email; |
|
162 | + return $this; |
|
163 | + } |
|
164 | + |
|
165 | + /** |
|
166 | + * @inheritDoc |
|
167 | + */ |
|
168 | + public function getCheckoutReference():? string { |
|
169 | + return $this->reference; |
|
170 | + } |
|
171 | + |
|
172 | + /** |
|
173 | + * @inheritDoc |
|
174 | + */ |
|
175 | + public function setCheckoutReference(string $reference): CheckoutInterface { |
|
176 | + $this->reference = trim($reference) === '' ? null : $reference; |
|
177 | + return $this; |
|
178 | + } |
|
179 | + |
|
180 | + /** |
|
181 | + * @inheritDoc |
|
182 | + */ |
|
183 | + public function getDescription():? string { |
|
184 | + return $this->description; |
|
185 | + } |
|
186 | + |
|
187 | + /** |
|
188 | + * @inheritDoc |
|
189 | + */ |
|
190 | + public function setDescription(?string $description): CheckoutInterface { |
|
191 | + $this->description = $description; |
|
192 | + return $this; |
|
193 | + } |
|
194 | + |
|
195 | + /** |
|
196 | + * @inheritDoc |
|
197 | + */ |
|
198 | + public function getFeeAmount():? float { |
|
199 | + return $this->feeAmount; |
|
200 | + } |
|
201 | + |
|
202 | + /** |
|
203 | + * @inheritDoc |
|
204 | + */ |
|
205 | + public function setFeeAmount(?float $fee): CheckoutInterface { |
|
206 | + $this->feeAmount = $fee; |
|
207 | + return $this; |
|
208 | + } |
|
209 | + |
|
210 | + /** |
|
211 | + * @inheritDoc |
|
212 | + */ |
|
213 | + public function getPayFromEmail():? string { |
|
214 | + return $this->payFromEmail; |
|
215 | + } |
|
216 | + |
|
217 | + /** |
|
218 | + * @inheritDoc |
|
219 | + */ |
|
220 | + public function setPayFromEmail(?string $email): CheckoutInterface { |
|
221 | + $this->payFromEmail = $email; |
|
222 | + return $this; |
|
223 | + } |
|
224 | + |
|
225 | + /** |
|
226 | + * @inheritDoc |
|
227 | + */ |
|
228 | + public function getRedirectUrl():? string { |
|
229 | + return $this->redirectUrl; |
|
230 | + } |
|
231 | + |
|
232 | + /** |
|
233 | + * @inheritDoc |
|
234 | + */ |
|
235 | + public function setRedirectUrl(?string $url): CheckoutInterface { |
|
236 | + $this->redirectUrl = $url; |
|
237 | + return $this; |
|
238 | + } |
|
239 | + |
|
240 | + function getValidUntil():? string { |
|
241 | + return $this->validUntil; |
|
242 | + } |
|
243 | + |
|
244 | + function setValidUntil(?string $timestamp): CheckoutInterface { |
|
245 | + $this->validUntil = $timestamp; |
|
246 | + return $this; |
|
247 | + } |
|
248 | + |
|
249 | + function getTransactionCode():? string { |
|
250 | + return $this->transactionCode; |
|
251 | + } |
|
252 | + |
|
253 | + function setTransactionCode(?string $code): CheckoutInterface { |
|
254 | + $this->transactionCode = $code; |
|
255 | + return $this; |
|
256 | + } |
|
257 | + |
|
258 | + function getTransactionId():? string { |
|
259 | + return $this->transactionId; |
|
260 | + } |
|
261 | + |
|
262 | + function setTransactionId(?string $id): CheckoutInterface { |
|
263 | + $this->transactionId = $id; |
|
264 | + return $this; |
|
265 | + } |
|
266 | + |
|
267 | + function getTransactions():? array { |
|
268 | 268 | // return $this->transactions; |
269 | - //TODO remember myself whats is it. |
|
270 | - return []; |
|
271 | - } |
|
269 | + //TODO remember myself whats is it. |
|
270 | + return []; |
|
271 | + } |
|
272 | 272 | |
273 | - function setTransactions(?Array $transactions): CheckoutInterface { |
|
273 | + function setTransactions(?Array $transactions): CheckoutInterface { |
|
274 | 274 | // $this->transactions = $transactions; |
275 | - //TODO remember myself whats is it. |
|
276 | - return $this; |
|
277 | - } |
|
278 | - |
|
279 | - function getToken():? string { |
|
280 | - return $this->token; |
|
281 | - } |
|
282 | - |
|
283 | - function setToken(?string $token): CheckoutInterface { |
|
284 | - $this->token = $token; |
|
285 | - return $this; |
|
286 | - } |
|
287 | - |
|
288 | - /** |
|
289 | - * Get customer |
|
290 | - * @return CustomerInterface|null |
|
291 | - */ |
|
292 | - public function getCustomer(): ?CustomerInterface |
|
293 | - { |
|
294 | - return $this->customer; |
|
295 | - } |
|
296 | - |
|
297 | - /** |
|
298 | - * Set customer |
|
299 | - * |
|
300 | - * @param null|CustomerInterface $customer Customer |
|
301 | - * |
|
302 | - * @return CheckoutInterface |
|
303 | - */ |
|
304 | - public function setCustomer(?CustomerInterface $customer): CheckoutInterface |
|
305 | - { |
|
306 | - $this->customer = $customer; |
|
307 | - |
|
308 | - return $this; |
|
309 | - } |
|
310 | - |
|
311 | - /** |
|
312 | - * Get card |
|
313 | - * |
|
275 | + //TODO remember myself whats is it. |
|
276 | + return $this; |
|
277 | + } |
|
278 | + |
|
279 | + function getToken():? string { |
|
280 | + return $this->token; |
|
281 | + } |
|
282 | + |
|
283 | + function setToken(?string $token): CheckoutInterface { |
|
284 | + $this->token = $token; |
|
285 | + return $this; |
|
286 | + } |
|
287 | + |
|
288 | + /** |
|
289 | + * Get customer |
|
290 | + * @return CustomerInterface|null |
|
291 | + */ |
|
292 | + public function getCustomer(): ?CustomerInterface |
|
293 | + { |
|
294 | + return $this->customer; |
|
295 | + } |
|
296 | + |
|
297 | + /** |
|
298 | + * Set customer |
|
299 | + * |
|
300 | + * @param null|CustomerInterface $customer Customer |
|
301 | + * |
|
302 | + * @return CheckoutInterface |
|
303 | + */ |
|
304 | + public function setCustomer(?CustomerInterface $customer): CheckoutInterface |
|
305 | + { |
|
306 | + $this->customer = $customer; |
|
307 | + |
|
308 | + return $this; |
|
309 | + } |
|
310 | + |
|
311 | + /** |
|
312 | + * Get card |
|
313 | + * |
|
314 | 314 | * @return null|PaymentInstrumentInterface |
315 | - */ |
|
315 | + */ |
|
316 | 316 | public function getCard(): ?PaymentInstrumentInterface |
317 | - { |
|
318 | - return $this->card; |
|
319 | - } |
|
317 | + { |
|
318 | + return $this->card; |
|
319 | + } |
|
320 | 320 | |
321 | - /** |
|
322 | - * Set card |
|
323 | - * |
|
321 | + /** |
|
322 | + * Set card |
|
323 | + * |
|
324 | 324 | * @param null|PaymentInstrumentInterface $card |
325 | - * |
|
326 | - * @return CheckoutInterface |
|
327 | - */ |
|
325 | + * |
|
326 | + * @return CheckoutInterface |
|
327 | + */ |
|
328 | 328 | public function setCard(?PaymentInstrumentInterface $card): CheckoutInterface |
329 | - { |
|
330 | - $this->card = $card; |
|
331 | - |
|
332 | - return $this; |
|
333 | - } |
|
334 | - |
|
335 | - /** |
|
336 | - * Get checkout reference |
|
337 | - * |
|
338 | - * @return string |
|
339 | - */ |
|
340 | - public function getReference(): ?string |
|
341 | - { |
|
342 | - return $this->reference; |
|
343 | - } |
|
344 | - |
|
345 | - /** |
|
346 | - * Set checkout reference |
|
347 | - * |
|
348 | - * @param string $reference Checkout reference |
|
349 | - * |
|
350 | - * @return CheckoutInterface |
|
351 | - */ |
|
352 | - public function setReference(?string $reference): CheckoutInterface |
|
353 | - { |
|
354 | - $this->reference = $reference; |
|
355 | - |
|
356 | - return $this; |
|
357 | - } |
|
358 | - |
|
359 | - /** |
|
360 | - * @return mixed |
|
361 | - */ |
|
362 | - public function getType():? string |
|
363 | - { |
|
364 | - return $this->type; |
|
365 | - } |
|
366 | - |
|
367 | - /** |
|
368 | - * @param mixed $type |
|
369 | - * @return CheckoutInterface |
|
370 | - */ |
|
371 | - public function setType(?string $type = null): CheckoutInterface |
|
372 | - { |
|
373 | - $this->type = $type; |
|
374 | - |
|
375 | - return $this; |
|
376 | - } |
|
377 | - |
|
378 | - public function setInstallments(?string $installments): CheckoutInterface{ |
|
379 | - $this->installments = $installments; |
|
380 | - return $this; |
|
381 | - } |
|
382 | - |
|
383 | - public function getInstallments(): string |
|
384 | - { |
|
385 | - return $this->installments; |
|
386 | - } |
|
329 | + { |
|
330 | + $this->card = $card; |
|
331 | + |
|
332 | + return $this; |
|
333 | + } |
|
334 | + |
|
335 | + /** |
|
336 | + * Get checkout reference |
|
337 | + * |
|
338 | + * @return string |
|
339 | + */ |
|
340 | + public function getReference(): ?string |
|
341 | + { |
|
342 | + return $this->reference; |
|
343 | + } |
|
344 | + |
|
345 | + /** |
|
346 | + * Set checkout reference |
|
347 | + * |
|
348 | + * @param string $reference Checkout reference |
|
349 | + * |
|
350 | + * @return CheckoutInterface |
|
351 | + */ |
|
352 | + public function setReference(?string $reference): CheckoutInterface |
|
353 | + { |
|
354 | + $this->reference = $reference; |
|
355 | + |
|
356 | + return $this; |
|
357 | + } |
|
358 | + |
|
359 | + /** |
|
360 | + * @return mixed |
|
361 | + */ |
|
362 | + public function getType():? string |
|
363 | + { |
|
364 | + return $this->type; |
|
365 | + } |
|
366 | + |
|
367 | + /** |
|
368 | + * @param mixed $type |
|
369 | + * @return CheckoutInterface |
|
370 | + */ |
|
371 | + public function setType(?string $type = null): CheckoutInterface |
|
372 | + { |
|
373 | + $this->type = $type; |
|
374 | + |
|
375 | + return $this; |
|
376 | + } |
|
377 | + |
|
378 | + public function setInstallments(?string $installments): CheckoutInterface{ |
|
379 | + $this->installments = $installments; |
|
380 | + return $this; |
|
381 | + } |
|
382 | + |
|
383 | + public function getInstallments(): string |
|
384 | + { |
|
385 | + return $this->installments; |
|
386 | + } |
|
387 | 387 | |
388 | 388 | } |
@@ -13,9 +13,9 @@ |
||
13 | 13 | |
14 | 14 | class NotAllowedProperty extends \RuntimeException |
15 | 15 | { |
16 | - public function __construct($object, $property, Throwable $previous = null) |
|
17 | - { |
|
18 | - $message = sprintf('Not allowed property %s into %s class!', $property,get_class($object)); |
|
19 | - parent::__construct($message, 100, $previous); |
|
20 | - } |
|
16 | + public function __construct($object, $property, Throwable $previous = null) |
|
17 | + { |
|
18 | + $message = sprintf('Not allowed property %s into %s class!', $property,get_class($object)); |
|
19 | + parent::__construct($message, 100, $previous); |
|
20 | + } |
|
21 | 21 | } |
@@ -15,7 +15,7 @@ |
||
15 | 15 | { |
16 | 16 | public function __construct($object, $property, Throwable $previous = null) |
17 | 17 | { |
18 | - $message = sprintf('Not allowed property %s into %s class!', $property,get_class($object)); |
|
18 | + $message = sprintf('Not allowed property %s into %s class!', $property, get_class($object)); |
|
19 | 19 | parent::__construct($message, 100, $previous); |
20 | 20 | } |
21 | 21 | } |
@@ -68,5 +68,5 @@ |
||
68 | 68 | /** |
69 | 69 | * @return AccessToken |
70 | 70 | */ |
71 | - function getToken():? AccessToken; |
|
71 | + function getToken(): ? AccessToken; |
|
72 | 72 | } |
@@ -20,12 +20,12 @@ discard block |
||
20 | 20 | * @param integer $expiresIn |
21 | 21 | * @param string|null $scope |
22 | 22 | */ |
23 | - function __construct(string $token, string $type, int $expiresIn, string $scope = null){ |
|
23 | + function __construct(string $token, string $type, int $expiresIn, string $scope = null) { |
|
24 | 24 | $this->token = $token; |
25 | 25 | $this->type = $type; |
26 | 26 | $this->expiration = time() + $expiresIn; |
27 | 27 | |
28 | - if($scope !== null) { |
|
28 | + if ($scope !== null) { |
|
29 | 29 | $this->scope = $scope; |
30 | 30 | } |
31 | 31 | } |
@@ -86,9 +86,9 @@ discard block |
||
86 | 86 | * @param string $scope[,$scope[,$scope[,...]]] |
87 | 87 | * @return boolean |
88 | 88 | */ |
89 | - function canAccess(string $scope){ |
|
89 | + function canAccess(string $scope) { |
|
90 | 90 | $scopes = func_get_args(); |
91 | 91 | $diff = array_diff($scopes, $this->scope); |
92 | - return count($diff)>0; |
|
92 | + return count($diff) > 0; |
|
93 | 93 | } |
94 | 94 | } |
@@ -7,8 +7,8 @@ discard block |
||
7 | 7 | class InvalidCheckoutException extends \RuntimeException |
8 | 8 | { |
9 | 9 | public function __construct(CheckoutInterface $checkout, $code = 10, Throwable $previous = null) |
10 | - { |
|
11 | - $message = sprintf(<<<MSG |
|
10 | + { |
|
11 | + $message = sprintf(<<<MSG |
|
12 | 12 | Something is wrong with this checkout: |
13 | 13 | checkout_reference: %s |
14 | 14 | amount: %s |
@@ -19,6 +19,6 @@ discard block |
||
19 | 19 | $checkout->getAmount(), |
20 | 20 | $checkout->getPayToEmail() |
21 | 21 | ); |
22 | - parent::__construct($message, $code, $previous); |
|
23 | - } |
|
22 | + parent::__construct($message, $code, $previous); |
|
23 | + } |
|
24 | 24 | } |