@@ -17,5 +17,5 @@ |
||
17 | 17 | * @param string|null $endpoint |
18 | 18 | * @return bool|null |
19 | 19 | */ |
20 | - function request(string $action, $object, string $endpoint = null):? bool; |
|
20 | + function request(string $action, $object, string $endpoint = null): ? bool; |
|
21 | 21 | } |
@@ -11,107 +11,107 @@ |
||
11 | 11 | const OAUTH_AUTHORIZATION = '/authorize'; |
12 | 12 | const OAUTH_TOKEN = '/token'; |
13 | 13 | |
14 | - /** |
|
15 | - * Generate an url to merchant authorization. |
|
16 | - * |
|
17 | - * @param ContextInterface $context |
|
18 | - * @return string |
|
19 | - */ |
|
14 | + /** |
|
15 | + * Generate an url to merchant authorization. |
|
16 | + * |
|
17 | + * @param ContextInterface $context |
|
18 | + * @return string |
|
19 | + */ |
|
20 | 20 | public static function getAuthorizationURL(ContextInterface $context) |
21 | - { |
|
22 | - $queryString = [ |
|
23 | - 'client_id' => $context->getClientId(), |
|
24 | - 'client_secret' => $context->getClientSecret(), |
|
25 | - 'redirect_uri' => $context->getRedirectUri(), |
|
26 | - 'response_type' => 'code', |
|
27 | - ]; |
|
28 | - |
|
29 | - return SumUp::ENTRYPOINT . self::OAUTH_AUTHORIZATION . '?' . http_build_query($queryString); |
|
30 | - } |
|
31 | - |
|
32 | - /** |
|
33 | - * Request an acess token from sumup services. |
|
34 | - * |
|
21 | + { |
|
22 | + $queryString = [ |
|
23 | + 'client_id' => $context->getClientId(), |
|
24 | + 'client_secret' => $context->getClientSecret(), |
|
25 | + 'redirect_uri' => $context->getRedirectUri(), |
|
26 | + 'response_type' => 'code', |
|
27 | + ]; |
|
28 | + |
|
29 | + return SumUp::ENTRYPOINT . self::OAUTH_AUTHORIZATION . '?' . http_build_query($queryString); |
|
30 | + } |
|
31 | + |
|
32 | + /** |
|
33 | + * Request an acess token from sumup services. |
|
34 | + * |
|
35 | 35 | * @param ContextInterface $context |
36 | 36 | * @param array|null $scopes |
37 | 37 | * @param array $options |
38 | 38 | * @return \BPCI\SumUp\OAuth\AccessToken |
39 | - */ |
|
39 | + */ |
|
40 | 40 | public static function getAccessToken( |
41 | 41 | ContextInterface $context, |
42 | 42 | array $scopes = null, |
43 | 43 | array $options = [] |
44 | 44 | ): AccessToken |
45 | - { |
|
46 | - $formParams = [ |
|
47 | - 'grant_type' => 'client_credentials', |
|
48 | - 'client_id' => $context->getClientId(), |
|
49 | - 'client_secret' => $context->getClientSecret(), |
|
50 | - ]; |
|
45 | + { |
|
46 | + $formParams = [ |
|
47 | + 'grant_type' => 'client_credentials', |
|
48 | + 'client_id' => $context->getClientId(), |
|
49 | + 'client_secret' => $context->getClientSecret(), |
|
50 | + ]; |
|
51 | 51 | |
52 | - if ($scopes !== null) { |
|
53 | - $formParams['scope'] = implode(',', $scopes); |
|
54 | - } |
|
52 | + if ($scopes !== null) { |
|
53 | + $formParams['scope'] = implode(',', $scopes); |
|
54 | + } |
|
55 | 55 | |
56 | 56 | $client = SumUp::getClient($options); |
57 | 57 | |
58 | - $response = $client->request( |
|
59 | - 'POST', |
|
60 | - self::OAUTH_TOKEN, |
|
61 | - [ |
|
62 | - 'form_params' => $formParams, |
|
63 | - ]); |
|
64 | - |
|
65 | - $code = $response->getStatusCode(); |
|
66 | - if ($code !== 200) { |
|
67 | - $message = " Request code: $code \n Message: " . $response->getReasonPhrase(); |
|
68 | - throw new BadRequestException($message); |
|
69 | - } |
|
70 | - |
|
71 | - $body = json_decode($response->getBody()->getContents(), true); |
|
72 | - $token_params = [ |
|
73 | - $body['access_token'], |
|
74 | - $body['token_type'], |
|
75 | - $body['expires_in'], |
|
76 | - ]; |
|
77 | - |
|
78 | - if (isset($body['scope'])) { |
|
79 | - $token_params[] = $body['scope']; |
|
80 | - } |
|
81 | - |
|
82 | - return new AccessToken(...$token_params); |
|
83 | - } |
|
84 | - |
|
85 | - /** |
|
86 | - * If available check token or generate a new token |
|
87 | - * |
|
88 | - * @param ContextInterface $context |
|
89 | - * @param AccessToken $token |
|
90 | - * @param array $scopes |
|
58 | + $response = $client->request( |
|
59 | + 'POST', |
|
60 | + self::OAUTH_TOKEN, |
|
61 | + [ |
|
62 | + 'form_params' => $formParams, |
|
63 | + ]); |
|
64 | + |
|
65 | + $code = $response->getStatusCode(); |
|
66 | + if ($code !== 200) { |
|
67 | + $message = " Request code: $code \n Message: " . $response->getReasonPhrase(); |
|
68 | + throw new BadRequestException($message); |
|
69 | + } |
|
70 | + |
|
71 | + $body = json_decode($response->getBody()->getContents(), true); |
|
72 | + $token_params = [ |
|
73 | + $body['access_token'], |
|
74 | + $body['token_type'], |
|
75 | + $body['expires_in'], |
|
76 | + ]; |
|
77 | + |
|
78 | + if (isset($body['scope'])) { |
|
79 | + $token_params[] = $body['scope']; |
|
80 | + } |
|
81 | + |
|
82 | + return new AccessToken(...$token_params); |
|
83 | + } |
|
84 | + |
|
85 | + /** |
|
86 | + * If available check token or generate a new token |
|
87 | + * |
|
88 | + * @param ContextInterface $context |
|
89 | + * @param AccessToken $token |
|
90 | + * @param array $scopes |
|
91 | 91 | * @param array $options |
92 | 92 | * |
93 | 93 | * @return \BPCI\SumUp\OAuth\AccessToken |
94 | - */ |
|
94 | + */ |
|
95 | 95 | public static function getValidToken( |
96 | 96 | ContextInterface $context, |
97 | 97 | AccessToken $token = null, |
98 | 98 | array $scopes = null, |
99 | 99 | array $options = [] |
100 | 100 | ): AccessToken |
101 | - { |
|
102 | - if ($token === null || !$token->isValid()) { |
|
101 | + { |
|
102 | + if ($token === null || !$token->isValid()) { |
|
103 | 103 | $token = AuthenticationHelper::getAccessToken($context, $scopes, $options); |
104 | - } |
|
105 | - |
|
106 | - return $token; |
|
107 | - } |
|
108 | - |
|
109 | - public static function getOAuthHeader(AccessToken $token): array |
|
110 | - { |
|
111 | - return [ |
|
112 | - 'headers' => [ |
|
113 | - 'Authorization' => $token->getType() . ' ' . $token->getToken(), |
|
114 | - ], |
|
115 | - ]; |
|
116 | - } |
|
104 | + } |
|
105 | + |
|
106 | + return $token; |
|
107 | + } |
|
108 | + |
|
109 | + public static function getOAuthHeader(AccessToken $token): array |
|
110 | + { |
|
111 | + return [ |
|
112 | + 'headers' => [ |
|
113 | + 'Authorization' => $token->getType() . ' ' . $token->getToken(), |
|
114 | + ], |
|
115 | + ]; |
|
116 | + } |
|
117 | 117 | } |
@@ -8,390 +8,390 @@ |
||
8 | 8 | */ |
9 | 9 | class Address implements AddressInterface |
10 | 10 | { |
11 | - /** |
|
12 | - * First address line |
|
13 | - * |
|
14 | - * @var string $line1 |
|
15 | - */ |
|
16 | - protected $line1; |
|
17 | - /** |
|
18 | - * Second address line |
|
19 | - * |
|
20 | - * @var string |
|
21 | - */ |
|
22 | - protected $line2; |
|
23 | - /** |
|
24 | - * Address Country |
|
25 | - * |
|
26 | - * @var string |
|
27 | - */ |
|
28 | - protected $country; |
|
29 | - /** |
|
30 | - * Address postal code |
|
31 | - * |
|
32 | - * @var string |
|
33 | - */ |
|
34 | - protected $postalCode; |
|
35 | - /** |
|
36 | - * Address City |
|
37 | - * |
|
38 | - * @var string |
|
39 | - */ |
|
40 | - protected $city; |
|
41 | - /** |
|
42 | - * @var string |
|
43 | - */ |
|
44 | - protected $countryEnName; |
|
45 | - /** |
|
46 | - * @var string |
|
47 | - */ |
|
48 | - protected $countryNativeName; |
|
49 | - /** |
|
50 | - * @var integer |
|
51 | - */ |
|
52 | - protected $regionId; |
|
53 | - /** |
|
54 | - * @var string |
|
55 | - */ |
|
56 | - protected $regionName; |
|
57 | - /** |
|
58 | - * @var string |
|
59 | - */ |
|
60 | - protected $postCode; |
|
61 | - /** |
|
62 | - * @var string |
|
63 | - */ |
|
64 | - protected $landline; |
|
65 | - /** |
|
66 | - * @var string |
|
67 | - */ |
|
68 | - protected $addressLine1; |
|
69 | - /** |
|
70 | - * @var string |
|
71 | - */ |
|
72 | - protected $addressLine2; |
|
73 | - /** |
|
74 | - * Address State |
|
75 | - * |
|
76 | - * @var string |
|
77 | - */ |
|
78 | - protected $state; |
|
79 | - |
|
80 | - /** |
|
81 | - * Address constructor. |
|
82 | - * @param array|null $data |
|
83 | - */ |
|
84 | - function __construct(?array $data = []) |
|
85 | - { |
|
86 | - $this->setAddressLine1($data['address_line1']??null); |
|
87 | - $this->setAddressLine2($data['address_line2']??null); |
|
88 | - $this->setCity($data['city']??null); |
|
89 | - $this->setCountry($data['country']??null); |
|
90 | - $this->setCountryEnName($data['country_en_name']??null); |
|
91 | - $this->setCountryNativeName($data['country_native_name']??null); |
|
92 | - $this->setRegionId($data['region_id']??null); |
|
93 | - $this->setRegionName($data['region_name']??null); |
|
94 | - $this->setPostCode($data['post_code']??null); |
|
95 | - $this->setLandline($data['landline']??null); |
|
96 | - $this->setLine1($data['line1']??null); |
|
97 | - $this->setLine2($data['line2']??null); |
|
98 | - $this->setPostalCode($data['postal_code']??null); |
|
99 | - $this->setState($data['state']??null); |
|
100 | - } |
|
101 | - |
|
102 | - /** |
|
103 | - * Get $line1 |
|
104 | - * |
|
105 | - * @return string |
|
106 | - */ |
|
107 | - public function getLine1(): ?string |
|
108 | - { |
|
109 | - return $this->line1; |
|
110 | - } |
|
111 | - |
|
112 | - /** |
|
113 | - * Set $line1 |
|
114 | - * |
|
115 | - * @param string $line1 $line1 |
|
116 | - * |
|
117 | - * @return AddressInterface |
|
118 | - */ |
|
119 | - public function setLine1(?string $line1): AddressInterface |
|
120 | - { |
|
121 | - $this->line1 = $line1; |
|
122 | - |
|
123 | - return $this; |
|
124 | - } |
|
125 | - |
|
126 | - /** |
|
127 | - * Get second address line |
|
128 | - * |
|
129 | - * @return string |
|
130 | - */ |
|
131 | - public function getLine2(): ?string |
|
132 | - { |
|
133 | - return $this->line2; |
|
134 | - } |
|
135 | - |
|
136 | - /** |
|
137 | - * Set second address line |
|
138 | - * |
|
139 | - * @param string $line2 Second address line |
|
140 | - * |
|
141 | - * @return AddressInterface |
|
142 | - */ |
|
143 | - public function setLine2(?string $line2): AddressInterface |
|
144 | - { |
|
145 | - $this->line2 = $line2; |
|
146 | - |
|
147 | - return $this; |
|
148 | - } |
|
149 | - |
|
150 | - /** |
|
151 | - * Get address Country |
|
152 | - * |
|
153 | - * @return string |
|
154 | - */ |
|
155 | - public function getCountry(): ?string |
|
156 | - { |
|
157 | - return $this->country; |
|
158 | - } |
|
159 | - |
|
160 | - /** |
|
161 | - * Set address Country |
|
162 | - * |
|
163 | - * @param string $country Address Country |
|
164 | - * |
|
165 | - * @return AddressInterface |
|
166 | - */ |
|
167 | - public function setCountry(?string $country): AddressInterface |
|
168 | - { |
|
169 | - $this->country = $country; |
|
170 | - |
|
171 | - return $this; |
|
172 | - } |
|
173 | - |
|
174 | - /** |
|
175 | - * Get address postal code |
|
176 | - * |
|
177 | - * @return string |
|
178 | - */ |
|
179 | - public function getPostalCode(): ?string |
|
180 | - { |
|
181 | - return $this->postalCode; |
|
182 | - } |
|
183 | - |
|
184 | - /** |
|
185 | - * Set address postal code |
|
186 | - * |
|
187 | - * @param string $postalCode Address postal code |
|
188 | - * |
|
189 | - * @return AddressInterface |
|
190 | - */ |
|
191 | - public function setPostalCode(?string $postalCode): AddressInterface |
|
192 | - { |
|
193 | - $this->postalCode = $postalCode; |
|
194 | - |
|
195 | - return $this; |
|
196 | - } |
|
197 | - |
|
198 | - /** |
|
199 | - * Get address City |
|
200 | - * |
|
201 | - * @return string |
|
202 | - */ |
|
203 | - public function getCity(): ?string |
|
204 | - { |
|
205 | - return $this->city; |
|
206 | - } |
|
207 | - |
|
208 | - /** |
|
209 | - * Set address City |
|
210 | - * |
|
211 | - * @param string $city Address City |
|
212 | - * |
|
213 | - * @return AddressInterface |
|
214 | - */ |
|
215 | - public function setCity(?string $city): AddressInterface |
|
216 | - { |
|
217 | - $this->city = $city; |
|
218 | - |
|
219 | - return $this; |
|
220 | - } |
|
221 | - |
|
222 | - /** |
|
223 | - * @return mixed |
|
224 | - */ |
|
225 | - public function getCountryEnName():? string |
|
226 | - { |
|
227 | - return $this->countryEnName; |
|
228 | - } |
|
229 | - |
|
230 | - /** |
|
231 | - * @param mixed $countryEnName |
|
232 | - * @return AddressInterface |
|
233 | - */ |
|
234 | - public function setCountryEnName($countryEnName): AddressInterface |
|
235 | - { |
|
236 | - $this->countryEnName = $countryEnName; |
|
237 | - |
|
238 | - return $this; |
|
239 | - } |
|
240 | - |
|
241 | - /** |
|
242 | - * @return mixed |
|
243 | - */ |
|
244 | - public function getCountryNativeName():? string |
|
245 | - { |
|
246 | - return $this->countryNativeName; |
|
247 | - } |
|
11 | + /** |
|
12 | + * First address line |
|
13 | + * |
|
14 | + * @var string $line1 |
|
15 | + */ |
|
16 | + protected $line1; |
|
17 | + /** |
|
18 | + * Second address line |
|
19 | + * |
|
20 | + * @var string |
|
21 | + */ |
|
22 | + protected $line2; |
|
23 | + /** |
|
24 | + * Address Country |
|
25 | + * |
|
26 | + * @var string |
|
27 | + */ |
|
28 | + protected $country; |
|
29 | + /** |
|
30 | + * Address postal code |
|
31 | + * |
|
32 | + * @var string |
|
33 | + */ |
|
34 | + protected $postalCode; |
|
35 | + /** |
|
36 | + * Address City |
|
37 | + * |
|
38 | + * @var string |
|
39 | + */ |
|
40 | + protected $city; |
|
41 | + /** |
|
42 | + * @var string |
|
43 | + */ |
|
44 | + protected $countryEnName; |
|
45 | + /** |
|
46 | + * @var string |
|
47 | + */ |
|
48 | + protected $countryNativeName; |
|
49 | + /** |
|
50 | + * @var integer |
|
51 | + */ |
|
52 | + protected $regionId; |
|
53 | + /** |
|
54 | + * @var string |
|
55 | + */ |
|
56 | + protected $regionName; |
|
57 | + /** |
|
58 | + * @var string |
|
59 | + */ |
|
60 | + protected $postCode; |
|
61 | + /** |
|
62 | + * @var string |
|
63 | + */ |
|
64 | + protected $landline; |
|
65 | + /** |
|
66 | + * @var string |
|
67 | + */ |
|
68 | + protected $addressLine1; |
|
69 | + /** |
|
70 | + * @var string |
|
71 | + */ |
|
72 | + protected $addressLine2; |
|
73 | + /** |
|
74 | + * Address State |
|
75 | + * |
|
76 | + * @var string |
|
77 | + */ |
|
78 | + protected $state; |
|
79 | + |
|
80 | + /** |
|
81 | + * Address constructor. |
|
82 | + * @param array|null $data |
|
83 | + */ |
|
84 | + function __construct(?array $data = []) |
|
85 | + { |
|
86 | + $this->setAddressLine1($data['address_line1']??null); |
|
87 | + $this->setAddressLine2($data['address_line2']??null); |
|
88 | + $this->setCity($data['city']??null); |
|
89 | + $this->setCountry($data['country']??null); |
|
90 | + $this->setCountryEnName($data['country_en_name']??null); |
|
91 | + $this->setCountryNativeName($data['country_native_name']??null); |
|
92 | + $this->setRegionId($data['region_id']??null); |
|
93 | + $this->setRegionName($data['region_name']??null); |
|
94 | + $this->setPostCode($data['post_code']??null); |
|
95 | + $this->setLandline($data['landline']??null); |
|
96 | + $this->setLine1($data['line1']??null); |
|
97 | + $this->setLine2($data['line2']??null); |
|
98 | + $this->setPostalCode($data['postal_code']??null); |
|
99 | + $this->setState($data['state']??null); |
|
100 | + } |
|
101 | + |
|
102 | + /** |
|
103 | + * Get $line1 |
|
104 | + * |
|
105 | + * @return string |
|
106 | + */ |
|
107 | + public function getLine1(): ?string |
|
108 | + { |
|
109 | + return $this->line1; |
|
110 | + } |
|
111 | + |
|
112 | + /** |
|
113 | + * Set $line1 |
|
114 | + * |
|
115 | + * @param string $line1 $line1 |
|
116 | + * |
|
117 | + * @return AddressInterface |
|
118 | + */ |
|
119 | + public function setLine1(?string $line1): AddressInterface |
|
120 | + { |
|
121 | + $this->line1 = $line1; |
|
122 | + |
|
123 | + return $this; |
|
124 | + } |
|
125 | + |
|
126 | + /** |
|
127 | + * Get second address line |
|
128 | + * |
|
129 | + * @return string |
|
130 | + */ |
|
131 | + public function getLine2(): ?string |
|
132 | + { |
|
133 | + return $this->line2; |
|
134 | + } |
|
135 | + |
|
136 | + /** |
|
137 | + * Set second address line |
|
138 | + * |
|
139 | + * @param string $line2 Second address line |
|
140 | + * |
|
141 | + * @return AddressInterface |
|
142 | + */ |
|
143 | + public function setLine2(?string $line2): AddressInterface |
|
144 | + { |
|
145 | + $this->line2 = $line2; |
|
146 | + |
|
147 | + return $this; |
|
148 | + } |
|
149 | + |
|
150 | + /** |
|
151 | + * Get address Country |
|
152 | + * |
|
153 | + * @return string |
|
154 | + */ |
|
155 | + public function getCountry(): ?string |
|
156 | + { |
|
157 | + return $this->country; |
|
158 | + } |
|
159 | + |
|
160 | + /** |
|
161 | + * Set address Country |
|
162 | + * |
|
163 | + * @param string $country Address Country |
|
164 | + * |
|
165 | + * @return AddressInterface |
|
166 | + */ |
|
167 | + public function setCountry(?string $country): AddressInterface |
|
168 | + { |
|
169 | + $this->country = $country; |
|
170 | + |
|
171 | + return $this; |
|
172 | + } |
|
173 | + |
|
174 | + /** |
|
175 | + * Get address postal code |
|
176 | + * |
|
177 | + * @return string |
|
178 | + */ |
|
179 | + public function getPostalCode(): ?string |
|
180 | + { |
|
181 | + return $this->postalCode; |
|
182 | + } |
|
183 | + |
|
184 | + /** |
|
185 | + * Set address postal code |
|
186 | + * |
|
187 | + * @param string $postalCode Address postal code |
|
188 | + * |
|
189 | + * @return AddressInterface |
|
190 | + */ |
|
191 | + public function setPostalCode(?string $postalCode): AddressInterface |
|
192 | + { |
|
193 | + $this->postalCode = $postalCode; |
|
194 | + |
|
195 | + return $this; |
|
196 | + } |
|
197 | + |
|
198 | + /** |
|
199 | + * Get address City |
|
200 | + * |
|
201 | + * @return string |
|
202 | + */ |
|
203 | + public function getCity(): ?string |
|
204 | + { |
|
205 | + return $this->city; |
|
206 | + } |
|
207 | + |
|
208 | + /** |
|
209 | + * Set address City |
|
210 | + * |
|
211 | + * @param string $city Address City |
|
212 | + * |
|
213 | + * @return AddressInterface |
|
214 | + */ |
|
215 | + public function setCity(?string $city): AddressInterface |
|
216 | + { |
|
217 | + $this->city = $city; |
|
218 | + |
|
219 | + return $this; |
|
220 | + } |
|
221 | + |
|
222 | + /** |
|
223 | + * @return mixed |
|
224 | + */ |
|
225 | + public function getCountryEnName():? string |
|
226 | + { |
|
227 | + return $this->countryEnName; |
|
228 | + } |
|
229 | + |
|
230 | + /** |
|
231 | + * @param mixed $countryEnName |
|
232 | + * @return AddressInterface |
|
233 | + */ |
|
234 | + public function setCountryEnName($countryEnName): AddressInterface |
|
235 | + { |
|
236 | + $this->countryEnName = $countryEnName; |
|
237 | + |
|
238 | + return $this; |
|
239 | + } |
|
240 | + |
|
241 | + /** |
|
242 | + * @return mixed |
|
243 | + */ |
|
244 | + public function getCountryNativeName():? string |
|
245 | + { |
|
246 | + return $this->countryNativeName; |
|
247 | + } |
|
248 | 248 | |
249 | 249 | /** |
250 | 250 | * @param mixed $countryNativeName |
251 | 251 | * @return AddressInterface |
252 | 252 | */ |
253 | - public function setCountryNativeName(?string $countryNativeName): AddressInterface |
|
254 | - { |
|
255 | - $this->countryNativeName = $countryNativeName; |
|
253 | + public function setCountryNativeName(?string $countryNativeName): AddressInterface |
|
254 | + { |
|
255 | + $this->countryNativeName = $countryNativeName; |
|
256 | 256 | |
257 | - return $this; |
|
258 | - } |
|
257 | + return $this; |
|
258 | + } |
|
259 | 259 | |
260 | - /** |
|
260 | + /** |
|
261 | 261 | * @return int|null |
262 | - */ |
|
262 | + */ |
|
263 | 263 | public function getRegionId():? int |
264 | - { |
|
265 | - return $this->regionId; |
|
266 | - } |
|
264 | + { |
|
265 | + return $this->regionId; |
|
266 | + } |
|
267 | 267 | |
268 | - /** |
|
268 | + /** |
|
269 | 269 | * @param int|null $regionId |
270 | 270 | * @return AddressInterface |
271 | - */ |
|
271 | + */ |
|
272 | 272 | public function setRegionId(?int $regionId): AddressInterface |
273 | - { |
|
274 | - $this->regionId = $regionId; |
|
275 | - |
|
276 | - return $this; |
|
277 | - } |
|
278 | - |
|
279 | - /** |
|
280 | - * @return string|null |
|
281 | - */ |
|
282 | - public function getRegionName():? string |
|
283 | - { |
|
284 | - return $this->regionName; |
|
285 | - } |
|
286 | - |
|
287 | - /** |
|
288 | - * @param string|null $regionName |
|
289 | - * @return AddressInterface |
|
290 | - */ |
|
291 | - public function setRegionName(?string $regionName): AddressInterface |
|
292 | - { |
|
293 | - $this->regionName = $regionName; |
|
294 | - |
|
295 | - return $this; |
|
296 | - } |
|
297 | - |
|
298 | - /** |
|
299 | - * @return string|null |
|
300 | - */ |
|
301 | - public function getPostCode():? string |
|
302 | - { |
|
303 | - return $this->postCode; |
|
304 | - } |
|
305 | - |
|
306 | - /** |
|
307 | - * @param string|null $postCode |
|
308 | - * @return AddressInterface |
|
309 | - */ |
|
310 | - public function setPostCode(?string $postCode): AddressInterface |
|
311 | - { |
|
312 | - $this->postCode = $postCode; |
|
313 | - |
|
314 | - return $this; |
|
315 | - } |
|
316 | - |
|
317 | - /** |
|
318 | - * @return string|null |
|
319 | - */ |
|
320 | - public function getLandline():? string |
|
321 | - { |
|
322 | - return $this->landline; |
|
323 | - } |
|
324 | - |
|
325 | - /** |
|
326 | - * @param string|null $landline |
|
327 | - * @return AddressInterface |
|
328 | - */ |
|
329 | - public function setLandline(?string $landline): AddressInterface |
|
330 | - { |
|
331 | - $this->landline = $landline; |
|
332 | - |
|
333 | - return $this; |
|
334 | - } |
|
335 | - |
|
336 | - /** |
|
337 | - * @return string|null |
|
338 | - */ |
|
339 | - public function getAddressLine1():? string |
|
340 | - { |
|
341 | - return $this->addressLine1; |
|
342 | - } |
|
343 | - |
|
344 | - /** |
|
345 | - * @param string|null $addressLine1 |
|
346 | - * @return AddressInterface |
|
347 | - */ |
|
348 | - public function setAddressLine1(?string $addressLine1): AddressInterface |
|
349 | - { |
|
350 | - $this->addressLine1 = $addressLine1; |
|
351 | - |
|
352 | - return $this; |
|
353 | - } |
|
354 | - |
|
355 | - /** |
|
356 | - * @return string|null |
|
357 | - */ |
|
358 | - public function getAddressLine2():? string |
|
359 | - { |
|
360 | - return $this->addressLine2; |
|
361 | - } |
|
362 | - |
|
363 | - /** |
|
364 | - * @param string|null $addressLine2 |
|
365 | - * @return AddressInterface |
|
366 | - */ |
|
367 | - public function setAddressLine2(?string $addressLine2): AddressInterface |
|
368 | - { |
|
369 | - $this->addressLine2 = $addressLine2; |
|
370 | - |
|
371 | - return $this; |
|
372 | - } |
|
373 | - |
|
374 | - /** |
|
375 | - * Get address State |
|
376 | - * |
|
377 | - * @return string|null |
|
378 | - */ |
|
379 | - public function getState(): ?string |
|
380 | - { |
|
381 | - return $this->state; |
|
382 | - } |
|
383 | - |
|
384 | - /** |
|
385 | - * Set address State |
|
386 | - * |
|
387 | - * @param string|null $state Address State |
|
388 | - * |
|
389 | - * @return AddressInterface |
|
390 | - */ |
|
391 | - public function setState(?string $state): AddressInterface |
|
392 | - { |
|
393 | - $this->state = $state; |
|
394 | - |
|
395 | - return $this; |
|
396 | - } |
|
273 | + { |
|
274 | + $this->regionId = $regionId; |
|
275 | + |
|
276 | + return $this; |
|
277 | + } |
|
278 | + |
|
279 | + /** |
|
280 | + * @return string|null |
|
281 | + */ |
|
282 | + public function getRegionName():? string |
|
283 | + { |
|
284 | + return $this->regionName; |
|
285 | + } |
|
286 | + |
|
287 | + /** |
|
288 | + * @param string|null $regionName |
|
289 | + * @return AddressInterface |
|
290 | + */ |
|
291 | + public function setRegionName(?string $regionName): AddressInterface |
|
292 | + { |
|
293 | + $this->regionName = $regionName; |
|
294 | + |
|
295 | + return $this; |
|
296 | + } |
|
297 | + |
|
298 | + /** |
|
299 | + * @return string|null |
|
300 | + */ |
|
301 | + public function getPostCode():? string |
|
302 | + { |
|
303 | + return $this->postCode; |
|
304 | + } |
|
305 | + |
|
306 | + /** |
|
307 | + * @param string|null $postCode |
|
308 | + * @return AddressInterface |
|
309 | + */ |
|
310 | + public function setPostCode(?string $postCode): AddressInterface |
|
311 | + { |
|
312 | + $this->postCode = $postCode; |
|
313 | + |
|
314 | + return $this; |
|
315 | + } |
|
316 | + |
|
317 | + /** |
|
318 | + * @return string|null |
|
319 | + */ |
|
320 | + public function getLandline():? string |
|
321 | + { |
|
322 | + return $this->landline; |
|
323 | + } |
|
324 | + |
|
325 | + /** |
|
326 | + * @param string|null $landline |
|
327 | + * @return AddressInterface |
|
328 | + */ |
|
329 | + public function setLandline(?string $landline): AddressInterface |
|
330 | + { |
|
331 | + $this->landline = $landline; |
|
332 | + |
|
333 | + return $this; |
|
334 | + } |
|
335 | + |
|
336 | + /** |
|
337 | + * @return string|null |
|
338 | + */ |
|
339 | + public function getAddressLine1():? string |
|
340 | + { |
|
341 | + return $this->addressLine1; |
|
342 | + } |
|
343 | + |
|
344 | + /** |
|
345 | + * @param string|null $addressLine1 |
|
346 | + * @return AddressInterface |
|
347 | + */ |
|
348 | + public function setAddressLine1(?string $addressLine1): AddressInterface |
|
349 | + { |
|
350 | + $this->addressLine1 = $addressLine1; |
|
351 | + |
|
352 | + return $this; |
|
353 | + } |
|
354 | + |
|
355 | + /** |
|
356 | + * @return string|null |
|
357 | + */ |
|
358 | + public function getAddressLine2():? string |
|
359 | + { |
|
360 | + return $this->addressLine2; |
|
361 | + } |
|
362 | + |
|
363 | + /** |
|
364 | + * @param string|null $addressLine2 |
|
365 | + * @return AddressInterface |
|
366 | + */ |
|
367 | + public function setAddressLine2(?string $addressLine2): AddressInterface |
|
368 | + { |
|
369 | + $this->addressLine2 = $addressLine2; |
|
370 | + |
|
371 | + return $this; |
|
372 | + } |
|
373 | + |
|
374 | + /** |
|
375 | + * Get address State |
|
376 | + * |
|
377 | + * @return string|null |
|
378 | + */ |
|
379 | + public function getState(): ?string |
|
380 | + { |
|
381 | + return $this->state; |
|
382 | + } |
|
383 | + |
|
384 | + /** |
|
385 | + * Set address State |
|
386 | + * |
|
387 | + * @param string|null $state Address State |
|
388 | + * |
|
389 | + * @return AddressInterface |
|
390 | + */ |
|
391 | + public function setState(?string $state): AddressInterface |
|
392 | + { |
|
393 | + $this->state = $state; |
|
394 | + |
|
395 | + return $this; |
|
396 | + } |
|
397 | 397 | } |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | /** |
223 | 223 | * @return mixed |
224 | 224 | */ |
225 | - public function getCountryEnName():? string |
|
225 | + public function getCountryEnName(): ? string |
|
226 | 226 | { |
227 | 227 | return $this->countryEnName; |
228 | 228 | } |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | /** |
242 | 242 | * @return mixed |
243 | 243 | */ |
244 | - public function getCountryNativeName():? string |
|
244 | + public function getCountryNativeName(): ? string |
|
245 | 245 | { |
246 | 246 | return $this->countryNativeName; |
247 | 247 | } |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | /** |
261 | 261 | * @return int|null |
262 | 262 | */ |
263 | - public function getRegionId():? int |
|
263 | + public function getRegionId(): ? int |
|
264 | 264 | { |
265 | 265 | return $this->regionId; |
266 | 266 | } |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | /** |
280 | 280 | * @return string|null |
281 | 281 | */ |
282 | - public function getRegionName():? string |
|
282 | + public function getRegionName(): ? string |
|
283 | 283 | { |
284 | 284 | return $this->regionName; |
285 | 285 | } |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | /** |
299 | 299 | * @return string|null |
300 | 300 | */ |
301 | - public function getPostCode():? string |
|
301 | + public function getPostCode(): ? string |
|
302 | 302 | { |
303 | 303 | return $this->postCode; |
304 | 304 | } |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | /** |
318 | 318 | * @return string|null |
319 | 319 | */ |
320 | - public function getLandline():? string |
|
320 | + public function getLandline(): ? string |
|
321 | 321 | { |
322 | 322 | return $this->landline; |
323 | 323 | } |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | /** |
337 | 337 | * @return string|null |
338 | 338 | */ |
339 | - public function getAddressLine1():? string |
|
339 | + public function getAddressLine1(): ? string |
|
340 | 340 | { |
341 | 341 | return $this->addressLine1; |
342 | 342 | } |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | /** |
356 | 356 | * @return string|null |
357 | 357 | */ |
358 | - public function getAddressLine2():? string |
|
358 | + public function getAddressLine2(): ? string |
|
359 | 359 | { |
360 | 360 | return $this->addressLine2; |
361 | 361 | } |
@@ -34,10 +34,10 @@ discard block |
||
34 | 34 | ]; |
35 | 35 | } |
36 | 36 | |
37 | - /** |
|
37 | + /** |
|
38 | 38 | * Retrieve a paymentInstrument from server and fill the $paymentInstrument Object with response. |
39 | - * |
|
40 | - */ |
|
39 | + * |
|
40 | + */ |
|
41 | 41 | public function get(): array |
42 | 42 | { |
43 | 43 | $response = []; |
@@ -49,49 +49,49 @@ discard block |
||
49 | 49 | }; |
50 | 50 | |
51 | 51 | return $response; |
52 | - } |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
54 | + /** |
|
55 | 55 | * Delete an paymentInstrument from server. |
56 | - * |
|
56 | + * |
|
57 | 57 | * @param PaymentInstrumentInterface $paymentInstrument |
58 | 58 | * @return bool |
59 | - */ |
|
59 | + */ |
|
60 | 60 | public function disable(PaymentInstrumentInterface $paymentInstrument):?bool |
61 | 61 | { |
62 | 62 | $uri = $this->getEndPoint().'/'.$paymentInstrument->getToken(); |
63 | 63 | |
64 | 64 | return $this->request('delete', $paymentInstrument, $uri); |
65 | - } |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * CheckoutClientInterface constructor. |
|
69 | - * @param ContextInterface $context |
|
67 | + /** |
|
68 | + * CheckoutClientInterface constructor. |
|
69 | + * @param ContextInterface $context |
|
70 | 70 | * @param array $options |
71 | 71 | */ |
72 | 72 | public function __construct(ContextInterface $context, ?array $options = []) |
73 | - { |
|
73 | + { |
|
74 | 74 | $this->context = $context; |
75 | 75 | $this->options = $options; |
76 | - } |
|
77 | - |
|
78 | - /** |
|
79 | - * Return last response of client |
|
80 | - * @return ResponseInterface |
|
81 | - */ |
|
82 | - function getLastResponse(): ResponseInterface |
|
83 | - { |
|
76 | + } |
|
77 | + |
|
78 | + /** |
|
79 | + * Return last response of client |
|
80 | + * @return ResponseInterface |
|
81 | + */ |
|
82 | + function getLastResponse(): ResponseInterface |
|
83 | + { |
|
84 | 84 | return $this->lastResponse; |
85 | - } |
|
86 | - |
|
87 | - /** |
|
88 | - * return the context used to created the client. |
|
89 | - * @return ContextInterface |
|
90 | - */ |
|
91 | - function getContext(): ContextInterface |
|
92 | - { |
|
85 | + } |
|
86 | + |
|
87 | + /** |
|
88 | + * return the context used to created the client. |
|
89 | + * @return ContextInterface |
|
90 | + */ |
|
91 | + function getContext(): ContextInterface |
|
92 | + { |
|
93 | 93 | return $this->context; |
94 | - } |
|
94 | + } |
|
95 | 95 | |
96 | 96 | /** |
97 | 97 | * @param PaymentInstrumentInterface $object |
@@ -166,5 +166,5 @@ discard block |
||
166 | 166 | public function getCustomer(): CustomerInterface |
167 | 167 | { |
168 | 168 | return $this->customer; |
169 | - } |
|
169 | + } |
|
170 | 170 | } |
@@ -57,9 +57,9 @@ discard block |
||
57 | 57 | * @param PaymentInstrumentInterface $paymentInstrument |
58 | 58 | * @return bool |
59 | 59 | */ |
60 | - public function disable(PaymentInstrumentInterface $paymentInstrument):?bool |
|
60 | + public function disable(PaymentInstrumentInterface $paymentInstrument): ?bool |
|
61 | 61 | { |
62 | - $uri = $this->getEndPoint().'/'.$paymentInstrument->getToken(); |
|
62 | + $uri = $this->getEndPoint() . '/' . $paymentInstrument->getToken(); |
|
63 | 63 | |
64 | 64 | return $this->request('delete', $paymentInstrument, $uri); |
65 | 65 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | */ |
128 | 128 | function getEndPoint(): string |
129 | 129 | { |
130 | - return 'customers/'.$this->customer->getCustomerId().'/payment-instruments'; |
|
130 | + return 'customers/' . $this->customer->getCustomerId() . '/payment-instruments'; |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | /** |
145 | 145 | * @return AccessToken |
146 | 146 | */ |
147 | - function getToken():? AccessToken |
|
147 | + function getToken(): ? AccessToken |
|
148 | 148 | { |
149 | 149 | return $this->token; |
150 | 150 | } |