【问题标题】:Use Google Pay response token in Stripe api在 Stripe api 中使用 Google Pay 响应令牌
【发布时间】:2021-10-10 01:38:59
【问题描述】:

我已经按照 Google Pay 文档在我的页面上设置了 Google Pay 按钮,但我陷入了最后一步,我需要按照 Google Pay 文档的描述将令牌响应从 Google Pay 发送到 Stripe。

为了执行支付,后端处理购买并将支付令牌发送给支付服务提供商。

我搜索了 Stripe 文档,但似乎找不到如何使用该令牌,但他们向我展示了如何使用 Stripe 付款请求按钮 来集成 Google Pay。 那么,Stripe 是否支持来自 Google Pay api 的令牌,还是我需要使用 Stripe Payment Request Button 来与 Google Pay 集成?

【问题讨论】:

    标签: stripe-payments google-pay


    【解决方案1】:

    你可以做任何一个,你不/不应该混合这两种方法

    基于Stripe doc here你可以使用

    1. Stripe 的 PaymentRequestButton
    2. 或者您可以使用 Stripe 作为网关直接与 Google Pay 集成。看看怎么做here;在教程的第 2 步中,搜索 stripe 以查找网关配置
    const tokenizationSpecification = {
      type: 'PAYMENT_GATEWAY',
      parameters: {
        "gateway": "stripe"
        "stripe:version": "2018-10-31" // your stripe API version
        "stripe:publishableKey": "pk_test_xxxx" // your stripe publishable key
      }
    };
    

    对于选项 2,您基本上会得到一个类似 tok_xxxx 的 Stripe 令牌,代表来自 paymentData.paymentMethodData.tokenizationData.token 的 GooglePay 钱包,您可以使用 Stripe 的密钥 sk_test_xxxx 直接将令牌与 Stripe API 一起使用,例如创建收费following this

    const stripe = require('stripe')('sk_test_xxxxx');
    
    const charge = await stripe.charges.create({
      amount: 2000,
      currency: 'usd',
      source: 'tok_obtained_from_google_pay_api', 
      description: 'My First Test Charge (created for API docs)',
    });
    

    仅供参考 token/charge API 不再推荐,您可以从 token 创建一个 payment_method,例如 this

    const paymentMethod = await stripe.paymentMethods.create({
      type: 'card',
      card: {
        token: 'tok_xxxxx',
      },
    });
    

    并将其与 Stripe 一起使用 PaymentIntent API

    【讨论】:

      猜你喜欢
      • 2017-09-05
      • 2020-05-05
      • 2021-09-02
      • 1970-01-01
      • 2023-03-03
      • 2023-04-03
      • 1970-01-01
      • 1970-01-01
      • 2018-06-25
      相关资源
      最近更新 更多