#donut_code
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1430471775820709908
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- donut_code, 16 hours ago, 26 messages
hey there, looking into this now
ok so it sounds like you're using SetupIntents and subscriptions, but sometimes the payment method isn't set as default
would you be able to share an example where it was, and an example where it wasn't, so we can compare? (either the subscription IDs or SetupIntent IDs are perfect)
sub_1SKxOORvd0kOjiXVmtJzmjuM
sub_1SKxODRvd0kOjiXVpKw2Fi0A
thanks, taking a look at these now
is it possible that i should first
confirm
Setup
before creating the subscription
?
it can be either before or after, depending on your integration flow - I'll explain the difference between these two examples ๐
-
sub_1SKxOORvd0kOjiXVmtJzmjuM
a. SetupIntent (seti_1SKxO4Rvd0kOjiXVOyMFNIHK) created via the API before the subscription: https://dashboard.stripe.com/acct_1NkVdERvd0kOjiXV/test/logs/req_k1QY4GOspUHITR
b. SetupIntent confirmed
c. Subscription created, passing the payment method ID generated in (b) indefault_payment_method: https://dashboard.stripe.com/acct_1NkVdERvd0kOjiXV/test/logs/req_KYYJ4HYAwDJu2S -
sub_1SKxODRvd0kOjiXVpKw2Fi0A
a. Subscription created before a SetupIntent (not passingdefault_payment_method): https://dashboard.stripe.com/acct_1NkVdERvd0kOjiXV/test/logs/req_Ixj0gtwVdLMPNi
b. Stripe automatically generates apending_setup_intenton the subscription object: https://docs.stripe.com/api/subscriptions/object#subscription_object-pending_setup_intent
the step missing for example number 2 is to confirm the pending_setup_intent to collect and save the customer's payment method details - you can read more about this here: https://docs.stripe.com/billing/subscriptions/deferred-payment#use-setupintents
this can be done after creating the subscription
since you set payment_settings.save_default_payment_method: 'on_subscription', once the pending SetupIntent is confirmed succesfully, the customer's payment method will be set as the default for the subscription
so you are saying that 'on_subscription' means that if i confirm setup after creating the subscription it should automatically link the costumers payment method to the subscription but in my case it is not doing that
I always call confirm setup after creatingthe subscriptions with ayment_settings.save_default_payment_method: 'on_subscription'
but only after i created a subscription with an already confirmed setup the payment method was linked
even though it was the same setup intent
yes exactly, and the reason it's not doing that for the example above is because the pending_setup_intent wasn't confirmed
since this subscription is for a customer that already has a card saved (from the previous SetupIntent), it makes more sense to pass default_payment_method when creating the second subscription
alternatively, you could set invoice_settings.default_payment_method on the customer object, so that the card is used by default for invoices/subscriptions for that customer
https://docs.stripe.com/api/customers/object#customer_object-invoice_settings-default_payment_method
but this is the same customer in both subscriptions and the setup intent which was confirmed after the first subscription creation
why is it pending_setup_intent for the first subscription
because when a card is saved to a customer, that card isn't automatically set as the default for future subscriptions
you either need to set it in invoice_settings.default_payment_method on the Customer object (to make the card default for all invoices/subscriptions for that customer), or else pass it to default_payment_method explicitly when creating a new subscription