diff --git a/accounts/api/views.py b/accounts/api/views.py index 1095da3..4a18f49 100644 --- a/accounts/api/views.py +++ b/accounts/api/views.py @@ -285,7 +285,7 @@ class RegistrationPasswordView(APIView): token_data["type"] = str(principal.principal_type) return ApiResponse.success( - message=constants.REGISTRATION_SUCCESS, data=token_data + message="Password updated successfully.", data=token_data ) diff --git a/manage_subscriptions/api/views.py b/manage_subscriptions/api/views.py index 9d3fadf..78b1562 100644 --- a/manage_subscriptions/api/views.py +++ b/manage_subscriptions/api/views.py @@ -176,6 +176,7 @@ class StripeWebhookTest(APIView): try: event = stripe.Event.construct_from(json.loads(payload), stripe.api_key) event_id = event["id"] + event_type = event["type"] # Check if the event has been processed already if WebhookEvent.objects.filter(event_id=event_id, status="processed").exists(): return ApiResponse.success( @@ -186,6 +187,7 @@ class StripeWebhookTest(APIView): # Log event processing WebhookEvent.objects.create( event_id=event_id, + event_type=event_type, event_payload=json.loads(payload), # optional ) diff --git a/manage_subscriptions/migrations/0005_webhookevent_event_type.py b/manage_subscriptions/migrations/0005_webhookevent_event_type.py new file mode 100644 index 0000000..13021ed --- /dev/null +++ b/manage_subscriptions/migrations/0005_webhookevent_event_type.py @@ -0,0 +1,18 @@ +# Generated by Django 5.0.2 on 2024-04-19 10:28 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("manage_subscriptions", "0004_webhookevent"), + ] + + operations = [ + migrations.AddField( + model_name="webhookevent", + name="event_type", + field=models.CharField(blank=True, max_length=255, null=True), + ), + ] diff --git a/manage_subscriptions/models.py b/manage_subscriptions/models.py index 51e2a4b..71bf9ed 100644 --- a/manage_subscriptions/models.py +++ b/manage_subscriptions/models.py @@ -78,6 +78,7 @@ class PrincipalSubscription(BaseModel): class WebhookEvent(BaseModel): event_id = models.CharField(max_length=255, unique=True, db_index=True) + event_type = models.CharField(max_length=255, null=True, blank=True) received_at = models.DateTimeField(auto_now_add=True) processed_at = models.DateTimeField(null=True, blank=True) status = models.CharField(