#wim_webhooks

1 messages ยท Page 1 of 1 (latest)

mellow pebbleBOT
#

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

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

echo warren
amber tapir
#

Oh okay, so it doesnt have anything to do with the payment method (paypal) right? Because that was our suspect at first

echo warren
#

Don't believe so no, there was at least attempts to pay the invoice before the sub was cancelled:

#

So we did retry it, but then stopped

amber tapir
#

okay, then do you have an idea on how to handle such cases?

so we specifically just listen to the invoice.payment_failed as of now and have something like this on the webhook listener:

if (invoice.getNextPaymentAttempt() == null) {
   overduePaymentService.saveOverduePayment(invoice, OverdueReasonEnum.FAILED_PAYMENT);
}
echo warren
#

Handle what specifically?

amber tapir
#

well, due to canceling the subscription we lost our way of creating a overdue payment in our system
the thing is, that we keep subscriptions active or in overdue if payment fails, we dont cancel them immeditialy
we need to collect overdue payments so we can charge the customer, even if the payment via stripe failed

#

and in this case, the subscription was canceled manually, with that remove the customers access from our product

echo warren
#

Not sure what you're asking me? You have logic that must cancel the subscription somewhere?

amber tapir
#

no, im sorry if im not explaining good
even tho the subscription was cancelled, i want to be able to run the logic, that would've run if there was an invoice.payment_failed event with nextPaymentAttempt: null

echo warren
#

next_payment_attempt will never be null in invoice.payment_failed events I don't think

#

You're going to need to handle invoice.updated events which reflect the cancellation and next_payment_attempt: null

amber tapir
#

it does, we are using it
after 3 payments attempt the next invoice failed has null on next payment attempt

echo warren
#

OK, but not in the scenario the sub is cancelled

#

Sorry overall I don't really understand what you're asking me

#

The subscription was cancelled, if you want to charge an overdue fee or whatever when perhaps you should listen to customer.subscription.deleted events and check to see if there are any open/overdue invoices for that subscription

#

Then run your logic

amber tapir
#

Okay, thanks for your input
I will check it out ๐Ÿ™‚