#lory1234_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/1225125620401438783
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
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.
- lory_subscription-billingcycle, 4 hours ago, 30 messages
Hello! Can you provide a bit more information? An example scenario would help me understand the situation, with specific timeframes.
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?
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?
yes, exactly
or maybe not pausing the subscription at all but wait until they pay and just reset the billing cycle
I think you would need to listen for invoice.payment_failed Events, then pause the Subscription when that happens: https://docs.stripe.com/billing/subscriptions/pause-payment
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.
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?
Probably not, no, but maybe I'm misunderstanding your use case.
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
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?
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?
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.
Okay thanks for your quick help ๐
Always happy to help!
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?
๐ 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?
in_1P1Xd6J0UbsrfDm7YyvTZEJN
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
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?
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_endto when you want the next full charge to occur in your update request insead of usingbilling_cycle_anchor: now
Got it. Thanks. And what event is better to use when I set the trial_end?
What do you mean by that?
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?
If you want this to happen after invoice payment has succeeded you'll want to listen for invoice.paid