| 
 | 1 | +diff --git a/vendor/magento/module-re-captcha-gift-card/view/frontend/layout/checkout_cart_index.xml b/vendor/magento/module-re-captcha-gift-card/view/frontend/layout/checkout_cart_index.xml  | 
 | 2 | +index 8a7e43ed..822f51a0 100644  | 
 | 3 | +--- a/vendor/magento/module-re-captcha-gift-card/view/frontend/layout/checkout_cart_index.xml  | 
 | 4 | ++++ b/vendor/magento/module-re-captcha-gift-card/view/frontend/layout/checkout_cart_index.xml  | 
 | 5 | +@@ -19,7 +19,7 @@  | 
 | 6 | +                         <argument name="jsLayout" xsi:type="array">  | 
 | 7 | +                             <item name="components" xsi:type="array">  | 
 | 8 | +                                 <item name="recaptcha" xsi:type="array">  | 
 | 9 | +-                                    <item name="component" xsi:type="string">Magento_ReCaptchaFrontendUi/js/reCaptcha</item>  | 
 | 10 | ++                                    <item name="component" xsi:type="string">Magento_ReCaptchaGiftCard/js/checkoutReCaptcha</item>  | 
 | 11 | +                                 </item>  | 
 | 12 | +                             </item>  | 
 | 13 | +                         </argument>  | 
 | 14 | +diff --git a/vendor/magento/module-re-captcha-gift-card/view/frontend/web/js/action/get-gift-card-information-mixin.js b/vendor/magento/module-re-captcha-gift-card/view/frontend/web/js/action/get-gift-card-information-mixin.js  | 
 | 15 | +index 2eda05a0..c16606ad 100644  | 
 | 16 | +--- a/vendor/magento/module-re-captcha-gift-card/view/frontend/web/js/action/get-gift-card-information-mixin.js  | 
 | 17 | ++++ b/vendor/magento/module-re-captcha-gift-card/view/frontend/web/js/action/get-gift-card-information-mixin.js  | 
 | 18 | +@@ -3,7 +3,10 @@  | 
 | 19 | +  * See COPYING.txt for license details.  | 
 | 20 | +  */  | 
 | 21 | +   | 
 | 22 | ++ /* eslint-disable max-nested-callbacks */  | 
 | 23 | ++  | 
 | 24 | + define([  | 
 | 25 | ++    'jquery',  | 
 | 26 | +     'ko',  | 
 | 27 | +     'mage/storage',  | 
 | 28 | +     'Magento_Customer/js/model/customer',  | 
 | 29 | +@@ -15,6 +18,7 @@ define([  | 
 | 30 | +     'mage/utils/wrapper',  | 
 | 31 | +     'Magento_ReCaptchaWebapiUi/js/webapiReCaptchaRegistry'  | 
 | 32 | + ], function (  | 
 | 33 | ++    $,  | 
 | 34 | +     ko,  | 
 | 35 | +     storage,  | 
 | 36 | +     customer,  | 
 | 37 | +@@ -35,43 +39,57 @@ define([  | 
 | 38 | +          * @param {Object} giftCardCode - giftCardCode model.  | 
 | 39 | +          */  | 
 | 40 | +         check: function (originFn, giftCardCode) {  | 
 | 41 | +-            var self = this,  | 
 | 42 | ++            var recaptchaDeferred,  | 
 | 43 | ++                self = this,  | 
 | 44 | +                 serviceUrl, headers = {};  | 
 | 45 | +   | 
 | 46 | ++            if (!customer.isLoggedIn()) {  | 
 | 47 | ++                serviceUrl = urlBuilder.createUrl('/carts/guest-carts/:cartId/checkGiftCard/:giftCardCode', {  | 
 | 48 | ++                    cartId: quote.getQuoteId(),  | 
 | 49 | ++                    giftCardCode: giftCardCode  | 
 | 50 | ++                });  | 
 | 51 | ++            } else {  | 
 | 52 | ++                serviceUrl = urlBuilder.createUrl('/carts/mine/checkGiftCard/:giftCardCode', {  | 
 | 53 | ++                    giftCardCode: giftCardCode  | 
 | 54 | ++                });  | 
 | 55 | ++            }  | 
 | 56 | ++            messageList.clear();  | 
 | 57 | ++  | 
 | 58 | +             this.isLoading(true);  | 
 | 59 | +   | 
 | 60 | +             if (recaptchaRegistry.triggers.hasOwnProperty('recaptcha-checkout-gift-apply')) {  | 
 | 61 | ++                //ReCaptcha is present for checkout  | 
 | 62 | ++                recaptchaDeferred = $.Deferred();  | 
 | 63 | +                 recaptchaRegistry.addListener('recaptcha-checkout-gift-apply', function (token) {  | 
 | 64 | +                     headers  = {  | 
 | 65 | +                         'X-ReCaptcha': token  | 
 | 66 | +                     };  | 
 | 67 | +-                });  | 
 | 68 | +   | 
 | 69 | +-                if (!customer.isLoggedIn()) {  | 
 | 70 | +-                    serviceUrl = urlBuilder.createUrl('/carts/guest-carts/:cartId/checkGiftCard/:giftCardCode', {  | 
 | 71 | +-                        cartId: quote.getQuoteId(),  | 
 | 72 | +-                        giftCardCode: giftCardCode  | 
 | 73 | +-                    });  | 
 | 74 | +-                } else {  | 
 | 75 | +-                    serviceUrl = urlBuilder.createUrl('/carts/mine/checkGiftCard/:giftCardCode', {  | 
 | 76 | +-                        giftCardCode: giftCardCode  | 
 | 77 | ++                    storage.get(  | 
 | 78 | ++                        serviceUrl,  true, 'application/json', headers  | 
 | 79 | ++                   ).done(function (response) {  | 
 | 80 | ++                        giftCardAccount.isChecked(true);  | 
 | 81 | ++                        giftCardAccount.code(giftCardCode);  | 
 | 82 | ++                        giftCardAccount.amount(response);  | 
 | 83 | ++                        giftCardAccount.isValid(true);  | 
 | 84 | ++                    }).fail(function (response) {  | 
 | 85 | ++                        giftCardAccount.isValid(false);  | 
 | 86 | ++                        errorProcessor.process(response, messageList);  | 
 | 87 | ++                    }).always(function () {  | 
 | 88 | ++                        self.isLoading(false);  | 
 | 89 | +                     });  | 
 | 90 | ++                });  | 
 | 91 | ++                //Trigger ReCaptcha validation  | 
 | 92 | ++                recaptchaRegistry.triggers['recaptcha-checkout-gift-apply']();  | 
 | 93 | ++                if (  | 
 | 94 | ++                    !recaptchaRegistry._isInvisibleType.hasOwnProperty('recaptcha-checkout-gift-apply') ||  | 
 | 95 | ++                    recaptchaRegistry._isInvisibleType['recaptcha-checkout-gift-apply'] === false  | 
 | 96 | ++                ) {  | 
 | 97 | ++                    //remove listener so that get gift action is only triggered by the 'Gift Apply' button  | 
 | 98 | ++                    recaptchaRegistry.removeListener('recaptcha-checkout-gift-apply');  | 
 | 99 | +                 }  | 
 | 100 | +-                messageList.clear();  | 
 | 101 | +   | 
 | 102 | +-                return storage.get(  | 
 | 103 | +-                    serviceUrl,  true, 'application/json', headers  | 
 | 104 | +-               ).done(function (response) {  | 
 | 105 | +-                    giftCardAccount.isChecked(true);  | 
 | 106 | +-                    giftCardAccount.code(giftCardCode);  | 
 | 107 | +-                    giftCardAccount.amount(response);  | 
 | 108 | +-                    giftCardAccount.isValid(true);  | 
 | 109 | +-                }).fail(function (response) {  | 
 | 110 | +-                    giftCardAccount.isValid(false);  | 
 | 111 | +-                    errorProcessor.process(response, messageList);  | 
 | 112 | +-                }).always(function () {  | 
 | 113 | +-                    self.isLoading(false);  | 
 | 114 | +-                });  | 
 | 115 | ++                return recaptchaDeferred;  | 
 | 116 | +             }  | 
 | 117 | +   | 
 | 118 | +             return originFn(giftCardCode);  | 
 | 119 | +diff --git a/vendor/magento/module-re-captcha-gift-card/view/frontend/web/js/action/set-gift-card-information-mixin.js b/vendor/magento/module-re-captcha-gift-card/view/frontend/web/js/action/set-gift-card-information-mixin.js  | 
 | 120 | +index e8fd257e..25561f8e 100644  | 
 | 121 | +--- a/vendor/magento/module-re-captcha-gift-card/view/frontend/web/js/action/set-gift-card-information-mixin.js  | 
 | 122 | ++++ b/vendor/magento/module-re-captcha-gift-card/view/frontend/web/js/action/set-gift-card-information-mixin.js  | 
 | 123 | +@@ -3,6 +3,8 @@  | 
 | 124 | +  * See COPYING.txt for license details.  | 
 | 125 | +  */  | 
 | 126 | +   | 
 | 127 | ++ /* eslint-disable max-nested-callbacks */  | 
 | 128 | ++  | 
 | 129 | + define([  | 
 | 130 | +     'jquery',  | 
 | 131 | +     'mage/storage',  | 
 | 132 | +@@ -34,7 +36,8 @@ define([  | 
 | 133 | +   | 
 | 134 | +     return function (setGiftCardAction) {  | 
 | 135 | +         return wrapper.wrap(setGiftCardAction, function (originalAction, giftCardCode) {  | 
 | 136 | +-            var serviceUrl,  | 
 | 137 | ++            var recaptchaDeferred,  | 
 | 138 | ++                serviceUrl,  | 
 | 139 | +                 payload,  | 
 | 140 | +                 headers = {},  | 
 | 141 | +                 message = $.mage.__('Gift Card %1 was added.').replace('%1', giftCardCode);  | 
 | 142 | +@@ -63,34 +66,46 @@ define([  | 
 | 143 | +             }  | 
 | 144 | +   | 
 | 145 | +             if (recaptchaRegistry.triggers.hasOwnProperty('recaptcha-checkout-gift-apply')) {  | 
 | 146 | ++                //ReCaptcha is present for checkout  | 
 | 147 | ++                recaptchaDeferred = $.Deferred();  | 
 | 148 | +                 recaptchaRegistry.addListener('recaptcha-checkout-gift-apply', function (token) {  | 
 | 149 | +                     headers['X-ReCaptcha'] = token;  | 
 | 150 | +-                });  | 
 | 151 | ++                    storage.post(  | 
 | 152 | ++                        serviceUrl, JSON.stringify(payload), true, 'application/json', headers  | 
 | 153 | ++                    ).done(function (response) {  | 
 | 154 | ++                        /**  | 
 | 155 | ++                         * Callback for getPaymentInformationAction.  | 
 | 156 | ++                         */  | 
 | 157 | ++                        var onGetPaymentInformationAction = function () {  | 
 | 158 | ++                            totals.isLoading(false);  | 
 | 159 | ++                        },  | 
 | 160 | ++                            deferred = $.Deferred();  | 
 | 161 | +   | 
 | 162 | +-                return storage.post(  | 
 | 163 | +-                    serviceUrl, JSON.stringify(payload), true, 'application/json', headers  | 
 | 164 | +-                ).done(function (response) {  | 
 | 165 | +-                    /**  | 
 | 166 | +-                     * Callback for getPaymentInformationAction.  | 
 | 167 | +-                     */  | 
 | 168 | +-                    var onGetPaymentInformationAction = function () {  | 
 | 169 | ++                        if (response) {  | 
 | 170 | ++                            totals.isLoading(true);  | 
 | 171 | ++                            $.when(getPaymentInformationAction(deferred)).done(onGetPaymentInformationAction);  | 
 | 172 | ++                            messageList.addSuccessMessage({  | 
 | 173 | ++                                'message': message  | 
 | 174 | ++                            });  | 
 | 175 | ++                        }  | 
 | 176 | ++                    }).fail(function (response) {  | 
 | 177 | +                         totals.isLoading(false);  | 
 | 178 | +-                    },  | 
 | 179 | +-                        deferred = $.Deferred();  | 
 | 180 | +-  | 
 | 181 | +-                    if (response) {  | 
 | 182 | +-                        totals.isLoading(true);  | 
 | 183 | +-                        $.when(getPaymentInformationAction(deferred)).done(onGetPaymentInformationAction);  | 
 | 184 | +-                        messageList.addSuccessMessage({  | 
 | 185 | +-                            'message': message  | 
 | 186 | +-                        });  | 
 | 187 | +-                    }  | 
 | 188 | +-                }).fail(function (response) {  | 
 | 189 | +-                    totals.isLoading(false);  | 
 | 190 | +-                    errorProcessor.process(response, messageList);  | 
 | 191 | +-                }).always(function () {  | 
 | 192 | +-                    fullScreenLoader.stopLoader();  | 
 | 193 | ++                        errorProcessor.process(response, messageList);  | 
 | 194 | ++                    }).always(function () {  | 
 | 195 | ++                        fullScreenLoader.stopLoader();  | 
 | 196 | ++                    });  | 
 | 197 | +                 });  | 
 | 198 | ++                //Trigger ReCaptcha validation  | 
 | 199 | ++                recaptchaRegistry.triggers['recaptcha-checkout-gift-apply']();  | 
 | 200 | ++                if (  | 
 | 201 | ++                    !recaptchaRegistry._isInvisibleType.hasOwnProperty('recaptcha-checkout-gift-apply') ||  | 
 | 202 | ++                    recaptchaRegistry._isInvisibleType['recaptcha-checkout-gift-apply'] === false  | 
 | 203 | ++                ) {  | 
 | 204 | ++                    //remove listener so that gift-apply action is only triggered by the 'Gift Apply' button  | 
 | 205 | ++                    recaptchaRegistry.removeListener('recaptcha-checkout-gift-apply');  | 
 | 206 | ++                }  | 
 | 207 | ++  | 
 | 208 | ++                return recaptchaDeferred;  | 
 | 209 | +             }  | 
 | 210 | +   | 
 | 211 | +             //No ReCaptcha, just sending the request  | 
 | 212 | +diff --git a/vendor/magento/module-re-captcha-gift-card/view/frontend/web/js/checkoutReCaptcha.js b/vendor/magento/module-re-captcha-gift-card/view/frontend/web/js/checkoutReCaptcha.js  | 
 | 213 | +new file mode 100644  | 
 | 214 | +index 00000000..8896649a  | 
 | 215 | +--- /dev/null  | 
 | 216 | ++++ b/vendor/magento/module-re-captcha-gift-card/view/frontend/web/js/checkoutReCaptcha.js  | 
 | 217 | +@@ -0,0 +1,58 @@  | 
 | 218 | ++/************************************************************************  | 
 | 219 | ++ *  | 
 | 220 | ++ * ADOBE CONFIDENTIAL  | 
 | 221 | ++ * ___________________  | 
 | 222 | ++ *  | 
 | 223 | ++ * Copyright 2023 Adobe  | 
 | 224 | ++ * All Rights Reserved.  | 
 | 225 | ++ *  | 
 | 226 | ++ * NOTICE: All information contained herein is, and remains  | 
 | 227 | ++ * the property of Adobe and its suppliers, if any. The intellectual  | 
 | 228 | ++ * and technical concepts contained herein are proprietary to Adobe  | 
 | 229 | ++ * and its suppliers and are protected by all applicable intellectual  | 
 | 230 | ++ * property laws, including trade secret and copyright laws.  | 
 | 231 | ++ * Dissemination of this information or reproduction of this material  | 
 | 232 | ++ * is strictly forbidden unless prior written permission is obtained  | 
 | 233 | ++ * from Adobe.  | 
 | 234 | ++ * ************************************************************************  | 
 | 235 | ++ */  | 
 | 236 | ++  | 
 | 237 | ++define(  | 
 | 238 | ++    [  | 
 | 239 | ++        'Magento_ReCaptchaFrontendUi/js/reCaptcha'  | 
 | 240 | ++    ],  | 
 | 241 | ++    function (Component) {  | 
 | 242 | ++        'use strict';  | 
 | 243 | ++  | 
 | 244 | ++        return Component.extend({  | 
 | 245 | ++            /**  | 
 | 246 | ++             * Auto-trigger validation so that ReCaptcha is ready for Quick Checkout  | 
 | 247 | ++             *  | 
 | 248 | ++             * @param {Object} parentForm  | 
 | 249 | ++             * @param {String} widgetId  | 
 | 250 | ++             */  | 
 | 251 | ++            initParentForm: function (parentForm, widgetId) {  | 
 | 252 | ++                window.grecaptcha.execute(widgetId);  | 
 | 253 | ++                parentForm.find('.action.check').click(function (event) {  | 
 | 254 | ++                    if (this.getIsInvisibleRecaptcha()) {  | 
 | 255 | ++                        window.grecaptcha.execute(widgetId);  | 
 | 256 | ++                        event.preventDefault(event);  | 
 | 257 | ++                        event.stopImmediatePropagation();  | 
 | 258 | ++                    }  | 
 | 259 | ++                }.bind(this));  | 
 | 260 | ++            },  | 
 | 261 | ++  | 
 | 262 | ++            /**  | 
 | 263 | ++             * Recording the token  | 
 | 264 | ++             *  | 
 | 265 | ++             * @param {String} token  | 
 | 266 | ++             */  | 
 | 267 | ++            reCaptchaCallback: function (token) {  | 
 | 268 | ++                if (this.getIsInvisibleRecaptcha() && this.tokenField) {  | 
 | 269 | ++                    this.tokenField.value = token;  | 
 | 270 | ++                }  | 
 | 271 | ++            }  | 
 | 272 | ++        });  | 
 | 273 | ++    }  | 
 | 274 | ++);  | 
 | 275 | ++  | 
 | 276 | +diff --git a/vendor/magento/module-re-captcha-gift-card/view/frontend/web/js/gift-card-recaptcha.js b/vendor/magento/module-re-captcha-gift-card/view/frontend/web/js/gift-card-recaptcha.js  | 
 | 277 | +index 7587c258..53bd4834 100644  | 
 | 278 | +--- a/vendor/magento/module-re-captcha-gift-card/view/frontend/web/js/gift-card-recaptcha.js  | 
 | 279 | ++++ b/vendor/magento/module-re-captcha-gift-card/view/frontend/web/js/gift-card-recaptcha.js  | 
 | 280 | +@@ -2,7 +2,8 @@  | 
 | 281 | +  * Copyright © Magento, Inc. All rights reserved.  | 
 | 282 | +  * See COPYING.txt for license details.  | 
 | 283 | +  */  | 
 | 284 | +-/* global grecaptcha */  | 
 | 285 | ++  | 
 | 286 | ++/* eslint-disable no-unused-vars */  | 
 | 287 | + define(  | 
 | 288 | +     [  | 
 | 289 | +         'Magento_ReCaptchaWebapiUi/js/webapiReCaptcha',  | 
 | 290 | +@@ -41,10 +42,6 @@ define(  | 
 | 291 | +                     captchaId = this.getReCaptchaId();  | 
 | 292 | +   | 
 | 293 | +                 this._super();  | 
 | 294 | +-                if (self.getIsInvisibleRecaptcha()) {  | 
 | 295 | +-                    grecaptcha.execute(widgetId);  | 
 | 296 | +-                    self.validateReCaptcha(true);  | 
 | 297 | +-                }  | 
 | 298 | +                 if (GiftCode() != null) {  | 
 | 299 | +                     if (isApplied) {  | 
 | 300 | +                         self.validateReCaptcha(true);  | 
0 commit comments