Stripe 定期支付与 masterpass 集成

问题描述

有没有办法使用 Stripe 使用 Masterpass 进行定期付款?

Google Pay 和 Apple Pay 可以通过返回用于 Stripe 处理的卡令牌来使用 Stripe 进行定期付款。有没有办法用Masterpass获得这样的卡令牌?

解决方法

是的,您可以,您可以使用从 Secure Remote Commerce 返回的数据创建 PaymentMethod(Masterpass 现在自称),然后使用它开始订阅。

遵循 Stripe 的 SRC 指南,然后当您到达“complete the payment”部分时,您可以这样做:

  // create the payment method
  const pm = await stripe.paymentMethods.create({
    type: 'card',card: {
      masterpass: {
        cart_id: cartId,// your unique cart ID
        transaction_id: req.query.oauth_verifier,// get this from the SRC callback URL
      },}
  });

  // create the Stripe customer
  const cust = await stripe.customers.create({
    payment_method: pm.id,});

  // create the subscription
  const sub = await stripe.subscriptions.create({
    customer: cust.id,items: [{
      price: {{PRICE_ID}},}],default_payment_method: pm.id,});