Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
MarijusCoding committed Oct 7, 2024
1 parent 21cdd45 commit 1ac979e
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion controllers/front/validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions src/Api/Request/AssertService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions src/Core/Payment/DTO/CheckoutData.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ private function setCreateAfterAuthorization($paymentMethod)
{
$methodsToForceBeforeAuthorization = [
SaferPayConfig::PAYMENT_ACCOUNTTOACCOUNT,
SaferPayConfig::PAYMENT_WECHATPAY,
];

if (in_array($paymentMethod, $methodsToForceBeforeAuthorization, true)) {
Expand Down
1 change: 1 addition & 0 deletions src/Service/SaferPayInitialize.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public function buildRequest(
'isBusinessLicence' => $isBusinessLicence,
'fieldToken' => $fieldToken,
'successController' => $successController,
'paymentMethod' => $paymentMethod,
],
true
);
Expand Down
5 changes: 3 additions & 2 deletions src/Service/TransactionFlow/SaferPayTransactionAssertion.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 1ac979e

Please sign in to comment.