#lory1234_api

1 messages ยท Page 1 of 1 (latest)

brittle wraithBOT
#

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

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

warm swallowBOT
#

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

deft schooner
#

Hello! Can you provide a bit more information? An example scenario would help me understand the situation, with specific timeframes.

glass sundial
#

yes, sure. There is a scenario when a subscription is created in a specific date e.g 03 April and the next billing date is 03 may. The user for some reason didnt pay the invoice on time and it got delayed by 14 days, so the payment was successful on 17 April. The user receives the order and then he gets charged and gets another order after 16days (03 May). Is any to delay the next cycle date in case of failed previous payments?

deft schooner
#

So if a payment for a Subscription fails you want to basically pause the Subscription until they pay successfully, then resume the Subscription at that point in time and reset the billing cycle anchor based on their successful payment date?

glass sundial
#

yes, exactly

#

or maybe not pausing the subscription at all but wait until they pay and just reset the billing cycle

deft schooner
#

Then when that Invoice is paid resume the Subscription and set the billing_cycle_anchor to now, probably with proration disabled.

#

Another approach would be to cancel the Subscription when the payment fails, then create a new one when payment succeeds.

#

You should try those two approaches in test mode to see which one works best for your use case.

glass sundial
#

what if I dont pause it at all but wait till its payed and then set billing_cycle_anchor to now and proration_behavior: create_prorations? Does this work?

deft schooner
#

Probably not, no, but maybe I'm misunderstanding your use case.

glass sundial
#

probably with proration disabled => how to disable it? I tried with proration_behaviour: 'none' and it took money in that moment so it charged 2 times

deft schooner
#

Going back to your example scenario, if payment fails on 03 and the payment was, say, $100, then there's a delay of 14 days before payment succeeds, how much do you want to charge them for the next Invoice?

glass sundial
#

when the payment succeeds I want to charge them 100$ and on 17 May 100$ again

#

but if I update the subscription on 17 April after the payment was successful, proration_behavior: 'none' will make the user to be charged again right?

deft schooner
#

If you always want to charge $100 then you want prorations off, otherwise the gap time will be charged when you reset the billing cycle anchor.

#

Honestly, it's probably easier to cancel the Subscription immediatley when the payment fails and start a new one later after they pay the outstanding Invoice.

glass sundial
#

Okay thanks for your quick help ๐Ÿ™‚

deft schooner
#

Always happy to help!

warm swallowBOT
glass sundial
#

Sorry for asking again but when I set the proration_behavior: 'none' if I'm not wrong, it charges the full amount immediately. Could you please help me clarify it?

tepid lantern
#

๐Ÿ‘‹ Hello! Hopping in here since rubeus had to head out - can you share the request ID or invoice ID so I can take a closer look?

glass sundial
#

in_1P1Xd6J0UbsrfDm7YyvTZEJN

tepid lantern
#

Is there a reason you're also resetting the billing cycle anchor? The invoice that was generated has no prorations (as expected since you passed in proration_behavior: none) but because you reset the billing cycle anchor to now that means a new cycle has started so we charge the full amount for the new cycle

glass sundial
#

because I want to reset the billing cycle anchor so the next billing cycle is 1 month from the last payment date, not 1 month from the invoice creation date.

#

So basically my issue is this: There is a scenario when a subscription is created on a specific date e.g 03 April and the next billing date is 03 may. The user's payment failed 2 times and the payment
got delayed by 14 days, so the payment was successful on 17 April. The user receives the order and then he gets charged and gets another order after 16days (03 May). Is any to delay the next cycle date in case of failed previous payments?

tepid lantern
#

Gotcha - so there isn't really a clean way to do that (because of what I mentioned where resetting the BCA will charge the full amount for the new cycle). There's some ways you could work around it:

  • Immediately void the invoice that's generated for the new BCA
  • Set trial_end to when you want the next full charge to occur in your update request insead of using billing_cycle_anchor: now
glass sundial
#

Got it. Thanks. And what event is better to use when I set the trial_end?

tepid lantern
#

What do you mean by that?

glass sundial
#

Ah okay, so I need to listen to an event like invoice.updated or invoice.payment_succeeded and then make the call to change the trial_end. For e.g I used invoice.updated to call this method:

#

My question is, what event should I listen to?

tepid lantern
#

If you want this to happen after invoice payment has succeeded you'll want to listen for invoice.paid