Magento 2.4.3 Checkout JS Knockout Error – renderReCaptcha Issue

javascriptknockoutknockoutjsmagento2.4

We upgrade to Magento 2.4.3 and now face the following JS knockout error in the checkout:

TypeError: Unable to process binding "afterRender: function (){return renderReCaptcha() }"
Message: undefined is not an object (evaluating 'this.settings.rendering')

We disabled the Magento CAPTCHA on storefront, the default Magento module.

Solution, update Magento_RecaptchaFrontendUi/js/reCapthca.js

if (typeof this.settings === 'undefined') { 
    return; 
}
parameters = _.extend(
    {
        'callback': function (token) { // jscs:ignore jsDoc
            this.reCaptchaCallback(token);
            this.validateReCaptcha(true);
        }.bind(this),
        'expired-callback': function () {
            this.validateReCaptcha(false);
        }.bind(this)
    },
    this.settings.rendering
);

Best Answer

This "error" occurs if you have ReCaptcha disabled. To get rid of it you can either enable ReCatptcha for checkout, rewrite the file which throws this error for proper error handling or just ignore it - it doesn't actually break anything.

parameters = _.extend(
    {
        'callback': function (token) { // jscs:ignore jsDoc
            this.reCaptchaCallback(token);
            this.validateReCaptcha(true);
        }.bind(this),
        'expired-callback': function () {
            this.validateReCaptcha(false);
        }.bind(this)
    },
    this.settings.rendering
);

this.settings is undefined if ReCatptcha is disabled so reading the rendering property obviously throws an error.

Related Topic