refactored webhook realted to coupon 4

This commit is contained in:
rizwanisready
2024-08-05 19:24:56 +05:30
parent fccd7378f7
commit 7aabd0c9fa

View File

@@ -63,17 +63,17 @@ class PaymentProcessingService:
)
return transaction
def process_event(self, transactio):
def process_event(self):
event_type = self.webhook_service.event_type
if event_type == "checkout.session.completed":
self.handle_success(transactio)
self.handle_success()
elif event_type == "invoice.payment_succeeded":
if self.charge_data.get("billing_reason") != "subscription_create":
self.handle_success(transactio)
self.handle_success()
else:
self.handle_failure(transactio)
self.handle_failure()
def handle_success(self, transactio):
def handle_success(self):
with transaction.atomic():
# Create or update the principal subscription
transactio = self.create_transaction()