【发布时间】:2018-08-21 11:06:37
【问题描述】:
正如标题所说,我正在尝试使用未保存在客户资料中的一次性来源(信用卡)进行付款。我仍然希望能够在 Stripe 上的客户资料中记录该费用。
根据the docs,这可以通过在发送到Stripe.customers.createCharge 的有效负载中传递customer 中的客户id 密钥来完成。但是,在这样做时,我收到一条错误消息,指出该卡未与客户关联(显然不是,而且我不希望这样)。
客户
cus_***没有ID tok_visa的卡
为了解决这个问题,我暂时应用了in this answer 提到的修复程序,它基本上涉及为支付创建一个临时卡,然后将其删除。
我想知道当 API 以其他方式明确记录时,它是如何不起作用的,希望有使用 Stripe 经验的人也能提出相同的意见。
这是我要运行的代码:
await stripeService.charges.create({
source: token, // temporary token received from Checkout
customer: user.stripeCustomerId, // the Stripe customer ID from my database
amount,
currency: 'usd',
description: 'Test charge'
});
【问题讨论】: