#damonzucconi

1 messages · Page 1 of 1 (latest)

maiden siloBOT
zinc vale
#

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

Learn how to reduce the number of requests you make to the Stripe API by expanding objects in responses.

exotic plume
#

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?

zinc vale
#

Any invoice that requires payment, yes

#

Are you trying to add new recurring items, or one off items to the next invoice?

exotic plume
#

new recurring items

zinc vale
#

The second snippet shows replacing an item with new item, but you can also add the new item without deleting the existing one

exotic plume
#

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?

zinc vale
#

YOu want to invoice for the change immediately and then collect payment?

exotic plume
#

yeah

zinc vale
#

you can specify to invoice the change immediately and use the expansion to get those payment intent details for manual payment

exotic plume
#

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."

zinc vale
#

I was about to say, "Pending Updates" offer this kind of upgrade flow

exotic plume
#

so i can do this in two separate calls though?

zinc vale
#

What would those calls be for?

exotic plume
#

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

zinc vale
#

(instead of the pending updates flow, for example)

exotic plume
#

yeah but do those have a payment intent

#

(it's nil when i look)

zinc vale
#

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

exotic plume
#

heh but the whole problem is i need a payment intent to even display the payment method input