Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrii-fediuk committed Aug 3, 2023
1 parent f530a43 commit 8ec49eb
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 17 deletions.
5 changes: 3 additions & 2 deletions Api/Checkout/V2/Exception.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
namespace Dfe\Klarna\Api\Checkout\V2;
use \Throwable as T; # 2023-08-03 "Treat `\Throwable` similar to `\Exception`": https://github.com/mage2pro/core/issues/311
/**
* 2017-01-26
* @used-by \Dfe\Klarna\Api\Checkout::html()
Expand All @@ -10,8 +11,8 @@ final class Exception extends \Dfe\Klarna\Exception {
* @override
* @see \Dfe\Klarna\Exception::responseA()
* @used-by \Dfe\Klarna\Exception::message()
* @param \Exception|\Klarna_Checkout_ApiErrorException $e
* @param T|\Klarna_Checkout_ApiErrorException $t
* @return array(string => mixed)
*/
protected function responseA(\Exception $e):array {return $e->getPayload();}
protected function responseA(T $t):array {return $t->getPayload();}
}
8 changes: 4 additions & 4 deletions Api/Checkout/V3/Exception/Connector.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
namespace Dfe\Klarna\Api\Checkout\V3\Exception;
use \Throwable as T; # 2023-08-03 "Treat `\Throwable` similar to `\Exception`": https://github.com/mage2pro/core/issues/311
/**
* 2017-01-26
* @see \Klarna\Rest\Transport\Connector::send():
Expand All @@ -13,10 +14,9 @@ class Connector extends \Dfe\Klarna\Api\Checkout\V3\Exception {
* @override
* @see \Dfe\Klarna\Exception::responseA()
* @used-by \Dfe\Klarna\Exception::message()
* @param \Exception|\Klarna\Rest\Transport\Exception\ConnectorException $e
* @param T|\Klarna\Rest\Transport\Exception\ConnectorException $t
* @return array(string => mixed)
* @todo Ещё не реализовано, потому что у меня нет пока доступов к API версии 3:
* https://mage2.pro/t/2531
* @todo Ещё не реализовано, потому что у меня нет пока доступов к API версии 3: https://mage2.pro/t/2531
*/
protected function responseA(\Exception $e):array {return [];}
protected function responseA(T $t):array {return [];}
}
7 changes: 4 additions & 3 deletions Api/Checkout/V3/Exception/Guzzle.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
namespace Dfe\Klarna\Api\Checkout\V3\Exception;
use GuzzleHttp\Psr7\Response;
use Psr\Http\Message\RequestInterface as IResponse;
use \Throwable as T; # 2023-08-03 "Treat `\Throwable` similar to `\Exception`": https://github.com/mage2pro/core/issues/311
/**
* 2017-01-26
* Исключительная ситуация этого класса возбуждается в 2 случаях:
Expand Down Expand Up @@ -33,11 +34,11 @@ class Guzzle extends \Dfe\Klarna\Api\Checkout\V3\Exception {
* @override
* @see \Dfe\Klarna\Exception::responseA()
* @used-by \Dfe\Klarna\Exception::message()
* @param \Exception|\GuzzleHttp\Exception\ClientException $e
* @param T|\GuzzleHttp\Exception\ClientException $t
* @return array(string => mixed)
*/
protected function responseA(\Exception $e):array {
$r = $e->getResponse(); /** @var IResponse|Response $r */
protected function responseA(T $t):array {
$r = $t->getResponse(); /** @var IResponse|Response $r */
return ['HTTP Status Code' => $r->getStatusCode(), 'Reason' => $r->getReasonPhrase()];
}
}
8 changes: 4 additions & 4 deletions Exception.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
namespace Dfe\Klarna;
use \Throwable as T; # 2023-08-03 "Treat `\Throwable` similar to `\Exception`": https://github.com/mage2pro/core/issues/311
/**
* 2017-01-26
* @see \Dfe\Klarna\Api\Checkout\V2\Exception
Expand All @@ -12,10 +13,9 @@ abstract class Exception extends \Df\Payment\Exception {
* @see \Dfe\Klarna\Api\Checkout\V2\Exception::responseA()
* @see \Dfe\Klarna\Api\Checkout\V3\Exception\Guzzle::responseA()
* @see \Dfe\Klarna\Api\Checkout\V3\Exception\Connector::responseA()
* @param \Exception $e
* @return array(string => mixed)
*/
abstract protected function responseA(\Exception $e):array;
abstract protected function responseA(T $t):array;

/**
* 2017-01-26
Expand All @@ -24,7 +24,7 @@ abstract protected function responseA(\Exception $e):array;
* @used-by \Dfe\Klarna\Api\Checkout::html()
* @param array(string => mixed) $req
*/
final function __construct(\Exception $e, array $req) {$this->_req = $req; parent::__construct($e);}
final function __construct(T $t, array $req) {$this->_req = $req; parent::__construct($t);}

/**
* 2017-01-26
Expand All @@ -40,7 +40,7 @@ final function message():string {return df_api_rr_failed($this, $this->responseA
* @see \Df\Core\Exception::messageC()
* @used-by \Df\Payment\PlaceOrderInternal::message()
*/
final function messageC():string {return dfp_error_message($this->prev()->getMessage());}
final function messageC():string {return dfp_error_message(df_xts($this->prev()));}

/**
* 2017-01-26
Expand Down
4 changes: 2 additions & 2 deletions Test/Charge.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ function t01():void {
}
}
}
catch (\Exception $e) {
print_r(df_xtsd($e));
catch (\Throwable $t) {
print_r(df_xtsd($t));
}
}
}
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mage2pro/klarna"
,"version": "0.5.1"
,"version": "0.5.2"
,"description": "Klarna integration with Magento 2"
,"type": "magento2-module"
,"homepage": "https://mage2.pro/c/extensions/klarna"
Expand All @@ -12,7 +12,7 @@
"role": "Developer"
}]
,"require": {
"klarna/checkout": "*", "mage2pro/core": ">=9.0.5", "mage2pro/klarna-sdk-v3": "^2.2.3", "php-http/guzzle7-adapter": "*"
"klarna/checkout": "*", "mage2pro/core": ">=10.2.1", "mage2pro/klarna-sdk-v3": "^2.2.3", "php-http/guzzle7-adapter": "*"
}
,"autoload": {"files": ["registration.php"], "psr-4": {"Dfe\\Klarna\\": ""}}
,"keywords": [
Expand Down

0 comments on commit 8ec49eb

Please sign in to comment.