From 4987862dfcd98e8eaab85b639260b36d5c218229 Mon Sep 17 00:00:00 2001 From: rizwanisready Date: Sun, 5 May 2024 01:08:41 +0530 Subject: [PATCH] Notifications Testing 2 --- goodtimes/webhook.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/goodtimes/webhook.py b/goodtimes/webhook.py index fd58aff..d5e6cf7 100644 --- a/goodtimes/webhook.py +++ b/goodtimes/webhook.py @@ -40,10 +40,13 @@ class NotificationService: response = self.client.send_notification(notification_payload) return response - def payment_success_notification(self, principal, subscription, amount): + def payment_success_notification( + self, principal, subscription, principal_subscription, amount + ): print("payment_success_notification: ", principal.player_id) title = "Payment Successful" - message = f"Your payment for {subscription} of ${amount} was successfully processed. Your subscription is valid till {subscription.end_date}" + end_date = principal_subscription.end_date + message = f"Your payment for {subscription} of ${amount} was successfully processed. Your subscription is valid till {end_date}" self.send_notification(title, message, principal.player_id) def referral_received_notification(self, principal, amount, email): @@ -79,9 +82,7 @@ class WebhookService: def get_transaction(self): transaction_id = self.charge_data["metadata"]["transaction_id"] try: - return Transaction.objects.get( - id=int(transaction_id) - ) + return Transaction.objects.get(id=int(transaction_id)) except (ObjectDoesNotExist, ValueError): logger.error(f"Invalid transaction ID: {transaction_id}") raise ValueError(f"Invalid transaction ID: {transaction_id}") @@ -256,7 +257,7 @@ class PaymentProcessingService: referral_service.credit_referral_reward_if_applicable() print("Third Part Done....!!!!!") self.notification_service.payment_success_notification( - self.principal, self.subscription, self.transaction.amount + self.principal, self.subscription, self.principal_subscription, self.transaction.amount ) def handle_failure(self):