From 78b819116524fa0a717dec8e2db45f18bf1bdd6e Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 23 Dec 2020 17:10:23 +0530 Subject: [PATCH] Implement invoice.payment_failed case --- webhook/views.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/webhook/views.py b/webhook/views.py index c61bf3f0..5627c648 100644 --- a/webhook/views.py +++ b/webhook/views.py @@ -215,6 +215,14 @@ def handle_webhook(request): 'body': "Response = %s" % str(ex), } send_plain_email_task.delay(email_data) + elif event.type == 'invoice.payment_failed': + invoice_obj = event.data.object + logger.debug("Webhook Event: invoice.payment_failed") + logger.debug("invoice_obj %s " % str(invoice_obj)) + if (invoice_obj.payment_failed and + invoice_obj.billing_reason == "subscription_update"): + logger.debug("Payment failed, inform the users") + else: logger.error("Unhandled event : " + event.type) return HttpResponse(status=200)