【问题标题】:Stripe API Pass Dynamic DataStripe API 传递动态数据
【发布时间】:2021-06-28 23:52:04
【问题描述】:

有没有办法将动态数据传递给 Stripe API?我正在使用此处找到的示例:https://stripe.com/docs/payments/checkout/client

我希望能够将令牌与购买一起传递,以便将帐户与该付款相关联。在客户端将付款发送到 API 后,我的后端将收到付款的详细信息,包括将其链接到在此之前创建的帐户的令牌。我会将其作为参数添加到成功的重定向中,但如果他们提前关闭窗口,那么这些帐户将不会被链接。我使用仪表板设置我的产品。

我尝试使用元数据和描述作为订单项的一部分,但它一直说“无效的 stripe.redirectToCheckout 参数:lineItems.0.description 不是可接受的参数。”

let token;
stripe.redirectToCheckout({
    lineItems: [{
      price: 'boop', // Replace with the ID of your price
      quantity: 1,
      description: token
    }],
    mode: 'payment',
    successUrl: 'http://boop.com',
    cancelUrl: 'http://boop.com',
  }).then(function (result) {
    // If `redirectToCheckout` fails due to a browser or network
    // error, display the localized error message to your customer
    // using `result.error.message`.
  });

谢谢!

【问题讨论】:

    标签: javascript payment stripe-payments


    【解决方案1】:

    为了在 Checkout 中传递 metadata 和其他字段,您需要使用 Server + Client 集成路径而不是仅客户端集成。

    【讨论】:

    • 我也使用了服务器+客户端集成,但仍然不知道将令牌值放在交易中的哪个位置,因为每个客户的令牌值都不相同。
    【解决方案2】:

    您可以通过在创建会话时使用client_reference_id 通过服务器+客户端集成来实现我想要的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-06-10
      • 2020-09-13
      • 2017-03-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-27
      相关资源
      最近更新 更多