我想知道如何使用 Node.js 库向 Stripe 中的现有客户添加新银行卡。例如:我有一位客户的 Stripe 客户 ID:cus_XXXXXXXXXX,该客户已经有 1 张卡,我想为同一客户添加另一张卡。
最佳答案
你应该使用 createSource像这样:
var stripe = require("stripe")(
// your secret key
);
stripe.customers.createSource(
"cus_XXXXXXXXXX",
{ source: "tok_amex" },
function(err, card) {
// asynchronously called
}
);
source
是其中之一:
- 一个 token ,就像Stripe.js返回的一样,
包含用户信用卡详细信息的字典!像这样(未测试):
stripe.customers.createSource( "cus_XXXXXXXXXX", { source: { object: 'card', exp_month: ... ,//expiry month exp_year: ... ,//expiry year number: ... ,//card number cvc: ... // cvc of the card }}, function(err, card) { // asynchronously called } );
此外,如果您希望将新卡设置为客户的默认卡,您应该更新customer对象。
关于node.js - 在 Stripe Node.js 中向现有客户添加新卡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46805154/