refactored webhook realted to coupon 4
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user