#enraged-camel_api

1 messages ยท Page 1 of 1 (latest)

empty knollBOT
#

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

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

restive brook
#

Hi there

#

You're right, the Subscription object tracks the items and discounts but all amount calculation is handled at the Invoice level

indigo pebble
#

How does this work for accounts that are currently trialing?

restive brook
#

Ah good question

#

For trial Subscriptions, I assume you'll want to show customers the amount of their upcoming Invoice

indigo pebble
#

Correct

#

As a way to say "here's how much you'll pay once your trial ends" (assuming they have a card on file)

restive brook
indigo pebble
#

Hmm, I could have sworn that this used to not work for subscriptions that are currently trialing - we have some code that prevents the endpoint from being called in that scenario. Did that change?

restive brook
#

Let's see, give me a few minutes to test

#

Digging into whether that's changed but I was just able to use the upcoming invoice endpoint to retrieve the next non-zero invoice for a customer who's in trial

indigo pebble
#

OK, here's the error (for a customer who has not yet provided a payment method):

{: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`."}
#

So we cannot rely on the upcoming invoice endpoint

restive brook
#

Hm, that's slightly different but I see what you mean

indigo pebble
#

As we do not collect payment info upfront. We use various discounts to encourage the customer to do so, but we need to also show them the preview of what they would pay

restive brook
#

Can you share the Subscription ID or the Customer ID you're working with?

indigo pebble
#

In test mode, it is this one: sub_1QyhetKvt64dqOba1TNMBMj6

#

That one is brand new - no coupons or anything, and no payment method

restive brook
#

Huh, that's so strange

#

If you make the same call to retrieve the upcoming Invoice for Customer cus_RsSabLMGiKuroO but omit subscription in your request, you won't receive an error

indigo pebble
#

But if we omit the subscription, and the customer has multiple subscriptions (which is possible in our case), what will the endpoint return?

restive brook
#

Got it, not ideal. If you omit subscription and just pass customer, we'll return the next upcoming invoice from their list of Subscriptions (so the one that's set to renew soonest). The response will still include a subscription property so you'll know which Subscription it corresponds to but still not ideal

#

Let me do a bit more testing

empty knollBOT
indigo pebble
#

I think what we need is some sort of review_hypothetical_invoice endpoint that works similar to upcoming_invoice but works for all subscriptions ๐Ÿ™‚

#

It is the end of the day for me so I need to go. Will try to follow up tomorrow. Thank you

restive brook
indigo pebble
#

Bummer

restive brook
#

I'm not seeing a way to be able to do this while the Customer is missing a PaymentMethod and the Subscription is set to pause at trial end

#

A workaround is to create a preview or get an upcoming Invoice without specifying a Customer. What you'd do instead is pass in all relevant attributes that would apply to the customer in question (i.e., address details under customer_details if tax is involved, line items, any discounts)

indigo pebble
#

Okay

#

We will have to do it on our end, I think that's going to be easier

solar glade
#

Hello! Taking over... yeah, I agree it's probably easier to do this on your end given these conditions.

indigo pebble
#

One more question, unrelated: we have a product with multiple prices: one on the monthly billing cycle and another on the annual billing cycle. We are creating coupons, and see that we can have the coupon apply to specific products - however, we don't see how we can make it apply to specific prices in the products