From 1ac979e6aa8b2d524ceaa301b69ce1fef5595bdf Mon Sep 17 00:00:00 2001 From: MarijusCoding Date: Mon, 7 Oct 2024 14:13:19 +0300 Subject: [PATCH] fix --- controllers/front/validation.php | 2 +- src/Api/Request/AssertService.php | 4 ++-- src/Core/Payment/DTO/CheckoutData.php | 1 + src/Service/SaferPayInitialize.php | 1 + src/Service/TransactionFlow/SaferPayTransactionAssertion.php | 5 +++-- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/controllers/front/validation.php b/controllers/front/validation.php index 4976e525..7ad594ec 100755 --- a/controllers/front/validation.php +++ b/controllers/front/validation.php @@ -44,7 +44,7 @@ class SaferPayOfficialValidationModuleFrontController extends AbstractSaferPayCo public function postProcess() { $paymentMethod = Tools::getValue('saved_card_method'); - $isBusiness = $paymentMethod === 'ACCOUNTTOACCOUNT' ? false : (bool) Tools::getValue(SaferPayConfig::IS_BUSINESS_LICENCE); + $isBusiness = $paymentMethod === 'ACCOUNTTOACCOUNT' || $paymentMethod === 'WECHATPAY' ? false : (bool) Tools::getValue(SaferPayConfig::IS_BUSINESS_LICENCE); $cart = $this->context->cart; $redirectLink = $this->context->link->getPageLink( 'order', diff --git a/src/Api/Request/AssertService.php b/src/Api/Request/AssertService.php index 97259a20..9117f027 100755 --- a/src/Api/Request/AssertService.php +++ b/src/Api/Request/AssertService.php @@ -78,7 +78,7 @@ public function __construct( * @return object|null * @throws \Exception */ - public function assert(AssertRequest $assertRequest, $isAccount = null) + public function assert(AssertRequest $assertRequest, $isAccount = null, $isWeChatPay = null) { $assertApi = self::ASSERT_API_PAYMENT; @@ -88,7 +88,7 @@ public function assert(AssertRequest $assertRequest, $isAccount = null) $assertApi = self::ASSERT_API_TRANSACTION; } - if ($isAccount) { + if ($isAccount || $isWeChatPay) { $assertApi = self::ASSERT_API_PAYMENT; } diff --git a/src/Core/Payment/DTO/CheckoutData.php b/src/Core/Payment/DTO/CheckoutData.php index a5cf6336..9d948592 100644 --- a/src/Core/Payment/DTO/CheckoutData.php +++ b/src/Core/Payment/DTO/CheckoutData.php @@ -192,6 +192,7 @@ private function setCreateAfterAuthorization($paymentMethod) { $methodsToForceBeforeAuthorization = [ SaferPayConfig::PAYMENT_ACCOUNTTOACCOUNT, + SaferPayConfig::PAYMENT_WECHATPAY, ]; if (in_array($paymentMethod, $methodsToForceBeforeAuthorization, true)) { diff --git a/src/Service/SaferPayInitialize.php b/src/Service/SaferPayInitialize.php index 450f1e3a..815c5054 100755 --- a/src/Service/SaferPayInitialize.php +++ b/src/Service/SaferPayInitialize.php @@ -117,6 +117,7 @@ public function buildRequest( 'isBusinessLicence' => $isBusinessLicence, 'fieldToken' => $fieldToken, 'successController' => $successController, + 'paymentMethod' => $paymentMethod, ], true ); diff --git a/src/Service/TransactionFlow/SaferPayTransactionAssertion.php b/src/Service/TransactionFlow/SaferPayTransactionAssertion.php index 568e7d42..a99bf25f 100755 --- a/src/Service/TransactionFlow/SaferPayTransactionAssertion.php +++ b/src/Service/TransactionFlow/SaferPayTransactionAssertion.php @@ -79,12 +79,13 @@ public function assert($cartId, $saveCard, $selectedCard, $update = true) } $order = new \Order($orderId); - $isAccount = $order->payment === 'ACCOUNTTOACCOUNT' ? true : null; + $isAccount = $order->payment === SaferPayConfig::PAYMENT_ACCOUNTTOACCOUNT ? true : null; + $isWeChatPay = $order->payment === SaferPayConfig::PAYMENT_WECHATPAY ? true : null; $saferPayOrder = new SaferPayOrder($this->orderRepository->getIdByCartId($cartId)); \PrestaShopLogger::addLog('saferpayOrderId:' . $saferPayOrder->id); $assertRequest = $this->assertRequestCreator->create($saferPayOrder->token, $saveCard); - $assertResponse = $this->assertionService->assert($assertRequest, $isAccount); + $assertResponse = $this->assertionService->assert($assertRequest, $isAccount, $isWeChatPay); if (empty($assertResponse)) { return null;