#vladgrego_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/1277694071720378432
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
You would likely need to setup your own provisioning services to listen for invoice.payment_failed webhooks and perform some action to stop the provisioning of services.
At that point you can then listen for invoice.paid events to automatically update the Subscription's billing_cycle_anchor to account for the new billing day and handle (or remove) prorations
I want to keep retrying the payment, but when the payment really succeeds (for example for a monthly subscription) I want to change the new billing cycle anchor to now, but avoid charging the user again. The payment already succeeded so it is not necessary to generate a new invoice
Is that possible?
hello?
Please be patient, we have several other open threads.
Okay! ๐
Have you attempted to test the suggestion I gave with Test Clocks yet? As far as I can tell, the resolution I provided should have the outcome you're looking for
Happy to walk through how to do specific parts of that in the API if you are getting stuck
Thanks @cobalt tangle
this is my issue
Lets say I have a subscription in stripe (starting on 2021-10-01), and at the end of the first billing cycle on 2021-11-01
stripe attempts to charge the card on file
lets say that transaction fails due to insufficient_funds
stripe retries again after 2 days (on 2021-11-03), this time the transaction is successful.
now the subscription will again charge the user again on 2021-12-01 even though the prev payment was done on 2021-11-03
I do not provide services to the user (2021-11-01 to 2021-11-03) when they payment is not complete
What is the solution to update the sub for the new dates without charging him again?
So two-shoes's suggestion is that you make this API call when you want to start the new cycle when your invoice has actually been paid https://docs.stripe.com/billing/subscriptions/billing-cycle#reset-the-billing-cycle-to-the-current-time
Though you would want to pass proration_behavior='none'
Also I think I have an alternate idea to listening to the invoice.payment_failed event. I think you can just check the subscription's cycle while handling the invoice paid event. Checking in to that
Thats already done on my app, when invoice is paid, I catch the event and then I update the billing cycle if thats required
here is a code snippet
if the payment fails, I set on my db the EXPIRED status
if one of the retries the payment succeeds and the sub is on expired status, I update the billing cycle to the date the invoice was paid with no prorations
Gotcha, and what part of this are you trying to tweak?
That does sound like it should properly reset the billing cycle anchor, though here it would do it for every paid invoice, so it might make sense to do another check to try to only do it for invoice payments that were a retry
The thing is that I just want to update the billing cycle without charging the user again for a new subscription because the payment was already succesfull
If I use billing_cycle_anchor' => "now"
'proration_behavior' => "none" It does seem to create another charge for the user
I do not want that to happen
maybe Im missing something. I thought that putting proration behavior to none already blocked any inmediate charges
If you set 'proration_behavior' => "none" then there shouldn't be a new payment from that. Can you send me the ID of a subscription that you saw this behavior with? (sub_1234)
Yup! this
sub_1PaocJBZU8isInqAmCPN8kQQ
Ive updated the sub through the api and I cancelled an invoices that was created because I didnt want the user to pay again since he already did a few days ago
Gotcha, found the request and invoice
https://dashboard.stripe.com/logs/req_Nf1JutYWUKNpH1
in_1Ps6FcBZU8isInqACqXWx6FA
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Looking in to this and will get back to you with what I can find.
Great thanks!! It is really weird
It looks like changing the billing cycle anchor will always create an invoice. So you will need a workaround here, the three that have come up are:
- Create a one time 100% off coupon and apply it along with the update
- Create a credit note for the amount of the full subscription cycle and then update the anchor
- Create a trial period on the subscription that lasts until your desired next billing cycle. So in your example you would create a trial that ends 2021-11-03
Unfortunately in all cases it may be a bit confusing to the user why there is an extra invoice here if there is a way for them to see it but those will bill them the way that you described
Okey, I can try with the trial period to see how it works. I would need to notify the user the double invoice
So, whats the purpose of setting proration behavior equal to none if the invoice is always generated?
I want to understand it better
because "none" is a valid value on the api docs