#stripe22_unexpected
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฑ๏ธ We automatically close idle threads, which makes them read-only. Make sure you stick around to chat in realtime!
๐ 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/1212434050728333403
๐ Have more to share? You can add more detail below, including code, screenshots, videos, etc.
โฒ๏ธ 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. Thank you for your patience!
Hi there ๐ do you have an ID of a request where you previewed an upcoming Invoice and saw this behavior, that you can share here so I can take a closer look at that?
One more thing to add before I look for the request ID
The first subscription with the free trial is monthly and the 2nd is yearly
It seems to work if I choose a different monthly, but not yearly
Request-Id=req_IzX2XT5LFxfgby
Gotcha, so you are passing in the ID of an existing Subscription, and are overwriting the Subscription Item's Price. Bear with me a moment while I take a closer look at the specifics.
thank you
That Subscription seems to be on a trial period until 2025, so it's expected for all Invoices until then to be $0 Invoices. If you're trying to see what the Invoice amount would be if the trial period also ended, I would recommend trying to pass the subscription_trial_end parameter as well:
https://docs.stripe.com/api/invoices/upcoming#upcoming_invoice-subscription_trial_end
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
ok, so if i pass the subscription_trial_end, will it give me the amount due at that point, plus the correct due date?
It will preview the upcoming Invoice as if the Subscription's trial period ended at the time you specified. I'm not sure what you mean by correct due date, so I'm not sure how to answer that.
ok, thanks. i will try it out.
is there a line item that tells me when the existing trial is ending?
It's shown in the trial_end property on the Subscription:
https://docs.stripe.com/api/subscriptions/object#subscription_object-trial_end
Any time!
One more quick question
why does this request return an amount due then
Request-Id=req_2hlG7bLdjwyBEL
I'm not sure offhand, can you share the full output from that?
Hope that is what you need
Hello! I'm taking over and catching up...
That's a preview of the upcoming Invoice that hasn't been created yet. That's the next Invoice that will be created, when the trial ends, which is why there's an amount due.
Hi
I understand that, but when I choose a different price, it gives $0 due
I want to know why one shows an amount and the other does not
even though the customer is the same
Do you want the upcoming invoice for the one that returns $0?
I imagine because you're using a $0 Price.
But yeah, if you have more questions, please share the output you have questions about.
I am not using a $0 price
I have a free trial for a year
so your colleague explained that i should add the subscription_trial_end to the request
however, I am curious why one request returns an amount due and the other does not even though they are just different prices with different intervals
(this is without adding the subscription_trial_end)
In order to answer that I need to know what parameters you're passing to the upcoming Invoice endpoint and the output for each.
ok
Here is my code
// Set the proration date to this moment:
DateTimeOffset prorationDate = DateTimeOffset.UtcNow;
var subService = new SubscriptionService();
Subscription subscription = subService.Get(subId);
// See what the next invoice would look like with a price switch
// and proration set:
var items = new List<InvoiceSubscriptionItemOptions>
{
new InvoiceSubscriptionItemOptions
{
Id = subscription.Items.Data[0].Id,
Price = subNewPrice, // switch to new price
},
};
var options = new UpcomingInvoiceOptions
{
Customer = subCustId,
Subscription = subId,
SubscriptionItems = items,
SubscriptionProrationDate = prorationDate.UtcDateTime,
};
var invService = new InvoiceService();
Invoice invoice = invService.Upcoming(options);
var amountDue = string.Format("{0:0.00}", Decimal.Divide(invoice.AmountDue, 100));
var dueDate = string.Format("{0: MMMM dd, yyyy}", invoice.DueDate);
var interval = invoice.Lines.Data[0].Plan.Interval.ToString();
The first one has a trial period. The second one does not. Look at the description for the line item on each one; one explains it's for the trial period (thus zero), the other one is charging the amount because there is no trial.
Can you give me the request IDs for both of those?
Sure
Request-Id=req_iouvCrNLAwiCH7
Request-Id=req_Db4gu0fQh24Ymd
My expectation was that Stripe would know about the trial period and just adjust the due date to reflect the time directly after the trial period
and price accordingly. For example, if i have a 30 free trial, then it would return a date 30 days from the trial start and the price after the free trial
Ah, I think the confusion is due to the intervals involved. The Subscription you're specifying is currently using a monthly Price. One of the Prices you specified above when getting the upcoming Invoice is also monthly, but the other is yearly. When you change the interval we bill immediately: https://docs.stripe.com/billing/subscriptions/upgrade-downgrade#immediate-payment
When you specify the yearly Price the interval doesn't change, so the trial remains intact. When you specify the monthly Price the interval does change and the trial is lost.
that is it! thank you!