@@ -58,7 +58,7 @@ |
||
| 58 | 58 | public function isValid() |
| 59 | 59 | { |
| 60 | 60 | return parent::isValid() && |
| 61 | - ($this->call instanceof CallEntity && $this->call->isValid()) && |
|
| 61 | + ($this->call instanceof CallEntity && $this->call->isValid()) && |
|
| 62 | 62 | ($this->result instanceof ResultEntity && $this->result->isValid() || !$this->result) |
| 63 | 63 | ; |
| 64 | 64 | } |
@@ -43,7 +43,7 @@ |
||
| 43 | 43 | { |
| 44 | 44 | if (!self::$registered) { |
| 45 | 45 | self::$registered = spl_autoload_register( |
| 46 | - function ($className) { |
|
| 46 | + function($className) { |
|
| 47 | 47 | if (strncmp(PEI_NAMESPACE, $className, strlen(PEI_NAMESPACE)) !== 0) { |
| 48 | 48 | return; |
| 49 | 49 | } |
@@ -219,7 +219,7 @@ |
||
| 219 | 219 | public function getImagesUuid() |
| 220 | 220 | { |
| 221 | 221 | return array_map( |
| 222 | - function ($imageName) { |
|
| 222 | + function($imageName) { |
|
| 223 | 223 | return substr($imageName, 0, strpos($imageName, '.')); |
| 224 | 224 | }, |
| 225 | 225 | $this->getImages() |
@@ -67,7 +67,7 @@ |
||
| 67 | 67 | public function isValid() |
| 68 | 68 | { |
| 69 | 69 | return parent::isValid() && |
| 70 | - (!$this->call || ($this->call instanceof CallEntity && $this->call->isValid())) && |
|
| 70 | + (!$this->call || ($this->call instanceof CallEntity && $this->call->isValid())) && |
|
| 71 | 71 | ( |
| 72 | 72 | !$this->result || ($this->result instanceof ResultEntity && $this->result->isValid()) |
| 73 | 73 | || is_array($this->result) |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | const SUB_URL_LIST_CHANNEL_SETS = 'api/shop/oauth/%s/channel-sets'; |
| 48 | 48 | const SUB_URL_CURRENCY = 'api/rest/v1/currency'; |
| 49 | 49 | |
| 50 | - const FORBIDDEN_ERROR_CODE = 403; |
|
| 50 | + const FORBIDDEN_ERROR_CODE = 403; |
|
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | 53 | * Stores oAuth Authentication Tokens |
@@ -370,31 +370,31 @@ discard block |
||
| 370 | 370 | return $this->getHttpClient()->execute($request); |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | - /** |
|
| 374 | - * @param Request $request |
|
| 375 | - * @param string $scope |
|
| 376 | - * |
|
| 377 | - * @return \Payever\ExternalIntegration\Core\Http\Response |
|
| 378 | - * @throws \Exception |
|
| 379 | - */ |
|
| 380 | - protected function executeRequest($request, $scope = OauthToken::SCOPE_PAYMENT_ACTIONS) |
|
| 381 | - { |
|
| 382 | - try { |
|
| 383 | - return $this->getHttpClient()->execute($request); |
|
| 384 | - } catch (\Exception $exception) { |
|
| 385 | - if ($exception->getCode() === self::FORBIDDEN_ERROR_CODE) { |
|
| 386 | - $this->getTokens()->clear()->save(); |
|
| 387 | - |
|
| 388 | - $newToken = $this->getToken($scope)->getAuthorizationString(); |
|
| 389 | - $pieces = explode(':', $newToken, 2); |
|
| 390 | - $request->addHeader($pieces[0], $pieces[1]); |
|
| 391 | - |
|
| 392 | - return $this->getHttpClient()->execute($request); |
|
| 393 | - } |
|
| 394 | - |
|
| 395 | - throw $exception; |
|
| 396 | - } |
|
| 397 | - } |
|
| 373 | + /** |
|
| 374 | + * @param Request $request |
|
| 375 | + * @param string $scope |
|
| 376 | + * |
|
| 377 | + * @return \Payever\ExternalIntegration\Core\Http\Response |
|
| 378 | + * @throws \Exception |
|
| 379 | + */ |
|
| 380 | + protected function executeRequest($request, $scope = OauthToken::SCOPE_PAYMENT_ACTIONS) |
|
| 381 | + { |
|
| 382 | + try { |
|
| 383 | + return $this->getHttpClient()->execute($request); |
|
| 384 | + } catch (\Exception $exception) { |
|
| 385 | + if ($exception->getCode() === self::FORBIDDEN_ERROR_CODE) { |
|
| 386 | + $this->getTokens()->clear()->save(); |
|
| 387 | + |
|
| 388 | + $newToken = $this->getToken($scope)->getAuthorizationString(); |
|
| 389 | + $pieces = explode(':', $newToken, 2); |
|
| 390 | + $request->addHeader($pieces[0], $pieces[1]); |
|
| 391 | + |
|
| 392 | + return $this->getHttpClient()->execute($request); |
|
| 393 | + } |
|
| 394 | + |
|
| 395 | + throw $exception; |
|
| 396 | + } |
|
| 397 | + } |
|
| 398 | 398 | |
| 399 | 399 | /** |
| 400 | 400 | * Returns URL for Authentication path |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | ->setResponseEntity(new RetrievePaymentResponse()) |
| 114 | 114 | ->build(); |
| 115 | 115 | |
| 116 | - return $this->executeRequest($request, OauthToken::SCOPE_CREATE_PAYMENT); |
|
| 116 | + return $this->executeRequest($request, OauthToken::SCOPE_CREATE_PAYMENT); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | /** |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | ->setResponseEntity(new RetrievePaymentResponse()) |
| 133 | 133 | ->build(); |
| 134 | 134 | |
| 135 | - return $this->executeRequest($request, OauthToken::SCOPE_PAYMENT_INFO); |
|
| 135 | + return $this->executeRequest($request, OauthToken::SCOPE_PAYMENT_INFO); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | /** |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | ->setResponseEntity(new ListPaymentsResponse()) |
| 153 | 153 | ->build(); |
| 154 | 154 | |
| 155 | - return $this->executeRequest($request); |
|
| 155 | + return $this->executeRequest($request); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | /** |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | ->setResponseEntity(new RefundPaymentResponse()) |
| 176 | 176 | ->build(); |
| 177 | 177 | |
| 178 | - return $this->executeRequest($request); |
|
| 178 | + return $this->executeRequest($request); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | /** |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | ->setResponseEntity(new RefundPaymentResponse()) |
| 200 | 200 | ->build(); |
| 201 | 201 | |
| 202 | - return $this->executeRequest($request); |
|
| 202 | + return $this->executeRequest($request); |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | /** |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | ->setResponseEntity(new AuthorizePaymentResponse()) |
| 220 | 220 | ->build(); |
| 221 | 221 | |
| 222 | - return $this->executeRequest($request); |
|
| 222 | + return $this->executeRequest($request); |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | /** |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | ->setResponseEntity(new RemindPaymentResponse()) |
| 241 | 241 | ->build(); |
| 242 | 242 | |
| 243 | - return $this->executeRequest($request); |
|
| 243 | + return $this->executeRequest($request); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | /** |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | ->setResponseEntity(new CollectPaymentsResponse()) |
| 262 | 262 | ->build(); |
| 263 | 263 | |
| 264 | - return $this->executeRequest($request); |
|
| 264 | + return $this->executeRequest($request); |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | /** |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | ->setResponseEntity(new LatePaymentsResponse()) |
| 283 | 283 | ->build(); |
| 284 | 284 | |
| 285 | - return $this->executeRequest($request); |
|
| 285 | + return $this->executeRequest($request); |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | /** |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | ->setResponseEntity(new ShippingGoodsPaymentResponse()) |
| 305 | 305 | ->build(); |
| 306 | 306 | |
| 307 | - return $this->executeRequest($request); |
|
| 307 | + return $this->executeRequest($request); |
|
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | /** |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | ->setResponseEntity(new CancelPaymentResponse()) |
| 324 | 324 | ->build(); |
| 325 | 325 | |
| 326 | - return $this->executeRequest($request); |
|
| 326 | + return $this->executeRequest($request); |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | /** |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | ->setResponseEntity(new RetrieveApiCallResponse()) |
| 343 | 343 | ->build(); |
| 344 | 344 | |
| 345 | - return $this->executeRequest($request); |
|
| 345 | + return $this->executeRequest($request); |
|
| 346 | 346 | } |
| 347 | 347 | |
| 348 | 348 | /** |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | ->setResponseEntity(new ListPaymentOptionsResponse()) |
| 363 | 363 | ->build(); |
| 364 | 364 | |
| 365 | - return $this->executeRequest($request, OauthToken::SCOPE_PAYMENT_INFO); |
|
| 365 | + return $this->executeRequest($request, OauthToken::SCOPE_PAYMENT_INFO); |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | /** |
@@ -382,7 +382,7 @@ discard block |
||
| 382 | 382 | ->setResponseEntity(new ListPaymentOptionsWithVariantsResponse()) |
| 383 | 383 | ->build(); |
| 384 | 384 | |
| 385 | - return $this->executeRequest($request, OauthToken::SCOPE_PAYMENT_INFO); |
|
| 385 | + return $this->executeRequest($request, OauthToken::SCOPE_PAYMENT_INFO); |
|
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | /** |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | ->setResponseEntity(new GetTransactionResponse()) |
| 402 | 402 | ->build(); |
| 403 | 403 | |
| 404 | - return $this->executeRequest($request); |
|
| 404 | + return $this->executeRequest($request); |
|
| 405 | 405 | } |
| 406 | 406 | |
| 407 | 407 | /** |