我正在我的平台上保存客户及其来源,并尝试为我的关联帐户创建费用。我能够成功创建目的地费用,但在创建直接费用时遇到问题。
我尝试创建一个 token :https://stripe.com/docs/connect/shared-customers
如果我仅使用客户示例创建 token ,错误为:
'您提供了一位客户,但未指定来源。客户的默认来源是一个来源,不能与现有客户共享。'
即使文档说您需要“该客户的卡或银行帐户 ID,如果您想向特定卡或银行帐户而不是默认帐户收费”。
我找不到可以让我指定来源或代替客户的参数。
我已尝试与连接的帐户共享客户选择的来源:https://stripe.com/docs/sources/connect#shared-card-sources 这会导致错误:
'将信用卡号直接发送到 Stripe API 通常是不安全的。我们建议您使用映射到您正在使用的测试卡的测试 token ,请参阅https://stripe.com/docs/testing .'
我尝试将测试 token (tok_visa) 附加到我的客户,并用它创建费用,但结果相同。
每次我取得一些成功时,即使我只发送 Stripe 提供的 token 或源 ID,我也会收到有关发送号码不安全的错误。
我已经尝试过这个:
const newToken = await stripe.tokens.create({
customer: customerId,
}, {
stripe_account: stripeAccountId,
}).catch((e) => {
console.log(e);
});
还有这个:
const newToken = await stripe.sources.create({
customer: customerId,
usage: 'single_use',
original_source: sourceId,
}, {
stripe_account: stripeAccountId,
}).catch((e) => {
console.log(e);
});
我取得的唯一成功是使用测试 token (tok_visa)创建直接费用,完全绕过 token /源的共享。似乎没有其他组合有效。但这让我在需要时不知道如何获得真正的共享 token 。
最佳答案
我发现我应该使用源,而不是 token 。事实证明,我不小心使用了整个 newToken 作为收费来源。现在它正在工作,我正在将 newToken.id 传递给费用。
关于node.js - Stripe 连接共享卡源不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54125293/