From 5fc24add395283b805997f7ec92f05cb400fcbf4 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 24 Apr 2024 16:41:14 +0200 Subject: [PATCH 1/6] Fix channel and group collision --- Model/ApiFacade/OpenApi.php | 4 ++++ Model/ApiFacade/OpenApiException.php | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 Model/ApiFacade/OpenApiException.php diff --git a/Model/ApiFacade/OpenApi.php b/Model/ApiFacade/OpenApi.php index 182a828..ecd2fd7 100755 --- a/Model/ApiFacade/OpenApi.php +++ b/Model/ApiFacade/OpenApi.php @@ -150,6 +150,10 @@ private function handleDataStructure(array $data): array ], ]; + if ($data['group'] && $data['channel']) { + throw \OpenApiException::channelAndGroupCollision(); + } + if ($data['group']) { $paymentData['pay']['groupId'] = $data['group']; } diff --git a/Model/ApiFacade/OpenApiException.php b/Model/ApiFacade/OpenApiException.php new file mode 100644 index 0000000..4043244 --- /dev/null +++ b/Model/ApiFacade/OpenApiException.php @@ -0,0 +1,17 @@ + Date: Thu, 25 Apr 2024 10:18:13 +0200 Subject: [PATCH 2/6] CI Fix --- Model/ApiFacade/OpenApi.php | 3 ++- Model/ApiFacade/OpenApiException.php | 3 +-- Model/ApiFacade/Transaction/TransactionOriginApi.php | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Model/ApiFacade/OpenApi.php b/Model/ApiFacade/OpenApi.php index ecd2fd7..fc5f4e8 100755 --- a/Model/ApiFacade/OpenApi.php +++ b/Model/ApiFacade/OpenApi.php @@ -4,6 +4,7 @@ use Magento\Framework\App\CacheInterface; use Magento\Payment\Model\InfoInterface; +use OpenApiException; use Tpay\Magento2\Api\TpayConfigInterface; use Tpay\Magento2\Model\ApiFacade\Transaction\Dto\Channel; use tpaySDK\Api\TpayApi; @@ -151,7 +152,7 @@ private function handleDataStructure(array $data): array ]; if ($data['group'] && $data['channel']) { - throw \OpenApiException::channelAndGroupCollision(); + throw OpenApiException::channelAndGroupCollision(); } if ($data['group']) { diff --git a/Model/ApiFacade/OpenApiException.php b/Model/ApiFacade/OpenApiException.php index 4043244..029c904 100644 --- a/Model/ApiFacade/OpenApiException.php +++ b/Model/ApiFacade/OpenApiException.php @@ -4,8 +4,7 @@ class OpenApiException extends \Exception { - - public function __construct($message = "", $code = 0, Throwable $previous = null) + public function __construct($message = '', $code = 0, ?Throwable $previous = null) { parent::__construct($message, $code, $previous); } diff --git a/Model/ApiFacade/Transaction/TransactionOriginApi.php b/Model/ApiFacade/Transaction/TransactionOriginApi.php index c83389d..5329086 100755 --- a/Model/ApiFacade/Transaction/TransactionOriginApi.php +++ b/Model/ApiFacade/Transaction/TransactionOriginApi.php @@ -13,6 +13,7 @@ class TransactionOriginApi extends PaymentBlik * @param string $apiKey * @param int $merchantId * @param string $merchantSecret + * @param mixed $isProd */ public function __construct($apiPassword, $apiKey, $merchantId, $merchantSecret, $isProd = true) { From 7111b754ee0a6e8f948a8fc46c387cf51cf35501 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 25 Apr 2024 10:21:58 +0200 Subject: [PATCH 3/6] CI Fix --- Model/ApiFacade/OpenApiException.php | 2 +- Model/ApiFacade/Transaction/TransactionOriginApi.php | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Model/ApiFacade/OpenApiException.php b/Model/ApiFacade/OpenApiException.php index 029c904..716d8ab 100644 --- a/Model/ApiFacade/OpenApiException.php +++ b/Model/ApiFacade/OpenApiException.php @@ -2,7 +2,7 @@ declare(strict_types=1); -class OpenApiException extends \Exception +class OpenApiException extends Exception { public function __construct($message = '', $code = 0, ?Throwable $previous = null) { diff --git a/Model/ApiFacade/Transaction/TransactionOriginApi.php b/Model/ApiFacade/Transaction/TransactionOriginApi.php index 5329086..c83389d 100755 --- a/Model/ApiFacade/Transaction/TransactionOriginApi.php +++ b/Model/ApiFacade/Transaction/TransactionOriginApi.php @@ -13,7 +13,6 @@ class TransactionOriginApi extends PaymentBlik * @param string $apiKey * @param int $merchantId * @param string $merchantSecret - * @param mixed $isProd */ public function __construct($apiPassword, $apiKey, $merchantId, $merchantSecret, $isProd = true) { From 37ceb2ccc069c480e10be667a70d06a1b3645af2 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 25 Apr 2024 10:24:25 +0200 Subject: [PATCH 4/6] Add missing namespace --- Model/ApiFacade/OpenApiException.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Model/ApiFacade/OpenApiException.php b/Model/ApiFacade/OpenApiException.php index 716d8ab..814ce94 100644 --- a/Model/ApiFacade/OpenApiException.php +++ b/Model/ApiFacade/OpenApiException.php @@ -2,6 +2,8 @@ declare(strict_types=1); +namespace Tpay\Magento2\Model\ApiFacade; + class OpenApiException extends Exception { public function __construct($message = '', $code = 0, ?Throwable $previous = null) From 2faa9025aaf442e24f4424c1a1d146f2c9da34ef Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 25 Apr 2024 10:26:11 +0200 Subject: [PATCH 5/6] Fix imports --- Model/ApiFacade/OpenApiException.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Model/ApiFacade/OpenApiException.php b/Model/ApiFacade/OpenApiException.php index 814ce94..e7b18c3 100644 --- a/Model/ApiFacade/OpenApiException.php +++ b/Model/ApiFacade/OpenApiException.php @@ -4,6 +4,9 @@ namespace Tpay\Magento2\Model\ApiFacade; +use Exception; +use Throwable; + class OpenApiException extends Exception { public function __construct($message = '', $code = 0, ?Throwable $previous = null) From 4cb5a5445d280d81600c94f9883637c227c8efa6 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 25 Apr 2024 10:28:26 +0200 Subject: [PATCH 6/6] Fix imports --- Model/ApiFacade/OpenApi.php | 1 - 1 file changed, 1 deletion(-) diff --git a/Model/ApiFacade/OpenApi.php b/Model/ApiFacade/OpenApi.php index fc5f4e8..4bfaea8 100755 --- a/Model/ApiFacade/OpenApi.php +++ b/Model/ApiFacade/OpenApi.php @@ -4,7 +4,6 @@ use Magento\Framework\App\CacheInterface; use Magento\Payment\Model\InfoInterface; -use OpenApiException; use Tpay\Magento2\Api\TpayConfigInterface; use Tpay\Magento2\Model\ApiFacade\Transaction\Dto\Channel; use tpaySDK\Api\TpayApi;