#lea173589_api

1 messages Ā· Page 1 of 1 (latest)

past frigateBOT
#

šŸ‘‹ 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/1397960261440245850

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

hot edge
#

Here is the screenshot of the preview on the dahsboard

echo swan
#

hi thanks for the two examples, taking a look

#

Both of the requests you shared appear to be from the Dashboard, though

#

So not sure if you mean to share a different request from your API call

hot edge
#

I used the shell for the 2 requests, and I'm getting the same result from the api. The preview of the dashboard is a different attempt, and I'm getting a different result that the other 2 requests

#

i would like to know how to achieve the result from the dashbord preview, with an api request

echo swan
#

Well these examples are using different parameters so different results seems reasonable

#

You should test with the same parameters for the same subscription context and see if that resolves the difference

hot edge
#

the problem is that I don't know the parameters that the dashboard uses

#

From the shell :
req_eY0dHAO9FQD3YP -> amount 226
req_TvcfeI63eWuOmm -> amount 9814

From the dashboard :
Amount 9211

#

I cannot manage to get the amount 9211 from the shell, do you know which parameters should i use ?

echo swan
#

At the links I gave you

hot edge
#

thoses links are for the requests I made from the shell, I already know what parameters I used and this is not what I want

#

is there any way i can see the log of the request made on the dashboard ?

past frigateBOT
echo swan
hot edge
#

I went through the process on the dashboard but no request were visible on the logs

feral lily
#

šŸ‘‹ stepping in as synthrider needed to step away

hot edge
#

hi!

feral lily
#

If you use the API endpoint filter in Workbench and filter for /v1/invoices/create_preview do you see the logs?

#

I see them from my end

hot edge
#

yes but those are the requests I made using the shell :

feral lily
#

Oh I see what you are saying -- yeah if you go to make an update in the Dashboard then the preview shown in the modal does not generate an API request. That is all Dashboard calculation done via the Dashboard logic.

#

You can't use that to mirror an API request.

hot edge
#

Ok thanks for your reply, then how can I achieve the preview in the modal with an api request ? the result from the dashboard is the result I want, and the results from the 2 shell request are not what I want

feral lily
#

You would need to continue changing the parameters for the API request to achieve what you want.

Perhaps if you can give me the specific scenario then I can help. Overall though you should think of setting the params to how you want things handled, not focus on trying to achieve a specific amount.

hot edge
#

ok i'll explain my scenario better :

#

I want my customer (cus_SjsVALCWpNxSez) to update subscription prices (sub_1RoOkQCrKhyR1Db2h5x3PvNd) from price_1Lri2ZCrKhyR1Db2DYpping9 to price_1RRV9RCrKhyR1Db2im6jS9oR
I want my user to start a new billing cycle at the moment of the upgrade, and I want a discount of the time not used of the first billing cycle on the invoice.
I can manage to have this exact result when doing the preview on the dashboard with the final amount of 92,11€

feral lily
#

Okay so you basically just want to create a Preview that uses proration_behavior: always_invoice and update the Subscription Item.

#

From looking at your Workbench preview it seems you are using a Test Clock and thus setting proration_date: "1782913912"

#

But that could potentially be throwing things off

#

Overall if you see a different than expected amount then providing the exact request ID would help. Or you could even perform the update in test mode to a test Subscription and then we can look at the generated Invoice to see what happened.

hot edge
#

Then I tried on the api shell to replicate this result
The first request req_eY0dHAO9FQD3YP with proration_behavior as create_proration gave me an invoice of 2,26€ which is only the amount of the proration, and not the start of a new billing cycle.

The second request req_TvcfeI63eWuOmm with proration_behavior as always_invoice, gave me an invoice of 98,14€, which is more than the amount of the price_1RRV9RCrKhyR1Db2im6jS9oR (95,88€) and with no discount

Those requests are not what I want

feral lily
#

My advice is to create a new Customer that isn't using a Test Clock

#

With a new Subscription with the Price you want them to originally have.

#

Then create a preview of an update