99
1010use Magento \Framework \Webapi \Rest \Request ;
1111use Magento \Paypal \Model \Config ;
12+ use Magento \Quote \Model \QuoteIdMaskFactory ;
1213use Magento \ReCaptchaCheckout \Model \WebapiConfigProvider ;
1314use Magento \ReCaptchaPaypal \Model \ReCaptchaSession ;
1415use 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
0 commit comments