#nerder
1 messages · Page 1 of 1 (latest)
You can either set the default at the Customer level using: https://stripe.com/docs/api/customers/update#update_customer-invoice_settings-default_payment_method
Or the subscription level using: https://stripe.com/docs/api/subscriptions/update#update_subscription-default_payment_method
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
ok, in my case I'm doing this:
const setupIntent = await this.stripe.setupIntents.create(
{
payment_method_types: ['card', 'sepa_debit'],
customer: customerId,
},
{
stripeAccount: stripeAccountId,
},
);
first creating a setup intent, returning the client secret to the UI
My doubt is, I can't simply call the customer API and set the payment method as default
because is the frontend that is completing that with the client secret no?
I don't understand the question. You can make an Update Customer API call at any point after the creation of the Payment Method
I try to explain better, the integration i've made is the following:
- User attempt to attach a new payment method
- Frontend call endpoint to create a setup intent (using the code I showed you)
- Backend reply with client_secret
- Frontend confirm the setup intent and set the payment method
now the payment method is set, but is not the default
My options now are:
- Listen for
payment_method.attachedevent in the webhook and setup the payment method as default on the customer - As soon as the frontend confirms the setup_intent I perform another call to the Backend to setup that payment method as the default one
There is a better 3rd option here? If not, of the 2 I mentioned, which one is the best?
There are a lot of reasons to choose either, so it's largely up to you to decided based on your integration, but I don't know of another 3rd option