Skip to content

Commit 0e537a5

Browse files
committed
ACP2E-1338: Google reCaptcha in Incorrect position
1 parent 9b65c30 commit 0e537a5

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

ReCaptchaPaypal/Plugin/ReplayPayflowReCaptchaForPlaceOrder.php

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
use Magento\Framework\Webapi\Rest\Request;
1111
use Magento\Paypal\Model\Config;
12+
use Magento\Quote\Model\QuoteIdMaskFactory;
1213
use Magento\ReCaptchaCheckout\Model\WebapiConfigProvider;
1314
use Magento\ReCaptchaPaypal\Model\ReCaptchaSession;
1415
use Magento\ReCaptchaUi\Model\IsCaptchaEnabledInterface;
@@ -34,19 +35,27 @@ class ReplayPayflowReCaptchaForPlaceOrder
3435
*/
3536
private ReCaptchaSession $reCaptchaSession;
3637

38+
/**
39+
* @var QuoteIdMaskFactory
40+
*/
41+
private QuoteIdMaskFactory $quoteIdMaskFactory;
42+
3743
/**
3844
* @param IsCaptchaEnabledInterface $isCaptchaEnabled
3945
* @param Request $request
4046
* @param ReCaptchaSession $reCaptchaSession
47+
* @param QuoteIdMaskFactory $quoteIdMaskFactory
4148
*/
4249
public function __construct(
4350
IsCaptchaEnabledInterface $isCaptchaEnabled,
4451
Request $request,
45-
ReCaptchaSession $reCaptchaSession
52+
ReCaptchaSession $reCaptchaSession,
53+
QuoteIdMaskFactory $quoteIdMaskFactory
4654
) {
4755
$this->isCaptchaEnabled = $isCaptchaEnabled;
4856
$this->request = $request;
4957
$this->reCaptchaSession = $reCaptchaSession;
58+
$this->quoteIdMaskFactory = $quoteIdMaskFactory;
5059
}
5160

5261
/**
@@ -71,9 +80,14 @@ public function afterGetConfigFor(
7180
if (isset($paymentMethod['method'])
7281
&& $paymentMethod['method'] === Config::METHOD_PAYFLOWPRO
7382
&& $cartId
74-
&& $this->reCaptchaSession->isValid((int) $cartId)
7583
) {
76-
return null;
84+
// check if it is guest cart, then resolve cart id by mask ID
85+
if (!is_numeric($cartId)) {
86+
$cartId = $this->quoteIdMaskFactory->create()->load($cartId, 'masked_id')->getQuoteId();
87+
}
88+
if ($this->reCaptchaSession->isValid((int) $cartId)) {
89+
return null;
90+
}
7791
}
7892
}
7993

ReCaptchaPaypal/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"magento/module-re-captcha-validation-api": "*",
99
"magento/module-checkout": "*",
1010
"magento/module-re-captcha-webapi-api": "*",
11+
"magento/module-quote": "*",
1112
"magento/module-paypal": "*",
1213
"magento/module-re-captcha-checkout": "*"
1314
},

0 commit comments

Comments
 (0)