0
votes

I am trying to save a credit card during payment using stripe connect.

I am following the docs here

However, the docs are not for stripe connect. They are for regular stripe payments.

My code is the same as the docs except my paymentIntents is created on the connected account because I want the charge to be on the connected account.

                                stripe.paymentIntents.create({
                                    payment_method_types: ['card'],
                                    amount: Math.round(Number(req.body.stripeData.amount *100)),
                                    currency: userEvent.currency,
                                    description: userEvent.title,
                                    application_fee_amount: Math.round(Number((fees.applicationFee) *100)),
                                    customer: stripeCustomerID 
                                    },{
                                    stripe_account: sellerDetails.stripeAccountID,
                                    }
                                )

This is throwing me the error No such customer: 'cus_ITBFODvD6dB1vP' which makes sense because the customer is set up on the platform account.

I want to save the customer and the payment method to my platform account and then charge on the connected account.

Is there a slick way I can do this similar to the docs or must I do a work around - code to save the customer and payment method on the platform account and then automatically charge it on the connected account

1

1 Answers

1
votes

You can create the Customer on the connected account instead of your platform by specifying the stripe_account in the Customer creation call as well. Something like this:

stripe.customers.create({
    // Customer details here
},
{
    stripe_account: sellerDetails.stripeAccountID
});

You can use this technique to make almost any API call on behalf of a connected account instead of your platform account. For more details check out the documentation for authentication with Connect.

Note: It looks like you're using an older version of Stripe's Node library; the newer versions use stripeAccount instead of stripe_account in the last options object passed to the library methods. Just something to watch out for if you upgrade to a newer version of the library!