#websiddu
1 messages ยท Page 1 of 1 (latest)
Wait, why doesn't stripe.invoices.retrieveUpcoming work?
it does work,
but I have to manually calculate the Amount due today
by subtracting from each line items
in the strip dashboard, the preview is super celar, like shown in the image.
And I see in strip dashboard, this is the request sent.
You shouldn't have to calculate it manually right? Like, the Upcoming Invoice API returns an Invoice object, which has a total attribute: https://stripe.com/docs/api/invoices/object#invoice_object-total
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
is there an equivalent API call that I could use.
I'm not sure I understand. The API you're using returns a total with all the same line items you would see in the dashboard
I'm not sure if that is true for me ๐ฆ
What do you mean? It's right there in your screenshot
Got it. That's exactly what the payload will look like when you retrieve an upcoming invoice as well
but when I send the request, in my app,
I'm follwing this https://stripe.com/docs/billing/subscriptions/prorations
and passing a subscription_proration_date
the response is not the same as what I have been seeing in the strip app itself,
so I have do my own math to figure out the amount due today when the user is updating the quantity of a subscription.
When you look at the upcoming invoice in the Dashboard, you're seeing what it will look like with no changes, but by passing in a subscription_proration_date you are getting a mock-up of what the Invoice would look like if you changed the proration date
Does that make sense?
Yes, the data accurate.
But I think, its just not in the right format to dispaly that subscription update preview
in the same way in when I update the quantity of a subscription from the dashboard.
So the data is correct but you want to know how to display it?
yes, I want to display the update preview like what strip dashboard is doing, when I update the quantity of a subscripotpn
I'm looking for a call that sends me data in that format. ๐
Got it, you would need to figure out how to display that on your own. Stripe doesn't provide an UI components that do that for you. The closest thing we have is the Customer Billing Portal (which wouldn't allow you to customixe subscription updates to this degree)
I'm more looking for an API call,
give a subscription quantiy change, that will provide me with amount due today
The upcoming invoice endpoint is meant for exactly this kind of subscription update preview
What about the endpoint is not providing what you need?
Can you share an example request you're making, and the response body (redacting anything sensitive) to help me understand your challenge here?
Oh it does provide all the info, but I have to do math by myself
e.g Let's say, I have subsribed to 5 seats per $10 each currently, and I want chagne the seats from 5 to 2 in the middle of the month
Ok, can you show me an example request where you get this change preview?
And then explain using the response you get what you need to calculate compared to what you get back?
In the strip portal, it give a clear view of what is being credited.
I mean via the API
so I want to recreate this UI using API
e.g the text "Applied account balance" I have basically pick line item
from the updcoming invoice resopnse
can you rephrase that? i don't understand
and display it by myself,
Sorry, If I were to display the line that say "Applied account balance" that piece of text is not present in the api response at all today.
oh, that particular one no not exactly, but there is starting_balance and ending_balance
https://stripe.com/docs/api/invoices/object#invoice_object-ending_balance
Can you share a specific example request & response data with a customer balance so we can look at the data together?
This is the response I get when I go from a 4 seat to 3 seat (each $15 per month)
So currently the customer is paying $60 per month, for 4 seats, and they want to change it to 3 seats moving forward, assuming they changed their mind quickly after paying, the new monthly amount they would pay is $45 per month and they will have a $15 credit, and today amount they pay right now is 0.
Here is the response i get
for the due today -> I use the amount_due,
not sure i get to show the credit
Other than doing subtraction by myself
Well what are you expecting here? There is no amount due right?
Can you share the request you're making to get that?
But this seems expected
You're crediting back ~60 for the proration, charging ~45 for the proration, charging 45 for the next month, so the net is ~30
and the customer has ~90 balance, so ~30 is applied from that balance and now they have ~60 balance remaining (ending_balance)
if you want the prorated net before balance, that's subtotal=3030 here (or total, depending on whether you want with or without tax)