Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
test_stripe: Use cursor-stable Event.list polling with pin_event_cursor.
Aman Agrawal4afcd3106d86
diff --git a/corporate/lib/test_stripe_class.py b/corporate/lib/test_stripe_class.pyindex 5552e5c84ca..14846a006a6 100644--- a/corporate/lib/test_stripe_class.py+++ b/corporate/lib/test_stripe_class.py@@ -9,6 +9,21 @@ Fixtures live in ``corporate/tests/stripe_fixtures/``, one fileper call, named ``<test>--<Class>.<method>.<call_count>.json``(e.g. ``upgrade_by_card--Customer.create.1.json``).+Two special cases keep ``Event.list`` fixture generation stable,+even though Stripe's view of "recent events" changes every run:++- ``StripeTestCase.pin_event_cursor`` returns the id of Stripe's+ most-recent event, used as the ``ending_before`` cursor for the+ next ``send_stripe_webhook_events`` poll. In regen, it bypasses the+ mock and calls Stripe directly (no fixture saved; the response is+ randomized). In replay it returns a sentinel id, and the mocked+ ``Event.list`` ignores ``ending_before``.+- ``send_stripe_webhook_events`` runs a cursor-stable polling loop in+ regen, accumulates the union of events seen across the run, keeps+ only ``HANDLED_STRIPE_EVENT_TYPES`` (matching the webhook view's+ dispatcher), and writes one canonical fixture per polling run.+ Replay reads that fixture once and delivers every event in it.+After each test, ``normalize_fixture_data`` rewrites every savedfixture in place to collapse per-run variance (ids, timestamps, uuids,etc.) so regenerating fixtures produces zero diff. See@@ -38,7 +53,7 @@ from collections.abc import Callable, Iterator, Mapping, Sequencefrom contextlib import contextmanagerfrom datetime import datetime, timezonefrom functools import wraps-from time import sleep+from time import monotonic, sleepfrom typing import TYPE_CHECKING, Any, Literal, Optional, TypeVar, castfrom unittest import mockfrom unittest.mock import Mock, patch@@ -444,6 +459,26 @@ def mock_stripe(return _mock_stripe+# Stripe event types that ``corporate/views/webhook.py`` actually+# dispatches on. Everything else is a 200-no-op for the webhook view,+# and the per-event cardinality of those unhandled types+# (``invoice.updated`` in particular) drifts regen to regen as Stripe's+# internal invoice state machine churns, which means including them in+# fixtures would make ``Event.list`` non-byte-stable.+HANDLED_STRIPE_EVENT_TYPES: frozenset[str] = frozenset(+ {+ "checkout.session.completed",+ "invoice.paid",+ }+)+++# Captured at module load before ``mock_stripe`` installs any patch, so+# ``pin_event_cursor`` and the regen polling loop can call the real+# ``Event.list`` without advancing the per-call fixture count.+_REAL_STRIPE_EVENT_LIST = stripe.Event.list++@contextmanagerdef _allow_stripe_api_passthru() -> Iterator[None]: # nocoverage"""Zulip's test harness blocks outgoing HTTP by default; allow the@@ -457,6 +492,10 @@ class StripeTestCase(ZulipTestCase):@overridedef setUp(self) -> None:super().setUp()+ # Per-test counter so each ``send_stripe_webhook_events`` run+ # writes its canonical fixture at a predictable ``Event.list``+ # call count (run 1 at .1, run 2 at .2, etc.).+ self._stripe_polling_runs = 0realm = get_realm("zulip")# Explicitly limit our active users to 6 regular users,@@ -636,36 +675,122 @@ class StripeTestCase(ZulipTestCase):f"event {payload.get('id')!r}: {response.content.decode(errors='replace')!r}")- def send_stripe_webhook_events(- self, most_recent_event: stripe.Event, must_have_event: str | None = None+ def pin_event_cursor(self) -> str:+ """Return the id of Stripe's most-recent event, anchoring the+ next ``send_stripe_webhook_events`` poll.++ In regen this hits the real ``Event.list``; in replay the+ returned id is inert because the mocked ``Event.list`` ignores+ ``ending_before``."""+ if not settings.GENERATE_STRIPE_FIXTURES:+ return "evt_normalized_cursor_lookup"+ with _allow_stripe_api_passthru(): # nocoverage+ [event] = _REAL_STRIPE_EVENT_LIST(limit=1)+ return event.id++ def send_stripe_webhook_events(self, cursor: str, must_have_event: str | None = None) -> None:+ # Stripe's ``Event.list`` is eventually consistent, but a freshly-created+ # event may not appear under an ``ending_before=cursor`` query right away.+ # Pin the cursor and dedupe locally so late arrivals still surface on a+ # subsequent poll. Regen and replay of fixtures need different termination+ # strategies.+ assert must_have_event is None or must_have_event in HANDLED_STRIPE_EVENT_TYPES, (+ f"Test waits on {must_have_event}, which is not in HANDLED_STRIPE_EVENT_TYPES"+ )+ if settings.GENERATE_STRIPE_FIXTURES:+ self._poll_stripe_events_for_regen(cursor, must_have_event) # nocoverage+ else:+ self._replay_stripe_events_from_fixtures(cursor, must_have_event)++ def _poll_stripe_events_for_regen(+ self, cursor: str, must_have_event: str | None) -> None: # nocoverage- # Stripe can delay events showing up in the Event list, so we- # keep looking until we find the must_have_event.+ # Bypass the ``Event.list`` mock during polling, because we don't want a+ # fixture per HTTP call (the grace-period loop produces many nearly+ # identical ones that just churn between regens). Instead, we accumulate+ # the union of events seen across the run and write one canonical fixture+ # at the end. Stripe's ``ending_before=cursor`` already excludes events+ # older than the pin, and ``normalize_fixture_data`` drops prior-test+ # events that leak through.+ deadline_seconds = 60.0+ grace_period_seconds = 3.0+ poll_interval_seconds = 0.2+found_must_have_event = must_have_event is None- num_of_attempts_to_look_for_must_have_event = 10+ hard_deadline = monotonic() + deadline_seconds+ last_progress = monotonic()+ seen_event_ids: set[str] = set()+ events_in_order: list[stripe.Event] = []while True:- events_old_to_new = list(- reversed(stripe.Event.list(ending_before=most_recent_event.id))- )+ if monotonic() >= hard_deadline:+ if not found_must_have_event:+ raise AssertionError(+ f"Did not find expected event {must_have_event} within {deadline_seconds}s"+ )+ break+ if found_must_have_event and monotonic() - last_progress >= grace_period_seconds:+ break- if len(events_old_to_new) == 0:- if found_must_have_event:- break- else:- num_of_attempts_to_look_for_must_have_event -= 1- if num_of_attempts_to_look_for_must_have_event == 0:- raise AssertionError(- f"Did not find expected event {must_have_event} after looking for it multiple times"- )- sleep(0.2)- continue-- for event in events_old_to_new:+ with _allow_stripe_api_passthru():+ events_old_to_new = [+ e+ for e in reversed(_REAL_STRIPE_EVENT_LIST(ending_before=cursor, limit=100))+ if e.type in HANDLED_STRIPE_EVENT_TYPES+ ]+ new_events = [e for e in events_old_to_new if e.id not in seen_event_ids]++ if not new_events:+ sleep(poll_interval_seconds)+ continue++ last_progress = monotonic()+ for event in new_events:+ seen_event_ids.add(event.id)+ events_in_order.append(event)if event.type == must_have_event:found_must_have_event = True-self.send_stripe_webhook_event(event)- most_recent_event = events_old_to_new[-1]++ self._write_polling_run_fixtures(events_in_order)++ def _write_polling_run_fixtures(self, events: list[stripe.Event]) -> None: # nocoverage+ """Persist the union of events for replay. See+ ``_poll_stripe_events_for_regen`` for why we bypass the per-call+ mock."""+ self._stripe_polling_runs += 1+ path = stripe_fixture_path(+ self._testMethodName, "stripe.Event.list", self._stripe_polling_runs+ )+ with open(path, "w") as f:+ f.write(+ json.dumps(+ {+ "data": [json.loads(str(e)) for e in events],+ "has_more": False,+ "object": "list",+ "url": "/v1/events",+ },+ indent=2,+ sort_keys=True,+ )+ + "\n"+ )++ def _replay_stripe_events_from_fixtures(self, cursor: str, must_have_event: str | None) -> None:+ # One ``Event.list`` call returns the next recorded canonical fixture,+ # and we deliver every event in it. The mock ignores ``ending_before``+ # and ``limit``. There is no unstable-event filter here, as the fixture+ # was already filtered during regen. Don't reverse because the fixture's+ # ``data`` array is in dispatch order (i.e., the order that+ # ``_poll_stripe_events_for_regen`` accumulated events), not Stripe's+ # newest-first API convention.+ events = list(stripe.Event.list(ending_before=cursor, limit=100))+ for event in events:+ self.send_stripe_webhook_event(event)+ if must_have_event is not None:+ assert any(e.type == must_have_event for e in events), (+ f"Replay fixture missing expected event {must_have_event}"+ )def add_card_to_customer_for_upgrade(self, charge_succeeds: bool = True) -> None:start_session_json_response = self.client_billing_post(@@ -748,9 +873,9 @@ class StripeTestCase(ZulipTestCase):params.pop(key, None)if talk_to_stripe:- # Store the event after which we pay the invoice so that we can- # process all the events from this event to the latest.- [last_event] = iter(stripe.Event.list(limit=1))+ # Anchor a cursor here so we can replay all subsequent events+ # (from the upgrade flow and the invoice paid webhook).+ cursor = self.pin_event_cursor()existing_customer = self.billing_session.customer_plan_exists()upgrade_json_response = self.client_billing_post("/billing/upgrade", params)@@ -794,7 +919,7 @@ class StripeTestCase(ZulipTestCase):stripe.Invoice.pay(last_sent_invoice.stripe_invoice_id, paid_out_of_band=True)self.send_stripe_webhook_events(- last_event,+ cursor,must_have_event="invoice.paid" if invoice else None,)return upgrade_json_responsediff --git a/corporate/tests/stripe_fixtures/upgrade_by_card--Event.list.1.json b/corporate/tests/stripe_fixtures/upgrade_by_card--Event.list.1.jsonindex 91128974d80..adfb3da1bb9 100644--- a/corporate/tests/stripe_fixtures/upgrade_by_card--Event.list.1.json+++ b/corporate/tests/stripe_fixtures/upgrade_by_card--Event.list.1.json@@ -1,1037 +1,5 @@{"data": [- {- "api_version": "2025-11-17.clover",- "created": 1000000000,- "data": {- "object": {- "account_country": "US",- "account_name": "NORMALIZED",- "account_tax_ids": null,- "amount_due": 0,- "amount_overpaid": 0,- "amount_paid": 0,- "amount_remaining": 0,- "amount_shipping": 0,- "application": null,- "attempt_count": 0,- "attempted": false,- "auto_advance": false,- "automatic_tax": {- "disabled_reason": null,- "enabled": false,- "liability": null,- "provider": null,- "status": null- },- "automatically_finalizes_at": null,- "billing_reason": "manual",- "collection_method": "charge_automatically",- "created": 1000000000,- "currency": "usd",- "custom_fields": null,- "customer": "upgrade_by_card--Customer.create.1.json",- "customer_account": null,- "customer_address": null,- "customer_email": "[email protected]",- "customer_name": null,- "customer_phone": null,- "customer_shipping": null,- "customer_tax_exempt": "none",- "customer_tax_ids": [],- "default_payment_method": null,- "default_source": null,- "default_tax_rates": [],- "description": "If paying by bank transfer outside of the US, use the OUR option for who should pay bank transfer fees, to make sure that your invoice is paid in full.",- "discounts": [],- "due_date": null,- "effective_at": null,- "ending_balance": null,- "footer": null,- "from_invoice": null,- "hosted_invoice_url": null,- "id": "upgrade_by_card--Event.list.1.json",- "invoice_pdf": null,- "issuer": {- "type": "self"- },- "last_finalization_error": null,- "latest_revision": null,- "lines": {- "data": [],- "has_more": false,- "object": "list",- "total_count": 0,- "url": "/v1/invoices/upgrade_by_card--Event.list.1.json/lines"- },- "livemode": false,- "metadata": {- "billing_schedule": "1",- "current_plan_id": "None",- "license_management": "automatic",- "licenses": "6",- "on_free_trial": "False",- "plan_tier": "1",- "user_id": "10"- },- "next_payment_attempt": null,- "number": null,- "object": "invoice",- "on_behalf_of": null,- "parent": null,- "payment_settings": {- "default_mandate": null,- "payment_method_options": null,- "payment_method_types": null- },- "period_end": 1000000000,- "period_start": 1000000000,- "post_payment_credit_notes_amount": 0,- "pre_payment_credit_notes_amount": 0,- "receipt_number": null,- "rendering": {- "amount_tax_display": null,- "pdf": {- "page_size": "auto"- },- "template": null,- "template_version": null- },- "shipping_cost": null,- "shipping_details": null,- "starting_balance": 0,- "statement_descriptor": "Zulip Cloud Standard",- "status": "draft",- "status_transitions": {- "finalized_at": null,- "marked_uncollectible_at": null,- "paid_at": null,- "voided_at": null- },- "subtotal": 0,- "subtotal_excluding_tax": 0,- "test_clock": null,- "total": 0,- "total_discount_amounts": [],- "total_excluding_tax": 0,- "total_pretax_credit_amounts": [],- "total_taxes": [],- "webhooks_delivered_at": null- }- },- "id": "upgrade_by_card--Event.list.1.json",- "livemode": false,- "object": "event",- "pending_webhooks": 0,- "request": {- "id": "upgrade_by_card--Event.list.1.json",- "idempotency_key": "00000000-0000-0000-0000-000000000000"- },- "type": "invoice.created"- },- {- "api_version": "2025-11-17.clover",- "created": 1000000000,- "data": {- "object": {- "account_country": "US",- "account_name": "NORMALIZED",- "account_tax_ids": null,- "amount_due": 48000,- "amount_overpaid": 0,- "amount_paid": 0,- "amount_remaining": 48000,- "amount_shipping": 0,- "application": null,- "attempt_count": 0,- "attempted": false,- "auto_advance": false,- "automatic_tax": {- "disabled_reason": null,- "enabled": false,- "liability": null,- "provider": null,- "status": null- },- "automatically_finalizes_at": null,- "billing_reason": "manual",- "collection_method": "charge_automatically",- "created": 1000000000,- "currency": "usd",- "custom_fields": null,- "customer": "upgrade_by_card--Customer.create.1.json",- "customer_account": null,- "customer_address": null,- "customer_email": "[email protected]",- "customer_name": null,- "customer_phone": null,- "customer_shipping": null,- "customer_tax_exempt": "none",- "customer_tax_ids": [],- "default_payment_method": null,- "default_source": null,- "default_tax_rates": [],- "description": "If paying by bank transfer outside of the US, use the OUR option for who should pay bank transfer fees, to make sure that your invoice is paid in full.",- "discounts": [],- "due_date": null,- "effective_at": 1000000000,- "ending_balance": 0,- "footer": null,- "from_invoice": null,- "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED/test_NORMALIZED?s=ap",- "id": "upgrade_by_card--Event.list.1.json",- "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED/test_NORMALIZED/pdf?s=ap",- "issuer": {- "type": "self"- },- "last_finalization_error": null,- "latest_revision": null,- "lines": {- "data": [- {- "amount": 48000,- "currency": "usd",- "description": "Zulip Cloud Standard",- "discount_amounts": [],- "discountable": false,- "discounts": [],- "id": "upgrade_by_card--Event.list.1.json",- "invoice": "upgrade_by_card--Event.list.1.json",- "livemode": false,- "metadata": {},- "object": "line_item",- "parent": {- "invoice_item_details": {- "invoice_item": "upgrade_by_card--Event.list.1.json",- "proration": false,- "proration_details": {- "credited_items": null- },- "subscription": null- },- "license_fee_subscription_details": null,- "subscription_item_details": null,- "type": "invoice_item_details"- },- "period": {- "end": 1357095845,- "start": 1325473445- },- "pretax_credit_amounts": [],- "pricing": {- "price_details": {- "price": "price_NORMALIZED",- "product": "prod_NORMALIZED"- },- "type": "price_details",- "unit_amount_decimal": "8000"- },- "quantity": 6,- "quantity_decimal": "6",- "subtotal": 48000,- "taxes": []- }- ],- "has_more": false,- "object": "list",- "total_count": 1,- "url": "/v1/invoices/upgrade_by_card--Event.list.1.json/lines"- },- "livemode": false,- "metadata": {- "billing_schedule": "1",- "current_plan_id": "None",- "license_management": "automatic",- "licenses": "6",- "on_free_trial": "False",- "plan_tier": "1",- "user_id": "10"- },- "next_payment_attempt": null,- "number": "NORMALIZED",- "object": "invoice",- "on_behalf_of": null,- "parent": null,- "payment_settings": {- "default_mandate": null,- "payment_method_options": null,- "payment_method_types": null- },- "period_end": 1000000000,- "period_start": 1000000000,- "post_payment_credit_notes_amount": 0,- "pre_payment_credit_notes_amount": 0,- "receipt_number": null,- "rendering": {- "amount_tax_display": null,- "pdf": {- "page_size": "letter"- },- "template": null,- "template_version": null- },- "shipping_cost": null,- "shipping_details": null,- "starting_balance": 0,- "statement_descriptor": "Zulip Cloud Standard",- "status": "open",- "status_transitions": {- "finalized_at": 1000000000,- "marked_uncollectible_at": null,- "paid_at": null,- "voided_at": null- },- "subtotal": 48000,- "subtotal_excluding_tax": 48000,- "test_clock": null,- "total": 48000,- "total_discount_amounts": [],- "total_excluding_tax": 48000,- "total_pretax_credit_amounts": [],- "total_taxes": [],- "webhooks_delivered_at": null- },- "previous_attributes": {- "effective_at": null,- "ending_balance": null,- "hosted_invoice_url": null,- "invoice_pdf": null,- "number": null,- "rendering": {- "pdf": {- "page_size": "auto"- }- },- "status": "draft",- "status_transitions": {- "finalized_at": null- }- }- },- "id": "upgrade_by_card--Event.list.1.json",- "livemode": false,- "object": "event",- "pending_webhooks": 0,- "request": {- "id": "upgrade_by_card--Event.list.1.json",- "idempotency_key": "00000000-0000-0000-0000-000000000000"- },- "type": "invoice.updated"- },- {- "api_version": "2025-11-17.clover",- "created": 1000000000,- "data": {- "object": {- "account_country": "US",- "account_name": "NORMALIZED",- "account_tax_ids": null,- "amount_due": 48000,- "amount_overpaid": 0,- "amount_paid": 0,- "amount_remaining": 48000,- "amount_shipping": 0,- "application": null,- "attempt_count": 0,- "attempted": false,- "auto_advance": false,- "automatic_tax": {- "disabled_reason": null,- "enabled": false,- "liability": null,- "provider": null,- "status": null- },- "automatically_finalizes_at": null,- "billing_reason": "manual",- "collection_method": "charge_automatically",- "created": 1000000000,- "currency": "usd",- "custom_fields": null,- "customer": "upgrade_by_card--Customer.create.1.json",- "customer_account": null,- "customer_address": null,- "customer_email": "[email protected]",- "customer_name": null,- "customer_phone": null,- "customer_shipping": null,- "customer_tax_exempt": "none",- "customer_tax_ids": [],- "default_payment_method": null,- "default_source": null,- "default_tax_rates": [],- "description": "If paying by bank transfer outside of the US, use the OUR option for who should pay bank transfer fees, to make sure that your invoice is paid in full.",- "discounts": [],- "due_date": null,- "effective_at": 1000000000,- "ending_balance": 0,- "footer": null,- "from_invoice": null,- "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED/test_NORMALIZED?s=ap",- "id": "upgrade_by_card--Event.list.1.json",- "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED/test_NORMALIZED/pdf?s=ap",- "issuer": {- "type": "self"- },- "last_finalization_error": null,- "latest_revision": null,- "lines": {- "data": [- {- "amount": 48000,- "currency": "usd",- "description": "Zulip Cloud Standard",- "discount_amounts": [],- "discountable": false,- "discounts": [],- "id": "upgrade_by_card--Event.list.1.json",- "invoice": "upgrade_by_card--Event.list.1.json",- "livemode": false,- "metadata": {},- "object": "line_item",- "parent": {- "invoice_item_details": {- "invoice_item": "upgrade_by_card--Event.list.1.json",- "proration": false,- "proration_details": {- "credited_items": null- },- "subscription": null- },- "license_fee_subscription_details": null,- "subscription_item_details": null,- "type": "invoice_item_details"- },- "period": {- "end": 1357095845,- "start": 1325473445- },- "pretax_credit_amounts": [],- "pricing": {- "price_details": {- "price": "price_NORMALIZED",- "product": "prod_NORMALIZED"- },- "type": "price_details",- "unit_amount_decimal": "8000"- },- "quantity": 6,- "quantity_decimal": "6",- "subtotal": 48000,- "taxes": []- }- ],- "has_more": false,- "object": "list",- "total_count": 1,- "url": "/v1/invoices/upgrade_by_card--Event.list.1.json/lines"- },- "livemode": false,- "metadata": {- "billing_schedule": "1",- "current_plan_id": "None",- "license_management": "automatic",- "licenses": "6",- "on_free_trial": "False",- "plan_tier": "1",- "user_id": "10"- },- "next_payment_attempt": null,- "number": "NORMALIZED",- "object": "invoice",- "on_behalf_of": null,- "parent": null,- "payment_settings": {- "default_mandate": null,- "payment_method_options": null,- "payment_method_types": null- },- "period_end": 1000000000,- "period_start": 1000000000,- "post_payment_credit_notes_amount": 0,- "pre_payment_credit_notes_amount": 0,- "receipt_number": null,- "rendering": {- "amount_tax_display": null,- "pdf": {- "page_size": "letter"- },- "template": null,- "template_version": null- },- "shipping_cost": null,- "shipping_details": null,- "starting_balance": 0,- "statement_descriptor": "Zulip Cloud Standard",- "status": "open",- "status_transitions": {- "finalized_at": 1000000000,- "marked_uncollectible_at": null,- "paid_at": null,- "voided_at": null- },- "subtotal": 48000,- "subtotal_excluding_tax": 48000,- "test_clock": null,- "total": 48000,- "total_discount_amounts": [],- "total_excluding_tax": 48000,- "total_pretax_credit_amounts": [],- "total_taxes": [],- "webhooks_delivered_at": null- }- },- "id": "upgrade_by_card--Event.list.1.json",- "livemode": false,- "object": "event",- "pending_webhooks": 0,- "request": {- "id": "upgrade_by_card--Event.list.1.json",- "idempotency_key": "00000000-0000-0000-0000-000000000000"- },- "type": "invoice.finalized"- },- {- "api_version": "2025-11-17.clover",- "created": 1000000000,- "data": {- "object": {- "account_country": "US",- "account_name": "NORMALIZED",- "account_tax_ids": null,- "amount_due": 48000,- "amount_overpaid": 0,- "amount_paid": 0,- "amount_remaining": 48000,- "amount_shipping": 0,- "application": null,- "attempt_count": 0,- "attempted": false,- "auto_advance": false,- "automatic_tax": {- "disabled_reason": null,- "enabled": false,- "liability": null,- "provider": null,- "status": null- },- "automatically_finalizes_at": null,- "billing_reason": "manual",- "collection_method": "charge_automatically",- "created": 1000000000,- "currency": "usd",- "custom_fields": null,- "customer": "upgrade_by_card--Customer.create.1.json",- "customer_account": null,- "customer_address": null,- "customer_email": "[email protected]",- "customer_name": null,- "customer_phone": null,- "customer_shipping": null,- "customer_tax_exempt": "none",- "customer_tax_ids": [],- "default_payment_method": null,- "default_source": null,- "default_tax_rates": [],- "description": "If paying by bank transfer outside of the US, use the OUR option for who should pay bank transfer fees, to make sure that your invoice is paid in full.",- "discounts": [],- "due_date": null,- "effective_at": null,- "ending_balance": null,- "footer": null,- "from_invoice": null,- "hosted_invoice_url": null,- "id": "upgrade_by_card--Event.list.1.json",- "invoice_pdf": null,- "issuer": {- "type": "self"- },- "last_finalization_error": null,- "latest_revision": null,- "lines": {- "data": [- {- "amount": 48000,- "currency": "usd",- "description": "Zulip Cloud Standard",- "discount_amounts": [],- "discountable": false,- "discounts": [],- "id": "upgrade_by_card--Event.list.1.json",- "invoice": "upgrade_by_card--Event.list.1.json",- "livemode": false,- "metadata": {},- "object": "line_item",- "parent": {- "invoice_item_details": {- "invoice_item": "upgrade_by_card--Event.list.1.json",- "proration": false,- "proration_details": {- "credited_items": null- },- "subscription": null- },- "license_fee_subscription_details": null,- "subscription_item_details": null,- "type": "invoice_item_details"- },- "period": {- "end": 1357095845,- "start": 1325473445- },- "pretax_credit_amounts": [],- "pricing": {- "price_details": {- "price": "price_NORMALIZED",- "product": "prod_NORMALIZED"- },- "type": "price_details",- "unit_amount_decimal": "8000"- },- "quantity": 6,- "quantity_decimal": "6",- "subtotal": 48000,- "taxes": []- }- ],- "has_more": false,- "object": "list",- "total_count": 1,- "url": "/v1/invoices/upgrade_by_card--Event.list.1.json/lines"- },- "livemode": false,- "metadata": {- "billing_schedule": "1",- "current_plan_id": "None",- "license_management": "automatic",- "licenses": "6",- "on_free_trial": "False",- "plan_tier": "1",- "user_id": "10"- },- "next_payment_attempt": null,- "number": null,- "object": "invoice",- "on_behalf_of": null,- "parent": null,- "payment_settings": {- "default_mandate": null,- "payment_method_options": null,- "payment_method_types": null- },- "period_end": 1000000000,- "period_start": 1000000000,- "post_payment_credit_notes_amount": 0,- "pre_payment_credit_notes_amount": 0,- "receipt_number": null,- "rendering": {- "amount_tax_display": null,- "pdf": {- "page_size": "auto"- },- "template": null,- "template_version": null- },- "shipping_cost": null,- "shipping_details": null,- "starting_balance": 0,- "statement_descriptor": "Zulip Cloud Standard",- "status": "draft",- "status_transitions": {- "finalized_at": null,- "marked_uncollectible_at": null,- "paid_at": null,- "voided_at": null- },- "subtotal": 48000,- "subtotal_excluding_tax": 48000,- "test_clock": null,- "total": 48000,- "total_discount_amounts": [],- "total_excluding_tax": 48000,- "total_pretax_credit_amounts": [],- "total_taxes": [],- "webhooks_delivered_at": null- },- "previous_attributes": {- "amount_due": 0,- "amount_remaining": 0,- "lines": {- "data": [],- "total_count": 0- },- "subtotal": 0,- "subtotal_excluding_tax": 0,- "total": 0,- "total_excluding_tax": 0- }- },- "id": "upgrade_by_card--Event.list.1.json",- "livemode": false,- "object": "event",- "pending_webhooks": 0,- "request": {- "id": "upgrade_by_card--Event.list.1.json",- "idempotency_key": "00000000-0000-0000-0000-000000000000"- },- "type": "invoice.updated"- },- {- "api_version": "2025-11-17.clover",- "created": 1000000000,- "data": {- "object": {- "account_country": "US",- "account_name": "NORMALIZED",- "account_tax_ids": null,- "amount_due": 48000,- "amount_overpaid": 0,- "amount_paid": 48000,- "amount_remaining": 0,- "amount_shipping": 0,- "application": null,- "attempt_count": 1,- "attempted": true,- "auto_advance": false,- "automatic_tax": {- "disabled_reason": null,- "enabled": false,- "liability": null,- "provider": null,- "status": null- },- "automatically_finalizes_at": null,- "billing_reason": "manual",- "collection_method": "charge_automatically",- "created": 1000000000,- "currency": "usd",- "custom_fields": null,- "customer": "upgrade_by_card--Customer.create.1.json",- "customer_account": null,- "customer_address": null,- "customer_email": "[email protected]",- "customer_name": null,- "customer_phone": null,- "customer_shipping": null,- "customer_tax_exempt": "none",- "customer_tax_ids": [],- "default_payment_method": null,- "default_source": null,- "default_tax_rates": [],- "description": "If paying by bank transfer outside of the US, use the OUR option for who should pay bank transfer fees, to make sure that your invoice is paid in full.",- "discounts": [],- "due_date": null,- "effective_at": 1000000000,- "ending_balance": 0,- "footer": null,- "from_invoice": null,- "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED/test_NORMALIZED?s=ap",- "id": "upgrade_by_card--Event.list.1.json",- "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED/test_NORMALIZED/pdf?s=ap",- "issuer": {- "type": "self"- },- "last_finalization_error": null,- "latest_revision": null,- "lines": {- "data": [- {- "amount": 48000,- "currency": "usd",- "description": "Zulip Cloud Standard",- "discount_amounts": [],- "discountable": false,- "discounts": [],- "id": "upgrade_by_card--Event.list.1.json",- "invoice": "upgrade_by_card--Event.list.1.json",- "livemode": false,- "metadata": {},- "object": "line_item",- "parent": {- "invoice_item_details": {- "invoice_item": "upgrade_by_card--Event.list.1.json",- "proration": false,- "proration_details": {- "credited_items": null- },- "subscription": null- },- "license_fee_subscription_details": null,- "subscription_item_details": null,- "type": "invoice_item_details"- },- "period": {- "end": 1357095845,- "start": 1325473445- },- "pretax_credit_amounts": [],- "pricing": {- "price_details": {- "price": "price_NORMALIZED",- "product": "prod_NORMALIZED"- },- "type": "price_details",- "unit_amount_decimal": "8000"- },- "quantity": 6,- "quantity_decimal": "6",- "subtotal": 48000,- "taxes": []- }- ],- "has_more": false,- "object": "list",- "total_count": 1,- "url": "/v1/invoices/upgrade_by_card--Event.list.1.json/lines"- },- "livemode": false,- "metadata": {- "billing_schedule": "1",- "current_plan_id": "None",- "license_management": "automatic",- "licenses": "6",- "on_free_trial": "False",- "plan_tier": "1",- "user_id": "10"- },- "next_payment_attempt": null,- "number": "NORMALIZED",- "object": "invoice",- "on_behalf_of": null,- "parent": null,- "payment_settings": {- "default_mandate": null,- "payment_method_options": null,- "payment_method_types": null- },- "period_end": 1000000000,- "period_start": 1000000000,- "post_payment_credit_notes_amount": 0,- "pre_payment_credit_notes_amount": 0,- "receipt_number": null,- "rendering": {- "amount_tax_display": null,- "pdf": {- "page_size": "letter"- },- "template": null,- "template_version": null- },- "shipping_cost": null,- "shipping_details": null,- "starting_balance": 0,- "statement_descriptor": "Zulip Cloud Standard",- "status": "paid",- "status_transitions": {- "finalized_at": 1000000000,- "marked_uncollectible_at": null,- "paid_at": 1000000000,- "voided_at": null- },- "subtotal": 48000,- "subtotal_excluding_tax": 48000,- "test_clock": null,- "total": 48000,- "total_discount_amounts": [],- "total_excluding_tax": 48000,- "total_pretax_credit_amounts": [],- "total_taxes": [],- "webhooks_delivered_at": null- },- "previous_attributes": {- "amount_paid": 0,- "amount_remaining": 48000,- "attempt_count": 0,- "attempted": false,- "status": "open",- "status_transitions": {- "paid_at": null- }- }- },- "id": "upgrade_by_card--Event.list.1.json",- "livemode": false,- "object": "event",- "pending_webhooks": 0,- "request": {- "id": "upgrade_by_card--Event.list.1.json",- "idempotency_key": "00000000-0000-0000-0000-000000000000"- },- "type": "invoice.updated"- },- {- "api_version": "2025-11-17.clover",- "created": 1000000000,- "data": {- "object": {- "account_country": "US",- "account_name": "NORMALIZED",- "account_tax_ids": null,- "amount_due": 48000,- "amount_overpaid": 0,- "amount_paid": 48000,- "amount_remaining": 0,- "amount_shipping": 0,- "application": null,- "attempt_count": 1,- "attempted": true,- "auto_advance": false,- "automatic_tax": {- "disabled_reason": null,- "enabled": false,- "liability": null,- "provider": null,- "status": null- },- "automatically_finalizes_at": null,- "billing_reason": "manual",- "collection_method": "charge_automatically",- "created": 1000000000,- "currency": "usd",- "custom_fields": null,- "customer": "upgrade_by_card--Customer.create.1.json",- "customer_account": null,- "customer_address": null,- "customer_email": "[email protected]",- "customer_name": null,- "customer_phone": null,- "customer_shipping": null,- "customer_tax_exempt": "none",- "customer_tax_ids": [],- "default_payment_method": null,- "default_source": null,- "default_tax_rates": [],- "description": "If paying by bank transfer outside of the US, use the OUR option for who should pay bank transfer fees, to make sure that your invoice is paid in full.",- "discounts": [],- "due_date": null,- "effective_at": 1000000000,- "ending_balance": 0,- "footer": null,- "from_invoice": null,- "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED/test_NORMALIZED?s=ap",- "id": "upgrade_by_card--Event.list.1.json",- "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED/test_NORMALIZED/pdf?s=ap",- "issuer": {- "type": "self"- },- "last_finalization_error": null,- "latest_revision": null,- "lines": {- "data": [- {- "amount": 48000,- "currency": "usd",- "description": "Zulip Cloud Standard",- "discount_amounts": [],- "discountable": false,- "discounts": [],- "id": "upgrade_by_card--Event.list.1.json",- "invoice": "upgrade_by_card--Event.list.1.json",- "livemode": false,- "metadata": {},- "object": "line_item",- "parent": {- "invoice_item_details": {- "invoice_item": "upgrade_by_card--Event.list.1.json",- "proration": false,- "proration_details": {- "credited_items": null- },- "subscription": null- },- "license_fee_subscription_details": null,- "subscription_item_details": null,- "type": "invoice_item_details"- },- "period": {- "end": 1357095845,- "start": 1325473445- },- "pretax_credit_amounts": [],- "pricing": {- "price_details": {- "price": "price_NORMALIZED",- "product": "prod_NORMALIZED"- },- "type": "price_details",- "unit_amount_decimal": "8000"- },- "quantity": 6,- "quantity_decimal": "6",- "subtotal": 48000,- "taxes": []- }- ],- "has_more": false,- "object": "list",- "total_count": 1,- "url": "/v1/invoices/upgrade_by_card--Event.list.1.json/lines"- },- "livemode": false,- "metadata": {- "billing_schedule": "1",- "current_plan_id": "None",- "license_management": "automatic",- "licenses": "6",- "on_free_trial": "False",- "plan_tier": "1",- "user_id": "10"- },- "next_payment_attempt": null,- "number": "NORMALIZED",- "object": "invoice",- "on_behalf_of": null,- "parent": null,- "payment_settings": {- "default_mandate": null,- "payment_method_options": null,- "payment_method_types": null- },- "period_end": 1000000000,- "period_start": 1000000000,- "post_payment_credit_notes_amount": 0,- "pre_payment_credit_notes_amount": 0,- "receipt_number": null,- "rendering": {- "amount_tax_display": null,- "pdf": {- "page_size": "letter"- },- "template": null,- "template_version": null- },- "shipping_cost": null,- "shipping_details": null,- "starting_balance": 0,- "statement_descriptor": "Zulip Cloud Standard",- "status": "paid",- "status_transitions": {- "finalized_at": 1000000000,- "marked_uncollectible_at": null,- "paid_at": 1000000000,- "voided_at": null- },- "subtotal": 48000,- "subtotal_excluding_tax": 48000,- "test_clock": null,- "total": 48000,- "total_discount_amounts": [],- "total_excluding_tax": 48000,- "total_pretax_credit_amounts": [],- "total_taxes": [],- "webhooks_delivered_at": null- }- },- "id": "upgrade_by_card--Event.list.1.json",- "livemode": false,- "object": "event",- "pending_webhooks": 0,- "request": {- "id": "upgrade_by_card--Event.list.1.json",- "idempotency_key": "00000000-0000-0000-0000-000000000000"- },- "type": "invoice.paid"- },{"api_version": "2025-11-17.clover","created": 1000000000,@@ -1105,7 +73,7 @@"object": "line_item","parent": {"invoice_item_details": {- "invoice_item": "upgrade_by_card--Event.list.1.json",+ "invoice_item": "ii_NORMALIZED","proration": false,"proration_details": {"credited_items": null@@ -1203,393 +171,10 @@"id": "upgrade_by_card--Event.list.1.json","idempotency_key": "00000000-0000-0000-0000-000000000000"},- "type": "invoice.payment_succeeded"- },- {- "api_version": "2025-11-17.clover",- "created": 1000000000,- "data": {- "object": {- "address": null,- "balance": 0,- "created": 1000000000,- "currency": "usd",- "customer_account": null,- "default_source": null,- "delinquent": false,- "description": "zulip (Zulip Dev)",- "discount": null,- "email": "[email protected]",- "id": "upgrade_by_card--Customer.create.1.json",- "invoice_prefix": "NORMALIZED",- "invoice_settings": {- "custom_fields": null,- "default_payment_method": "upgrade_by_card--Customer.retrieve.2.json",- "footer": null,- "rendering_options": null- },- "livemode": false,- "metadata": {- "realm_id": "1",- "realm_str": "zulip"- },- "name": null,- "next_invoice_sequence": 1,- "object": "customer",- "phone": null,- "preferred_locales": [],- "shipping": null,- "tax_exempt": "none",- "test_clock": null- },- "previous_attributes": {- "currency": null- }- },- "id": "upgrade_by_card--Event.list.1.json",- "livemode": false,- "object": "event",- "pending_webhooks": 0,- "request": {- "id": "upgrade_by_card--Event.list.1.json",- "idempotency_key": "00000000-0000-0000-0000-000000000000"- },- "type": "customer.updated"- },- {- "api_version": "2025-11-17.clover",- "created": 1000000000,- "data": {- "object": {- "amount": 48000,- "amount_capturable": 0,- "amount_details": {- "tip": {}- },- "amount_received": 0,- "application": null,- "application_fee_amount": null,- "automatic_payment_methods": null,- "canceled_at": 1000000000,- "cancellation_reason": "requested_by_customer",- "capture_method": "automatic",- "client_secret": "NORMALIZED",- "confirmation_method": "automatic",- "created": 1000000000,- "currency": "usd",- "customer": "cus_UNRECORDED",- "description": "Payment for Invoice",- "excluded_payment_method_types": null,- "id": "upgrade_by_card--Event.list.1.json",- "last_payment_error": null,- "latest_charge": null,- "livemode": false,- "metadata": {},- "next_action": null,- "object": "payment_intent",- "on_behalf_of": null,- "payment_details": {- "customer_reference": null,- "order_reference": "in_1SVWq3DwzgQ85STgbxIPlh"- },- "payment_method": null,- "payment_method_configuration_details": null,- "payment_method_options": {- "card": {- "installments": null,- "mandate_options": null,- "network": null,- "request_three_d_secure": "automatic"- },- "link": {- "persistent_token": null- }- },- "payment_method_types": [- "card",- "link"- ],- "processing": null,- "receipt_email": "[email protected]",- "review": null,- "setup_future_usage": null,- "shipping": null,- "source": null,- "statement_descriptor": "Zulip Cloud Standard",- "statement_descriptor_suffix": null,- "status": "canceled",- "transfer_data": null,- "transfer_group": null- }- },- "id": "upgrade_by_card--Event.list.1.json",- "livemode": false,- "object": "event",- "pending_webhooks": 0,- "request": {- "id": "upgrade_by_card--Event.list.1.json",- "idempotency_key": "00000000-0000-0000-0000-000000000000"- },- "type": "payment_intent.created"- },- {- "api_version": "2025-11-17.clover",- "created": 1000000000,- "data": {- "object": {- "amount": 48000,- "amount_capturable": 0,- "amount_details": {- "tip": {}- },- "amount_received": 48000,- "application": null,- "application_fee_amount": null,- "automatic_payment_methods": null,- "canceled_at": null,- "cancellation_reason": null,- "capture_method": "automatic",- "client_secret": "NORMALIZED",- "confirmation_method": "automatic",- "created": 1000000000,- "currency": "usd",- "customer": "upgrade_by_card--Customer.create.1.json",- "customer_account": null,- "description": "Payment for Invoice",- "excluded_payment_method_types": null,- "id": "upgrade_by_card--Event.list.1.json",- "last_payment_error": null,- "latest_charge": "upgrade_by_card--Charge.list.1.json",- "livemode": false,- "managed_payments": {- "enabled": false- },- "metadata": {},- "next_action": null,- "object": "payment_intent",- "on_behalf_of": null,- "payment_details": {- "customer_reference": null,- "order_reference": "upgrade_by_card--Event.list.1.json"- },- "payment_method": "upgrade_by_card--Customer.retrieve.2.json",- "payment_method_configuration_details": null,- "payment_method_options": {- "card": {- "installments": null,- "mandate_options": null,- "network": null,- "request_three_d_secure": "automatic"- },- "cashapp": {}- },- "payment_method_types": [- "card",- "cashapp"- ],- "processing": null,- "receipt_email": "[email protected]",- "review": null,- "setup_future_usage": null,- "shared_payment_granted_token": null,- "shipping": null,- "source": null,- "statement_descriptor": "Zulip Cloud Standard",- "statement_descriptor_suffix": null,- "status": "succeeded",- "transfer_data": null,- "transfer_group": null- }- },- "id": "upgrade_by_card--Event.list.1.json",- "livemode": false,- "object": "event",- "pending_webhooks": 0,- "request": {- "id": "upgrade_by_card--Event.list.1.json",- "idempotency_key": "00000000-0000-0000-0000-000000000000"- },- "type": "payment_intent.succeeded"- },- {- "api_version": "2025-11-17.clover",- "created": 1000000000,- "data": {- "object": {- "amount": 48000,- "amount_captured": 48000,- "amount_refunded": 0,- "application": null,- "application_fee": null,- "application_fee_amount": null,- "balance_transaction": "txn_NORMALIZED",- "billing_details": {- "address": {- "city": "San Francisco",- "country": "US",- "line1": "123 Main St",- "line2": null,- "postal_code": "12345",- "state": "CA"- },- "email": null,- "name": "John Doe",- "phone": null,- "tax_id": null- },- "calculated_statement_descriptor": "ZULIP CLOUD STANDARD",- "captured": true,- "created": 1000000000,- "currency": "usd",- "customer": "upgrade_by_card--Customer.create.1.json",- "description": "Payment for Invoice",- "destination": null,- "dispute": null,- "disputed": false,- "failure_balance_transaction": null,- "failure_code": null,- "failure_message": null,- "fraud_details": {},- "id": "upgrade_by_card--Charge.list.1.json",- "livemode": false,- "metadata": {},- "object": "charge",- "on_behalf_of": null,- "order": null,- "outcome": {- "advice_code": null,- "network_advice_code": null,- "network_decline_code": null,- "network_status": "approved_by_network",- "reason": null,- "risk_level": "normal",- "risk_score": 0,- "seller_message": "Payment complete.",- "type": "authorized"- },- "paid": true,- "payment_intent": "upgrade_by_card--Event.list.1.json",- "payment_method": "upgrade_by_card--Customer.retrieve.2.json",- "payment_method_details": {- "card": {- "amount_authorized": 48000,- "authorization_code": "000000",- "brand": "visa",- "checks": {- "address_line1_check": "pass",- "address_postal_code_check": "pass",- "cvc_check": "pass"- },- "country": "US",- "ds_transaction_id": null,- "exp_month": 1,- "exp_year": 9999,- "extended_authorization": {- "status": "disabled"- },- "fingerprint": "NORMALIZED",- "funding": "credit",- "incremental_authorization": {- "status": "unavailable"- },- "installments": null,- "last4": "4242",- "mandate": null,- "multicapture": {- "status": "unavailable"- },- "network": "visa",- "network_token": {- "used": false- },- "network_transaction_id": "000000000000000",- "overcapture": {- "maximum_amount_capturable": 48000,- "status": "unavailable"- },- "regulated_status": "unregulated",- "three_d_secure": null,- "wallet": null- },- "type": "card"- },- "radar_options": {},- "receipt_email": "[email protected]",- "receipt_number": null,- "receipt_url": "https://pay.stripe.com/receipts/invoices/NORMALIZED?s=ap",- "refunded": false,- "review": null,- "shipping": null,- "source": null,- "source_transfer": null,- "statement_descriptor": "Zulip Cloud Standard",- "statement_descriptor_suffix": null,- "status": "succeeded",- "transfer_data": null,- "transfer_group": null- }- },- "id": "upgrade_by_card--Event.list.1.json",- "livemode": false,- "object": "event",- "pending_webhooks": 0,- "request": {- "id": "upgrade_by_card--Event.list.1.json",- "idempotency_key": "00000000-0000-0000-0000-000000000000"- },- "type": "charge.succeeded"- },- {- "api_version": "2025-11-17.clover",- "created": 1000000000,- "data": {- "object": {- "amount": 48000,- "currency": "usd",- "customer": "upgrade_by_card--Customer.create.1.json",- "customer_account": null,- "date": 1000000000,- "description": "Zulip Cloud Standard",- "discountable": false,- "discounts": [],- "id": "upgrade_by_card--Event.list.1.json",- "invoice": "upgrade_by_card--Event.list.1.json",- "livemode": false,- "metadata": {},- "net_amount": 48000,- "object": "invoiceitem",- "parent": null,- "period": {- "end": 1357095845,- "start": 1325473445- },- "pricing": {- "price_details": {- "price": "price_NORMALIZED",- "product": "prod_NORMALIZED"- },- "type": "price_details",- "unit_amount_decimal": "8000"- },- "proration": false,- "quantity": 6,- "quantity_decimal": "6",- "tax_rates": [],- "test_clock": null- }- },- "id": "upgrade_by_card--Event.list.1.json",- "livemode": false,- "object": "event",- "pending_webhooks": 0,- "request": {- "id": "upgrade_by_card--Event.list.1.json",- "idempotency_key": "00000000-0000-0000-0000-000000000000"- },- "type": "invoiceitem.created"+ "type": "invoice.paid"}],- "has_more": true,+ "has_more": false,"object": "list","url": "/v1/events"}diff --git a/corporate/tests/stripe_fixtures/upgrade_by_card--Event.list.2.json b/corporate/tests/stripe_fixtures/upgrade_by_card--Event.list.2.jsondeleted file mode 100644index 81abc3e53c8..00000000000--- a/corporate/tests/stripe_fixtures/upgrade_by_card--Event.list.2.json+++ /dev/null@@ -1,59 +0,0 @@-{- "data": [- {- "api_version": "2025-11-17.clover",- "created": 1000000000,- "data": {- "object": {- "address": null,- "balance": 0,- "created": 1000000000,- "currency": null,- "default_source": null,- "delinquent": false,- "description": "zulip (Zulip Dev)",- "discount": null,- "email": "[email protected]",- "id": "upgrade_by_card--Customer.create.1.json",- "invoice_prefix": "NORMALIZED",- "invoice_settings": {- "custom_fields": null,- "default_payment_method": "upgrade_by_card--Customer.retrieve.2.json",- "footer": null,- "rendering_options": null- },- "livemode": false,- "metadata": {- "realm_id": "1",- "realm_str": "zulip"- },- "name": null,- "next_invoice_sequence": 1,- "object": "customer",- "phone": null,- "preferred_locales": [],- "shipping": null,- "tax_exempt": "none",- "test_clock": null- },- "previous_attributes": {- "invoice_settings": {- "default_payment_method": null- }- }- },- "id": "upgrade_by_card--Event.list.2.json",- "livemode": false,- "object": "event",- "pending_webhooks": 0,- "request": {- "id": "upgrade_by_card--Event.list.2.json",- "idempotency_key": "00000000-0000-0000-0000-000000000000"- },- "type": "customer.updated"- }- ],- "has_more": true,- "object": "list",- "url": "/v1/events"-}diff --git a/corporate/tests/stripe_fixtures/upgrade_by_card--Event.list.3.json b/corporate/tests/stripe_fixtures/upgrade_by_card--Event.list.3.jsondeleted file mode 100644index 955af33e67b..00000000000--- a/corporate/tests/stripe_fixtures/upgrade_by_card--Event.list.3.json+++ /dev/null@@ -1,1077 +0,0 @@-{- "data": [- {- "api_version": "2025-11-17.clover",- "created": 1000000000,- "data": {- "object": {- "amount": 48000,- "amount_capturable": 0,- "amount_details": {- "tip": {}- },- "amount_received": 48000,- "application": null,- "application_fee_amount": null,- "automatic_payment_methods": null,- "canceled_at": null,- "cancellation_reason": null,- "capture_method": "automatic",- "client_secret": "NORMALIZED",- "confirmation_method": "automatic",- "created": 1000000000,- "currency": "usd",- "customer": "upgrade_by_card--Customer.create.1.json",- "description": "Payment for Invoice",- "excluded_payment_method_types": null,- "id": "upgrade_by_card--Event.list.3.json",- "last_payment_error": null,- "latest_charge": "upgrade_by_card--Charge.list.1.json",- "livemode": false,- "metadata": {},- "next_action": null,- "object": "payment_intent",- "on_behalf_of": null,- "payment_details": {- "customer_reference": null,- "order_reference": "in_1SVWqIDwzgQ85STg2r6fJo"- },- "payment_method": "upgrade_by_card--Customer.retrieve.2.json",- "payment_method_configuration_details": null,- "payment_method_options": {- "card": {- "installments": null,- "mandate_options": null,- "network": null,- "request_three_d_secure": "automatic"- },- "link": {- "persistent_token": null- }- },- "payment_method_types": [- "card",- "link"- ],- "processing": null,- "receipt_email": "[email protected]",- "review": null,- "setup_future_usage": null,- "shipping": null,- "source": null,- "statement_descriptor": "Zulip Cloud Standard",- "statement_descriptor_suffix": null,- "status": "succeeded",- "transfer_data": null,- "transfer_group": null- }- },- "id": "upgrade_by_card--Event.list.3.json",- "livemode": false,- "object": "event",- "pending_webhooks": 0,- "request": {- "id": "upgrade_by_card--Event.list.3.json",- "idempotency_key": "00000000-0000-0000-0000-000000000000"- },- "type": "payment_intent.succeeded"- },- {- "api_version": "2025-11-17.clover",- "created": 1000000000,- "data": {- "object": {- "amount": 48000,- "amount_captured": 48000,- "amount_refunded": 0,- "application": null,- "application_fee": null,- "application_fee_amount": null,- "balance_transaction": "txn_NORMALIZED",- "billing_details": {- "address": {- "city": "San Francisco",- "country": "US",- "line1": "123 Main St",- "line2": null,- "postal_code": "12345",- "state": "CA"- },- "email": null,- "name": "John Doe",- "phone": null,- "tax_id": null- },- "calculated_statement_descriptor": "ZULIP CLOUD STANDARD",- "captured": true,- "created": 1000000000,- "currency": "usd",- "customer": "upgrade_by_card--Customer.create.1.json",- "description": "Payment for Invoice",- "destination": null,- "dispute": null,- "disputed": false,- "failure_balance_transaction": null,- "failure_code": null,- "failure_message": null,- "fraud_details": {},- "id": "upgrade_by_card--Charge.list.1.json",- "livemode": false,- "metadata": {},- "object": "charge",- "on_behalf_of": null,- "order": null,- "outcome": {- "advice_code": null,- "network_advice_code": null,- "network_decline_code": null,- "network_status": "approved_by_network",- "reason": null,- "risk_level": "normal",- "risk_score": 0,- "seller_message": "Payment complete.",- "type": "authorized"- },- "paid": true,- "payment_intent": "upgrade_by_card--Event.list.3.json",- "payment_method": "upgrade_by_card--Customer.retrieve.2.json",- "payment_method_details": {- "card": {- "amount_authorized": 48000,- "authorization_code": "000000",- "brand": "visa",- "checks": {- "address_line1_check": "pass",- "address_postal_code_check": "pass",- "cvc_check": "pass"- },- "country": "US",- "exp_month": 1,- "exp_year": 9999,- "extended_authorization": {- "status": "disabled"- },- "fingerprint": "NORMALIZED",- "funding": "credit",- "incremental_authorization": {- "status": "unavailable"- },- "installments": null,- "last4": "4242",- "mandate": null,- "multicapture": {- "status": "unavailable"- },- "network": "visa",- "network_token": {- "used": false- },- "network_transaction_id": "000000000000000",- "overcapture": {- "maximum_amount_capturable": 48000,- "status": "unavailable"- },- "regulated_status": "unregulated",- "three_d_secure": null,- "wallet": null- },- "type": "card"- },- "radar_options": {},- "receipt_email": "[email protected]",- "receipt_number": null,- "receipt_url": "https://pay.stripe.com/receipts/invoices/NORMALIZED?s=ap",- "refunded": false,- "review": null,- "shipping": null,- "source": null,- "source_transfer": null,- "statement_descriptor": "Zulip Cloud Standard",- "statement_descriptor_suffix": null,- "status": "succeeded",- "transfer_data": null,- "transfer_group": null- }- },- "id": "upgrade_by_card--Event.list.3.json",- "livemode": false,- "object": "event",- "pending_webhooks": 0,- "request": {- "id": "upgrade_by_card--Event.list.3.json",- "idempotency_key": "00000000-0000-0000-0000-000000000000"- },- "type": "charge.succeeded"- },- {- "api_version": "2025-11-17.clover",- "created": 1000000000,- "data": {- "object": {- "amount_paid": 4800,- "amount_requested": 4800,- "created": 1000000000,- "currency": "usd",- "id": "upgrade_by_card--Event.list.3.json",- "invoice": "upgrade_by_card--Event.list.3.json",- "is_default": true,- "livemode": false,- "object": "invoice_payment",- "payment": {- "payment_intent": "pi_NORMALIZED",- "type": "payment_intent"- },- "status": "paid",- "status_transitions": {- "canceled_at": null,- "paid_at": 1000000000- }- }- },- "id": "upgrade_by_card--Event.list.3.json",- "livemode": false,- "object": "event",- "pending_webhooks": 0,- "request": {- "id": null,- "idempotency_key": null- },- "type": "invoice_payment.paid"- },- {- "api_version": "2025-11-17.clover",- "created": 1000000000,- "data": {- "object": {- "account_country": "US",- "account_name": "NORMALIZED",- "account_tax_ids": null,- "amount_due": 48000,- "amount_overpaid": 0,- "amount_paid": 0,- "amount_remaining": 48000,- "amount_shipping": 0,- "application": null,- "attempt_count": 0,- "attempted": false,- "auto_advance": false,- "automatic_tax": {- "disabled_reason": null,- "enabled": false,- "liability": null,- "provider": null,- "status": null- },- "automatically_finalizes_at": null,- "billing_reason": "manual",- "collection_method": "charge_automatically",- "created": 1000000000,- "currency": "usd",- "custom_fields": null,- "customer": "upgrade_by_card--Customer.create.1.json",- "customer_address": null,- "customer_email": "[email protected]",- "customer_name": null,- "customer_phone": null,- "customer_shipping": null,- "customer_tax_exempt": "none",- "customer_tax_ids": [],- "default_payment_method": null,- "default_source": null,- "default_tax_rates": [],- "description": "If paying by bank transfer outside of the US, use the OUR option for who should pay bank transfer fees, to make sure that your invoice is paid in full.",- "discounts": [],- "due_date": null,- "effective_at": 1000000000,- "ending_balance": 0,- "footer": null,- "from_invoice": null,- "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED/test_NORMALIZED?s=ap",- "id": "upgrade_by_card--Event.list.3.json",- "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED/test_NORMALIZED/pdf?s=ap",- "issuer": {- "type": "self"- },- "last_finalization_error": null,- "latest_revision": null,- "lines": {- "data": [- {- "amount": 48000,- "currency": "usd",- "description": "Zulip Cloud Standard",- "discount_amounts": [],- "discountable": false,- "discounts": [],- "id": "upgrade_by_card--Event.list.3.json",- "invoice": "upgrade_by_card--Event.list.3.json",- "livemode": false,- "metadata": {},- "object": "line_item",- "parent": {- "invoice_item_details": {- "invoice_item": "upgrade_by_card--Event.list.3.json",- "proration": false,- "proration_details": {- "credited_items": null- },- "subscription": null- },- "subscription_item_details": null,- "type": "invoice_item_details"- },- "period": {- "end": 1357095845,- "start": 1325473445- },- "pretax_credit_amounts": [],- "pricing": {- "price_details": {- "price": "price_NORMALIZED",- "product": "prod_NORMALIZED"- },- "type": "price_details",- "unit_amount_decimal": "8000"- },- "quantity": 6,- "taxes": []- }- ],- "has_more": false,- "object": "list",- "total_count": 1,- "url": "/v1/invoices/upgrade_by_card--Event.list.3.json/lines"- },- "livemode": false,- "metadata": {- "billing_schedule": "1",- "current_plan_id": "None",- "license_management": "automatic",- "licenses": "6",- "on_free_trial": "False",- "plan_tier": "1",- "user_id": "10"- },- "next_payment_attempt": null,- "number": "NORMALIZED",- "object": "invoice",- "on_behalf_of": null,- "parent": null,- "payment_settings": {- "default_mandate": null,- "payment_method_options": null,- "payment_method_types": null- },- "period_end": 1000000000,- "period_start": 1000000000,- "post_payment_credit_notes_amount": 0,- "pre_payment_credit_notes_amount": 0,- "receipt_number": null,- "rendering": {- "amount_tax_display": null,- "pdf": {- "page_size": "letter"- },- "template": null,- "template_version": null- },- "shipping_cost": null,- "shipping_details": null,- "starting_balance": 0,- "statement_descriptor": "Zulip Cloud Standard",- "status": "open",- "status_transitions": {- "finalized_at": 1000000000,- "marked_uncollectible_at": null,- "paid_at": null,- "voided_at": null- },- "subtotal": 48000,- "subtotal_excluding_tax": 48000,- "test_clock": null,- "total": 48000,- "total_discount_amounts": [],- "total_excluding_tax": 48000,- "total_pretax_credit_amounts": [],- "total_taxes": [],- "webhooks_delivered_at": null- }- },- "id": "upgrade_by_card--Event.list.3.json",- "livemode": false,- "object": "event",- "pending_webhooks": 0,- "request": {- "id": "upgrade_by_card--Event.list.3.json",- "idempotency_key": "00000000-0000-0000-0000-000000000000"- },- "type": "invoice.finalized"- },- {- "api_version": "2025-11-17.clover",- "created": 1000000000,- "data": {- "object": {- "account_country": "US",- "account_name": "NORMALIZED",- "account_tax_ids": null,- "amount_due": 48000,- "amount_overpaid": 0,- "amount_paid": 0,- "amount_remaining": 48000,- "amount_shipping": 0,- "application": null,- "attempt_count": 0,- "attempted": false,- "auto_advance": false,- "automatic_tax": {- "disabled_reason": null,- "enabled": false,- "liability": null,- "provider": null,- "status": null- },- "automatically_finalizes_at": null,- "billing_reason": "manual",- "collection_method": "charge_automatically",- "created": 1000000000,- "currency": "usd",- "custom_fields": null,- "customer": "upgrade_by_card--Customer.create.1.json",- "customer_address": null,- "customer_email": "[email protected]",- "customer_name": null,- "customer_phone": null,- "customer_shipping": null,- "customer_tax_exempt": "none",- "customer_tax_ids": [],- "default_payment_method": null,- "default_source": null,- "default_tax_rates": [],- "description": "If paying by bank transfer outside of the US, use the OUR option for who should pay bank transfer fees, to make sure that your invoice is paid in full.",- "discounts": [],- "due_date": null,- "effective_at": 1000000000,- "ending_balance": 0,- "footer": null,- "from_invoice": null,- "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED/test_NORMALIZED?s=ap",- "id": "upgrade_by_card--Event.list.3.json",- "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED/test_NORMALIZED/pdf?s=ap",- "issuer": {- "type": "self"- },- "last_finalization_error": null,- "latest_revision": null,- "lines": {- "data": [- {- "amount": 48000,- "currency": "usd",- "description": "Zulip Cloud Standard",- "discount_amounts": [],- "discountable": false,- "discounts": [],- "id": "upgrade_by_card--Event.list.3.json",- "invoice": "upgrade_by_card--Event.list.3.json",- "livemode": false,- "metadata": {},- "object": "line_item",- "parent": {- "invoice_item_details": {- "invoice_item": "upgrade_by_card--Event.list.3.json",- "proration": false,- "proration_details": {- "credited_items": null- },- "subscription": null- },- "subscription_item_details": null,- "type": "invoice_item_details"- },- "period": {- "end": 1357095845,- "start": 1325473445- },- "pretax_credit_amounts": [],- "pricing": {- "price_details": {- "price": "price_NORMALIZED",- "product": "prod_NORMALIZED"- },- "type": "price_details",- "unit_amount_decimal": "8000"- },- "quantity": 6,- "taxes": []- }- ],- "has_more": false,- "object": "list",- "total_count": 1,- "url": "/v1/invoices/upgrade_by_card--Event.list.3.json/lines"- },- "livemode": false,- "metadata": {- "billing_schedule": "1",- "current_plan_id": "None",- "license_management": "automatic",- "licenses": "6",- "on_free_trial": "False",- "plan_tier": "1",- "user_id": "10"- },- "next_payment_attempt": null,- "number": "NORMALIZED",- "object": "invoice",- "on_behalf_of": null,- "parent": null,- "payment_settings": {- "default_mandate": null,- "payment_method_options": null,- "payment_method_types": null- },- "period_end": 1000000000,- "period_start": 1000000000,- "post_payment_credit_notes_amount": 0,- "pre_payment_credit_notes_amount": 0,- "receipt_number": null,- "rendering": {- "amount_tax_display": null,- "pdf": {- "page_size": "letter"- },- "template": null,- "template_version": null- },- "shipping_cost": null,- "shipping_details": null,- "starting_balance": 0,- "statement_descriptor": "Zulip Cloud Standard",- "status": "open",- "status_transitions": {- "finalized_at": 1000000000,- "marked_uncollectible_at": null,- "paid_at": null,- "voided_at": null- },- "subtotal": 48000,- "subtotal_excluding_tax": 48000,- "test_clock": null,- "total": 48000,- "total_discount_amounts": [],- "total_excluding_tax": 48000,- "total_pretax_credit_amounts": [],- "total_taxes": [],- "webhooks_delivered_at": null- },- "previous_attributes": {- "effective_at": null,- "ending_balance": null,- "hosted_invoice_url": null,- "invoice_pdf": null,- "number": null,- "rendering": {- "pdf": {- "page_size": "auto"- }- },- "status": "draft",- "status_transitions": {- "finalized_at": null- }- }- },- "id": "upgrade_by_card--Event.list.3.json",- "livemode": false,- "object": "event",- "pending_webhooks": 0,- "request": {- "id": "upgrade_by_card--Event.list.3.json",- "idempotency_key": "00000000-0000-0000-0000-000000000000"- },- "type": "invoice.updated"- },- {- "api_version": "2025-11-17.clover",- "created": 1000000000,- "data": {- "object": {- "amount": 48000,- "amount_capturable": 0,- "amount_details": {- "tip": {}- },- "amount_received": 0,- "application": null,- "application_fee_amount": null,- "automatic_payment_methods": null,- "canceled_at": null,- "cancellation_reason": null,- "capture_method": "automatic",- "client_secret": "NORMALIZED",- "confirmation_method": "automatic",- "created": 1000000000,- "currency": "usd",- "customer": "upgrade_by_card--Customer.create.1.json",- "description": "Payment for Invoice",- "excluded_payment_method_types": null,- "id": "upgrade_by_card--Event.list.3.json",- "last_payment_error": null,- "latest_charge": null,- "livemode": false,- "metadata": {},- "next_action": null,- "object": "payment_intent",- "on_behalf_of": null,- "payment_method": null,- "payment_method_configuration_details": null,- "payment_method_options": {- "card": {- "installments": null,- "mandate_options": null,- "network": null,- "request_three_d_secure": "automatic"- },- "link": {- "persistent_token": null- }- },- "payment_method_types": [- "card",- "link"- ],- "processing": null,- "receipt_email": "[email protected]",- "review": null,- "setup_future_usage": null,- "shipping": null,- "source": null,- "statement_descriptor": "Zulip Cloud Standard",- "statement_descriptor_suffix": null,- "status": "requires_payment_method",- "transfer_data": null,- "transfer_group": null- }- },- "id": "upgrade_by_card--Event.list.3.json",- "livemode": false,- "object": "event",- "pending_webhooks": 0,- "request": {- "id": "upgrade_by_card--Event.list.3.json",- "idempotency_key": "00000000-0000-0000-0000-000000000000"- },- "type": "payment_intent.created"- },- {- "api_version": "2025-11-17.clover",- "created": 1000000000,- "data": {- "object": {- "account_country": "US",- "account_name": "NORMALIZED",- "account_tax_ids": null,- "amount_due": 48000,- "amount_overpaid": 0,- "amount_paid": 0,- "amount_remaining": 48000,- "amount_shipping": 0,- "application": null,- "attempt_count": 0,- "attempted": false,- "auto_advance": false,- "automatic_tax": {- "disabled_reason": null,- "enabled": false,- "liability": null,- "provider": null,- "status": null- },- "automatically_finalizes_at": null,- "billing_reason": "manual",- "collection_method": "charge_automatically",- "created": 1000000000,- "currency": "usd",- "custom_fields": null,- "customer": "upgrade_by_card--Customer.create.1.json",- "customer_address": null,- "customer_email": "[email protected]",- "customer_name": null,- "customer_phone": null,- "customer_shipping": null,- "customer_tax_exempt": "none",- "customer_tax_ids": [],- "default_payment_method": null,- "default_source": null,- "default_tax_rates": [],- "description": "If paying by bank transfer outside of the US, use the OUR option for who should pay bank transfer fees, to make sure that your invoice is paid in full.",- "discounts": [],- "due_date": null,- "effective_at": null,- "ending_balance": null,- "footer": null,- "from_invoice": null,- "hosted_invoice_url": null,- "id": "upgrade_by_card--Event.list.3.json",- "invoice_pdf": null,- "issuer": {- "type": "self"- },- "last_finalization_error": null,- "latest_revision": null,- "lines": {- "data": [- {- "amount": 48000,- "currency": "usd",- "description": "Zulip Cloud Standard",- "discount_amounts": [],- "discountable": false,- "discounts": [],- "id": "upgrade_by_card--Event.list.3.json",- "invoice": "upgrade_by_card--Event.list.3.json",- "livemode": false,- "metadata": {},- "object": "line_item",- "parent": {- "invoice_item_details": {- "invoice_item": "upgrade_by_card--Event.list.3.json",- "proration": false,- "proration_details": {- "credited_items": null- },- "subscription": null- },- "subscription_item_details": null,- "type": "invoice_item_details"- },- "period": {- "end": 1357095845,- "start": 1325473445- },- "pretax_credit_amounts": [],- "pricing": {- "price_details": {- "price": "price_NORMALIZED",- "product": "prod_NORMALIZED"- },- "type": "price_details",- "unit_amount_decimal": "8000"- },- "quantity": 6,- "taxes": []- }- ],- "has_more": false,- "object": "list",- "total_count": 1,- "url": "/v1/invoices/upgrade_by_card--Event.list.3.json/lines"- },- "livemode": false,- "metadata": {- "billing_schedule": "1",- "current_plan_id": "None",- "license_management": "automatic",- "licenses": "6",- "on_free_trial": "False",- "plan_tier": "1",- "user_id": "10"- },- "next_payment_attempt": null,- "number": null,- "object": "invoice",- "on_behalf_of": null,- "parent": null,- "payment_settings": {- "default_mandate": null,- "payment_method_options": null,- "payment_method_types": null- },- "period_end": 1000000000,- "period_start": 1000000000,- "post_payment_credit_notes_amount": 0,- "pre_payment_credit_notes_amount": 0,- "receipt_number": null,- "rendering": {- "amount_tax_display": null,- "pdf": {- "page_size": "auto"- },- "template": null,- "template_version": null- },- "shipping_cost": null,- "shipping_details": null,- "starting_balance": 0,- "statement_descriptor": "Zulip Cloud Standard",- "status": "draft",- "status_transitions": {- "finalized_at": null,- "marked_uncollectible_at": null,- "paid_at": null,- "voided_at": null- },- "subtotal": 48000,- "subtotal_excluding_tax": 48000,- "test_clock": null,- "total": 48000,- "total_discount_amounts": [],- "total_excluding_tax": 48000,- "total_pretax_credit_amounts": [],- "total_taxes": [],- "webhooks_delivered_at": null- },- "previous_attributes": {- "amount_due": 0,- "amount_remaining": 0,- "lines": {- "data": [],- "total_count": 0- },- "subtotal": 0,- "subtotal_excluding_tax": 0,- "total": 0,- "total_excluding_tax": 0- }- },- "id": "upgrade_by_card--Event.list.3.json",- "livemode": false,- "object": "event",- "pending_webhooks": 0,- "request": {- "id": "upgrade_by_card--Event.list.3.json",- "idempotency_key": "00000000-0000-0000-0000-000000000000"- },- "type": "invoice.updated"- },- {- "api_version": "2025-11-17.clover",- "created": 1000000000,- "data": {- "object": {- "amount": 48000,- "currency": "usd",- "customer": "upgrade_by_card--Customer.create.1.json",- "date": 1000000000,- "description": "Zulip Cloud Standard",- "discountable": false,- "discounts": [],- "id": "upgrade_by_card--Event.list.3.json",- "invoice": "upgrade_by_card--Event.list.3.json",- "livemode": false,- "metadata": {},- "net_amount": 48000,- "object": "invoiceitem",- "parent": null,- "period": {- "end": 1357095845,- "start": 1325473445- },- "pricing": {- "price_details": {- "price": "price_NORMALIZED",- "product": "prod_NORMALIZED"- },- "type": "price_details",- "unit_amount_decimal": "8000"- },- "proration": false,- "quantity": 6,- "tax_rates": [],- "test_clock": null- }- },- "id": "upgrade_by_card--Event.list.3.json",- "livemode": false,- "object": "event",- "pending_webhooks": 0,- "request": {- "id": "upgrade_by_card--Event.list.3.json",- "idempotency_key": "00000000-0000-0000-0000-000000000000"- },- "type": "invoiceitem.created"- },- {- "api_version": "2025-11-17.clover",- "created": 1000000000,- "data": {- "object": {- "account_country": "US",- "account_name": "NORMALIZED",- "account_tax_ids": null,- "amount_due": 0,- "amount_overpaid": 0,- "amount_paid": 0,- "amount_remaining": 0,- "amount_shipping": 0,- "application": null,- "attempt_count": 0,- "attempted": false,- "auto_advance": false,- "automatic_tax": {- "disabled_reason": null,- "enabled": false,- "liability": null,- "provider": null,- "status": null- },- "automatically_finalizes_at": null,- "billing_reason": "manual",- "collection_method": "charge_automatically",- "created": 1000000000,- "currency": "usd",- "custom_fields": null,- "customer": "upgrade_by_card--Customer.create.1.json",- "customer_address": null,- "customer_email": "[email protected]",- "customer_name": null,- "customer_phone": null,- "customer_shipping": null,- "customer_tax_exempt": "none",- "customer_tax_ids": [],- "default_payment_method": null,- "default_source": null,- "default_tax_rates": [],- "description": "If paying by bank transfer outside of the US, use the OUR option for who should pay bank transfer fees, to make sure that your invoice is paid in full.",- "discounts": [],- "due_date": null,- "effective_at": null,- "ending_balance": null,- "footer": null,- "from_invoice": null,- "hosted_invoice_url": null,- "id": "upgrade_by_card--Event.list.3.json",- "invoice_pdf": null,- "issuer": {- "type": "self"- },- "last_finalization_error": null,- "latest_revision": null,- "lines": {- "data": [],- "has_more": false,- "object": "list",- "total_count": 0,- "url": "/v1/invoices/upgrade_by_card--Event.list.3.json/lines"- },- "livemode": false,- "metadata": {- "billing_schedule": "1",- "current_plan_id": "None",- "license_management": "automatic",- "licenses": "6",- "on_free_trial": "False",- "plan_tier": "1",- "user_id": "10"- },- "next_payment_attempt": null,- "number": null,- "object": "invoice",- "on_behalf_of": null,- "parent": null,- "payment_settings": {- "default_mandate": null,- "payment_method_options": null,- "payment_method_types": null- },- "period_end": 1000000000,- "period_start": 1000000000,- "post_payment_credit_notes_amount": 0,- "pre_payment_credit_notes_amount": 0,- "receipt_number": null,- "rendering": {- "amount_tax_display": null,- "pdf": {- "page_size": "auto"- },- "template": null,- "template_version": null- },- "shipping_cost": null,- "shipping_details": null,- "starting_balance": 0,- "statement_descriptor": "Zulip Cloud Standard",- "status": "draft",- "status_transitions": {- "finalized_at": null,- "marked_uncollectible_at": null,- "paid_at": null,- "voided_at": null- },- "subtotal": 0,- "subtotal_excluding_tax": 0,- "test_clock": null,- "total": 0,- "total_discount_amounts": [],- "total_excluding_tax": 0,- "total_pretax_credit_amounts": [],- "total_taxes": [],- "webhooks_delivered_at": null- }- },- "id": "upgrade_by_card--Event.list.3.json",- "livemode": false,- "object": "event",- "pending_webhooks": 0,- "request": {- "id": "upgrade_by_card--Event.list.3.json",- "idempotency_key": "00000000-0000-0000-0000-000000000000"- },- "type": "invoice.created"- },- {- "api_version": "2025-11-17.clover",- "created": 1000000000,- "data": {- "object": {- "address": null,- "balance": 0,- "created": 1000000000,- "currency": "usd",- "default_source": null,- "delinquent": false,- "description": "zulip (Zulip Dev)",- "discount": null,- "email": "[email protected]",- "id": "upgrade_by_card--Customer.create.1.json",- "invoice_prefix": "NORMALIZED",- "invoice_settings": {- "custom_fields": null,- "default_payment_method": "upgrade_by_card--Customer.retrieve.2.json",- "footer": null,- "rendering_options": null- },- "livemode": false,- "metadata": {- "realm_id": "1",- "realm_str": "zulip"- },- "name": null,- "next_invoice_sequence": 1,- "object": "customer",- "phone": null,- "preferred_locales": [],- "shipping": null,- "tax_exempt": "none",- "test_clock": null- },- "previous_attributes": {- "currency": null- }- },- "id": "upgrade_by_card--Event.list.3.json",- "livemode": false,- "object": "event",- "pending_webhooks": 0,- "request": {- "id": "upgrade_by_card--Event.list.3.json",- "idempotency_key": "00000000-0000-0000-0000-000000000000"- },- "type": "customer.updated"- }- ],- "has_more": true,- "object": "list",- "url": "/v1/events"-}diff --git a/corporate/tests/stripe_fixtures/upgrade_by_card--Event.list.4.json b/corporate/tests/stripe_fixtures/upgrade_by_card--Event.list.4.jsondeleted file mode 100644index 0778e0e9356..00000000000--- a/corporate/tests/stripe_fixtures/upgrade_by_card--Event.list.4.json+++ /dev/null@@ -1,524 +0,0 @@-{- "data": [- {- "api_version": "2025-11-17.clover",- "created": 1000000000,- "data": {- "object": {- "account_country": "US",- "account_name": "NORMALIZED",- "account_tax_ids": null,- "amount_due": 48000,- "amount_overpaid": 0,- "amount_paid": 48000,- "amount_remaining": 0,- "amount_shipping": 0,- "application": null,- "attempt_count": 1,- "attempted": true,- "auto_advance": false,- "automatic_tax": {- "disabled_reason": null,- "enabled": false,- "liability": null,- "provider": null,- "status": null- },- "automatically_finalizes_at": null,- "billing_reason": "manual",- "collection_method": "charge_automatically",- "created": 1000000000,- "currency": "usd",- "custom_fields": null,- "customer": "upgrade_by_card--Customer.create.1.json",- "customer_address": null,- "customer_email": "[email protected]",- "customer_name": null,- "customer_phone": null,- "customer_shipping": null,- "customer_tax_exempt": "none",- "customer_tax_ids": [],- "default_payment_method": null,- "default_source": null,- "default_tax_rates": [],- "description": "If paying by bank transfer outside of the US, use the OUR option for who should pay bank transfer fees, to make sure that your invoice is paid in full.",- "discounts": [],- "due_date": null,- "effective_at": 1000000000,- "ending_balance": 0,- "footer": null,- "from_invoice": null,- "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED/test_NORMALIZED?s=ap",- "id": "upgrade_by_card--Event.list.3.json",- "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED/test_NORMALIZED/pdf?s=ap",- "issuer": {- "type": "self"- },- "last_finalization_error": null,- "latest_revision": null,- "lines": {- "data": [- {- "amount": 48000,- "currency": "usd",- "description": "Zulip Cloud Standard",- "discount_amounts": [],- "discountable": false,- "discounts": [],- "id": "upgrade_by_card--Event.list.3.json",- "invoice": "upgrade_by_card--Event.list.3.json",- "livemode": false,- "metadata": {},- "object": "line_item",- "parent": {- "invoice_item_details": {- "invoice_item": "upgrade_by_card--Event.list.3.json",- "proration": false,- "proration_details": {- "credited_items": null- },- "subscription": null- },- "subscription_item_details": null,- "type": "invoice_item_details"- },- "period": {- "end": 1357095845,- "start": 1325473445- },- "pretax_credit_amounts": [],- "pricing": {- "price_details": {- "price": "price_NORMALIZED",- "product": "prod_NORMALIZED"- },- "type": "price_details",- "unit_amount_decimal": "8000"- },- "quantity": 6,- "taxes": []- }- ],- "has_more": false,- "object": "list",- "total_count": 1,- "url": "/v1/invoices/upgrade_by_card--Event.list.3.json/lines"- },- "livemode": false,- "metadata": {- "billing_schedule": "1",- "current_plan_id": "None",- "license_management": "automatic",- "licenses": "6",- "on_free_trial": "False",- "plan_tier": "1",- "user_id": "10"- },- "next_payment_attempt": null,- "number": "NORMALIZED",- "object": "invoice",- "on_behalf_of": null,- "parent": null,- "payment_settings": {- "default_mandate": null,- "payment_method_options": null,- "payment_method_types": null- },- "period_end": 1000000000,- "period_start": 1000000000,- "post_payment_credit_notes_amount": 0,- "pre_payment_credit_notes_amount": 0,- "receipt_number": null,- "rendering": {- "amount_tax_display": null,- "pdf": {- "page_size": "letter"- },- "template": null,- "template_version": null- },- "shipping_cost": null,- "shipping_details": null,- "starting_balance": 0,- "statement_descriptor": "Zulip Cloud Standard",- "status": "paid",- "status_transitions": {- "finalized_at": 1000000000,- "marked_uncollectible_at": null,- "paid_at": 1000000000,- "voided_at": null- },- "subtotal": 48000,- "subtotal_excluding_tax": 48000,- "test_clock": null,- "total": 48000,- "total_discount_amounts": [],- "total_excluding_tax": 48000,- "total_pretax_credit_amounts": [],- "total_taxes": [],- "webhooks_delivered_at": null- }- },- "id": "upgrade_by_card--Event.list.4.json",- "livemode": false,- "object": "event",- "pending_webhooks": 0,- "request": {- "id": "upgrade_by_card--Event.list.3.json",- "idempotency_key": "00000000-0000-0000-0000-000000000000"- },- "type": "invoice.payment_succeeded"- },- {- "api_version": "2025-11-17.clover",- "created": 1000000000,- "data": {- "object": {- "account_country": "US",- "account_name": "NORMALIZED",- "account_tax_ids": null,- "amount_due": 48000,- "amount_overpaid": 0,- "amount_paid": 48000,- "amount_remaining": 0,- "amount_shipping": 0,- "application": null,- "attempt_count": 1,- "attempted": true,- "auto_advance": false,- "automatic_tax": {- "disabled_reason": null,- "enabled": false,- "liability": null,- "provider": null,- "status": null- },- "automatically_finalizes_at": null,- "billing_reason": "manual",- "collection_method": "charge_automatically",- "created": 1000000000,- "currency": "usd",- "custom_fields": null,- "customer": "upgrade_by_card--Customer.create.1.json",- "customer_address": null,- "customer_email": "[email protected]",- "customer_name": null,- "customer_phone": null,- "customer_shipping": null,- "customer_tax_exempt": "none",- "customer_tax_ids": [],- "default_payment_method": null,- "default_source": null,- "default_tax_rates": [],- "description": "If paying by bank transfer outside of the US, use the OUR option for who should pay bank transfer fees, to make sure that your invoice is paid in full.",- "discounts": [],- "due_date": null,- "effective_at": 1000000000,- "ending_balance": 0,- "footer": null,- "from_invoice": null,- "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED/test_NORMALIZED?s=ap",- "id": "upgrade_by_card--Event.list.3.json",- "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED/test_NORMALIZED/pdf?s=ap",- "issuer": {- "type": "self"- },- "last_finalization_error": null,- "latest_revision": null,- "lines": {- "data": [- {- "amount": 48000,- "currency": "usd",- "description": "Zulip Cloud Standard",- "discount_amounts": [],- "discountable": false,- "discounts": [],- "id": "upgrade_by_card--Event.list.3.json",- "invoice": "upgrade_by_card--Event.list.3.json",- "livemode": false,- "metadata": {},- "object": "line_item",- "parent": {- "invoice_item_details": {- "invoice_item": "upgrade_by_card--Event.list.3.json",- "proration": false,- "proration_details": {- "credited_items": null- },- "subscription": null- },- "subscription_item_details": null,- "type": "invoice_item_details"- },- "period": {- "end": 1357095845,- "start": 1325473445- },- "pretax_credit_amounts": [],- "pricing": {- "price_details": {- "price": "price_NORMALIZED",- "product": "prod_NORMALIZED"- },- "type": "price_details",- "unit_amount_decimal": "8000"- },- "quantity": 6,- "taxes": []- }- ],- "has_more": false,- "object": "list",- "total_count": 1,- "url": "/v1/invoices/upgrade_by_card--Event.list.3.json/lines"- },- "livemode": false,- "metadata": {- "billing_schedule": "1",- "current_plan_id": "None",- "license_management": "automatic",- "licenses": "6",- "on_free_trial": "False",- "plan_tier": "1",- "user_id": "10"- },- "next_payment_attempt": null,- "number": "NORMALIZED",- "object": "invoice",- "on_behalf_of": null,- "parent": null,- "payment_settings": {- "default_mandate": null,- "payment_method_options": null,- "payment_method_types": null- },- "period_end": 1000000000,- "period_start": 1000000000,- "post_payment_credit_notes_amount": 0,- "pre_payment_credit_notes_amount": 0,- "receipt_number": null,- "rendering": {- "amount_tax_display": null,- "pdf": {- "page_size": "letter"- },- "template": null,- "template_version": null- },- "shipping_cost": null,- "shipping_details": null,- "starting_balance": 0,- "statement_descriptor": "Zulip Cloud Standard",- "status": "paid",- "status_transitions": {- "finalized_at": 1000000000,- "marked_uncollectible_at": null,- "paid_at": 1000000000,- "voided_at": null- },- "subtotal": 48000,- "subtotal_excluding_tax": 48000,- "test_clock": null,- "total": 48000,- "total_discount_amounts": [],- "total_excluding_tax": 48000,- "total_pretax_credit_amounts": [],- "total_taxes": [],- "webhooks_delivered_at": null- }- },- "id": "upgrade_by_card--Event.list.4.json",- "livemode": false,- "object": "event",- "pending_webhooks": 0,- "request": {- "id": "upgrade_by_card--Event.list.3.json",- "idempotency_key": "00000000-0000-0000-0000-000000000000"- },- "type": "invoice.paid"- },- {- "api_version": "2025-11-17.clover",- "created": 1000000000,- "data": {- "object": {- "account_country": "US",- "account_name": "NORMALIZED",- "account_tax_ids": null,- "amount_due": 48000,- "amount_overpaid": 0,- "amount_paid": 48000,- "amount_remaining": 0,- "amount_shipping": 0,- "application": null,- "attempt_count": 1,- "attempted": true,- "auto_advance": false,- "automatic_tax": {- "disabled_reason": null,- "enabled": false,- "liability": null,- "provider": null,- "status": null- },- "automatically_finalizes_at": null,- "billing_reason": "manual",- "collection_method": "charge_automatically",- "created": 1000000000,- "currency": "usd",- "custom_fields": null,- "customer": "upgrade_by_card--Customer.create.1.json",- "customer_address": null,- "customer_email": "[email protected]",- "customer_name": null,- "customer_phone": null,- "customer_shipping": null,- "customer_tax_exempt": "none",- "customer_tax_ids": [],- "default_payment_method": null,- "default_source": null,- "default_tax_rates": [],- "description": "If paying by bank transfer outside of the US, use the OUR option for who should pay bank transfer fees, to make sure that your invoice is paid in full.",- "discounts": [],- "due_date": null,- "effective_at": 1000000000,- "ending_balance": 0,- "footer": null,- "from_invoice": null,- "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED/test_NORMALIZED?s=ap",- "id": "upgrade_by_card--Event.list.3.json",- "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED/test_NORMALIZED/pdf?s=ap",- "issuer": {- "type": "self"- },- "last_finalization_error": null,- "latest_revision": null,- "lines": {- "data": [- {- "amount": 48000,- "currency": "usd",- "description": "Zulip Cloud Standard",- "discount_amounts": [],- "discountable": false,- "discounts": [],- "id": "upgrade_by_card--Event.list.3.json",- "invoice": "upgrade_by_card--Event.list.3.json",- "livemode": false,- "metadata": {},- "object": "line_item",- "parent": {- "invoice_item_details": {- "invoice_item": "upgrade_by_card--Event.list.3.json",- "proration": false,- "proration_details": {- "credited_items": null- },- "subscription": null- },- "subscription_item_details": null,- "type": "invoice_item_details"- },- "period": {- "end": 1357095845,- "start": 1325473445- },- "pretax_credit_amounts": [],- "pricing": {- "price_details": {- "price": "price_NORMALIZED",- "product": "prod_NORMALIZED"- },- "type": "price_details",- "unit_amount_decimal": "8000"- },- "quantity": 6,- "taxes": []- }- ],- "has_more": false,- "object": "list",- "total_count": 1,- "url": "/v1/invoices/upgrade_by_card--Event.list.3.json/lines"- },- "livemode": false,- "metadata": {- "billing_schedule": "1",- "current_plan_id": "None",- "license_management": "automatic",- "licenses": "6",- "on_free_trial": "False",- "plan_tier": "1",- "user_id": "10"- },- "next_payment_attempt": null,- "number": "NORMALIZED",- "object": "invoice",- "on_behalf_of": null,- "parent": null,- "payment_settings": {- "default_mandate": null,- "payment_method_options": null,- "payment_method_types": null- },- "period_end": 1000000000,- "period_start": 1000000000,- "post_payment_credit_notes_amount": 0,- "pre_payment_credit_notes_amount": 0,- "receipt_number": null,- "rendering": {- "amount_tax_display": null,- "pdf": {- "page_size": "letter"- },- "template": null,- "template_version": null- },- "shipping_cost": null,- "shipping_details": null,- "starting_balance": 0,- "statement_descriptor": "Zulip Cloud Standard",- "status": "paid",- "status_transitions": {- "finalized_at": 1000000000,- "marked_uncollectible_at": null,- "paid_at": 1000000000,- "voided_at": null- },- "subtotal": 48000,- "subtotal_excluding_tax": 48000,- "test_clock": null,- "total": 48000,- "total_discount_amounts": [],- "total_excluding_tax": 48000,- "total_pretax_credit_amounts": [],- "total_taxes": [],- "webhooks_delivered_at": null- },- "previous_attributes": {- "amount_paid": 0,- "amount_remaining": 48000,- "attempt_count": 0,- "attempted": false,- "status": "open",- "status_transitions": {- "paid_at": null- }- }- },- "id": "upgrade_by_card--Event.list.4.json",- "livemode": false,- "object": "event",- "pending_webhooks": 0,- "request": {- "id": "upgrade_by_card--Event.list.3.json",- "idempotency_key": "00000000-0000-0000-0000-000000000000"- },- "type": "invoice.updated"- }- ],- "has_more": false,- "object": "list",- "url": "/v1/events"-}diff --git a/corporate/tests/stripe_fixtures/upgrade_by_card--Event.list.5.json b/corporate/tests/stripe_fixtures/upgrade_by_card--Event.list.5.jsondeleted file mode 100644index 6d922067afe..00000000000--- a/corporate/tests/stripe_fixtures/upgrade_by_card--Event.list.5.json+++ /dev/null@@ -1,6 +0,0 @@-{- "data": [],- "has_more": false,- "object": "list",- "url": "/v1/events"-}diff --git a/corporate/tests/stripe_fixtures/upgrade_by_card--Invoice.create.1.json b/corporate/tests/stripe_fixtures/upgrade_by_card--Invoice.create.1.jsonindex 406b7400dbb..abe1125761a 100644--- a/corporate/tests/stripe_fixtures/upgrade_by_card--Invoice.create.1.json+++ b/corporate/tests/stripe_fixtures/upgrade_by_card--Invoice.create.1.json@@ -43,7 +43,7 @@"footer": null,"from_invoice": null,"hosted_invoice_url": null,- "id": "upgrade_by_card--Event.list.3.json",+ "id": "upgrade_by_card--Event.list.1.json","invoice_pdf": null,"issuer": {"type": "self"@@ -55,7 +55,7 @@"has_more": false,"object": "list","total_count": 0,- "url": "/v1/invoices/upgrade_by_card--Event.list.3.json/lines"+ "url": "/v1/invoices/upgrade_by_card--Event.list.1.json/lines"},"livemode": false,"metadata": {diff --git a/corporate/tests/stripe_fixtures/upgrade_by_card--Invoice.finalize_invoice.1.json b/corporate/tests/stripe_fixtures/upgrade_by_card--Invoice.finalize_invoice.1.jsonindex 48300fcb833..b1d961eb468 100644--- a/corporate/tests/stripe_fixtures/upgrade_by_card--Invoice.finalize_invoice.1.json+++ b/corporate/tests/stripe_fixtures/upgrade_by_card--Invoice.finalize_invoice.1.json@@ -43,7 +43,7 @@"footer": null,"from_invoice": null,"hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED/test_NORMALIZED?s=ap",- "id": "upgrade_by_card--Event.list.3.json",+ "id": "upgrade_by_card--Event.list.1.json","invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED/test_NORMALIZED/pdf?s=ap","issuer": {"type": "self"@@ -59,14 +59,14 @@"discount_amounts": [],"discountable": false,"discounts": [],- "id": "upgrade_by_card--Event.list.3.json",- "invoice": "upgrade_by_card--Event.list.3.json",+ "id": "upgrade_by_card--Event.list.1.json",+ "invoice": "upgrade_by_card--Event.list.1.json","livemode": false,"metadata": {},"object": "line_item","parent": {"invoice_item_details": {- "invoice_item": "upgrade_by_card--Event.list.3.json",+ "invoice_item": "upgrade_by_card--Event.list.1.json","proration": false,"proration_details": {"credited_items": null@@ -96,7 +96,7 @@"has_more": false,"object": "list","total_count": 1,- "url": "/v1/invoices/upgrade_by_card--Event.list.3.json/lines"+ "url": "/v1/invoices/upgrade_by_card--Event.list.1.json/lines"},"livemode": false,"metadata": {diff --git a/corporate/tests/stripe_fixtures/upgrade_by_card--Invoice.list.2.json b/corporate/tests/stripe_fixtures/upgrade_by_card--Invoice.list.2.jsonindex 25f5119bc4a..40acea2f110 100644--- a/corporate/tests/stripe_fixtures/upgrade_by_card--Invoice.list.2.json+++ b/corporate/tests/stripe_fixtures/upgrade_by_card--Invoice.list.2.json@@ -45,7 +45,7 @@"footer": null,"from_invoice": null,"hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED/test_NORMALIZED?s=ap",- "id": "upgrade_by_card--Event.list.3.json",+ "id": "upgrade_by_card--Event.list.1.json","invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED/test_NORMALIZED/pdf?s=ap","issuer": {"type": "self"@@ -61,14 +61,14 @@"discount_amounts": [],"discountable": false,"discounts": [],- "id": "upgrade_by_card--Event.list.3.json",- "invoice": "upgrade_by_card--Event.list.3.json",+ "id": "upgrade_by_card--Event.list.1.json",+ "invoice": "upgrade_by_card--Event.list.1.json","livemode": false,"metadata": {},"object": "line_item","parent": {"invoice_item_details": {- "invoice_item": "upgrade_by_card--Event.list.3.json",+ "invoice_item": "upgrade_by_card--Event.list.1.json","proration": false,"proration_details": {"credited_items": null@@ -98,7 +98,7 @@"has_more": false,"object": "list","total_count": 1,- "url": "/v1/invoices/upgrade_by_card--Event.list.3.json/lines"+ "url": "/v1/invoices/upgrade_by_card--Event.list.1.json/lines"},"livemode": false,"metadata": {diff --git a/corporate/tests/stripe_fixtures/upgrade_by_card--Invoice.pay.1.json b/corporate/tests/stripe_fixtures/upgrade_by_card--Invoice.pay.1.jsonindex 0d296b95192..1e34ad0b7e2 100644--- a/corporate/tests/stripe_fixtures/upgrade_by_card--Invoice.pay.1.json+++ b/corporate/tests/stripe_fixtures/upgrade_by_card--Invoice.pay.1.json@@ -43,7 +43,7 @@"footer": null,"from_invoice": null,"hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED/test_NORMALIZED?s=ap",- "id": "upgrade_by_card--Event.list.3.json",+ "id": "upgrade_by_card--Event.list.1.json","invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED/test_NORMALIZED/pdf?s=ap","issuer": {"type": "self"@@ -59,14 +59,14 @@"discount_amounts": [],"discountable": false,"discounts": [],- "id": "upgrade_by_card--Event.list.3.json",- "invoice": "upgrade_by_card--Event.list.3.json",+ "id": "upgrade_by_card--Event.list.1.json",+ "invoice": "upgrade_by_card--Event.list.1.json","livemode": false,"metadata": {},"object": "line_item","parent": {"invoice_item_details": {- "invoice_item": "upgrade_by_card--Event.list.3.json",+ "invoice_item": "upgrade_by_card--Event.list.1.json","proration": false,"proration_details": {"credited_items": null@@ -96,7 +96,7 @@"has_more": false,"object": "list","total_count": 1,- "url": "/v1/invoices/upgrade_by_card--Event.list.3.json/lines"+ "url": "/v1/invoices/upgrade_by_card--Event.list.1.json/lines"},"livemode": false,"metadata": {diff --git a/corporate/tests/stripe_fixtures/upgrade_by_card--InvoiceItem.create.1.json b/corporate/tests/stripe_fixtures/upgrade_by_card--InvoiceItem.create.1.jsonindex 16471e29739..73666ca5af5 100644--- a/corporate/tests/stripe_fixtures/upgrade_by_card--InvoiceItem.create.1.json+++ b/corporate/tests/stripe_fixtures/upgrade_by_card--InvoiceItem.create.1.json@@ -6,8 +6,8 @@"description": "Zulip Cloud Standard","discountable": false,"discounts": [],- "id": "upgrade_by_card--Event.list.3.json",- "invoice": "upgrade_by_card--Event.list.3.json",+ "id": "upgrade_by_card--Event.list.1.json",+ "invoice": "upgrade_by_card--Event.list.1.json","livemode": false,"metadata": {},"net_amount": 48000,diff --git a/corporate/tests/test_stripe.py b/corporate/tests/test_stripe.pyindex 11564acb0e6..a7f40d31c4f 100644--- a/corporate/tests/test_stripe.py+++ b/corporate/tests/test_stripe.py@@ -1010,7 +1010,7 @@ class StripeTest(StripeTestCase):self.assertEqual(customer_plan.status, CustomerPlan.FREE_TRIAL)self.assertEqual(customer_plan.next_invoice_date, free_trial_end_date)- [last_event] = iter(stripe.Event.list(limit=1))+ cursor = self.pin_event_cursor()last_renewal_ledger = (LicenseLedger.objects.filter(plan=plan, is_renewal=True).order_by("-id").first())@@ -1023,7 +1023,7 @@ class StripeTest(StripeTestCase):# Customer pays the invoiceassert invoice.id is not Nonestripe.Invoice.pay(invoice.id, paid_out_of_band=True)- self.send_stripe_webhook_events(last_event, "invoice.paid")+ self.send_stripe_webhook_events(cursor, "invoice.paid")with time_machine.travel(self.now, tick=False):response = self.client_get("/billing/")@@ -1206,11 +1206,11 @@ class StripeTest(StripeTestCase):self.assertEqual(customer_plan.status, CustomerPlan.FREE_TRIAL)self.assertEqual(customer_plan.next_invoice_date, free_trial_end_date)- [last_event] = iter(stripe.Event.list(limit=1))+ cursor = self.pin_event_cursor()# Customer pays the invoiceassert invoice.id is not Nonestripe.Invoice.pay(invoice.id, paid_out_of_band=True)- self.send_stripe_webhook_events(last_event, "invoice.paid")+ self.send_stripe_webhook_events(cursor, "invoice.paid")with time_machine.travel(self.now, tick=False):response = self.client_get("/billing/")@@ -1404,10 +1404,10 @@ class StripeTest(StripeTestCase):)# Customer decides to pay later- [last_event] = iter(stripe.Event.list(limit=1))+ cursor = self.pin_event_cursor()assert invoice.id is not Nonestripe.Invoice.pay(invoice.id, paid_out_of_band=True)- self.send_stripe_webhook_events(last_event, "invoice.paid")+ self.send_stripe_webhook_events(cursor, "invoice.paid")invoice_plans_as_needed(free_trial_end_date)CustomerPlan.objects.get(customer=customer, status=CustomerPlan.ACTIVE)@@ -1651,7 +1651,7 @@ class StripeTest(StripeTestCase):self.login_user(hamlet)self.add_card_to_customer_for_upgrade()- [stripe_event_before_upgrade] = iter(stripe.Event.list(limit=1))+ cursor_before_upgrade = self.pin_event_cursor()hamlet_upgrade_page_response = self.client_get("/upgrade/")self.client_billing_post("/billing/upgrade",@@ -1690,7 +1690,7 @@ class StripeTest(StripeTestCase):)with self.assertLogs("corporate.stripe", "WARNING"):- self.send_stripe_webhook_events(stripe_event_before_upgrade)+ self.send_stripe_webhook_events(cursor_before_upgrade)assert hamlet_invoice.id is not Noneself.assert_details_of_valid_invoice_payment_from_event_status_endpoint(@@ -4440,6 +4440,26 @@ class StripeWebhookEndpointTest(ZulipTestCase):)self.assertEqual(error_log.output, [f"ERROR:corporate.stripe:{expected_error_message}"])+ def test_stripe_webhook_drops_unhandled_event_type(self) -> None:+ # The polling loop when generating test fixtures filters down to+ # HANDLED_STRIPE_EVENT_TYPES, so saved test fixtures never carry+ # unhandled types, but Stripe will still POST other types in+ # production. The webhook view must send a 200 response for+ # those events without touching the database.+ unhandled_event_data = {+ "id": "stripe_event_id",+ "api_version": STRIPE_API_VERSION,+ "type": "invoice.updated",+ "data": {"object": {"object": "invoice", "id": "stripe_invoice_id"}},+ }+ result = self.client_post(+ "/stripe/webhook/",+ unhandled_event_data,+ content_type="application/json",+ )+ self.assertEqual(result.status_code, 200)+ self.assert_length(Event.objects.all(), 0)+def test_stripe_webhook_for_session_completed_event(self) -> None:# We don't process sessions for which we don't have a `Session` entry.valid_session_event_data = {