diff --git a/Api/Checkout/V2/Exception.php b/Api/Checkout/V2/Exception.php index a942322..17c2723 100644 --- a/Api/Checkout/V2/Exception.php +++ b/Api/Checkout/V2/Exception.php @@ -1,5 +1,6 @@ mixed) */ - protected function responseA(\Exception $e):array {return $e->getPayload();} + protected function responseA(T $t):array {return $t->getPayload();} } \ No newline at end of file diff --git a/Api/Checkout/V3/Exception/Connector.php b/Api/Checkout/V3/Exception/Connector.php index 5de7dd6..d53e53e 100644 --- a/Api/Checkout/V3/Exception/Connector.php +++ b/Api/Checkout/V3/Exception/Connector.php @@ -1,5 +1,6 @@ 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 [];} } \ No newline at end of file diff --git a/Api/Checkout/V3/Exception/Guzzle.php b/Api/Checkout/V3/Exception/Guzzle.php index 7d34912..69ffb72 100644 --- a/Api/Checkout/V3/Exception/Guzzle.php +++ b/Api/Checkout/V3/Exception/Guzzle.php @@ -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 случаях: @@ -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()]; } } \ No newline at end of file diff --git a/Exception.php b/Exception.php index 8a9aa67..b695721 100644 --- a/Exception.php +++ b/Exception.php @@ -1,5 +1,6 @@ mixed) */ - abstract protected function responseA(\Exception $e):array; + abstract protected function responseA(T $t):array; /** * 2017-01-26 @@ -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 @@ -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 diff --git a/Test/Charge.php b/Test/Charge.php index cd4235f..2949050 100644 --- a/Test/Charge.php +++ b/Test/Charge.php @@ -33,8 +33,8 @@ function t01():void { } } } - catch (\Exception $e) { - print_r(df_xtsd($e)); + catch (\Throwable $t) { + print_r(df_xtsd($t)); } } } \ No newline at end of file diff --git a/composer.json b/composer.json index a91c467..691af09 100644 --- a/composer.json +++ b/composer.json @@ -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" @@ -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": [