2

How would I trigger a pop-up modal to show the error, when a card is declined or and AVS error?

Checkout errors seem to be set inside the file below

app/design/frontend/YOUR/TEMPLATE/Magento_Payment/templates/transparent/iframe.phtml in this section.

<?php elseif (isset($params['error_msg'])): ?>
            var require = window.top.require;
            require(
                [
                    'jquery',
                    'Magento_Ui/js/model/messageList',
                    'mage/translate',
                    'Magento_Checkout/js/model/full-screen-loader'
                ],
                function($, globalMessageList, $t, fullScreenLoader) {
                    var parent = window.top;
                    $(parent).trigger('clearTimeout');
                    fullScreenLoader.stopLoader();
                    globalMessageList.addErrorMessage({
                        message: $t(<?= /* @escapeNotVerified */ json_encode($params['error_msg'])?>)
                    });
                }
            );

I'm trying to figure out how to pass/trigger the error into display inside a pop-up modal, because most people don't see the error message, and on a mobile, it's almost impossible to see before the message disappears.

I've made it to where the message last longer, but having a pop-up modal would be ideal, however I've yet to figure out how to implement it.

On GitHub there are mentions of the use of modal, but no code to do so.

This is for Authorize.net on 2.2.8

How would I trigger a pop-up modal to show the error, when a card is declined or and AVS error?

The error message can be static, but would prefer if the message were inside the modal. I had asked before, but can confirm, it can be done, via GitHub posts about the same subject.

0
<?php elseif (isset($params['error_msg'])): ?>
        var require = window.top.require;
        require(
            [
                'jquery',
                'Magento_Ui/js/model/messageList',
                'mage/translate',
                'Magento_Checkout/js/model/full-screen-loader',
                'Magento_Ui/js/modal/alert'
            ],
            function($, globalMessageList, $t, fullScreenLoader, alert) {
                var parent = window.top;
                $(parent).trigger('clearTimeout');
                fullScreenLoader.stopLoader();
                alert({
                    title: 'YOUR RECENT TRANSACTION HAS BEEN DECLINED BY YOUR BANK.',
                    content: '<?= /* @escapeNotVerified */ json_encode($params['error_msg'])?>',
                    actions: {
                        always: function(){
                            window.scrollTo(0,0);
                            globalMessageList.addErrorMessage({
                                message: $t(<?= /* @escapeNotVerified */ json_encode($params['error_msg'])?>)
                            });
                        }
                    }
                });
            }
        );

Above is what it used to be working up until Magento 2.3 came out.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.