[英]Stripe later payment direct charges, create token error, The customer must have an active payment source attached
I am trying to make a Stripe later payment direct charge on a connected account in Node.js.我正在尝试对 Node.js 中的连接帐户进行 Stripe 稍后付款直接收费。 This is all in test mode using the paymentMethods API.这一切都在使用 paymentMethods API 的测试模式下。
I create a customer and attach a payment method with stripe.setupIntents.create() and am able to make later payments to my stripe account/the platform without any issues.我创建了一个客户并使用 stripe.setupIntents.create() 附加了一种付款方式,并且能够在以后向我的 Stripe 帐户/平台付款而没有任何问题。 However I would like to make a direct payment to a connected account using stripe.paymentIntents.create().但是,我想使用 stripe.paymentIntents.create() 直接向连接的帐户付款。
Following this guide, https://stripe.com/docs/connect/cloning-saved-payment-methods , I am under the impression I can clone a payment method used for my platform and use it to make a direct payment for a connected account.遵循本指南https://stripe.com/docs/connect/cloning-saved-payment-methods ,我的印象是我可以克隆用于我的平台的付款方式,并使用它直接支付连接帐户。 I attempt to create a token for the customer but receive the error "The customer must have an active payment source attached."我尝试为客户创建令牌,但收到错误消息“客户必须附加有效的付款来源”。 despite the customer having an active default payment method that works for my platform, 'pm_1HFjvsLIOnOaY98HTxPugN5i'.尽管客户拥有适用于我的平台的有效默认付款方式“pm_1HFjvsLIOnOaY98HTxPugN5i”。
const token = await stripe.tokens.create({customer: 'cus_HpOf9y6TJ5XYlA'}, { stripeAccount: 'acct_1HDuHbBwYBNGN1ir'}
I am further confused by this guide https://stripe.com/docs/payments/payment-methods/connect#cloning-payment-methods , is this just an alternative method to accomplish essentially the same thing?我对本指南https://stripe.com/docs/payments/payment-methods/connect#cloning-payment-methods感到更加困惑,这只是完成基本相同事情的另一种方法吗? Or do I need to create a new payment method onto the connected account, but wouldn't that defeat the purpose of creating a token?或者我是否需要在已连接的帐户上创建新的付款方式,但这不会违背创建令牌的目的吗?
Great question, In the API call you shared, you're passing only the customer
parameter.很好的问题,在您共享的 API 调用中,您只传递了customer
参数。 Cloning a Payment Method requires passing both customer
and payment_method
like so:克隆支付方式需要同时传递customer
和payment_method
,如下所示:
const paymentMethod = await stripe.paymentMethods.create({
customer: 'cus_HpOf9y6TJ5XYlA',
payment_method: 'pm_1HFjvsLIOnOaY98HTxPugN5i',
}, {
stripeAccount: 'acct_1HDuHbBwYBNGN1ir',
});
With Payment Methods there's no concept of a "default source" for a customer—When creating a charge or sharing a payment method you must always specify both the customer ID and payment method ID.使用付款方式时,客户没有“默认来源”的概念 - 创建费用或共享付款方式时,您必须始终指定客户 ID 和付款方式 ID。 The exception to this is Subscriptions, which will look at the invoice_settings.default_payment_method property on the customer and use that for subscription and invoice payments.例外情况是订阅,它将查看客户的invoice_settings.default_payment_method属性并将其用于订阅和发票付款。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.