#welshdev_api

1 messages ยท Page 1 of 1 (latest)

brisk pierBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! We typically respond in a few minutes, but in some cases we might need a bit more time (e.g., server's busy, you've got a complex question, etc.).

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can start a new thread if you have another question.

๐Ÿ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1254735938391900160

๐Ÿ“ Have more to share? Add details, code, screenshots, videos, etc. below.

inland goblet
#

๐Ÿ‘‹ happy to help

#

would you mind sharing the request ID?

unreal fog
#

In Developers > Logs, I'm not seeing any logs for this \Stripe\Invoice::upcoming request

#

I'm definitely using the right Stripe keys, as I can see plenty of other logs for when users have upgraded/paid their subscriptions over the last few days

brisk pierBOT
unreal fog
#

These are the latest logs/requests showing in my Stripe account

brisk pierBOT
unreal fog
#

I've followed that and I have the logs page open but I'm not seeing any logs at all for this as per my screenshot. I've just made sure that I'm looking at the correct Stripe account and that my keys match which they do, but I'm not seeing any logs for my \Stripe\Invoice::upcoming request
Can you please confirm if I should be seeing logs for this?

floral canopy
#

Could you please share that Susbcription Id ? (copy/pas it as text)

unreal fog
#

sub_1OlYDZBanUf6N95kEvmowWIB

#

And the price I'm trying to upgrade the user to is price_1OcbE6BanUf6N95k5u8Ll1Ov

floral canopy
#

Yes and what is the latest issue you are facing exactly ?

unreal fog
#

When calculating the pro-rata price for my user to upgrade frmo their current $12 per month plan to $25 per month, the "upcoming" invoice has a total of around $35.
But surely that can't be right? How can a partial month upgrade cost significantly more than a full month?

#

The upcoming invoice generated includes 3 lines...

"Unused time on XXX after 24 Jun 2024": -1008
"Remaining time on XXX after 24 Jun 2024": 2099
"1 ร— XXX (at $25.00 / month)": 2500

The total of which is $35.91

floral canopy
#

The latest update you made on that Subscription was this one req_Vjiau9NnctMiwp

#

You are trying to update to this price price_1OcbCcBanUf6N95kPeAIk9Ag and not price_1OcbE6BanUf6N95k5u8Ll1Ov

unreal fog
#

Keep in mind, this is NOT in test, this is all in production.

#

I'm trying to upgrade from price_1OcbCcBanUf6N95kPeAIk9Ag (their current price) to price_1OcbE6BanUf6N95k5u8Ll1Ov

#

Okay... weird... I've just switched from production to testing and then back, and now I'm seeing the logs for my requests.

#

req_MqoBtEGW1b6vFh

floral canopy
floral canopy
unreal fog
#

Thanks. Maybe I'm just missing something, I just don't understand how a pro-rata upgrade can be more than the price of a full month.
It's worth noting that I've tested this against some of my other users and I'm getting the same result where the upcoming invoice total is wildly higher than the total plan upgrade.

floral canopy
#

So the price price_1OcbE6BanUf6N95k5u8Ll1Ov has $25.00 usd as an amount, the lastest invocie amount is $4.67 for the period between June 21st and Jully 21st. You are trying to simulate a proration for today (June 24th) so far this is right ?

unreal fog
#

That's correct. On 21st June the user upgraded from a $7/mo price to a $12/mo price which is why there's a paid invoice for $4.67.
When the user did this, my UI didn't explain to them that they'll only need to pay $4.67 so that's what I'm implementing now via the "upcoming invoices" feature of the API.

In doing so when generating the upcoming invoice, instead of it taking the new monthly amount of $25 and pro-rata deducting the unused time of their currently $12/mo cycle, it's returning an invoice which is adding an additional $25 on top of that calculation...

"Unused time on XXX after 24 Jun 2024": -1008
"Remaining time on XXX after 24 Jun 2024": 2099
"1 ร— XXX (at $25.00 / month)": 2500

The total of which is $35.91

So my understanding is the following (quick math with rough figures)...

Days used so far on plan: 3
Days unused on plan: 27 (assuming 30 days in a month)
Per day price of new plan: $25 / 30 = $0.83
Unused value on current plan: ($12 / 30) * 27 = $10.80
Pro-rated upgrade amount: $25 - $10.80 = $14.0

floral canopy
#

"Unused time on XXX after 24 Jun 2024": -1008
"Remaining time on XXX after 24 Jun 2024": 2099
"1 ร— XXX (at $25.00 / month)": 2500

The total of which is $35.91
Can you share all the values you are seeing here please ?

#

Or share the json response here ?

unreal fog
brisk pierBOT
unreal fog
#

It may be worth mentioning that in the Stripe Web dashboard, if I edit the customers subscription and remove the $12/mo price, add the $25/mo price then tick the "prorate charges" and "charge proration amount immediately" options then this seems to be calculating it correctly i.e. $10.91 due immediately. But for some reason I'm unable to get this figure back from the API.

inland goblet
#

๐Ÿ‘‹ taking over for my colleague. Let me catch up.

unreal fog
#

๐Ÿ‘

inland goblet
#

let's see if this helps first

#

then we can see if that might be related to why you're getting this behavior on your API

unreal fog
#

I've just tried that, same result. req_93lQZBqjKV6SRG

inland goblet
#

would you mind sharing the JSON you received?

#

I can see that the total amount is correctly being calculated

unreal fog
#

Yes, the total amount calculated is correct in the sense that all items add up correctly but that's not my question/issue here.

Perhaps I'm not making myself clear and we should take a step back on this.
My question is... when generating an upcoming invoice for a prorated subscription price change from $12/mo to $25/mo, why am I getting an invoice total ($35+) which is significantly greater than a full months subscription payment ($25)?

brittle plinthBOT
unreal fog
#

Actually, I've just worked it out.
By changing "proration_behavior" to "always_invoice" instead of "create_prorations", this is now returning an upcoming invoices with the correct total of around $11.

buoyant basin
#

because the upcoming invoice represents the invoice that will happen next month

#

it includes the amount for the upcoming month, plus the prorations. It's not just the proration.

unreal fog
#

The documentation that I was following to implement this has perhaps confused me a little.
I've just re-read the whole thing and there's a sentence under "Immediate payment" which mentions the "always_inoivce" option which makes it do what I need.