#alan_api
1 messages Β· Page 1 of 1 (latest)
π Welcome to your new thread!
β²οΈ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
β±οΈ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always 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/1462721741230047346
π Have more to share? Add more details, code, screenshots, videos, etc. below.
The several prices displayed on this page
π Hey there. the /v1/invoices/create_preview API will give you a preview of the upcoming invoice for the subscription, but this would be assuming no updates, so this probably isn't what you're looking for. The Quote API https://docs.stripe.com/api/quotes might be more along the lines of what you're looking for. This provides a way to model prices that you'd like to provide to a customer
There are many Endpoints in this system. How should I use them? Is there a demo I can refer to? I mainly need to update the price preview when subscribing, which involves calculating how much money should be refunded or added. Through which interface is the refund or addition calculated
What do you mean by updating the price preview? Can you give me an example?
What I mean is, how can I obtain the amount of money displayed in the subscription preview interface of this update? Is there any code I can refer to
How should I use the Quote API to meet this requirement
I am not creating a new subscription. What I want to obtain is a preview of the amount when changes are about to be made to my existing subscription
Ah, I see, in the case the Invoice preview endpoint may indeed be what you need. If will create an upcoming invoice object that should contain the line items with the relevant amounts
Are you referring to this /v1/invoices/create_preview? Then why does the returned result differ from the amount displayed in my test on the sandbox client portal? Could you please take a look at the returned result of my req_WLeihyvfJy13xu
What are the differences you're noticing?
req_N8k4hEusItLCpL This is the new requestId
In different places, for example, the Amount due today displayed on the customer portal preview interface is 373.44, but what I get through the API is 106625. Other amounts are similar. I don't know how to match the amount returned by the API interface with the amount on the preview interface
hey there, taking over for my colleague π are both of these updates for the same subscription?
ahh I see the issue
yes
so your second screenshot shows an 'Amount due today', but the first screenshot isn't billing any amount immediately - it's showing you a preview of the next scheduled invoice on the subscription
it's the difference between proration_behavior: 'create_prorations' (added to the next invoice) vs proration_behavior: 'always_invoice' (billed immediately)
so in effect, the first screenshot (i.e. the Invoice Preview API) is showing you the prorated amount due + 500 for the next full billing period
you can control this using this parameter when creating the Invoice Preview:
https://docs.stripe.com/api/invoices/create_preview#create_create_preview-schedule_details-proration_behavior
What I want is the amount displayed in the second screenshot. How should I use it
create an invoice preview and pass subscription_details.proration_behavior: 'always_invoice'
that will result in a preview invoice that only includes the proration items (i.e. the same as the second screenshot)
use always_invoice?
assuming you want to bill the customer for the prorated amount immediately, then yes
this will preview the full amount due for the prorated invoice
There are two situations. For upshifts, the update is immediate. For downshifts, the update will only occur after the current package ends. Is this how it's used
ok! well in either case, if you only want to preview the prorated amount, you'll want to set always_invoice when creating the preview
if you want to preview the prorated amount + the next billing cycle, then you can omit this parameter (so it defaults to create_prorations)
Ok, thank you very much. I'll give it a try first. If I have any questions later, can I still contact you?
of course! these threads are locked after a little while of inactivity, but you're always welcome to open a new thread and we can see this one for context
Okay, thank you again. Both of you are professionals, and you deserve our admiration
thanks a lot, that's highly appreciated π
π
create an invoice preview and pass subscription_details.proration_behavior: 'always_invoice'
I have written according to this, but why is it still different? Request ID is req_i9TdgIKnAlgH90
hi there
I'd have expected to have two items in the preview, but there's only one for some reason - looking into why
ok,thank you
thanks for your patience so far - it seems like this is related to the subscription using billing_mode: 'flexible', but I'm still investigating
π taking over for my colleague. catching up
If the API is relatively complex, can we also refer to how the amount code is obtained in the preview interface, and then compare it with this API
@rigid lily you'll receive a DM with a link to open a case with Stripe, this would be automatically filed with our team and someone will continue investigating and get back to you. please add as much details as you can.
Hello @rigid lily, we have sent you a direct message, please check it at https://discord.com/channels/@me/1462750445016580159
- πThe message has instructions on how to open a direct support case with our Developer Support team, in order to help you more effectively.
@rigid lily where you able to do it?