#hotwire_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/1420763554390212821
📝 Have more to share? Add more details, code, screenshots, videos, etc. below.
Hi, you're using the correct API here, https://docs.stripe.com/api/invoices/create_preview?api-version=2025-07-30.preview
When you make that call, what is not working?
Are you able to share a bit more context here please?
Let me double check the API version first so we're on the same page on that
You're using 2025-05-28.basil and we introduced it in https://docs.stripe.com/changelog#2025-03-31.basil
Ah okay, just checked the code and we're using whatever it will default to.
When I make that call, depending on if I set the proration behaviour or not, I either get the full amount the new product quantities will invoice in the next billing cycle, or the amount the new items will add to your costs.
As we're billing for the prorated additional product immediately I'm looking for the invoice the person will be paying right then.
So say we're adding £400 to their billing at the next billing cycle, and they are buying somewhere in the middle of the month, I'm looking to tell them they are about to be billed £278.38 (or whatever the correct number is).
On that request, https://dashboard.stripe.com/logs/req_WUYTilzwLQ4zHW you're not passing any invoice items data: https://docs.stripe.com/api/invoices/create_preview?api-version=2025-07-30.preview#create_create_preview-invoice_items and proration behaviors: https://docs.stripe.com/api/invoices/create_preview?api-version=2025-07-30.preview#create_create_preview-subscription_details-proration_behavior
You'd need to pass that data, othersiwe, we will just show you the upcoming invoice as is on the subscription
Why changes did you make on https://dashboard.stripe.com/logs/req_WUYTilzwLQ4zHW to show the data you're looking for?
Let me run a new test with the code as it is right now and we can look at that request. It is possible I picked a poor choice of request to examine. One moment.
I realised I've picked a Live site request and my dev requests are going to be easier to debug this end
Okay this is better for us to look at :
req_WETGEfOZyFymhX
sorry, first time using Stripe support (product has been a dream so far)
This request is my starting point, at the moment shows the full amount billed next cycle. I want to alter this to get the prorated amount about to be billed
I've tried unsuccessfully to do this
Right, so let me add those (how I've been doing it so far) and then show you the new request.
The default value is create_prorations
Am I using the right end points for a start
yes, you're
So I'm adding this: SubscriptionDetails = new InvoiceSubscriptionDetailsOptions { ProrationBehavior = "always_invoice"}
req_gLtZWQixH1yqqc
So what I get back now is the cost of the products I've added including Tax
What I'm looking for is what the user will be paying right now
On that latest request, what amount did you expect to see and why?
I expected to see a number less than £420, but more than £0, which would have been the prorated amount that we were about to charge the user, I can complete the flow this end to tell you exactly how much that will be if needed.
You've already make multiple updates on that subscription. Can you simplify your subscription and share exact numbers please? You're saying that the proration does not calculate the amount correctly so having a concerete example with numbers will be help here.
Okay give me a few minutes and I'll set up a fresh account and step through it and send you all the numbers.
You do not need to set a fresh account if you're rereferring to a Stripe account. If you mean a new customer, that makese sense.
apologies, ended up in a call... about the billing and prorated invoices!
Okay this is the default setup for the account:
I go and add licenses selecting to add 1 Advisor level license
I hit next and get this
Which is this request
req_pBtArHRnZD2Elq
Hey there, stepping in for pgskc who needs to step away
taking a look at the request
I press buy now and get this as the invoice amount ... which is correct (only a VERY short prorated amount of usage haha)
that 179.97 is what I would be expecting to have in the step before Buy Now
That request is just a preview of the upcoming invoice for the subscription with no changes, so it would seem expected to me it would be for the recurring amount.
https://dashboard.stripe.com/test/logs/req_pBtArHRnZD2Elq
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
I'm 100% sure I'm doing something wrong in the code that fetches this stuff, I'm just not sure what.
What is the request where you get that amount?
var options = new InvoiceCreatePreviewOptions
{
Subscription = subscriptionId,
SubscriptionDetails = new InvoiceSubscriptionDetailsOptions { ProrationBehavior = "always_invoice"}
};
if (items?.Count > 0)
{
options.InvoiceItems = items;
}
var service = new InvoiceService();
return await service.CreatePreviewAsync(options);
using the C# wrapper for the API
I mean the request ID that ends up with the 179.97 result
It sounds like you're making a change to the subscription that leads to a small proration
To get a preview invoice for changes to the subscription, you need to send those changes in the preview request
If that includes specific proration timing, you likely need to look at using proration_date too
https://docs.corp.stripe.com/api/invoices/create_preview?api-version=2025-08-27.basil&rds=1#create_create_preview-subscription_details-proration_date
So the 179 comes from actually creating the invoice
req_i4VguDTqwDkFfZ
So if I do the same request:
var updatedSubscription = await _stripe.UpdateSubscriptionCheckoutAsync(
id,
metadata,
items);
To CreatePreviewAsync (obviously with the model matching for a preview model) will that get me the result I'm looking for?
Yea i would expect so -- the point of the preview with optional change details is to preview the next invoice that would get generated if you made the same changes to the subscription
Okay the code base has this as two entirely seperate code paths this end for preview and updating subscription, I'll give it a go with calling the CreatePreview rather than update UpdateSubscriptionCheckout as an option in that method and see where I get to.
Thank you both for you help. Stripe continues to be excellent