【问题标题】:How to trigger a modal to popup only if the back-end process needs it?仅当后端进程需要时,如何触发模态弹出?
【发布时间】:2020-08-30 16:31:32
【问题描述】:

我正在尝试在结帐过程中完成 3D 安全身份验证的实施,但是由于 3DS 身份验证需要使用 iframe 将用户重定向到银行 URL 以批准付款的模式弹出窗口,因为没有所有卡都需要 3DS 身份验证,我的问题是如果卡需要,我如何从后端触发模式弹出窗口?

结帐示例

const checkout = async () => {
    var status = await foo();
    var next = await nextAction();
    
    if(status === 'succeeded') {
        // ...more code here...

        newSale.save()
        .then(() => {
            //payment is processed

            // ...code and redirect here...
        })
        .catch(err => console.log(err));
    } else if(status === 'awaiting_next_action'){
        console.log('3D Secure Authentication required');
        console.log(next);

        // I need to trigger the modal from the front-end here if needed...
        
    } else if(paymentIntentStatus === 'awaiting_payment_method') {
        console.log('The PaymentIntent encountered a processing error. ');
    }
}

如上图所示,该 3DS Auth 模式只需要在需要时弹出,否则不得显示。

【问题讨论】:

    标签: javascript html css node.js


    【解决方案1】:

    那么后端必须在响应中传递一定的参数,然后你可以使用if,else条件来检查该条件是否存在,然后相应地打开模态。

    【讨论】:

    • 如果我问一个示例代码来作为它的基础会不会太多?我非常需要它,但我想不通
    • 当然,您能否更具体一点,您在代码示例中需要什么
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-12-10
    • 1970-01-01
    • 1970-01-01
    • 2013-01-10
    • 2014-02-22
    • 1970-01-01
    • 2015-12-06
    相关资源
    最近更新 更多