#maxime_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/1242849774986854476
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
We have an endpoint that can help you preview invoice info. You can pass it the customer's ID and the ID of the subscription and it should preview what the next invoice will look like https://docs.stripe.com/api/invoices/create_preview
This endpoint can do that as well. The main difference being that this endpoint only returns the line item objects from the invoice https://docs.stripe.com/api/invoices/upcoming_invoice_lines
Hey, thanks! So, just to clarify as I've got quite a lot of code already for this ๐ซ ...
It's not possible with the upcoming invoice?
Both of the methods that I linked to can be made without a PaymentMethod or even a Subscription being made yet
Is that what you are asking about being possible? If not can you clarify what you are trying to do with these previews that doesn't seem possible? I may not be reading your question correctly.
Aaah I didn't see the upcoming_invoice_lines maybe that's it
but essentially
I've got the following error
The subscription will pause at the end of the trial instead of generating an invoice because the customer has not provided a payment method and trial_settings[end_behavior][missing_payment_method] is set to pause.; code: invoice_upcoming_none; request-id: req_SHDZDn3lsqHMib
All I'm trying to do, is generate a preview even if the customer is trialing and has no payment method attached
so that I know with all the taxes applies and if there's a coupon code, how much it's going to be in total
Interesting, checking in to that error. Worst comes to worst the workaround would be to make those calls and provide data to subscription_details to basically pretend you are making a new Subscription
I've just tried your solution with the upcoming invoice lines, same issue req_8zHhvQ5Hoey6Kz
I don't see that ๐ค
From the java sdk
Interesting, it is definitely a param in both endpoints. Those params may not have been added until a later version of the java library?
https://docs.stripe.com/api/invoices/create_preview#create_create_preview-subscription_details
https://docs.stripe.com/api/invoices/upcoming#upcoming_invoice-schedule_details
Trying to upgrade to latest now
@slow eagle did the upgrade help?
I have not found a way to do this preview with the existing subscription without a PM unfortunately
Sorry, what do you mean by PM?
PaymentMethod
Thanks (yeah I'm tired ๐)
Arf we have a few bits of code that broke so I need to fix those before I can upgrade
ooooooook I've got the subscription details now, trying
So now that I've got the set subscription details, what should I pass though? ๐ค
The idea for the workaround that I had was basically "pass in the details of the existing subscription but without a trial"
val nextInvoiceParams = InvoiceUpcomingLinesParams
.builder()
.setCustomer("cus_PyjH8iayxcn9DK")
.setSubscription("sub_1PJFQrJdX8lIDNia4ulpwWDo")
.addSubscriptionItem(
InvoiceUpcomingLinesParams.SubscriptionItem.builder().setId("si_Q9YXuT0pgaWdTY")
.setPrice("price_1NwbjlJdX8lIDNiah3lx5Qp3").build()
)
.setSubscriptionProrationBehavior(InvoiceUpcomingLinesParams.SubscriptionProrationBehavior.NONE)
.setSubscriptionBillingCycleAnchor(InvoiceUpcomingLinesParams.SubscriptionBillingCycleAnchor.NOW)
.setSubscriptionTrialEnd(InvoiceUpcomingLinesParams.SubscriptionTrialEnd.NOW)
.build()
So I remove the .setSubscription("sub_1PJFQrJdX8lIDNia4ulpwWDo") first and use the set subscription details to try recreating it?
Hello! I'm taking over and catching up...
Hm, I'm not sure that approach will work. I don't think it's possible to get an upcoming or preview Invoice under these conditions without updating the Subscription itself to change trial_settings.missing_payment_method to create_invoice. Could you make that update, get the upcoming Invoice, then change it back to pause?
I cannot update the subscription no
Oh, re-reading sorry
Uuumh that'd be a bit nasty ๐ฆ
Yeah, it's not great, but your Subscription is currently explicitly configured to not produce an Invoice. If you want to preview an upcoming Invoice you need a Subscription that will, you know, actually produce one. ๐
Ok let me ask this differently then because maybe there's a totally different way:
I want to be able to get the amount a customer is going to pay for a subscription not matter what's the state of the subscription. Paused, cancelled, ongoing...
So for a given price (maybe not even subscription?) I want to know with taxes how much that user would have to pay in total.
And if there's a coupon code provided, be able to get the result with the coupon applied
That's exactly what the upcoming Invoice and preview Invoice APIs are for.
๐ haha
so how do I do it lol
I know it feels like those API should work... But if I'm trialing for some reason it doesn't.
And having a sub that is set to be using invoices is not an option but I want to simulate that. Is there a way to override a subscription param by any chance?
You can override many parameters when you call those endpoints, but trial_settings.missing_payment_method isn't one of them. The only way this will work is if you change that setting on the actual Subscription.
It's just not currently supported in the API.
I can flag it as a feature request internally, but for now the workaround is to modify the Subscription temporarily when you're getting the upcoming Invoice.
Why won't that approach work for you?
I can flag it as a feature request internally
That'd be great, thanks.
Why won't that approach work for you?
I'm guessing that the customer may receive an email etc. And what if he does call that endpoint riiight the sec before the sub expires? Then he's on invoice and then back to pay (which he can't) without a payment method? This is really ugly
Why would the customer receive an email?
Also, you can check to see if the Subscription's trial is about to expire before you make the change, and avoid making any risky updates.
I don't understand how that's even an option to be honnest
This is really not something I should do. With my endpoint being a GET, I would really not want to modify data behind the scenes
I understand it's less than ideal, but it's a workaround if you want to get the upcoming Invoice for one of these Subscriptions.