#njp-subscription-upcoming
1 messages ยท Page 1 of 1 (latest)
njp-subscription-upcoming
I reproduced this behavior in our test mode on subscription sub_1NgE2GCcKlYJxALVy922Pknp. The CLI commands I used for this, to mimic our server code:
$ stripe invoices upcoming \
--subscription sub_1NgE2GCcKlYJxALVy922Pknp \
-d "subscription_items[0][price]=student_free" \
-d "subscription_items[0][quantity]=1" \
-d "subscription_items[1][id]=si_OTANjc9NkPVCEg" \
-d "subscription_items[1][price]=ai_add_on_standard_monthly_10" \
-d "subscription_items[1][quantity]=1" \
--subscription-billing-cycle-anchor "unchanged" \
--subscription-proration-behavior "always_invoice" \
--subscription-proration-date 1692015927 \
--subscription-cancel-at-period-end false
$ stripe subscriptions update sub_1NgE2GCcKlYJxALVy922Pknp \
-d "items[0][price]=student_free" \
-d "items[0][quantity]=1" \
-d "items[1][id]=si_OTANjc9NkPVCEg" \
-d "items[1][price]=ai_add_on_standard_monthly_10" \
-d "items[1][quantity]=1" \
--billing-cycle-anchor "unchanged" \
--proration-behavior "always_invoice" \
--proration-date 1692015927 \
--cancel_at_period_end false
-d "add_invoice_items[0][quantity]=1" \
-d "add_invoice_items[0][price_data][unit_amount]=200" \
-d "add_invoice_items[0][price_data][currency]=usd" \
-d "add_invoice_items[0][price_data][product]=prod_Na6ZBmvpWJQdQ7"
The invoice preview had lines for both the student_free item and the ai_add_on_standard_monthly_10 item, but the actually generated invoice only had the $2 added invoice item.
I also tried to get the invoice preview with proration_behavior=create_prorations, but still got a $10 subtotal.
I'm going to need to see the exact raw JSON you got from both of those (expand latest_invoice on the second call)
Here's the JSON response from stripe invoices retrieveing the generated invoice
And here's the actual JSON response from the update subscription request
you didn't expand on the second one
I already submitted that request, so I can't resend the request with the expanded latest_invoice. Instead, I retrieved the invoice directly; that's the first message
I'm... confused
If it's better for you, I can retrieve the subscription with latest_invoice expanded
I need to see the exact raw JSON of both requests so that I can compare them
If you can't resend you should be able to quickly reproduce that flow from scratch on a brand new customer right?
I will reproduce the flow as fast as I can, but I'm on a slow connection right now. I thought that this might be enough for you (the retrieved invoice should be the same as what is in the expanded latest_invoice, right?)
Sure but how can I compare it to anything else?
What you said is "I get 2 different results from 2 calls" but gave me only one
Oh, I was using a test clock too, to mimic what the customer experienced
Well, I can post the invoice preview too
Here is the result from the upcoming invoice call
That is the other call to compare with
I sent the JSON as attached files. Can you not open them?
or expand them?
When I hover over the "expand" button, all three files have at least 200 lines
Sorry we're talking past each other
Let's take a step back because I am completely lost with what you are asking I'm sorry.
First: Why do you expect the Upcoming Invoice API to mirror what you'd get with the Update Subscription API when passing add_invoice_items in the latter but not the former?
Like to me you are making two completely different calls, why would they match?
First: Why do you expect the Upcoming Invoice API to mirror what you'd get with the Update Subscription API when passing add_invoice_items in the latter but not the former?
The requests use identical params except for the added invoice item, so I would expect that the invoice created through Update Subscription would be the same, but with the added invoice item. But what I'm seeing is that the invoice preview has line items forstudent_freeandai_add_on_standard_monthly_10, but the actual invoice does not have those line items
The docs for Upcoming Invoice say that you can use it to preview the effects of updating a subscription https://stripe.com/docs/api/invoices/upcoming
yeah sorry you're going too fast
1/ Can you work on doing exactly what you're doing without add_invoice_items?
2/ The Update Subscription would definitely give you the line items for proration if you were properly modifying that Subscription. I'm not super clear on what's happening here and you seem to use maybe the CLI + TestClock and it's hard to reverse engineer the overall state after the fact.
it seems the JSON also comes from the Dashboard not the API + the Invoice you shared was created manually in the Dashboard based on https://dashboard.stripe.com/test/logs/req_OqNipeeysS76YS so I'm even more confused by the ask
1/ Yes, when I called Update Subscription without add_invoice_items, no invoice was generated
2/ I was using the CLI through Stripe Shell in the dashboard
gotcha, that's why it looks so weird
I think at this point, the first step is to take a step back from all of this and do the simplest example in Test mode with real code (no shell and such) to be able to repro fast
Just looking at your update request it didn't seem to change the Subscription much. But you're also a big user with lots of custom settings so it's not easy to figure out what's happening with a clean end to end repro
Okay, working on getting a simple repro from code ๐
as far as I can tell your Subscription was on Price A, and you move to Price A + Price B ($0) + one-time fee ($2)
so the Invoice ended up being just for $2, since there's no proration needed for the $0 Price B
That Upcoming Invoice had 2 lines as if the billing cycle was changing, it's not even proration so it's like the Subscription was in a different state
Yeah, so why did Upcoming Invoice act like the billing cycle was changing?
That I don't know, it's hard to say without seeing exactly what you were doing in the exact order. Especially when using the shell + TestClocks without much more info
Okay, so when I do it through the API (via my server code), it will generate logs/events that will be easier for you to use to investigate?
Kind of. This is barely scratching the surface of the 20+ things we'll need to work through
But it'll be the first step yes
In that case, I may need to come back to this issue tomorrow. Would that be okay?
In that case I'd highly recommend contacting support and providing all the details needed for an end to end repro instead of Discord
Okay, I'll do that. Thanks for your help!
Sure thing! Overall what we need is basically a repro with a clear Customer, with a Subscription where you call the Upcoming Invoice, see specific lines then immediately update that Subscription and see different lines. Ignore the add_invoice_items it's likely unrelated