#vladgrego_api

1 messages ยท Page 1 of 1 (latest)

ivory spokeBOT
#

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

long slate
#

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

slow oar
#

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?

ivory spokeBOT
long slate
#

Please be patient, we have several other open threads.

slow oar
#

Okay! ๐Ÿ˜„

long slate
#

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

cobalt tangle
#

Happy to walk through how to do specific parts of that in the API if you are getting stuck

slow oar
#

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?

cobalt tangle
#

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

slow oar
#

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

cobalt tangle
#

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

slow oar
#

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

cobalt tangle
#

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)

slow oar
#

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

cobalt tangle
#

Looking in to this and will get back to you with what I can find.

slow oar
#

Great thanks!! It is really weird

cobalt tangle
#

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:

  1. Create a one time 100% off coupon and apply it along with the update
  2. Create a credit note for the amount of the full subscription cycle and then update the anchor
  3. 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

slow oar
#

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