#welshdev_api
1 messages ยท Page 1 of 1 (latest)
๐ 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.
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
These are the latest logs/requests showing in my Stripe account
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?
Could you please share that Susbcription Id ? (copy/pas it as text)
sub_1OlYDZBanUf6N95kEvmowWIB
And the price I'm trying to upgrade the user to is price_1OcbE6BanUf6N95k5u8Ll1Ov
Yes and what is the latest issue you are facing exactly ?
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
Ok I need to get the request Id of this update, because I'm not finding it.
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
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
Sorry, yes I just updated the Dashboard link
Thanks, checking...
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.
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 ?
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
"Unused time on XXX after 24 Jun 2024": -1008
"Remaining time on XXX after 24 Jun 2024": 2099
"1 ร XXX (at $25.00 / month)": 2500The total of which is $35.91
Can you share all the values you are seeing here please ?
Or share the json response here ?
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.
๐ taking over for my colleague. Let me catch up.
๐
can you please retry the same request with a simple change? please use the latest API version https://docs.stripe.com/api/versioning with this request
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
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
I've just tried that, same result. req_93lQZBqjKV6SRG
would you mind sharing the JSON you received?
I can see that the total amount is correctly being calculated
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)?
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.
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.
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.