From d44043d0b508f72092ebb173527f4843e8fb2acb Mon Sep 17 00:00:00 2001 From: chrisjsimpson Date: Wed, 11 Oct 2023 22:55:52 +0100 Subject: [PATCH] #1256 comment plan metadata by retrieving process for failed payments --- subscribie/blueprints/checkout/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/subscribie/blueprints/checkout/__init__.py b/subscribie/blueprints/checkout/__init__.py index 478b801c..cb36c7d6 100644 --- a/subscribie/blueprints/checkout/__init__.py +++ b/subscribie/blueprints/checkout/__init__.py @@ -827,6 +827,12 @@ def stripe_webhook(): log.info("Stripe webhook event: payment_intent.payment_failed") plan_title = None try: + # Get plan metadata by retrieving the stripe invoice id + # and then the metadata (stripe ultimatly puts plan metadata + # on the invoice->lines->data[0] object. Metadata is not available + # directly on the payment_intent.payment_failed event, hence the need + # to extract and fetch the stripe invoice id -> invoice and work backwards + # to identify the associated Subscribie plan. eventObj = event["data"]["object"] stripe_invoice_id = eventObj["invoice"] try: