@@ -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 | } |
@@ -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 | } |
@@ -4,132 +4,132 @@ |
||
4 | 4 | |
5 | 5 | class Customer implements CustomerInterface |
6 | 6 | { |
7 | - /** |
|
8 | - * Customer SumUp ID |
|
9 | - * |
|
10 | - * @var string |
|
11 | - */ |
|
12 | - protected $customerId; |
|
13 | - |
|
14 | - /** |
|
15 | - * Customer Name |
|
16 | - * |
|
17 | - * @var string |
|
18 | - */ |
|
19 | - protected $name; |
|
20 | - |
|
21 | - /** |
|
22 | - * Customer phone |
|
23 | - * |
|
24 | - * @var string |
|
25 | - */ |
|
26 | - protected $phone; |
|
27 | - |
|
28 | - /** |
|
29 | - * Cusomter address |
|
30 | - * |
|
31 | - * @var AddressInterface |
|
32 | - */ |
|
33 | - protected $address; |
|
34 | - |
|
35 | - function __construct(?array $data = []) |
|
36 | - { |
|
37 | - $this->setCustomerId($data['customer_id']??null); |
|
38 | - $personal_details = $data['personal_details']??$data; |
|
39 | - $this->setName($personal_details['name']??null); |
|
40 | - $this->setPhone($personal_details['phone']??null); |
|
41 | - $this->setAddress(new Address($personal_details['address']??null)); |
|
42 | - } |
|
43 | - |
|
44 | - /** |
|
45 | - * Get customer SumUp ID |
|
46 | - * |
|
47 | - * @return string |
|
48 | - */ |
|
49 | - public function getCustomerId(): ?string |
|
50 | - { |
|
51 | - return $this->customerId; |
|
52 | - } |
|
53 | - |
|
54 | - /** |
|
55 | - * Set customer SumUp ID |
|
56 | - * |
|
57 | - * @param string $customerId Customer SumUp ID |
|
58 | - * @return CustomerInterface |
|
59 | - */ |
|
60 | - public function setCustomerId(?string $customerId): CustomerInterface |
|
61 | - { |
|
62 | - $this->customerId = $customerId; |
|
63 | - |
|
64 | - return $this; |
|
65 | - } |
|
66 | - |
|
67 | - /** |
|
68 | - * Get customer Name |
|
69 | - * |
|
70 | - * @return string |
|
71 | - */ |
|
72 | - public function getName(): ?string |
|
73 | - { |
|
74 | - return $this->name; |
|
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * Set customer Name |
|
79 | - * |
|
7 | + /** |
|
8 | + * Customer SumUp ID |
|
9 | + * |
|
10 | + * @var string |
|
11 | + */ |
|
12 | + protected $customerId; |
|
13 | + |
|
14 | + /** |
|
15 | + * Customer Name |
|
16 | + * |
|
17 | + * @var string |
|
18 | + */ |
|
19 | + protected $name; |
|
20 | + |
|
21 | + /** |
|
22 | + * Customer phone |
|
23 | + * |
|
24 | + * @var string |
|
25 | + */ |
|
26 | + protected $phone; |
|
27 | + |
|
28 | + /** |
|
29 | + * Cusomter address |
|
30 | + * |
|
31 | + * @var AddressInterface |
|
32 | + */ |
|
33 | + protected $address; |
|
34 | + |
|
35 | + function __construct(?array $data = []) |
|
36 | + { |
|
37 | + $this->setCustomerId($data['customer_id']??null); |
|
38 | + $personal_details = $data['personal_details']??$data; |
|
39 | + $this->setName($personal_details['name']??null); |
|
40 | + $this->setPhone($personal_details['phone']??null); |
|
41 | + $this->setAddress(new Address($personal_details['address']??null)); |
|
42 | + } |
|
43 | + |
|
44 | + /** |
|
45 | + * Get customer SumUp ID |
|
46 | + * |
|
47 | + * @return string |
|
48 | + */ |
|
49 | + public function getCustomerId(): ?string |
|
50 | + { |
|
51 | + return $this->customerId; |
|
52 | + } |
|
53 | + |
|
54 | + /** |
|
55 | + * Set customer SumUp ID |
|
56 | + * |
|
57 | + * @param string $customerId Customer SumUp ID |
|
58 | + * @return CustomerInterface |
|
59 | + */ |
|
60 | + public function setCustomerId(?string $customerId): CustomerInterface |
|
61 | + { |
|
62 | + $this->customerId = $customerId; |
|
63 | + |
|
64 | + return $this; |
|
65 | + } |
|
66 | + |
|
67 | + /** |
|
68 | + * Get customer Name |
|
69 | + * |
|
70 | + * @return string |
|
71 | + */ |
|
72 | + public function getName(): ?string |
|
73 | + { |
|
74 | + return $this->name; |
|
75 | + } |
|
76 | + |
|
77 | + /** |
|
78 | + * Set customer Name |
|
79 | + * |
|
80 | 80 | * @param string $name Customer Name |
81 | 81 | * @return Customer|CustomerInterface |
82 | - */ |
|
83 | - public function setName(?string $name): CustomerInterface |
|
84 | - { |
|
85 | - $this->name = $name; |
|
86 | - |
|
87 | - return $this; |
|
88 | - } |
|
89 | - |
|
90 | - /** |
|
91 | - * Get customer phone |
|
92 | - * |
|
93 | - * @return string |
|
94 | - */ |
|
95 | - public function getPhone(): ?string |
|
96 | - { |
|
97 | - return $this->phone; |
|
98 | - } |
|
99 | - |
|
100 | - /** |
|
101 | - * Set customer phone |
|
102 | - * |
|
82 | + */ |
|
83 | + public function setName(?string $name): CustomerInterface |
|
84 | + { |
|
85 | + $this->name = $name; |
|
86 | + |
|
87 | + return $this; |
|
88 | + } |
|
89 | + |
|
90 | + /** |
|
91 | + * Get customer phone |
|
92 | + * |
|
93 | + * @return string |
|
94 | + */ |
|
95 | + public function getPhone(): ?string |
|
96 | + { |
|
97 | + return $this->phone; |
|
98 | + } |
|
99 | + |
|
100 | + /** |
|
101 | + * Set customer phone |
|
102 | + * |
|
103 | 103 | * @param string $phone Customer phone |
104 | 104 | * @return Customer|CustomerInterface |
105 | - */ |
|
106 | - public function setPhone(?string $phone): CustomerInterface |
|
107 | - { |
|
108 | - $this->phone = $phone; |
|
109 | - |
|
110 | - return $this; |
|
111 | - } |
|
112 | - |
|
113 | - /** |
|
114 | - * Get cusomter address |
|
115 | - * |
|
116 | - * @return AddressInterface |
|
117 | - */ |
|
118 | - public function getAddress(): AddressInterface |
|
119 | - { |
|
120 | - return $this->address; |
|
121 | - } |
|
122 | - |
|
123 | - /** |
|
124 | - * Set cusomter address |
|
125 | - * |
|
126 | - * @param AddressInterface $address |
|
127 | - * @return Customer|CustomerInterface |
|
128 | - */ |
|
129 | - public function setAddress(AddressInterface $address): CustomerInterface |
|
130 | - { |
|
131 | - $this->address = $address; |
|
132 | - return $this; |
|
133 | - } |
|
105 | + */ |
|
106 | + public function setPhone(?string $phone): CustomerInterface |
|
107 | + { |
|
108 | + $this->phone = $phone; |
|
109 | + |
|
110 | + return $this; |
|
111 | + } |
|
112 | + |
|
113 | + /** |
|
114 | + * Get cusomter address |
|
115 | + * |
|
116 | + * @return AddressInterface |
|
117 | + */ |
|
118 | + public function getAddress(): AddressInterface |
|
119 | + { |
|
120 | + return $this->address; |
|
121 | + } |
|
122 | + |
|
123 | + /** |
|
124 | + * Set cusomter address |
|
125 | + * |
|
126 | + * @param AddressInterface $address |
|
127 | + * @return Customer|CustomerInterface |
|
128 | + */ |
|
129 | + public function setAddress(AddressInterface $address): CustomerInterface |
|
130 | + { |
|
131 | + $this->address = $address; |
|
132 | + return $this; |
|
133 | + } |
|
134 | 134 | |
135 | 135 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | |
7 | 7 | interface CheckoutClientInterface extends SumUpClientInterface |
8 | 8 | { |
9 | - /** |
|
9 | + /** |
|
10 | 10 | * Create a checkout |
11 | 11 | * |
12 | 12 | * @param CheckoutInterface $checkout |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | /** |
28 | 28 | * @param CheckoutInterface $checkout |
29 | 29 | * @return string |
30 | - */ |
|
30 | + */ |
|
31 | 31 | static function getCompleteUrl(CheckoutInterface $checkout): string; |
32 | 32 | |
33 | 33 | } |
@@ -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 | } |
@@ -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 |
@@ -11,48 +11,48 @@ |
||
11 | 11 | |
12 | 12 | trait PropertyHandler |
13 | 13 | { |
14 | - /** |
|
15 | - * @param array $data |
|
16 | - */ |
|
14 | + /** |
|
15 | + * @param array $data |
|
16 | + */ |
|
17 | 17 | function fillProperties(array $data): void |
18 | - { |
|
19 | - foreach ($data as $p => $v) |
|
20 | - { |
|
21 | - $this->fillProperty($p, $v); |
|
22 | - } |
|
23 | - } |
|
18 | + { |
|
19 | + foreach ($data as $p => $v) |
|
20 | + { |
|
21 | + $this->fillProperty($p, $v); |
|
22 | + } |
|
23 | + } |
|
24 | 24 | |
25 | - /** |
|
26 | - * @param string $property |
|
27 | - * @param mixed $value |
|
28 | - */ |
|
25 | + /** |
|
26 | + * @param string $property |
|
27 | + * @param mixed $value |
|
28 | + */ |
|
29 | 29 | function fillProperty(string $property, $value): void |
30 | - { |
|
31 | - $property = lcfirst(str_replace('_', '', ucwords($property, '_'))); |
|
32 | - if(property_exists(__CLASS__, $property)) |
|
33 | - { |
|
34 | - $method = sprintf('set%s', ucfirst($property)); |
|
35 | - $this->{$method}($value); |
|
36 | - } |
|
37 | - } |
|
30 | + { |
|
31 | + $property = lcfirst(str_replace('_', '', ucwords($property, '_'))); |
|
32 | + if(property_exists(__CLASS__, $property)) |
|
33 | + { |
|
34 | + $method = sprintf('set%s', ucfirst($property)); |
|
35 | + $this->{$method}($value); |
|
36 | + } |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * @return array |
|
41 | - */ |
|
42 | - function getPropertyArray(): array |
|
43 | - { |
|
44 | - $reflection = new \ReflectionClass(__CLASS__); |
|
45 | - $properties = $reflection->getProperties(\ReflectionProperty::IS_PROTECTED); |
|
46 | - $data = []; |
|
47 | - foreach($properties as $property){ |
|
48 | - $prop_name = $property->getName(); |
|
49 | - $method = sprintf('get%s', ucfirst($prop_name)); |
|
50 | - $form_name = strtolower(preg_replace('/[A-Z]/', '_$0', $prop_name)); |
|
51 | - if($reflection->hasMethod($method)){ |
|
52 | - $data[$form_name] = $this->{$method}(); |
|
53 | - } |
|
54 | - } |
|
55 | - return $data; |
|
56 | - } |
|
39 | + /** |
|
40 | + * @return array |
|
41 | + */ |
|
42 | + function getPropertyArray(): array |
|
43 | + { |
|
44 | + $reflection = new \ReflectionClass(__CLASS__); |
|
45 | + $properties = $reflection->getProperties(\ReflectionProperty::IS_PROTECTED); |
|
46 | + $data = []; |
|
47 | + foreach($properties as $property){ |
|
48 | + $prop_name = $property->getName(); |
|
49 | + $method = sprintf('get%s', ucfirst($prop_name)); |
|
50 | + $form_name = strtolower(preg_replace('/[A-Z]/', '_$0', $prop_name)); |
|
51 | + if($reflection->hasMethod($method)){ |
|
52 | + $data[$form_name] = $this->{$method}(); |
|
53 | + } |
|
54 | + } |
|
55 | + return $data; |
|
56 | + } |
|
57 | 57 | |
58 | 58 | } |
@@ -22,71 +22,71 @@ discard block |
||
22 | 22 | request as protected traitRequest; |
23 | 23 | } |
24 | 24 | |
25 | - protected $context; |
|
26 | - protected $lastResponse; |
|
25 | + protected $context; |
|
26 | + protected $lastResponse; |
|
27 | 27 | protected $options = []; |
28 | 28 | protected $currentToken; |
29 | 29 | |
30 | 30 | function __construct(ContextInterface $context, ?array $options = []) |
31 | - { |
|
32 | - $this->context = $context; |
|
31 | + { |
|
32 | + $this->context = $context; |
|
33 | 33 | $this->options = $options; |
34 | - } |
|
34 | + } |
|
35 | 35 | |
36 | - /** |
|
37 | - * @inheritDoc |
|
38 | - * @throws BadResponseException |
|
39 | - * @throws ConnectException |
|
40 | - */ |
|
36 | + /** |
|
37 | + * @inheritDoc |
|
38 | + * @throws BadResponseException |
|
39 | + * @throws ConnectException |
|
40 | + */ |
|
41 | 41 | function create(CheckoutInterface $checkout, AccessToken $accessToken = null):? CheckoutInterface |
42 | - { |
|
42 | + { |
|
43 | 43 | return $this->request('post', $checkout) ? $checkout : null; |
44 | - } |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * @inheritDoc |
|
48 | - * @throws BadResponseException |
|
49 | - * @throws ConnectException |
|
50 | - */ |
|
46 | + /** |
|
47 | + * @inheritDoc |
|
48 | + * @throws BadResponseException |
|
49 | + * @throws ConnectException |
|
50 | + */ |
|
51 | 51 | function complete(CheckoutInterface $checkout, AccessToken $accessToken = null):? CheckoutInterface |
52 | - { |
|
52 | + { |
|
53 | 53 | return $this->request('put', $checkout) ? $checkout : null; |
54 | - } |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @param string $action |
|
58 | - * @param CheckoutInterface $checkout |
|
56 | + /** |
|
57 | + * @param string $action |
|
58 | + * @param CheckoutInterface $checkout |
|
59 | 59 | * @param string|null $endpoint |
60 | - * @return bool|null |
|
61 | - */ |
|
60 | + * @return bool|null |
|
61 | + */ |
|
62 | 62 | function request(string $action, $checkout, string $endpoint = null):? bool |
63 | - { |
|
63 | + { |
|
64 | 64 | if (!$checkout->isValid()) { |
65 | 65 | throw new InvalidCheckoutException($checkout); |
66 | - } |
|
66 | + } |
|
67 | 67 | |
68 | 68 | return $this->traitRequest($action, $checkout); |
69 | - } |
|
70 | - |
|
71 | - /** |
|
72 | - * Generate a body to create a new checkout |
|
73 | - * |
|
74 | - * @param CheckoutInterface $checkout |
|
75 | - * @return array |
|
76 | - */ |
|
69 | + } |
|
70 | + |
|
71 | + /** |
|
72 | + * Generate a body to create a new checkout |
|
73 | + * |
|
74 | + * @param CheckoutInterface $checkout |
|
75 | + * @return array |
|
76 | + */ |
|
77 | 77 | protected static function getCheckoutBody(CheckoutInterface $checkout): array |
78 | - { |
|
79 | - return [ |
|
80 | - "checkout_reference" => $checkout->getReference(), |
|
81 | - "amount" => $checkout->getAmount(), |
|
82 | - "currency" => $checkout->getCurrency(), |
|
83 | - "fee_amount" => $checkout->getFeeAmount(), |
|
84 | - "pay_to_email" => $checkout->getPayToEmail(), |
|
85 | - "pay_from_email" => $checkout->getPayFromEmail(), |
|
86 | - "description" => $checkout->getDescription(), |
|
87 | - "return_url" => $checkout->getRedirectUrl(), |
|
88 | - ]; |
|
89 | - } |
|
78 | + { |
|
79 | + return [ |
|
80 | + "checkout_reference" => $checkout->getReference(), |
|
81 | + "amount" => $checkout->getAmount(), |
|
82 | + "currency" => $checkout->getCurrency(), |
|
83 | + "fee_amount" => $checkout->getFeeAmount(), |
|
84 | + "pay_to_email" => $checkout->getPayToEmail(), |
|
85 | + "pay_from_email" => $checkout->getPayFromEmail(), |
|
86 | + "description" => $checkout->getDescription(), |
|
87 | + "return_url" => $checkout->getRedirectUrl(), |
|
88 | + ]; |
|
89 | + } |
|
90 | 90 | |
91 | 91 | /** |
92 | 92 | * @param CheckoutInterface $checkout |
@@ -94,74 +94,74 @@ discard block |
||
94 | 94 | * @return array |
95 | 95 | */ |
96 | 96 | static function getBody($checkout, string $type = null): array |
97 | - { |
|
98 | - $defaultBody = self::getCheckoutBody($checkout); |
|
99 | - switch ($checkout->getType()) { |
|
100 | - case 'card': |
|
101 | - $completeBody = self::getCardBody($checkout); |
|
102 | - break; |
|
103 | - |
|
104 | - case 'boleto': |
|
105 | - $completeBody = self::getBoletoBody($checkout); |
|
106 | - break; |
|
107 | - |
|
108 | - default: |
|
109 | - $completeBody = []; |
|
110 | - } |
|
111 | - |
|
112 | - return array_merge($defaultBody, $completeBody); |
|
113 | - } |
|
114 | - |
|
115 | - private static function getCardBody(CheckoutInterface $checkout): array |
|
116 | - { |
|
117 | - return [ |
|
118 | - 'payment_type' => $checkout->getType(), |
|
119 | - 'token' => $checkout->getCard()->getToken(), |
|
120 | - 'customer_id' => $checkout->getCustomer()->getCustomerId() |
|
121 | - ]; |
|
122 | - } |
|
123 | - |
|
124 | - private static function getBoletoBody(CheckoutInterface $checkout): array |
|
125 | - { |
|
126 | - $customer = $checkout->getCustomer(); |
|
127 | - return [ |
|
128 | - 'payment_type' => $checkout->getType(), |
|
129 | - 'description' => $checkout->getDescription(), |
|
130 | - 'boleto_details' => [ |
|
97 | + { |
|
98 | + $defaultBody = self::getCheckoutBody($checkout); |
|
99 | + switch ($checkout->getType()) { |
|
100 | + case 'card': |
|
101 | + $completeBody = self::getCardBody($checkout); |
|
102 | + break; |
|
103 | + |
|
104 | + case 'boleto': |
|
105 | + $completeBody = self::getBoletoBody($checkout); |
|
106 | + break; |
|
107 | + |
|
108 | + default: |
|
109 | + $completeBody = []; |
|
110 | + } |
|
111 | + |
|
112 | + return array_merge($defaultBody, $completeBody); |
|
113 | + } |
|
114 | + |
|
115 | + private static function getCardBody(CheckoutInterface $checkout): array |
|
116 | + { |
|
117 | + return [ |
|
118 | + 'payment_type' => $checkout->getType(), |
|
119 | + 'token' => $checkout->getCard()->getToken(), |
|
120 | + 'customer_id' => $checkout->getCustomer()->getCustomerId() |
|
121 | + ]; |
|
122 | + } |
|
123 | + |
|
124 | + private static function getBoletoBody(CheckoutInterface $checkout): array |
|
125 | + { |
|
126 | + $customer = $checkout->getCustomer(); |
|
127 | + return [ |
|
128 | + 'payment_type' => $checkout->getType(), |
|
129 | + 'description' => $checkout->getDescription(), |
|
130 | + 'boleto_details' => [ |
|
131 | 131 | // 'cpf_cnpj' => $customer->getCpfCnpj(), |
132 | - 'payer_name' => $customer->getName(), |
|
133 | - 'payer_address' => $customer->getAddress(), |
|
134 | - 'payer_city' => $customer->getAddress()->getCity(), |
|
135 | - 'payer_state_code' => $customer->getAddress()->getState(), |
|
136 | - 'payer_post_code' => $customer->getAddress()->getPostalCode() |
|
137 | - ], |
|
138 | - ]; |
|
139 | - } |
|
140 | - |
|
141 | - /** |
|
142 | - * @inheritDoc |
|
143 | - */ |
|
132 | + 'payer_name' => $customer->getName(), |
|
133 | + 'payer_address' => $customer->getAddress(), |
|
134 | + 'payer_city' => $customer->getAddress()->getCity(), |
|
135 | + 'payer_state_code' => $customer->getAddress()->getState(), |
|
136 | + 'payer_post_code' => $customer->getAddress()->getPostalCode() |
|
137 | + ], |
|
138 | + ]; |
|
139 | + } |
|
140 | + |
|
141 | + /** |
|
142 | + * @inheritDoc |
|
143 | + */ |
|
144 | 144 | static function getScopes(): array |
145 | - { |
|
146 | - return [ |
|
147 | - 'payments', |
|
148 | - 'boleto' |
|
149 | - ]; |
|
150 | - } |
|
151 | - |
|
152 | - function getLastResponse(): ResponseInterface |
|
153 | - { |
|
154 | - return $this->lastResponse; |
|
155 | - } |
|
156 | - |
|
157 | - /** |
|
158 | - * return the context used to created the client. |
|
159 | - * @return ContextInterface |
|
160 | - */ |
|
161 | - function getContext(): ContextInterface |
|
162 | - { |
|
163 | - return $this->context; |
|
164 | - } |
|
145 | + { |
|
146 | + return [ |
|
147 | + 'payments', |
|
148 | + 'boleto' |
|
149 | + ]; |
|
150 | + } |
|
151 | + |
|
152 | + function getLastResponse(): ResponseInterface |
|
153 | + { |
|
154 | + return $this->lastResponse; |
|
155 | + } |
|
156 | + |
|
157 | + /** |
|
158 | + * return the context used to created the client. |
|
159 | + * @return ContextInterface |
|
160 | + */ |
|
161 | + function getContext(): ContextInterface |
|
162 | + { |
|
163 | + return $this->context; |
|
164 | + } |
|
165 | 165 | |
166 | 166 | function getOptions(): array |
167 | 167 | { |
@@ -10,211 +10,211 @@ |
||
10 | 10 | */ |
11 | 11 | interface CheckoutInterface |
12 | 12 | { |
13 | - /** |
|
14 | - * @return null|string |
|
15 | - */ |
|
16 | - function getId(): ?string; |
|
17 | - |
|
18 | - /** |
|
19 | - * @param string $id |
|
20 | - * @return CheckoutInterface |
|
21 | - */ |
|
22 | - function setId(string $id): self; |
|
23 | - |
|
24 | - /** |
|
25 | - * @return null|string |
|
26 | - */ |
|
27 | - function getStatus(): ?string; |
|
28 | - |
|
29 | - /** |
|
30 | - * @param string $status |
|
31 | - * @return CheckoutInterface |
|
32 | - */ |
|
33 | - function setStatus(string $status): self; |
|
34 | - |
|
35 | - |
|
36 | - /** |
|
37 | - * @param float $amount |
|
38 | - * @return CheckoutInterface |
|
39 | - */ |
|
40 | - function setAmount(float $amount): self; |
|
41 | - |
|
42 | - /** |
|
43 | - * @return float |
|
44 | - */ |
|
45 | - function getAmount():? float; |
|
46 | - |
|
47 | - /** |
|
48 | - * @return float|null |
|
49 | - */ |
|
13 | + /** |
|
14 | + * @return null|string |
|
15 | + */ |
|
16 | + function getId(): ?string; |
|
17 | + |
|
18 | + /** |
|
19 | + * @param string $id |
|
20 | + * @return CheckoutInterface |
|
21 | + */ |
|
22 | + function setId(string $id): self; |
|
23 | + |
|
24 | + /** |
|
25 | + * @return null|string |
|
26 | + */ |
|
27 | + function getStatus(): ?string; |
|
28 | + |
|
29 | + /** |
|
30 | + * @param string $status |
|
31 | + * @return CheckoutInterface |
|
32 | + */ |
|
33 | + function setStatus(string $status): self; |
|
34 | + |
|
35 | + |
|
36 | + /** |
|
37 | + * @param float $amount |
|
38 | + * @return CheckoutInterface |
|
39 | + */ |
|
40 | + function setAmount(float $amount): self; |
|
41 | + |
|
42 | + /** |
|
43 | + * @return float |
|
44 | + */ |
|
45 | + function getAmount():? float; |
|
46 | + |
|
47 | + /** |
|
48 | + * @return float|null |
|
49 | + */ |
|
50 | 50 | function getFeeAmount():? float; |
51 | 51 | |
52 | - /** |
|
53 | - * @param float $amount |
|
54 | - * @return CheckoutInterface |
|
55 | - */ |
|
56 | - function setFeeAmount(float $amount): self; |
|
57 | - |
|
58 | - /** |
|
59 | - * @return null|string |
|
60 | - */ |
|
61 | - function getCurrency(): ?string; |
|
62 | - |
|
63 | - /** |
|
64 | - * @param string $currency |
|
65 | - * @return CheckoutInterface |
|
66 | - */ |
|
67 | - function setCurrency(string $currency): self; |
|
68 | - |
|
69 | - /** |
|
70 | - * @return CustomerInterface|null |
|
71 | - */ |
|
72 | - function getCustomer(): ?CustomerInterface; |
|
73 | - |
|
74 | - /** |
|
75 | - * @param CustomerInterface $customer |
|
76 | - * @return CheckoutInterface |
|
77 | - */ |
|
78 | - function setCustomer(CustomerInterface $customer): self; |
|
79 | - |
|
80 | - /** |
|
52 | + /** |
|
53 | + * @param float $amount |
|
54 | + * @return CheckoutInterface |
|
55 | + */ |
|
56 | + function setFeeAmount(float $amount): self; |
|
57 | + |
|
58 | + /** |
|
59 | + * @return null|string |
|
60 | + */ |
|
61 | + function getCurrency(): ?string; |
|
62 | + |
|
63 | + /** |
|
64 | + * @param string $currency |
|
65 | + * @return CheckoutInterface |
|
66 | + */ |
|
67 | + function setCurrency(string $currency): self; |
|
68 | + |
|
69 | + /** |
|
70 | + * @return CustomerInterface|null |
|
71 | + */ |
|
72 | + function getCustomer(): ?CustomerInterface; |
|
73 | + |
|
74 | + /** |
|
75 | + * @param CustomerInterface $customer |
|
76 | + * @return CheckoutInterface |
|
77 | + */ |
|
78 | + function setCustomer(CustomerInterface $customer): self; |
|
79 | + |
|
80 | + /** |
|
81 | 81 | * @return PaymentInstrumentInterface|null |
82 | - */ |
|
82 | + */ |
|
83 | 83 | function getCard(): ?PaymentInstrumentInterface; |
84 | 84 | |
85 | - /** |
|
85 | + /** |
|
86 | 86 | * @param PaymentInstrumentInterface $card |
87 | - * @return CheckoutInterface |
|
88 | - */ |
|
87 | + * @return CheckoutInterface |
|
88 | + */ |
|
89 | 89 | function setCard(PaymentInstrumentInterface $card): self; |
90 | 90 | |
91 | - /** |
|
92 | - * @return null|string |
|
93 | - */ |
|
94 | - function getPayToEmail(): ?string; |
|
95 | - |
|
96 | - /** |
|
97 | - * @param string $email |
|
98 | - * @return CheckoutInterface |
|
99 | - */ |
|
100 | - function setPayToEmail(string $email): self; |
|
101 | - |
|
102 | - /** |
|
103 | - * @return null|string |
|
104 | - */ |
|
105 | - function getPayFromEmail(): ?string; |
|
106 | - |
|
107 | - /** |
|
108 | - * @param string $email |
|
109 | - * @return CheckoutInterface |
|
110 | - */ |
|
111 | - function setPayFromEmail(string $email): self; |
|
112 | - |
|
113 | - /** |
|
114 | - * @return null|string |
|
115 | - */ |
|
116 | - function getReference(): ?string; |
|
117 | - |
|
118 | - /** |
|
119 | - * @param string $reference |
|
120 | - * @return CheckoutInterface |
|
121 | - */ |
|
122 | - function setReference(string $reference): self; |
|
123 | - |
|
124 | - /** |
|
125 | - * @return null|string |
|
126 | - */ |
|
127 | - function getDescription(): ?string; |
|
128 | - |
|
129 | - /** |
|
130 | - * @param string $description |
|
131 | - * @return CheckoutInterface |
|
132 | - */ |
|
133 | - function setDescription(string $description): self; |
|
134 | - |
|
135 | - /** |
|
136 | - * @return null|string |
|
137 | - */ |
|
138 | - function getRedirectUrl(): ?string; |
|
139 | - |
|
140 | - /** |
|
141 | - * @param string $url |
|
142 | - * @return CheckoutInterface |
|
143 | - */ |
|
144 | - function setRedirectUrl(string $url): self; |
|
145 | - |
|
146 | - /** |
|
147 | - * @return string |
|
148 | - */ |
|
149 | - function getValidUntil():? string; |
|
150 | - |
|
151 | - /** |
|
152 | - * @param string $timestamp |
|
153 | - * @return CheckoutInterface |
|
154 | - */ |
|
155 | - function setValidUntil(string $timestamp): self; |
|
156 | - |
|
157 | - /** |
|
158 | - * @return null|string |
|
159 | - */ |
|
160 | - function getTransactionCode(): ?string; |
|
161 | - |
|
162 | - /** |
|
163 | - * @param string $code |
|
164 | - * @return CheckoutInterface |
|
165 | - */ |
|
166 | - function setTransactionCode(string $code): self; |
|
167 | - |
|
168 | - /** |
|
169 | - * @return null|string |
|
170 | - */ |
|
171 | - function getTransactionId(): ?string; |
|
172 | - |
|
173 | - /** |
|
174 | - * @param string $id |
|
175 | - * @return CheckoutInterface |
|
176 | - */ |
|
177 | - function setTransactionId(string $id): self; |
|
178 | - |
|
179 | - /** |
|
180 | - * @return array|null |
|
181 | - */ |
|
182 | - function getTransactions(): ?array; |
|
183 | - |
|
184 | - /** |
|
185 | - * @param array $transactions |
|
186 | - * @return CheckoutInterface |
|
187 | - */ |
|
188 | - function setTransactions(array $transactions): self; |
|
189 | - |
|
190 | - /** |
|
191 | - * @return null|string |
|
192 | - */ |
|
193 | - function getToken(): ?string; |
|
194 | - |
|
195 | - /** |
|
196 | - * @param string $token |
|
197 | - * @return CheckoutInterface |
|
198 | - */ |
|
199 | - function setToken(string $token): self; |
|
200 | - |
|
201 | - /** |
|
91 | + /** |
|
92 | + * @return null|string |
|
93 | + */ |
|
94 | + function getPayToEmail(): ?string; |
|
95 | + |
|
96 | + /** |
|
97 | + * @param string $email |
|
98 | + * @return CheckoutInterface |
|
99 | + */ |
|
100 | + function setPayToEmail(string $email): self; |
|
101 | + |
|
102 | + /** |
|
103 | + * @return null|string |
|
104 | + */ |
|
105 | + function getPayFromEmail(): ?string; |
|
106 | + |
|
107 | + /** |
|
108 | + * @param string $email |
|
109 | + * @return CheckoutInterface |
|
110 | + */ |
|
111 | + function setPayFromEmail(string $email): self; |
|
112 | + |
|
113 | + /** |
|
114 | + * @return null|string |
|
115 | + */ |
|
116 | + function getReference(): ?string; |
|
117 | + |
|
118 | + /** |
|
119 | + * @param string $reference |
|
120 | + * @return CheckoutInterface |
|
121 | + */ |
|
122 | + function setReference(string $reference): self; |
|
123 | + |
|
124 | + /** |
|
125 | + * @return null|string |
|
126 | + */ |
|
127 | + function getDescription(): ?string; |
|
128 | + |
|
129 | + /** |
|
130 | + * @param string $description |
|
131 | + * @return CheckoutInterface |
|
132 | + */ |
|
133 | + function setDescription(string $description): self; |
|
134 | + |
|
135 | + /** |
|
136 | + * @return null|string |
|
137 | + */ |
|
138 | + function getRedirectUrl(): ?string; |
|
139 | + |
|
140 | + /** |
|
141 | + * @param string $url |
|
142 | + * @return CheckoutInterface |
|
143 | + */ |
|
144 | + function setRedirectUrl(string $url): self; |
|
145 | + |
|
146 | + /** |
|
147 | + * @return string |
|
148 | + */ |
|
149 | + function getValidUntil():? string; |
|
150 | + |
|
151 | + /** |
|
152 | + * @param string $timestamp |
|
153 | + * @return CheckoutInterface |
|
154 | + */ |
|
155 | + function setValidUntil(string $timestamp): self; |
|
156 | + |
|
157 | + /** |
|
158 | + * @return null|string |
|
159 | + */ |
|
160 | + function getTransactionCode(): ?string; |
|
161 | + |
|
162 | + /** |
|
163 | + * @param string $code |
|
164 | + * @return CheckoutInterface |
|
165 | + */ |
|
166 | + function setTransactionCode(string $code): self; |
|
167 | + |
|
168 | + /** |
|
169 | + * @return null|string |
|
170 | + */ |
|
171 | + function getTransactionId(): ?string; |
|
172 | + |
|
173 | + /** |
|
174 | + * @param string $id |
|
175 | + * @return CheckoutInterface |
|
176 | + */ |
|
177 | + function setTransactionId(string $id): self; |
|
178 | + |
|
179 | + /** |
|
180 | + * @return array|null |
|
181 | + */ |
|
182 | + function getTransactions(): ?array; |
|
183 | + |
|
184 | + /** |
|
185 | + * @param array $transactions |
|
186 | + * @return CheckoutInterface |
|
187 | + */ |
|
188 | + function setTransactions(array $transactions): self; |
|
189 | + |
|
190 | + /** |
|
191 | + * @return null|string |
|
192 | + */ |
|
193 | + function getToken(): ?string; |
|
194 | + |
|
195 | + /** |
|
196 | + * @param string $token |
|
197 | + * @return CheckoutInterface |
|
198 | + */ |
|
199 | + function setToken(string $token): self; |
|
200 | + |
|
201 | + /** |
|
202 | 202 | * @return bool |
203 | - */ |
|
203 | + */ |
|
204 | 204 | function isValid(): bool; |
205 | 205 | |
206 | - /** |
|
207 | - * @param string|null $type |
|
208 | - * @return CheckoutInterface |
|
209 | - */ |
|
210 | - function setType(string $type = null): self; |
|
206 | + /** |
|
207 | + * @param string|null $type |
|
208 | + * @return CheckoutInterface |
|
209 | + */ |
|
210 | + function setType(string $type = null): self; |
|
211 | 211 | |
212 | - /** |
|
213 | - * @return null|string |
|
214 | - */ |
|
215 | - function getType():? string; |
|
212 | + /** |
|
213 | + * @return null|string |
|
214 | + */ |
|
215 | + function getType():? string; |
|
216 | 216 | |
217 | - function setInstallments(?string $installments):? self; |
|
218 | - function getInstallments():? string; |
|
217 | + function setInstallments(?string $installments):? self; |
|
218 | + function getInstallments():? string; |
|
219 | 219 | |
220 | 220 | } |