#maxime_api

1 messages ยท Page 1 of 1 (latest)

chrome fiberBOT
#

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

brittle grail
slow eagle
#

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?

brittle grail
#

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.

slow eagle
#

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

brittle grail
#

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

slow eagle
#

I've just tried your solution with the upcoming invoice lines, same issue req_8zHhvQ5Hoey6Kz

slow eagle
#

From the java sdk

brittle grail
slow eagle
#

Trying to upgrade to latest now

brittle grail
#

@slow eagle did the upgrade help?

#

I have not found a way to do this preview with the existing subscription without a PM unfortunately

slow eagle
#

Sorry I had a live demo to make for end of sprint

#

looking back into it now

chrome fiberBOT
brittle grail
#

PaymentMethod

slow eagle
#

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? ๐Ÿค”

brittle grail
#

The idea for the workaround that I had was basically "pass in the details of the existing subscription but without a trial"

slow eagle
#
    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?

north heron
#

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?

slow eagle
#

I cannot update the subscription no

#

Oh, re-reading sorry

#

Uuumh that'd be a bit nasty ๐Ÿ˜ฆ

north heron
#

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. ๐Ÿ˜…

slow eagle
#

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

north heron
#

That's exactly what the upcoming Invoice and preview Invoice APIs are for.

slow eagle
#

๐Ÿ˜† 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?

north heron
#

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.

slow eagle
#

The customer portal is able to though

#

Why wouldn't I be able to do the same thing?

north heron
#

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?

slow eagle
#

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

north heron
#

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.

slow eagle
#

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

north heron
#

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.