#tcg_api
1 messages ¡ Page 1 of 1 (latest)
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! We typically respond in a few minutes, but in some cases we might need a bit more time (e.g., server's busy, you've got a complex question, etc.).
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can 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/1252730879931977833
đ Have more to share? Add details, code, screenshots, videos, etc. below.
Hi there
I see you're not passing subscription_details.proration_date when previewing the invoice: https://docs.stripe.com/api/invoices/create_preview#create_create_preview-subscription_details-proration_date
Could you try setting a value for this (should be a timestamp in unix time that corresponds to day 15, down to the second, to see the expected proration amount)
i have tried that param but i am receiving wrong values, suposing current period 11 jul. 2025 to 11 ago. 2025
i have to pass timestamp for 26-july-2025 wright?
now i am receiving it
Request req_EwBjYagN2Ypwhu: Recurring estimates do not support the following features: subscription prorations, trials, cancellations, prebilling, schedules, and invoice item additions.
using preview_mode='next' i am received negative amount
We're expecting the unix time stamp
So for July 26, 2025, it should be something like 1753564581 but that's for July 26, 2025, 9:16:21pm GMT
My current code
stripe.Invoice.create_preview(
customer=customer_id,
preview_mode="next",
subscription=subscription_data["id"],
subscription_details={
"items": [
{
"id": current_subscription_item_data["id"],
"quantity": quantity - current_quantity,
}
],
"proration_date": 1753573760
},
)
Okay, looking at the request you shared above
FYI quantity = 12 and current_quantity = 11
Looking at req_EwBjYagN2Ypwhu, you're passing subscription_details.items[0].quantity of 1
but more importantly, in order to calculate proration, you need to pass preview_mode: next. In req_EwBjYagN2Ypwhu, you passed recurring
ok, i will change preview_mode
let me try
my use case is
during current period 11 jul. 2025 to 11 ago. 2025 having an active subcription with quantity=10 I need to preview next invoice amount with quantity=11 (i have it ok) and in the other side I need to preview prorated amount ok the quantity difference on day 26 like before. Do you undestand?
Not sure I follow the second piece
ok, let me try againg (sorry about my english)
So given a billing period from July 11 - August 11, you want to preview the next invoice if you change the quantity to 11 midway through the cycle. I understand that piece
yes
the second piece. I want to show my customer how much cost the extra prorated (from July 26 - August 11) payment amount increase
Okay, got it
Assuming a cost per unit per month of 3 euros. The final result would be to inform the customer that with a quantity of 11, the next invoice (starting from August 11) will be 33 euros, and they now have to make an extra payment of 1.5 euros.
Hold on
Let's talk about proration
So you have a customer who is moving from a quantity of 12 to a quantity of 11?
it's an example. Supposing moving from 10 to 11
Okay, got it
my customer should pay half month (1.5 euros) and the next full month payment should be 33 euros
If you make an update from a quantity of 10 to a quantity of 11 partway through the billing cycle, they'll see two items on their next invoice:
- A credit for the "unused" 15 days at a quantity of 10
- A charge for the remaining 15 days at a quantity of 11
for the sake of simplicity, let's say it's a 15 Euro credit and a 16.50 Euro charge for a net of 1.50
You can preview this amount by using create_preview with the following params:
stripe.Invoice.create_preview(
customer=customer_id,
preview_mode="next",
subscription=subscription_data["id"],
subscription_details={
"items": [
{
"id": current_subscription_item_data["id"],
"quantity": 11,
}
],
"proration_date": 1753573760
},
)
You would have to make a second call to see the next recurring invoice (which is separate from the prorated invoice):
stripe.Invoice.create_preview(
customer=customer_id,
preview_mode="recurring",
subscription=subscription_data["id"],
subscription_details={
"items": [
{
"id": current_subscription_item_data["id"],
"quantity": 11
}
],
},
)
Note that preview_mode is recurring and I've omitted the proration_date. This will return to you what the full invoice amount will be during the first full billing cycle at a quantity of 11
to the second one i have to pass the final quantity
correct
the last one should get an amount of 1.5?
No, that last one will show you 33 euros
oo ok
The preview where preview_mode: next and with the proration date will give you the 1.5 amount
correct
mm it doesn't return 1.5
but i think I can calculate the difference between both calcs
It should return something very close for amount_due