首页 > 解决方案 > Stripe、webhooks 和 SCA 欧洲法律结帐流程

问题描述

我正在使用 Stripe 付款的网站工作,它是基于欧洲的,所以我必须处理 SCA 3D Secure auth,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 模式操作将如何完成?

这很令人困惑。

标签: javascriptphplaravelvue.js

解决方案


当我们在正面确认刷卡支付后,我们基本上关闭了支付模式,并显示“订单”页面或您当前状态的任何页面。

我们正在使用 Pusher 将状态更改的服务器更新从服务器推送到客户端,这使我们能够更新客户端以方便用户使用。

如果无法使用 pusher 或其他基于套接字的解决方案,您可以将其显示为“请稍候”状态,并每隔 X 次轮询服务器更新。

这里没有“对或错”;这仅取决于您的设置以及您的确切要求......


推荐阅读