#Bijay

1 messages ยท Page 1 of 1 (latest)

green hillBOT
white crest
#

Hi there ๐Ÿ‘‹ what I believe is happening is that you're seeing one Invoice from when the Subscription is first started (they typically automatically generated and immediately pay the first Invoice behind the scenes), and then a second Invoice from when you make the request to update the Subscription and trigger another Invoice by setting proration_behavior to always_invoice.

To be sure though, could you share the ID of a Subscription where you saw the behavior you're describing?

lavish obsidian
#

yeah sure

#

sub_1MKHHgBBLMvSLpwZcYwhpQT9

#

this is in test mode

white crest
#

Thank you, working on pulling that up.

lavish obsidian
#

Thanks

white crest
#

Hm, I'm finding more Invoices than I expected, do you know which two are the ones that you're referring to in your question?

#

Actually, let's try a different approach.

#

Can you help me understand what you want the flow you're working on to accomplish?

lavish obsidian
#

so, I have 3 subscription plans, free, basic and pro. I am trying to implement upgrading a subscription in my app instad of using customer portal

#

the flow that I am using is, Create Checkout Session -> Retrieve Current subscription -> Update the subscription -> Retrieve checkout session -> check forsuccessful payment

white crest
#

Gotcha, I don't think you'll want to use Checkout Sessions in that flow.

lavish obsidian
#

Then, how do i verify if the payment was successful?

#

I was using session.payment_status

white crest
#

Subscriptions will generate Invoices, which generate Payment Intents to handle the processing of their payments, so you would want to check either the Subscription's new Invoice or the Invoice's underlying Payment Intent.

For example, in this request where you updated that Subscription, a new Invoice was generated and its ID is included in the response to the request in the latest_invoice field.
https://dashboard.stripe.com/test/logs/req_5kHREgCe2tQCh1

That Invoice was then paid and so it shows a status of paid
https://dashboard.stripe.com/test/invoices/in_1MKL5uBBLMvSLpwZ271yYXDK

lavish obsidian
#

Thanks Toby.. will try this approach

#

Just one last question, how can i display this prorated amount that the customer will have to pay on Checkout page of stripe

#

currently, it shows the price of the subscription plan

white crest
#

You won't use a Checkout Session process, so you don't need to worry about that. If the automatic payment is not successful and you want to direct your customer to a hosted page to complete the payment, then you can provide them with a link to our Hosted Invoice page. The link for that page can be found on each Invoice, in the hosted_invoice_url field:
https://stripe.com/docs/api/invoices/object#invoice_object-hosted_invoice_url

lavish obsidian
#

Makes sense.. Thank you so much Toby.. appreciate it

white crest
#

Any time, always happy to help!