#aby_docs
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/1271028418858848278
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
hi there!
Hello! ๐
so currently you create Subscription, and then set the default payment method on the customer with an extra API call?
you could save the payment method on the subscription directly when creating the Subscription with https://docs.stripe.com/api/subscriptions/create#create_subscription-payment_settings-save_default_payment_method
Yes, we create the subscription passing the card details into the API, which creates the subscription successfully, but since the payment method is not automatically set as default, the next billing cycle is not being charged automatically, so we need to set that payment method as default payment method
but since the payment method is not automatically set as default
if you do what I suggested above, it would be set as default automatically for you
Yes, we know that, but our flow is a little bit different, since first the subscription is created without payment method since we don't have it at this time
Then when we get the payment method we confirm the payment intent
and the charge it's being made
So then Stripe returns us the PM_ID, which is the ID we need to set that payment method as default for that customer, passing 'invoice_settings.default_payment_method'. So in order to save us from another different call, I was wondering if we could use payment_method.attached event webhook to trigger invoice_settings.default_payment_method directly so this process would be automatized instead of us passing another call manually
but our flow is a little bit different, since first the subscription is created without payment method since we don't have it at this time
I'm not sure I follow. the normal flow:
- you create the Subscription, and use
payment_settings.save_default_payment_method - then you use the PaymentIntent created by the Subscription to collect the payment details of the customer
- once the PaymentIntent is confirmed, the payment method is automatically attached to the Subscription
I was wondering if we could use payment_method.attached event webhook to trigger invoice_settings.default_payment_method directly so this process would be automatized instead of us passing another call manually
yes it should work
I recommend testing all of this in test mode to make sure it work as expected.