diff --git a/vendor/magento/module-captcha/Plugin/ResetPaymentAttemptsAfterOrderIsPlacedPlugin.php b/vendor/magento/module-captcha/Plugin/ResetPaymentAttemptsAfterOrderIsPlacedPlugin.php new file mode 100644 index 00000000000..660d5acc758 --- /dev/null +++ b/vendor/magento/module-captcha/Plugin/ResetPaymentAttemptsAfterOrderIsPlacedPlugin.php @@ -0,0 +1,65 @@ +helper = $helper; + $this->resLogFactory = $resLogFactory; + } + + /** + * Reset attempts for frontend checkout + * + * @param OrderManagementInterface $subject + * @param OrderInterface $result + * @param OrderInterface $order + * @return OrderInterface + */ + public function afterPlace( + OrderManagementInterface $subject, + OrderInterface $result, + OrderInterface $order + ): OrderInterface { + $captchaModel = $this->helper->getCaptcha(self::FORM_ID); + $captchaModel->setShowCaptchaInSession(false); + $this->resLogFactory->create()->deleteUserAttempts($order->getCustomerEmail()); + return $result; + } +} diff --git a/vendor/magento/module-captcha/etc/frontend/di.xml b/vendor/magento/module-captcha/etc/frontend/di.xml index 490f1eab851..6ecbb156b44 100644 --- a/vendor/magento/module-captcha/etc/frontend/di.xml +++ b/vendor/magento/module-captcha/etc/frontend/di.xml @@ -34,4 +34,7 @@ + + + diff --git a/vendor/magento/module-captcha/etc/frontend/sections.xml b/vendor/magento/module-captcha/etc/frontend/sections.xml index 7f2070e10c8..665d989e229 100644 --- a/vendor/magento/module-captcha/etc/frontend/sections.xml +++ b/vendor/magento/module-captcha/etc/frontend/sections.xml @@ -10,4 +10,10 @@
+ +
+ + +
+ diff --git a/vendor/magento/module-captcha/etc/module.xml b/vendor/magento/module-captcha/etc/module.xml index 36a44a65430..7a7ffc7f460 100644 --- a/vendor/magento/module-captcha/etc/module.xml +++ b/vendor/magento/module-captcha/etc/module.xml @@ -10,6 +10,7 @@ + diff --git a/vendor/magento/module-captcha/etc/webapi_rest/di.xml b/vendor/magento/module-captcha/etc/webapi_rest/di.xml new file mode 100644 index 00000000000..7c5efea56a4 --- /dev/null +++ b/vendor/magento/module-captcha/etc/webapi_rest/di.xml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/vendor/magento/module-captcha/view/frontend/web/js/view/checkout/defaultCaptcha.js b/vendor/magento/module-captcha/view/frontend/web/js/view/checkout/defaultCaptcha.js index d79c42a7115..2e32efb3233 100644 --- a/vendor/magento/module-captcha/view/frontend/web/js/view/checkout/defaultCaptcha.js +++ b/vendor/magento/module-captcha/view/frontend/web/js/view/checkout/defaultCaptcha.js @@ -21,6 +21,7 @@ define([ }, dataScope: 'global', currentCaptcha: null, + subscribedFormIds: [], /** * @return {*} @@ -74,9 +75,12 @@ define([ * @param {Object} captcha */ subscribeCustomerData: function (formId, captcha) { - customerData.get('captcha').subscribe(function (captchaData) { - this.checkCustomerData(formId, captchaData, captcha); - }.bind(this)); + if (this.subscribedFormIds.includes(formId) === false) { + this.subscribedFormIds.push(formId); + customerData.get('captcha').subscribe(function (captchaData) { + this.checkCustomerData(formId, captchaData, captcha); + }.bind(this)); + } }, /**