From 3ac7e0d52243d4e7dc679b0c7b59113e4279f2e9 Mon Sep 17 00:00:00 2001 From: rizwanisready Date: Mon, 5 Aug 2024 18:51:49 +0530 Subject: [PATCH] refactored webhook realted to coupon 2 --- manage_subscriptions/api/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/manage_subscriptions/api/views.py b/manage_subscriptions/api/views.py index a91ec1b..cd89315 100644 --- a/manage_subscriptions/api/views.py +++ b/manage_subscriptions/api/views.py @@ -1,5 +1,6 @@ from datetime import timedelta import datetime +import json from django.db import transaction from django.shortcuts import get_object_or_404 from django.utils import timezone @@ -177,7 +178,7 @@ class StripeWebhookTest(APIView): endpoint_secret = "whsec_ccf1f87295603cdd1733995ee2d3c0d6f74c7ceaf28916ea45114a54b7ce1d0f" # Make sure to retrieve this from your settings event = None try: - event = stripe.Webhook.construct_event(payload, sig_header, endpoint_secret) + event = stripe.Event.construct_from(json.loads(payload), stripe.api_key) event_id = event["id"] event_type = event["type"] stripe_subscription_id = event["data"]["object"].get("subscription")