javascript - Stripe API 传递动态数据
问题描述
有没有办法将动态数据传递给 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`.
});
谢谢!
解决方案
为了metadata
在 Checkout 中传递和其他字段,您需要使用Server + Client集成路径而不是仅客户端集成。
推荐阅读
- javascript - 根据选择列表中的数字循环组件 - 反应js
- perl - Perl IPC::Run 输入文件大于 64KiB 的管道块
- validation - 无法删除 MVC 中的强制验证
- linux-device-driver - 如何使用 efivars 检索 BIOS 使用的控制台端口的详细信息?
- node.js - 如何使用 node 和 mongoose 或 mongo 对文档数组进行分页?
- django - Django DRF Swagger:在 urls.py SimpleRouter / DefaultRouter 中,swagger 文档不会自动发现
- python - 开放均匀 B 样条曲线中的 Python ZeroDivisionError
- postgresql - 转换表以使用另一列的记录创建新列
- javascript - 在每两个奇数或偶数之间插入破折号或星号的 Javascript 函数
- sql - 在访问数据库中运行多连接有什么问题吗