#stripe22_unexpected

1 messages ยท Page 1 of 1 (latest)

near anchorBOT
#

๐Ÿ‘‹ 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!

autumn quartzBOT
carmine wing
#

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?

timid edge
#

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

carmine wing
#

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.

timid edge
#

thank you

carmine wing
#

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

timid edge
#

ok, so if i pass the subscription_trial_end, will it give me the amount due at that point, plus the correct due date?

carmine wing
#

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.

timid edge
#

ok, thanks. i will try it out.

#

is there a line item that tells me when the existing trial is ending?

autumn quartzBOT
carmine wing
timid edge
#

thank you

#

appreciate your help

carmine wing
#

Any time!

timid edge
#

One more quick question

#

why does this request return an amount due then

#

Request-Id=req_2hlG7bLdjwyBEL

carmine wing
#

I'm not sure offhand, can you share the full output from that?

timid edge
plush girder
#

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.

timid edge
#

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?

plush girder
#

I imagine because you're using a $0 Price.

#

But yeah, if you have more questions, please share the output you have questions about.

timid edge
#

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)

plush girder
#

In order to answer that I need to know what parameters you're passing to the upcoming Invoice endpoint and the output for each.

timid edge
#

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();

plush girder
#

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?

timid edge
#

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

plush girder
#

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.

timid edge
#

that is it! thank you!