From 61632862367416dc5154af536a7a4a4e7751d9a6 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Wed, 12 Nov 2025 20:26:58 -0500 Subject: Update webhook test to match real Stripe API behavior - Use billing_cycle_anchor instead of current_period_start/end in test - Reflects actual Stripe API v2025-10-29 subscription structure - Test validates upgrade flow works with newer API versions - Removes debug logging (list of available keys) --- Biz/PodcastItLater/Billing.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'Biz/PodcastItLater') diff --git a/Biz/PodcastItLater/Billing.py b/Biz/PodcastItLater/Billing.py index 9664b9f..de3540b 100644 --- a/Biz/PodcastItLater/Billing.py +++ b/Biz/PodcastItLater/Billing.py @@ -381,9 +381,8 @@ def _update_subscription_state(subscription: dict[str, typing.Any]) -> None: if not period_start_ts: logger.warning( - "Missing period start in subscription: %s. Available keys: %s", + "Missing period start in subscription: %s", subscription_id, - list(subscription.keys()), ) return @@ -505,12 +504,12 @@ class TestWebhookHandling(Test.TestCase): self.assertEqual(user["stripe_customer_id"], "cus_test123") # Step 2: Handle customer.subscription.created + # (newer API uses billing_cycle_anchor instead of current_period_*) subscription = { "id": "sub_test123", "customer": "cus_test123", "status": "active", - "current_period_start": 1700000000, - "current_period_end": 1702592000, + "billing_cycle_anchor": 1700000000, "cancel_at_period_end": False, "items": { "data": [ -- cgit v1.2.3