#alan_api

1 messages Β· Page 1 of 1 (latest)

broken pineBOT
#

πŸ‘‹ 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.

rigid lily
#

The several prices displayed on this page

tawny mango
#

πŸ‘‹ 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

rigid lily
#

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

tawny mango
#

What do you mean by updating the price preview? Can you give me an example?

rigid lily
#

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

tawny mango
#

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

rigid lily
#

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

tawny mango
#

What are the differences you're noticing?

broken pineBOT
rigid lily
#

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

half raptor
#

hey there, taking over for my colleague πŸ‘‹ are both of these updates for the same subscription?

#

ahh I see the issue

rigid lily
#

yes

half raptor
#

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

rigid lily
#

What I want is the amount displayed in the second screenshot. How should I use it

half raptor
#

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)

rigid lily
#

use always_invoice?

half raptor
#

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

rigid lily
#

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

half raptor
#

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)

rigid lily
#

Ok, thank you very much. I'll give it a try first. If I have any questions later, can I still contact you?

half raptor
#

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

rigid lily
#

Okay, thank you again. Both of you are professionals, and you deserve our admiration

half raptor
#

thanks a lot, that's highly appreciated πŸ™‚

rigid lily
#

πŸ‘

rigid lily
#

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

half raptor
#

I'd have expected to have two items in the preview, but there's only one for some reason - looking into why

rigid lily
#

ok,thank you

half raptor
#

thanks for your patience so far - it seems like this is related to the subscription using billing_mode: 'flexible', but I'm still investigating

broken pineBOT
quartz mulch
#

πŸ‘‹ taking over for my colleague. catching up

rigid lily
#

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

quartz mulch
#

@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.

broken pineBOT
#

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.
quartz mulch
#

@rigid lily where you able to do it?