From 9c39ec0a19ec67f7b48e588c9e402e625768e660 Mon Sep 17 00:00:00 2001 From: rizwanisready Date: Mon, 18 Mar 2024 15:42:18 +0530 Subject: [PATCH] modified subscriptions webhook --- goodtimes/services.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/goodtimes/services.py b/goodtimes/services.py index 66050a2..20eafb0 100644 --- a/goodtimes/services.py +++ b/goodtimes/services.py @@ -214,8 +214,8 @@ class PaymentProcessingService: return self.charge_data.get("customer", None) def _get_transaction_by_id(self): - print("self.webhook_data: ", self.webhook_data) - print("self.charge_data: ", self.charge_data) + # print("self.webhook_data: ", self.webhook_data) + # print("self.charge_data: ", self.charge_data) print("self.metadata: ", self.charge_data["metadata"]) # Extract transaction_id from webhook metadata transaction_id = self.charge_data["metadata"]["transaction_id"] @@ -273,7 +273,7 @@ class PaymentProcessingService: self._update_reward( referral_record=referral_record, active_subscription=active_subscription, - create_subscription_method=self._create_principal_subscription(), + create_subscription_method=self._update_principal_subscription(), has_active_subscription=True, ) else: @@ -281,7 +281,7 @@ class PaymentProcessingService: self._update_reward( referral_record=referral_record, active_subscription=None, - create_subscription_method=self._create_principal_subscription, + create_subscription_method=self._update_principal_subscription, has_active_subscription=False, ) @@ -306,6 +306,7 @@ class PaymentProcessingService: def _update_principal_subscription(self): # Fetch the subscription object once and use it + print("Inside _update_principal_subscription") principal_subscription = self._get_principal_subscription_by_id() # Update IS_PAID PrincipalSubscription instance @@ -331,7 +332,7 @@ class PaymentProcessingService: ) # Create a new subscription for the referred principal - referred_subscription_id = self._create_principal_subscription() + referred_subscription_id = self._update_principal_subscription() # Create or update the ReferralTracking record ReferralTracking.objects.create(