#damonzucconi
1 messages · Page 1 of 1 (latest)
Hey there -- when you have an unpaid invoice due to payment failure (for any reason) you can retrieve the latest invoice for the subscription either directly via the API or using expansion and similarly expand the payment_intent of that invoice:
https://stripe.com/docs/api/subscriptions/object#subscription_object-latest_invoice
https://stripe.com/docs/expand
eg using expand[]='latest_invoice.payment_intent when retrieving the subscription
ah but it's not the case that it's an unpaid invoice, i want to say add new line items to the subscription and so it's cost will change
but your saying: any invoice will have a payment intent (and client secret) associated with it?
Any invoice that requires payment, yes
Are you trying to add new recurring items, or one off items to the next invoice?
For payment failures you need to recover from you can get notifications for those: https://stripe.com/docs/billing/subscriptions/webhooks#payment-failures
and then handle depending on the issue:
https://stripe.com/docs/billing/subscriptions/overview#requires-payment-method
new recurring items
See here for updating subscriptions: https://stripe.com/docs/billing/subscriptions/upgrade-downgrade#changing
The second snippet shows replacing an item with new item, but you can also add the new item without deleting the existing one
so like i know how to update a subscription but i need a client secret to be able to accept payment
and i dont know how to get the payment intent + client secret out of the existing subscription
and if i check payment_intent on the invoice it's nil?
YOu want to invoice for the change immediately and then collect payment?
yeah
See the section on Immediate payment: https://stripe.com/docs/billing/subscriptions/upgrade-downgrade#immediate-payment
you can specify to invoice the change immediately and use the expansion to get those payment intent details for manual payment
ohhh ok
but i dont entirely understand: like i don't want to actually update the subscription until i accept payment for those changes
and this doc makes it seem like: ok you have to update it to even get the invoice which you can then use to accept payment
ah RTFM: "Combine this setting with pending updates so the subscription doesn’t update unless payment succeeds on the new invoice."
I was about to say, "Pending Updates" offer this kind of upgrade flow
so i can do this in two separate calls though?
What would those calls be for?
like i have a stepped checkout flow: you make changes to the subscription, see the updated amount, hit next and if you don't have a payment method attached, i want to display the payment method input to accept it; then you fill that out and pay and if that succeeds, only then do i want to actually activate the subscription
or the changes in the subscription,r ather
since you'd already have an active one, you just removed the payment method in the interim
i guess one way around this is to simply not let you into the flow without a payment method attached
Yep that's up to you, depends on your specific checkout flow and what you need. Not that you can also simulate changes to subscriptions using the Upcoming Invoice API:
https://stripe.com/docs/api/invoices/upcoming#upcoming_invoice-subscription
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
(instead of the pending updates flow, for example)
No, its simulated, not a real invoice
but if you want to show an amount for the customer to "agree" to, you can then make the subscription update afterward for collecting payment
heh but the whole problem is i need a payment intent to even display the payment method input