【发布时间】:2020-08-10 15:38:20
【问题描述】:
我正在使用 Stripe 付款的网站,它是基于欧洲的,所以我必须处理 SCA 3D 安全身份验证,stripe 文档建议我异步处理付款履行,而不是等待 confirmCardPayment 承诺解决,要做到这一点,您必须使用 webhook。
来自文档:
stripe.confirmCardPayment(clientSecret, {
payment_method: {
card: card,
billing_details: {
name: 'Jenny Rosen'
}
},
setup_future_usage: 'off_session'
}).then(function(result) {
if (result.error) {
// Show error to your customer
console.log(result.error.message);
} else {
if (result.paymentIntent.status === 'succeeded') {
// Show a success message to your customer
// There's a risk of the customer closing the window before callback execution
// Set up a webhook or plugin to listen for the payment_intent.succeeded event
// to save the card to a Customer
// The PaymentMethod ID can be found on result.paymentIntent.payment_method
}
}
});
注意下面的评论:
// There's a risk of the customer closing the window before callback execution
// Set up a webhook or plugin to listen for the payment_intent.succeeded event
由于该警告,我对如何处理 confirmCardPayment 承诺感到困惑。
我是否应该在从客户端调用 confirmCardPayment 后将用户带到另一个页面,并在新页面中显示状态为 PENDING 或 PROCCESING 的订单。
我应该在使用计时器调用 confirmCardPayment 几秒钟后执行此操作,还是检查回调中没有错误,在 promise 回调的 else 括号内并使用 location.href 移动用户以查看订单?
之后,我将使用 webhook 在后端处理订单履行(监听 payment_intent.succeded 事件、从库存中移除、发送订单电子邮件并执行剩余的数据库操作)
如果我这样做,SCA 模式还会出现吗? Stripe 说 Stripe.js 处理 SCA 并显示模态,但是如果我将用户重定向到没有 stripe.js 的待处理订单页面,SCA 模态操作将如何完成?
这很令人困惑。
【问题讨论】:
标签: javascript php laravel vue.js