#njp-subscription-upcoming

1 messages ยท Page 1 of 1 (latest)

feral urchinBOT
slow anchor
#

njp-subscription-upcoming

tired lynx
#

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.

slow anchor
#

I'm going to need to see the exact raw JSON you got from both of those (expand latest_invoice on the second call)

tired lynx
slow anchor
#

you didn't expand on the second one

tired lynx
#

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

slow anchor
#

I'm... confused

tired lynx
#

If it's better for you, I can retrieve the subscription with latest_invoice expanded

slow anchor
#

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?

tired lynx
#

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?)

slow anchor
#

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

tired lynx
#

Oh, I was using a test clock too, to mimic what the customer experienced

#

Well, I can post the invoice preview too

#

That is the other call to compare with

slow anchor
#

but what do I compare?

#

I'm really sorry but both JSON have one line

tired lynx
#

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

slow anchor
#

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?

tired lynx
#

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 for student_free and ai_add_on_standard_monthly_10, but the actual invoice does not have those line items

slow anchor
#

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.

tired lynx
#

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

slow anchor
#

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

tired lynx
#

Okay, working on getting a simple repro from code ๐Ÿ‘

slow anchor
#

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

tired lynx
#

Yeah, so why did Upcoming Invoice act like the billing cycle was changing?

slow anchor
#

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

tired lynx
#

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?

slow anchor
#

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

tired lynx
#

In that case, I may need to come back to this issue tomorrow. Would that be okay?

slow anchor
#

In that case I'd highly recommend contacting support and providing all the details needed for an end to end repro instead of Discord

tired lynx
#

Okay, I'll do that. Thanks for your help!

slow anchor
#

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