Reputation: 23
I am trying to make a Stripe later payment direct charge on a connected account in Node.js. This is all in test mode using the 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. However I would like to make a direct payment to a connected account using 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. 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'.
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? 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?
Upvotes: 2
Views: 1903
Reputation: 738
Great question! In the API call you shared, you're passing only the customer
parameter. Cloning a Payment Method requires passing both customer
and payment_method
like so:
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. 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.
Upvotes: 3