Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

test_stripe: Add end-to-end test for RemoteRealm billing flow.

Prakhar Pratyush1588f49b4f9f
diff --git a/corporate/lib/stripe.py b/corporate/lib/stripe.py
index 059e7e0e1e4..160b1e6735f 100644
--- a/corporate/lib/stripe.py
+++ b/corporate/lib/stripe.py
@@ -3384,7 +3384,7 @@ class RemoteRealmBillingSession(BillingSession):
self.remote_realm.save(update_fields=["org_type"])
@override
- def sync_license_ledger_if_needed(self) -> None: # nocoverage
+ def sync_license_ledger_if_needed(self) -> None:
last_ledger = self.get_last_ledger_for_automanaged_plan_if_exists()
if last_ledger is None:
return
@@ -3406,7 +3406,7 @@ class RemoteRealmBillingSession(BillingSession):
current_plan, audit_log.event_time
)
if end_of_cycle_plan is None:
- return
+ return # nocoverage
current_plan = end_of_cycle_plan
def get_push_service_validity_dict(self) -> RemoteRealmDictValue:
diff --git a/corporate/tests/stripe_fixtures/non_sponsorship_billing--Customer.create.1.json b/corporate/tests/stripe_fixtures/non_sponsorship_billing--Customer.create.1.json
new file mode 100644
index 00000000000..a9f571a450f
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/non_sponsorship_billing--Customer.create.1.json
@@ -0,0 +1,33 @@
+{
+ "address": null,
+ "balance": 0,
+ "created": 1702576334,
+ "currency": null,
+ "default_currency": null,
+ "default_source": null,
+ "delinquent": false,
+ "description": "zulip.testserver 8bb4095c-58a",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_PBgRA4C5R3pi4D",
+ "invoice_prefix": "3F94EF3A",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": null,
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "remote_realm_host": "zulip.testserver",
+ "remote_realm_uuid": "8bb4095c-58a8-42b8-afd4-9d92e91691e5"
+ },
+ "name": null,
+ "next_invoice_sequence": 1,
+ "object": "customer",
+ "phone": null,
+ "preferred_locales": [],
+ "shipping": null,
+ "tax_exempt": "none",
+ "test_clock": null
+}
diff --git a/corporate/tests/stripe_fixtures/non_sponsorship_billing--Customer.modify.1.json b/corporate/tests/stripe_fixtures/non_sponsorship_billing--Customer.modify.1.json
new file mode 100644
index 00000000000..cd9f838240f
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/non_sponsorship_billing--Customer.modify.1.json
@@ -0,0 +1,33 @@
+{
+ "address": null,
+ "balance": 0,
+ "created": 1702576334,
+ "currency": null,
+ "default_currency": null,
+ "default_source": null,
+ "delinquent": false,
+ "description": "zulip.testserver 8bb4095c-58a",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_PBgRA4C5R3pi4D",
+ "invoice_prefix": "3F94EF3A",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": "pm_1ONJ51DEQaroqDjs55u0UX9G",
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "remote_realm_host": "zulip.testserver",
+ "remote_realm_uuid": "8bb4095c-58a8-42b8-afd4-9d92e91691e5"
+ },
+ "name": null,
+ "next_invoice_sequence": 1,
+ "object": "customer",
+ "phone": null,
+ "preferred_locales": [],
+ "shipping": null,
+ "tax_exempt": "none",
+ "test_clock": null
+}
diff --git a/corporate/tests/stripe_fixtures/non_sponsorship_billing--Customer.retrieve.1.json b/corporate/tests/stripe_fixtures/non_sponsorship_billing--Customer.retrieve.1.json
new file mode 100644
index 00000000000..ca0780edce3
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/non_sponsorship_billing--Customer.retrieve.1.json
@@ -0,0 +1,79 @@
+{
+ "address": null,
+ "balance": 0,
+ "created": 1702576334,
+ "currency": null,
+ "default_currency": null,
+ "default_source": null,
+ "delinquent": false,
+ "description": "zulip.testserver 8bb4095c-58a",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_PBgRA4C5R3pi4D",
+ "invoice_prefix": "3F94EF3A",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": {
+ "billing_details": {
+ "address": {
+ "city": null,
+ "country": null,
+ "line1": null,
+ "line2": null,
+ "postal_code": null,
+ "state": null
+ },
+ "email": null,
+ "name": null,
+ "phone": null
+ },
+ "card": {
+ "brand": "visa",
+ "checks": {
+ "address_line1_check": null,
+ "address_postal_code_check": null,
+ "cvc_check": "pass"
+ },
+ "country": "US",
+ "exp_month": 12,
+ "exp_year": 2024,
+ "fingerprint": "9XKsMixKBi6kIIzd",
+ "funding": "credit",
+ "generated_from": null,
+ "last4": "4242",
+ "networks": {
+ "available": [
+ "visa"
+ ],
+ "preferred": null
+ },
+ "three_d_secure_usage": {
+ "supported": true
+ },
+ "wallet": null
+ },
+ "created": 1702576335,
+ "customer": "cus_PBgRA4C5R3pi4D",
+ "id": "pm_1ONJ51DEQaroqDjs55u0UX9G",
+ "livemode": false,
+ "metadata": {},
+ "object": "payment_method",
+ "type": "card"
+ },
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "remote_realm_host": "zulip.testserver",
+ "remote_realm_uuid": "8bb4095c-58a8-42b8-afd4-9d92e91691e5"
+ },
+ "name": null,
+ "next_invoice_sequence": 1,
+ "object": "customer",
+ "phone": null,
+ "preferred_locales": [],
+ "shipping": null,
+ "tax_exempt": "none",
+ "test_clock": null
+}
diff --git a/corporate/tests/stripe_fixtures/non_sponsorship_billing--Customer.retrieve.2.json b/corporate/tests/stripe_fixtures/non_sponsorship_billing--Customer.retrieve.2.json
new file mode 100644
index 00000000000..ca0780edce3
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/non_sponsorship_billing--Customer.retrieve.2.json
@@ -0,0 +1,79 @@
+{
+ "address": null,
+ "balance": 0,
+ "created": 1702576334,
+ "currency": null,
+ "default_currency": null,
+ "default_source": null,
+ "delinquent": false,
+ "description": "zulip.testserver 8bb4095c-58a",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_PBgRA4C5R3pi4D",
+ "invoice_prefix": "3F94EF3A",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": {
+ "billing_details": {
+ "address": {
+ "city": null,
+ "country": null,
+ "line1": null,
+ "line2": null,
+ "postal_code": null,
+ "state": null
+ },
+ "email": null,
+ "name": null,
+ "phone": null
+ },
+ "card": {
+ "brand": "visa",
+ "checks": {
+ "address_line1_check": null,
+ "address_postal_code_check": null,
+ "cvc_check": "pass"
+ },
+ "country": "US",
+ "exp_month": 12,
+ "exp_year": 2024,
+ "fingerprint": "9XKsMixKBi6kIIzd",
+ "funding": "credit",
+ "generated_from": null,
+ "last4": "4242",
+ "networks": {
+ "available": [
+ "visa"
+ ],
+ "preferred": null
+ },
+ "three_d_secure_usage": {
+ "supported": true
+ },
+ "wallet": null
+ },
+ "created": 1702576335,
+ "customer": "cus_PBgRA4C5R3pi4D",
+ "id": "pm_1ONJ51DEQaroqDjs55u0UX9G",
+ "livemode": false,
+ "metadata": {},
+ "object": "payment_method",
+ "type": "card"
+ },
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "remote_realm_host": "zulip.testserver",
+ "remote_realm_uuid": "8bb4095c-58a8-42b8-afd4-9d92e91691e5"
+ },
+ "name": null,
+ "next_invoice_sequence": 1,
+ "object": "customer",
+ "phone": null,
+ "preferred_locales": [],
+ "shipping": null,
+ "tax_exempt": "none",
+ "test_clock": null
+}
diff --git a/corporate/tests/stripe_fixtures/non_sponsorship_billing--Customer.retrieve.3.json b/corporate/tests/stripe_fixtures/non_sponsorship_billing--Customer.retrieve.3.json
new file mode 100644
index 00000000000..ca0780edce3
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/non_sponsorship_billing--Customer.retrieve.3.json
@@ -0,0 +1,79 @@
+{
+ "address": null,
+ "balance": 0,
+ "created": 1702576334,
+ "currency": null,
+ "default_currency": null,
+ "default_source": null,
+ "delinquent": false,
+ "description": "zulip.testserver 8bb4095c-58a",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_PBgRA4C5R3pi4D",
+ "invoice_prefix": "3F94EF3A",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": {
+ "billing_details": {
+ "address": {
+ "city": null,
+ "country": null,
+ "line1": null,
+ "line2": null,
+ "postal_code": null,
+ "state": null
+ },
+ "email": null,
+ "name": null,
+ "phone": null
+ },
+ "card": {
+ "brand": "visa",
+ "checks": {
+ "address_line1_check": null,
+ "address_postal_code_check": null,
+ "cvc_check": "pass"
+ },
+ "country": "US",
+ "exp_month": 12,
+ "exp_year": 2024,
+ "fingerprint": "9XKsMixKBi6kIIzd",
+ "funding": "credit",
+ "generated_from": null,
+ "last4": "4242",
+ "networks": {
+ "available": [
+ "visa"
+ ],
+ "preferred": null
+ },
+ "three_d_secure_usage": {
+ "supported": true
+ },
+ "wallet": null
+ },
+ "created": 1702576335,
+ "customer": "cus_PBgRA4C5R3pi4D",
+ "id": "pm_1ONJ51DEQaroqDjs55u0UX9G",
+ "livemode": false,
+ "metadata": {},
+ "object": "payment_method",
+ "type": "card"
+ },
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "remote_realm_host": "zulip.testserver",
+ "remote_realm_uuid": "8bb4095c-58a8-42b8-afd4-9d92e91691e5"
+ },
+ "name": null,
+ "next_invoice_sequence": 1,
+ "object": "customer",
+ "phone": null,
+ "preferred_locales": [],
+ "shipping": null,
+ "tax_exempt": "none",
+ "test_clock": null
+}
diff --git a/corporate/tests/stripe_fixtures/non_sponsorship_billing--Customer.retrieve.4.json b/corporate/tests/stripe_fixtures/non_sponsorship_billing--Customer.retrieve.4.json
new file mode 100644
index 00000000000..ca0780edce3
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/non_sponsorship_billing--Customer.retrieve.4.json
@@ -0,0 +1,79 @@
+{
+ "address": null,
+ "balance": 0,
+ "created": 1702576334,
+ "currency": null,
+ "default_currency": null,
+ "default_source": null,
+ "delinquent": false,
+ "description": "zulip.testserver 8bb4095c-58a",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_PBgRA4C5R3pi4D",
+ "invoice_prefix": "3F94EF3A",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": {
+ "billing_details": {
+ "address": {
+ "city": null,
+ "country": null,
+ "line1": null,
+ "line2": null,
+ "postal_code": null,
+ "state": null
+ },
+ "email": null,
+ "name": null,
+ "phone": null
+ },
+ "card": {
+ "brand": "visa",
+ "checks": {
+ "address_line1_check": null,
+ "address_postal_code_check": null,
+ "cvc_check": "pass"
+ },
+ "country": "US",
+ "exp_month": 12,
+ "exp_year": 2024,
+ "fingerprint": "9XKsMixKBi6kIIzd",
+ "funding": "credit",
+ "generated_from": null,
+ "last4": "4242",
+ "networks": {
+ "available": [
+ "visa"
+ ],
+ "preferred": null
+ },
+ "three_d_secure_usage": {
+ "supported": true
+ },
+ "wallet": null
+ },
+ "created": 1702576335,
+ "customer": "cus_PBgRA4C5R3pi4D",
+ "id": "pm_1ONJ51DEQaroqDjs55u0UX9G",
+ "livemode": false,
+ "metadata": {},
+ "object": "payment_method",
+ "type": "card"
+ },
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "remote_realm_host": "zulip.testserver",
+ "remote_realm_uuid": "8bb4095c-58a8-42b8-afd4-9d92e91691e5"
+ },
+ "name": null,
+ "next_invoice_sequence": 1,
+ "object": "customer",
+ "phone": null,
+ "preferred_locales": [],
+ "shipping": null,
+ "tax_exempt": "none",
+ "test_clock": null
+}
diff --git a/corporate/tests/stripe_fixtures/non_sponsorship_billing--Customer.retrieve.5.json b/corporate/tests/stripe_fixtures/non_sponsorship_billing--Customer.retrieve.5.json
new file mode 100644
index 00000000000..e62154affaf
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/non_sponsorship_billing--Customer.retrieve.5.json
@@ -0,0 +1,79 @@
+{
+ "address": null,
+ "balance": 0,
+ "created": 1702576334,
+ "currency": "usd",
+ "default_currency": "usd",
+ "default_source": null,
+ "delinquent": false,
+ "description": "zulip.testserver 8bb4095c-58a",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_PBgRA4C5R3pi4D",
+ "invoice_prefix": "3F94EF3A",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": {
+ "billing_details": {
+ "address": {
+ "city": null,
+ "country": null,
+ "line1": null,
+ "line2": null,
+ "postal_code": null,
+ "state": null
+ },
+ "email": null,
+ "name": null,
+ "phone": null
+ },
+ "card": {
+ "brand": "visa",
+ "checks": {
+ "address_line1_check": null,
+ "address_postal_code_check": null,
+ "cvc_check": "pass"
+ },
+ "country": "US",
+ "exp_month": 12,
+ "exp_year": 2024,
+ "fingerprint": "9XKsMixKBi6kIIzd",
+ "funding": "credit",
+ "generated_from": null,
+ "last4": "4242",
+ "networks": {
+ "available": [
+ "visa"
+ ],
+ "preferred": null
+ },
+ "three_d_secure_usage": {
+ "supported": true
+ },
+ "wallet": null
+ },
+ "created": 1702576335,
+ "customer": "cus_PBgRA4C5R3pi4D",
+ "id": "pm_1ONJ51DEQaroqDjs55u0UX9G",
+ "livemode": false,
+ "metadata": {},
+ "object": "payment_method",
+ "type": "card"
+ },
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "remote_realm_host": "zulip.testserver",
+ "remote_realm_uuid": "8bb4095c-58a8-42b8-afd4-9d92e91691e5"
+ },
+ "name": null,
+ "next_invoice_sequence": 2,
+ "object": "customer",
+ "phone": null,
+ "preferred_locales": [],
+ "shipping": null,
+ "tax_exempt": "none",
+ "test_clock": null
+}
diff --git a/corporate/tests/stripe_fixtures/non_sponsorship_billing--Event.list.1.json b/corporate/tests/stripe_fixtures/non_sponsorship_billing--Event.list.1.json
new file mode 100644
index 00000000000..631a36eb0ba
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/non_sponsorship_billing--Event.list.1.json
@@ -0,0 +1,60 @@
+{
+ "data": [
+ {
+ "api_version": "2020-08-27",
+ "created": 1702576337,
+ "data": {
+ "object": {
+ "address": null,
+ "balance": 0,
+ "created": 1702576334,
+ "currency": null,
+ "default_currency": null,
+ "default_source": null,
+ "delinquent": false,
+ "description": "zulip.testserver 8bb4095c-58a",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_PBgRA4C5R3pi4D",
+ "invoice_prefix": "3F94EF3A",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": "pm_1ONJ51DEQaroqDjs55u0UX9G",
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "remote_realm_host": "zulip.testserver",
+ "remote_realm_uuid": "8bb4095c-58a8-42b8-afd4-9d92e91691e5"
+ },
+ "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": "evt_1ONJ53DEQaroqDjs6X8RdGoG",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 0,
+ "request": {
+ "id": "req_wwsRfdUsURvz0x",
+ "idempotency_key": "a708c9c9-d37a-45a2-a538-c68f7bab7c4f"
+ },
+ "type": "customer.updated"
+ }
+ ],
+ "has_more": true,
+ "object": "list",
+ "url": "/v1/events"
+}
diff --git a/corporate/tests/stripe_fixtures/non_sponsorship_billing--Event.list.2.json b/corporate/tests/stripe_fixtures/non_sponsorship_billing--Event.list.2.json
new file mode 100644
index 00000000000..e2ff6da703f
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/non_sponsorship_billing--Event.list.2.json
@@ -0,0 +1,445 @@
+{
+ "data": [
+ {
+ "api_version": "2020-08-27",
+ "created": 1702576341,
+ "data": {
+ "object": {
+ "amount": 80000,
+ "amount_capturable": 0,
+ "amount_details": {
+ "tip": {}
+ },
+ "amount_received": 80000,
+ "application": null,
+ "application_fee_amount": null,
+ "automatic_payment_methods": null,
+ "canceled_at": null,
+ "cancellation_reason": null,
+ "capture_method": "automatic",
+ "charges": {
+ "data": [
+ {
+ "amount": 80000,
+ "amount_captured": 80000,
+ "amount_refunded": 0,
+ "application": null,
+ "application_fee": null,
+ "application_fee_amount": null,
+ "balance_transaction": "txn_3ONJ56DEQaroqDjs0M2f9IAT",
+ "billing_details": {
+ "address": {
+ "city": null,
+ "country": null,
+ "line1": null,
+ "line2": null,
+ "postal_code": null,
+ "state": null
+ },
+ "email": null,
+ "name": null,
+ "phone": null
+ },
+ "calculated_statement_descriptor": "ZULIP BUSINESS",
+ "captured": true,
+ "created": 1702576341,
+ "currency": "usd",
+ "customer": "cus_PBgRA4C5R3pi4D",
+ "description": "Upgrade to Zulip Business, $80.0 x 10",
+ "destination": null,
+ "dispute": null,
+ "disputed": false,
+ "failure_balance_transaction": null,
+ "failure_code": null,
+ "failure_message": null,
+ "fraud_details": {},
+ "id": "ch_3ONJ56DEQaroqDjs0BpPKMXi",
+ "invoice": null,
+ "livemode": false,
+ "metadata": {
+ "billing_modality": "charge_automatically",
+ "billing_schedule": "1",
+ "license_management": "automatic",
+ "licenses": "10",
+ "plan_tier": "103",
+ "price_per_license": "8000",
+ "remote_realm_host": "zulip.testserver",
+ "remote_realm_user_email": "[email protected]",
+ "remote_realm_user_id": "1",
+ "seat_count": "10",
+ "type": "upgrade"
+ },
+ "object": "charge",
+ "on_behalf_of": null,
+ "order": null,
+ "outcome": {
+ "network_status": "approved_by_network",
+ "reason": null,
+ "risk_level": "normal",
+ "risk_score": 42,
+ "seller_message": "Payment complete.",
+ "type": "authorized"
+ },
+ "paid": true,
+ "payment_intent": "pi_3ONJ56DEQaroqDjs0GqTybKR",
+ "payment_method": "pm_1ONJ51DEQaroqDjs55u0UX9G",
+ "payment_method_details": {
+ "card": {
+ "amount_authorized": 80000,
+ "brand": "visa",
+ "checks": {
+ "address_line1_check": null,
+ "address_postal_code_check": null,
+ "cvc_check": "pass"
+ },
+ "country": "US",
+ "exp_month": 12,
+ "exp_year": 2024,
+ "extended_authorization": {
+ "status": "disabled"
+ },
+ "fingerprint": "9XKsMixKBi6kIIzd",
+ "funding": "credit",
+ "incremental_authorization": {
+ "status": "unavailable"
+ },
+ "installments": null,
+ "last4": "4242",
+ "mandate": null,
+ "multicapture": {
+ "status": "unavailable"
+ },
+ "network": "visa",
+ "network_token": {
+ "used": false
+ },
+ "overcapture": {
+ "maximum_amount_capturable": 80000,
+ "status": "unavailable"
+ },
+ "three_d_secure": null,
+ "wallet": null
+ },
+ "type": "card"
+ },
+ "receipt_email": "[email protected]",
+ "receipt_number": null,
+ "receipt_url": "https://pay.stripe.com/receipts/payment/CAcaFwoVYWNjdF8xN3ZUa3dERVFhcm9xRGpzKNaB7asGMgb_lG0CwDA6LBZCJioPOi6vvS1_5Jah85xVXTVBIwa3Q40b6QRKTkL8y6vv7b6n9LHk73Xx",
+ "refunded": false,
+ "refunds": {
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "total_count": 0,
+ "url": "/v1/charges/ch_3ONJ56DEQaroqDjs0BpPKMXi/refunds"
+ },
+ "review": null,
+ "shipping": null,
+ "source": null,
+ "source_transfer": null,
+ "statement_descriptor": "Zulip Business",
+ "statement_descriptor_suffix": null,
+ "status": "succeeded",
+ "transfer_data": null,
+ "transfer_group": null
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/charges?payment_intent=pi_3ONJ56DEQaroqDjs0GqTybKR"
+ },
+ "client_secret": "pi_3ONJ56DEQaroqDjs0GqTybKR_secret_fPt0ZuASHDpKHmov3pUovneYg",
+ "confirmation_method": "automatic",
+ "created": 1702576340,
+ "currency": "usd",
+ "customer": "cus_PBgRA4C5R3pi4D",
+ "description": "Upgrade to Zulip Business, $80.0 x 10",
+ "id": "pi_3ONJ56DEQaroqDjs0GqTybKR",
+ "invoice": null,
+ "last_payment_error": null,
+ "latest_charge": "ch_3ONJ56DEQaroqDjs0BpPKMXi",
+ "livemode": false,
+ "metadata": {
+ "billing_modality": "charge_automatically",
+ "billing_schedule": "1",
+ "license_management": "automatic",
+ "licenses": "10",
+ "plan_tier": "103",
+ "price_per_license": "8000",
+ "remote_realm_host": "zulip.testserver",
+ "remote_realm_user_email": "[email protected]",
+ "remote_realm_user_id": "1",
+ "seat_count": "10",
+ "type": "upgrade"
+ },
+ "next_action": null,
+ "object": "payment_intent",
+ "on_behalf_of": null,
+ "payment_method": "pm_1ONJ51DEQaroqDjs55u0UX9G",
+ "payment_method_configuration_details": null,
+ "payment_method_options": {
+ "card": {
+ "installments": null,
+ "mandate_options": null,
+ "network": null,
+ "request_three_d_secure": "automatic"
+ }
+ },
+ "payment_method_types": [
+ "card"
+ ],
+ "processing": null,
+ "receipt_email": "[email protected]",
+ "review": null,
+ "setup_future_usage": null,
+ "shipping": null,
+ "source": null,
+ "statement_descriptor": "Zulip Business",
+ "statement_descriptor_suffix": null,
+ "status": "succeeded",
+ "transfer_data": null,
+ "transfer_group": null
+ }
+ },
+ "id": "evt_3ONJ56DEQaroqDjs0F79v5g4",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 0,
+ "request": {
+ "id": "req_8V6izeXwNoDWNV",
+ "idempotency_key": "1cdc58e7-dec7-4356-9b72-61b61a9ed3ed"
+ },
+ "type": "payment_intent.succeeded"
+ },
+ {
+ "api_version": "2020-08-27",
+ "created": 1702576341,
+ "data": {
+ "object": {
+ "amount": 80000,
+ "amount_captured": 80000,
+ "amount_refunded": 0,
+ "application": null,
+ "application_fee": null,
+ "application_fee_amount": null,
+ "balance_transaction": "txn_3ONJ56DEQaroqDjs0M2f9IAT",
+ "billing_details": {
+ "address": {
+ "city": null,
+ "country": null,
+ "line1": null,
+ "line2": null,
+ "postal_code": null,
+ "state": null
+ },
+ "email": null,
+ "name": null,
+ "phone": null
+ },
+ "calculated_statement_descriptor": "ZULIP BUSINESS",
+ "captured": true,
+ "created": 1702576341,
+ "currency": "usd",
+ "customer": "cus_PBgRA4C5R3pi4D",
+ "description": "Upgrade to Zulip Business, $80.0 x 10",
+ "destination": null,
+ "dispute": null,
+ "disputed": false,
+ "failure_balance_transaction": null,
+ "failure_code": null,
+ "failure_message": null,
+ "fraud_details": {},
+ "id": "ch_3ONJ56DEQaroqDjs0BpPKMXi",
+ "invoice": null,
+ "livemode": false,
+ "metadata": {
+ "billing_modality": "charge_automatically",
+ "billing_schedule": "1",
+ "license_management": "automatic",
+ "licenses": "10",
+ "plan_tier": "103",
+ "price_per_license": "8000",
+ "remote_realm_host": "zulip.testserver",
+ "remote_realm_user_email": "[email protected]",
+ "remote_realm_user_id": "1",
+ "seat_count": "10",
+ "type": "upgrade"
+ },
+ "object": "charge",
+ "on_behalf_of": null,
+ "order": null,
+ "outcome": {
+ "network_status": "approved_by_network",
+ "reason": null,
+ "risk_level": "normal",
+ "risk_score": 42,
+ "seller_message": "Payment complete.",
+ "type": "authorized"
+ },
+ "paid": true,
+ "payment_intent": "pi_3ONJ56DEQaroqDjs0GqTybKR",
+ "payment_method": "pm_1ONJ51DEQaroqDjs55u0UX9G",
+ "payment_method_details": {
+ "card": {
+ "amount_authorized": 80000,
+ "brand": "visa",
+ "checks": {
+ "address_line1_check": null,
+ "address_postal_code_check": null,
+ "cvc_check": "pass"
+ },
+ "country": "US",
+ "exp_month": 12,
+ "exp_year": 2024,
+ "extended_authorization": {
+ "status": "disabled"
+ },
+ "fingerprint": "9XKsMixKBi6kIIzd",
+ "funding": "credit",
+ "incremental_authorization": {
+ "status": "unavailable"
+ },
+ "installments": null,
+ "last4": "4242",
+ "mandate": null,
+ "multicapture": {
+ "status": "unavailable"
+ },
+ "network": "visa",
+ "network_token": {
+ "used": false
+ },
+ "overcapture": {
+ "maximum_amount_capturable": 80000,
+ "status": "unavailable"
+ },
+ "three_d_secure": null,
+ "wallet": null
+ },
+ "type": "card"
+ },
+ "receipt_email": "[email protected]",
+ "receipt_number": null,
+ "receipt_url": "https://pay.stripe.com/receipts/payment/CAcaFwoVYWNjdF8xN3ZUa3dERVFhcm9xRGpzKNWB7asGMgZoVpKVI9Y6LBYFiEbfwSeeDRJVYhm1dXIiKeS-mvibLUviHCmDavwS0pBbUflfN5Ei_gW4",
+ "refunded": false,
+ "refunds": {
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "total_count": 0,
+ "url": "/v1/charges/ch_3ONJ56DEQaroqDjs0BpPKMXi/refunds"
+ },
+ "review": null,
+ "shipping": null,
+ "source": null,
+ "source_transfer": null,
+ "statement_descriptor": "Zulip Business",
+ "statement_descriptor_suffix": null,
+ "status": "succeeded",
+ "transfer_data": null,
+ "transfer_group": null
+ }
+ },
+ "id": "evt_3ONJ56DEQaroqDjs0h4RMitN",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 0,
+ "request": {
+ "id": "req_8V6izeXwNoDWNV",
+ "idempotency_key": "1cdc58e7-dec7-4356-9b72-61b61a9ed3ed"
+ },
+ "type": "charge.succeeded"
+ },
+ {
+ "api_version": "2020-08-27",
+ "created": 1702576340,
+ "data": {
+ "object": {
+ "amount": 80000,
+ "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",
+ "charges": {
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "total_count": 0,
+ "url": "/v1/charges?payment_intent=pi_3ONJ56DEQaroqDjs0GqTybKR"
+ },
+ "client_secret": "pi_3ONJ56DEQaroqDjs0GqTybKR_secret_fPt0ZuASHDpKHmov3pUovneYg",
+ "confirmation_method": "automatic",
+ "created": 1702576340,
+ "currency": "usd",
+ "customer": "cus_PBgRA4C5R3pi4D",
+ "description": "Upgrade to Zulip Business, $80.0 x 10",
+ "id": "pi_3ONJ56DEQaroqDjs0GqTybKR",
+ "invoice": null,
+ "last_payment_error": null,
+ "latest_charge": null,
+ "livemode": false,
+ "metadata": {
+ "billing_modality": "charge_automatically",
+ "billing_schedule": "1",
+ "license_management": "automatic",
+ "licenses": "10",
+ "plan_tier": "103",
+ "price_per_license": "8000",
+ "remote_realm_host": "zulip.testserver",
+ "remote_realm_user_email": "[email protected]",
+ "remote_realm_user_id": "1",
+ "seat_count": "10",
+ "type": "upgrade"
+ },
+ "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"
+ }
+ },
+ "payment_method_types": [
+ "card"
+ ],
+ "processing": null,
+ "receipt_email": "[email protected]",
+ "review": null,
+ "setup_future_usage": null,
+ "shipping": null,
+ "source": null,
+ "statement_descriptor": "Zulip Business",
+ "statement_descriptor_suffix": null,
+ "status": "requires_payment_method",
+ "transfer_data": null,
+ "transfer_group": null
+ }
+ },
+ "id": "evt_3ONJ56DEQaroqDjs07vmQzRX",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 2,
+ "request": {
+ "id": "req_8V6izeXwNoDWNV",
+ "idempotency_key": "1cdc58e7-dec7-4356-9b72-61b61a9ed3ed"
+ },
+ "type": "payment_intent.created"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "url": "/v1/events"
+}
diff --git a/corporate/tests/stripe_fixtures/non_sponsorship_billing--Event.list.3.json b/corporate/tests/stripe_fixtures/non_sponsorship_billing--Event.list.3.json
new file mode 100644
index 00000000000..15e823a6104
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/non_sponsorship_billing--Event.list.3.json
@@ -0,0 +1,650 @@
+{
+ "data": [
+ {
+ "api_version": "2020-08-27",
+ "created": 1702576344,
+ "data": {
+ "object": {
+ "account_country": "US",
+ "account_name": "Kandra Labs, Inc.",
+ "account_tax_ids": null,
+ "amount_due": 0,
+ "amount_paid": 0,
+ "amount_remaining": 0,
+ "amount_shipping": 0,
+ "application": null,
+ "application_fee_amount": null,
+ "attempt_count": 0,
+ "attempted": true,
+ "auto_advance": false,
+ "automatic_tax": {
+ "enabled": false,
+ "status": null
+ },
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "charge_automatically",
+ "created": 1702576343,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_PBgRA4C5R3pi4D",
+ "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": null,
+ "discount": null,
+ "discounts": [],
+ "due_date": null,
+ "effective_at": 1702576344,
+ "ending_balance": 0,
+ "footer": null,
+ "from_invoice": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_17vTkwDEQaroqDjs/test_YWNjdF8xN3ZUa3dERVFhcm9xRGpzLF9QQmdTSkNoaFdYRHpYT0E1QVJ1Y09WQ1lTQU9Lclk4LDkzMTE3MTQ102007SAk5Ult?s=ap",
+ "id": "in_1ONJ59DEQaroqDjsUzP2pYN4",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_17vTkwDEQaroqDjs/test_YWNjdF8xN3ZUa3dERVFhcm9xRGpzLF9QQmdTSkNoaFdYRHpYT0E1QVJ1Y09WQ1lTQU9Lclk4LDkzMTE3MTQ102007SAk5Ult/pdf?s=ap",
+ "last_finalization_error": null,
+ "latest_revision": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 80000,
+ "amount_excluding_tax": 80000,
+ "currency": "usd",
+ "description": "Zulip Business",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "il_1ONJ59DEQaroqDjssw1k4VTb",
+ "invoice_item": "ii_1ONJ59DEQaroqDjsWrf7ze7y",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1701482271,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1OIiSpDEQaroqDjsgWEnTxtK",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_P6wL91VQYef5Zp",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 10,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "8000"
+ },
+ {
+ "amount": -80000,
+ "amount_excluding_tax": -80000,
+ "currency": "usd",
+ "description": "Payment (Card ending in 4242)",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "il_1ONJ59DEQaroqDjsM5QX68m5",
+ "invoice_item": "ii_1ONJ58DEQaroqDjs8GcLTLsv",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1702576342,
+ "start": 1702576342
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1700565834,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1OEs3aDEQaroqDjszVnZ9owE",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_OvY3hKgN66WIeP",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": -80000,
+ "unit_amount_decimal": "-80000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 1,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "-80000"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 2,
+ "url": "/v1/invoices/in_1ONJ59DEQaroqDjsUzP2pYN4/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": null,
+ "number": "3F94EF3A-0001",
+ "object": "invoice",
+ "on_behalf_of": null,
+ "paid": true,
+ "paid_out_of_band": false,
+ "payment_intent": null,
+ "payment_settings": {
+ "default_mandate": null,
+ "payment_method_options": null,
+ "payment_method_types": null
+ },
+ "period_end": 1702576343,
+ "period_start": 1702576343,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "quote": null,
+ "receipt_number": null,
+ "rendering": {
+ "amount_tax_display": null,
+ "pdf": {
+ "page_size": "letter"
+ }
+ },
+ "rendering_options": null,
+ "shipping_cost": null,
+ "shipping_details": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Business",
+ "status": "paid",
+ "status_transitions": {
+ "finalized_at": 1702576344,
+ "marked_uncollectible_at": null,
+ "paid_at": 1702576344,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subscription_details": {
+ "metadata": null
+ },
+ "subtotal": 0,
+ "subtotal_excluding_tax": 0,
+ "tax": null,
+ "test_clock": null,
+ "total": 0,
+ "total_discount_amounts": [],
+ "total_excluding_tax": 0,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1702576344
+ },
+ "previous_attributes": {
+ "attempted": false,
+ "auto_advance": true,
+ "effective_at": null,
+ "ending_balance": null,
+ "hosted_invoice_url": null,
+ "invoice_pdf": null,
+ "next_payment_attempt": 1702579943,
+ "number": null,
+ "paid": false,
+ "rendering": {
+ "pdf": {
+ "page_size": "auto"
+ }
+ },
+ "status": "draft",
+ "status_transitions": {
+ "finalized_at": null,
+ "paid_at": null
+ }
+ }
+ },
+ "id": "evt_1ONJ5BDEQaroqDjsYQhfAK8o",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 2,
+ "request": {
+ "id": "req_C4QsvtqC0MULT7",
+ "idempotency_key": "7e929cfa-04e8-4d96-859e-c862f9d8aa0c"
+ },
+ "type": "invoice.updated"
+ },
+ {
+ "api_version": "2020-08-27",
+ "created": 1702576343,
+ "data": {
+ "object": {
+ "account_country": "US",
+ "account_name": "Kandra Labs, Inc.",
+ "account_tax_ids": null,
+ "amount_due": 0,
+ "amount_paid": 0,
+ "amount_remaining": 0,
+ "amount_shipping": 0,
+ "application": null,
+ "application_fee_amount": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "automatic_tax": {
+ "enabled": false,
+ "status": null
+ },
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "charge_automatically",
+ "created": 1702576343,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_PBgRA4C5R3pi4D",
+ "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": null,
+ "discount": null,
+ "discounts": [],
+ "due_date": null,
+ "effective_at": null,
+ "ending_balance": null,
+ "footer": null,
+ "from_invoice": null,
+ "hosted_invoice_url": null,
+ "id": "in_1ONJ59DEQaroqDjsUzP2pYN4",
+ "invoice_pdf": null,
+ "last_finalization_error": null,
+ "latest_revision": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 80000,
+ "amount_excluding_tax": 80000,
+ "currency": "usd",
+ "description": "Zulip Business",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "il_1ONJ59DEQaroqDjssw1k4VTb",
+ "invoice_item": "ii_1ONJ59DEQaroqDjsWrf7ze7y",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1701482271,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1OIiSpDEQaroqDjsgWEnTxtK",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_P6wL91VQYef5Zp",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 10,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "8000"
+ },
+ {
+ "amount": -80000,
+ "amount_excluding_tax": -80000,
+ "currency": "usd",
+ "description": "Payment (Card ending in 4242)",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "il_1ONJ59DEQaroqDjsM5QX68m5",
+ "invoice_item": "ii_1ONJ58DEQaroqDjs8GcLTLsv",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1702576342,
+ "start": 1702576342
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1700565834,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1OEs3aDEQaroqDjszVnZ9owE",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_OvY3hKgN66WIeP",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": -80000,
+ "unit_amount_decimal": "-80000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 1,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "-80000"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 2,
+ "url": "/v1/invoices/in_1ONJ59DEQaroqDjsUzP2pYN4/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": 1702579943,
+ "number": null,
+ "object": "invoice",
+ "on_behalf_of": null,
+ "paid": false,
+ "paid_out_of_band": false,
+ "payment_intent": null,
+ "payment_settings": {
+ "default_mandate": null,
+ "payment_method_options": null,
+ "payment_method_types": null
+ },
+ "period_end": 1702576343,
+ "period_start": 1702576343,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "quote": null,
+ "receipt_number": null,
+ "rendering": {
+ "amount_tax_display": null,
+ "pdf": {
+ "page_size": "auto"
+ }
+ },
+ "rendering_options": null,
+ "shipping_cost": null,
+ "shipping_details": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Business",
+ "status": "draft",
+ "status_transitions": {
+ "finalized_at": null,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subscription_details": {
+ "metadata": null
+ },
+ "subtotal": 0,
+ "subtotal_excluding_tax": 0,
+ "tax": null,
+ "test_clock": null,
+ "total": 0,
+ "total_discount_amounts": [],
+ "total_excluding_tax": 0,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": null
+ }
+ },
+ "id": "evt_1ONJ5ADEQaroqDjsZ0lhyuIF",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 0,
+ "request": {
+ "id": "req_bEUGBI20bpmfLA",
+ "idempotency_key": "b0b89be4-7c1f-448f-8e47-d16aea228cfa"
+ },
+ "type": "invoice.created"
+ },
+ {
+ "api_version": "2020-08-27",
+ "created": 1702576343,
+ "data": {
+ "object": {
+ "amount": 80000,
+ "currency": "usd",
+ "customer": "cus_PBgRA4C5R3pi4D",
+ "date": 1702576343,
+ "description": "Zulip Business",
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_1ONJ59DEQaroqDjsWrf7ze7y",
+ "invoice": null,
+ "livemode": false,
+ "metadata": {},
+ "object": "invoiceitem",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1701482271,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1OIiSpDEQaroqDjsgWEnTxtK",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_P6wL91VQYef5Zp",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 10,
+ "subscription": null,
+ "tax_rates": [],
+ "test_clock": null,
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ }
+ },
+ "id": "evt_1ONJ59DEQaroqDjsXRolg24c",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 0,
+ "request": {
+ "id": "req_qHCiOfgWnK4ggM",
+ "idempotency_key": "d10ca38c-6487-45b4-837a-044cf8e40e20"
+ },
+ "type": "invoiceitem.created"
+ },
+ {
+ "api_version": "2020-08-27",
+ "created": 1702576342,
+ "data": {
+ "object": {
+ "amount": -80000,
+ "currency": "usd",
+ "customer": "cus_PBgRA4C5R3pi4D",
+ "date": 1702576342,
+ "description": "Payment (Card ending in 4242)",
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_1ONJ58DEQaroqDjs8GcLTLsv",
+ "invoice": null,
+ "livemode": false,
+ "metadata": {},
+ "object": "invoiceitem",
+ "period": {
+ "end": 1702576342,
+ "start": 1702576342
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1700565834,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1OEs3aDEQaroqDjszVnZ9owE",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_OvY3hKgN66WIeP",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": -80000,
+ "unit_amount_decimal": "-80000"
+ },
+ "proration": false,
+ "quantity": 1,
+ "subscription": null,
+ "tax_rates": [],
+ "test_clock": null,
+ "unit_amount": -80000,
+ "unit_amount_decimal": "-80000"
+ }
+ },
+ "id": "evt_1ONJ59DEQaroqDjsQM6q8WPT",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 0,
+ "request": {
+ "id": "req_s6u52P6HI1FqZO",
+ "idempotency_key": "65868faa-9cb7-4c6f-a6d0-244c36f96ed4"
+ },
+ "type": "invoiceitem.created"
+ },
+ {
+ "api_version": "2020-08-27",
+ "created": 1702576342,
+ "data": {
+ "object": {
+ "address": null,
+ "balance": 0,
+ "created": 1702576334,
+ "currency": "usd",
+ "default_currency": "usd",
+ "default_source": null,
+ "delinquent": false,
+ "description": "zulip.testserver 8bb4095c-58a",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_PBgRA4C5R3pi4D",
+ "invoice_prefix": "3F94EF3A",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": "pm_1ONJ51DEQaroqDjs55u0UX9G",
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "remote_realm_host": "zulip.testserver",
+ "remote_realm_uuid": "8bb4095c-58a8-42b8-afd4-9d92e91691e5"
+ },
+ "name": null,
+ "next_invoice_sequence": 1,
+ "object": "customer",
+ "phone": null,
+ "preferred_locales": [],
+ "shipping": null,
+ "tax_exempt": "none",
+ "test_clock": null
+ },
+ "previous_attributes": {
+ "currency": null,
+ "default_currency": null
+ }
+ },
+ "id": "evt_1ONJ59DEQaroqDjsSwL1yXix",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 0,
+ "request": {
+ "id": "req_s6u52P6HI1FqZO",
+ "idempotency_key": "65868faa-9cb7-4c6f-a6d0-244c36f96ed4"
+ },
+ "type": "customer.updated"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "url": "/v1/events"
+}
diff --git a/corporate/tests/stripe_fixtures/non_sponsorship_billing--Event.list.4.json b/corporate/tests/stripe_fixtures/non_sponsorship_billing--Event.list.4.json
new file mode 100644
index 00000000000..42236941d15
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/non_sponsorship_billing--Event.list.4.json
@@ -0,0 +1,676 @@
+{
+ "data": [
+ {
+ "api_version": "2020-08-27",
+ "created": 1702576344,
+ "data": {
+ "object": {
+ "account_country": "US",
+ "account_name": "Kandra Labs, Inc.",
+ "account_tax_ids": null,
+ "amount_due": 0,
+ "amount_paid": 0,
+ "amount_remaining": 0,
+ "amount_shipping": 0,
+ "application": null,
+ "application_fee_amount": null,
+ "attempt_count": 0,
+ "attempted": true,
+ "auto_advance": false,
+ "automatic_tax": {
+ "enabled": false,
+ "status": null
+ },
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "charge_automatically",
+ "created": 1702576343,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_PBgRA4C5R3pi4D",
+ "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": null,
+ "discount": null,
+ "discounts": [],
+ "due_date": null,
+ "effective_at": 1702576344,
+ "ending_balance": 0,
+ "footer": null,
+ "from_invoice": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_17vTkwDEQaroqDjs/test_YWNjdF8xN3ZUa3dERVFhcm9xRGpzLF9QQmdTSkNoaFdYRHpYT0E1QVJ1Y09WQ1lTQU9Lclk4LDkzMTE3MTQ102007SAk5Ult?s=ap",
+ "id": "in_1ONJ59DEQaroqDjsUzP2pYN4",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_17vTkwDEQaroqDjs/test_YWNjdF8xN3ZUa3dERVFhcm9xRGpzLF9QQmdTSkNoaFdYRHpYT0E1QVJ1Y09WQ1lTQU9Lclk4LDkzMTE3MTQ102007SAk5Ult/pdf?s=ap",
+ "last_finalization_error": null,
+ "latest_revision": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 80000,
+ "amount_excluding_tax": 80000,
+ "currency": "usd",
+ "description": "Zulip Business",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "il_1ONJ59DEQaroqDjssw1k4VTb",
+ "invoice_item": "ii_1ONJ59DEQaroqDjsWrf7ze7y",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1701482271,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1OIiSpDEQaroqDjsgWEnTxtK",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_P6wL91VQYef5Zp",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 10,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "8000"
+ },
+ {
+ "amount": -80000,
+ "amount_excluding_tax": -80000,
+ "currency": "usd",
+ "description": "Payment (Card ending in 4242)",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "il_1ONJ59DEQaroqDjsM5QX68m5",
+ "invoice_item": "ii_1ONJ58DEQaroqDjs8GcLTLsv",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1702576342,
+ "start": 1702576342
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1700565834,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1OEs3aDEQaroqDjszVnZ9owE",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_OvY3hKgN66WIeP",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": -80000,
+ "unit_amount_decimal": "-80000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 1,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "-80000"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 2,
+ "url": "/v1/invoices/in_1ONJ59DEQaroqDjsUzP2pYN4/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": null,
+ "number": "3F94EF3A-0001",
+ "object": "invoice",
+ "on_behalf_of": null,
+ "paid": true,
+ "paid_out_of_band": false,
+ "payment_intent": null,
+ "payment_settings": {
+ "default_mandate": null,
+ "payment_method_options": null,
+ "payment_method_types": null
+ },
+ "period_end": 1702576343,
+ "period_start": 1702576343,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "quote": null,
+ "receipt_number": null,
+ "rendering": {
+ "amount_tax_display": null,
+ "pdf": {
+ "page_size": "letter"
+ }
+ },
+ "rendering_options": null,
+ "shipping_cost": null,
+ "shipping_details": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Business",
+ "status": "paid",
+ "status_transitions": {
+ "finalized_at": 1702576344,
+ "marked_uncollectible_at": null,
+ "paid_at": 1702576344,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subscription_details": {
+ "metadata": null
+ },
+ "subtotal": 0,
+ "subtotal_excluding_tax": 0,
+ "tax": null,
+ "test_clock": null,
+ "total": 0,
+ "total_discount_amounts": [],
+ "total_excluding_tax": 0,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1702576344
+ }
+ },
+ "id": "evt_1ONJ5BDEQaroqDjsqVWjxUDI",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 2,
+ "request": {
+ "id": "req_C4QsvtqC0MULT7",
+ "idempotency_key": "7e929cfa-04e8-4d96-859e-c862f9d8aa0c"
+ },
+ "type": "invoice.payment_succeeded"
+ },
+ {
+ "api_version": "2020-08-27",
+ "created": 1702576344,
+ "data": {
+ "object": {
+ "account_country": "US",
+ "account_name": "Kandra Labs, Inc.",
+ "account_tax_ids": null,
+ "amount_due": 0,
+ "amount_paid": 0,
+ "amount_remaining": 0,
+ "amount_shipping": 0,
+ "application": null,
+ "application_fee_amount": null,
+ "attempt_count": 0,
+ "attempted": true,
+ "auto_advance": false,
+ "automatic_tax": {
+ "enabled": false,
+ "status": null
+ },
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "charge_automatically",
+ "created": 1702576343,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_PBgRA4C5R3pi4D",
+ "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": null,
+ "discount": null,
+ "discounts": [],
+ "due_date": null,
+ "effective_at": 1702576344,
+ "ending_balance": 0,
+ "footer": null,
+ "from_invoice": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_17vTkwDEQaroqDjs/test_YWNjdF8xN3ZUa3dERVFhcm9xRGpzLF9QQmdTSkNoaFdYRHpYT0E1QVJ1Y09WQ1lTQU9Lclk4LDkzMTE3MTQ102007SAk5Ult?s=ap",
+ "id": "in_1ONJ59DEQaroqDjsUzP2pYN4",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_17vTkwDEQaroqDjs/test_YWNjdF8xN3ZUa3dERVFhcm9xRGpzLF9QQmdTSkNoaFdYRHpYT0E1QVJ1Y09WQ1lTQU9Lclk4LDkzMTE3MTQ102007SAk5Ult/pdf?s=ap",
+ "last_finalization_error": null,
+ "latest_revision": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 80000,
+ "amount_excluding_tax": 80000,
+ "currency": "usd",
+ "description": "Zulip Business",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "il_1ONJ59DEQaroqDjssw1k4VTb",
+ "invoice_item": "ii_1ONJ59DEQaroqDjsWrf7ze7y",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1701482271,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1OIiSpDEQaroqDjsgWEnTxtK",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_P6wL91VQYef5Zp",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 10,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "8000"
+ },
+ {
+ "amount": -80000,
+ "amount_excluding_tax": -80000,
+ "currency": "usd",
+ "description": "Payment (Card ending in 4242)",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "il_1ONJ59DEQaroqDjsM5QX68m5",
+ "invoice_item": "ii_1ONJ58DEQaroqDjs8GcLTLsv",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1702576342,
+ "start": 1702576342
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1700565834,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1OEs3aDEQaroqDjszVnZ9owE",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_OvY3hKgN66WIeP",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": -80000,
+ "unit_amount_decimal": "-80000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 1,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "-80000"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 2,
+ "url": "/v1/invoices/in_1ONJ59DEQaroqDjsUzP2pYN4/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": null,
+ "number": "3F94EF3A-0001",
+ "object": "invoice",
+ "on_behalf_of": null,
+ "paid": true,
+ "paid_out_of_band": false,
+ "payment_intent": null,
+ "payment_settings": {
+ "default_mandate": null,
+ "payment_method_options": null,
+ "payment_method_types": null
+ },
+ "period_end": 1702576343,
+ "period_start": 1702576343,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "quote": null,
+ "receipt_number": null,
+ "rendering": {
+ "amount_tax_display": null,
+ "pdf": {
+ "page_size": "letter"
+ }
+ },
+ "rendering_options": null,
+ "shipping_cost": null,
+ "shipping_details": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Business",
+ "status": "paid",
+ "status_transitions": {
+ "finalized_at": 1702576344,
+ "marked_uncollectible_at": null,
+ "paid_at": 1702576344,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subscription_details": {
+ "metadata": null
+ },
+ "subtotal": 0,
+ "subtotal_excluding_tax": 0,
+ "tax": null,
+ "test_clock": null,
+ "total": 0,
+ "total_discount_amounts": [],
+ "total_excluding_tax": 0,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1702576344
+ }
+ },
+ "id": "evt_1ONJ5BDEQaroqDjs5cCSUBTH",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 0,
+ "request": {
+ "id": "req_C4QsvtqC0MULT7",
+ "idempotency_key": "7e929cfa-04e8-4d96-859e-c862f9d8aa0c"
+ },
+ "type": "invoice.paid"
+ },
+ {
+ "api_version": "2020-08-27",
+ "created": 1702576344,
+ "data": {
+ "object": {
+ "account_country": "US",
+ "account_name": "Kandra Labs, Inc.",
+ "account_tax_ids": null,
+ "amount_due": 0,
+ "amount_paid": 0,
+ "amount_remaining": 0,
+ "amount_shipping": 0,
+ "application": null,
+ "application_fee_amount": null,
+ "attempt_count": 0,
+ "attempted": true,
+ "auto_advance": false,
+ "automatic_tax": {
+ "enabled": false,
+ "status": null
+ },
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "charge_automatically",
+ "created": 1702576343,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_PBgRA4C5R3pi4D",
+ "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": null,
+ "discount": null,
+ "discounts": [],
+ "due_date": null,
+ "effective_at": 1702576344,
+ "ending_balance": 0,
+ "footer": null,
+ "from_invoice": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_17vTkwDEQaroqDjs/test_YWNjdF8xN3ZUa3dERVFhcm9xRGpzLF9QQmdTSkNoaFdYRHpYT0E1QVJ1Y09WQ1lTQU9Lclk4LDkzMTE3MTQ102007SAk5Ult?s=ap",
+ "id": "in_1ONJ59DEQaroqDjsUzP2pYN4",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_17vTkwDEQaroqDjs/test_YWNjdF8xN3ZUa3dERVFhcm9xRGpzLF9QQmdTSkNoaFdYRHpYT0E1QVJ1Y09WQ1lTQU9Lclk4LDkzMTE3MTQ102007SAk5Ult/pdf?s=ap",
+ "last_finalization_error": null,
+ "latest_revision": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 80000,
+ "amount_excluding_tax": 80000,
+ "currency": "usd",
+ "description": "Zulip Business",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "il_1ONJ59DEQaroqDjssw1k4VTb",
+ "invoice_item": "ii_1ONJ59DEQaroqDjsWrf7ze7y",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1701482271,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1OIiSpDEQaroqDjsgWEnTxtK",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_P6wL91VQYef5Zp",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 10,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "8000"
+ },
+ {
+ "amount": -80000,
+ "amount_excluding_tax": -80000,
+ "currency": "usd",
+ "description": "Payment (Card ending in 4242)",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "il_1ONJ59DEQaroqDjsM5QX68m5",
+ "invoice_item": "ii_1ONJ58DEQaroqDjs8GcLTLsv",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1702576342,
+ "start": 1702576342
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1700565834,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1OEs3aDEQaroqDjszVnZ9owE",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_OvY3hKgN66WIeP",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": -80000,
+ "unit_amount_decimal": "-80000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 1,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "-80000"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 2,
+ "url": "/v1/invoices/in_1ONJ59DEQaroqDjsUzP2pYN4/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": null,
+ "number": "3F94EF3A-0001",
+ "object": "invoice",
+ "on_behalf_of": null,
+ "paid": true,
+ "paid_out_of_band": false,
+ "payment_intent": null,
+ "payment_settings": {
+ "default_mandate": null,
+ "payment_method_options": null,
+ "payment_method_types": null
+ },
+ "period_end": 1702576343,
+ "period_start": 1702576343,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "quote": null,
+ "receipt_number": null,
+ "rendering": {
+ "amount_tax_display": null,
+ "pdf": {
+ "page_size": "letter"
+ }
+ },
+ "rendering_options": null,
+ "shipping_cost": null,
+ "shipping_details": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Business",
+ "status": "paid",
+ "status_transitions": {
+ "finalized_at": 1702576344,
+ "marked_uncollectible_at": null,
+ "paid_at": 1702576344,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subscription_details": {
+ "metadata": null
+ },
+ "subtotal": 0,
+ "subtotal_excluding_tax": 0,
+ "tax": null,
+ "test_clock": null,
+ "total": 0,
+ "total_discount_amounts": [],
+ "total_excluding_tax": 0,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1702576344
+ }
+ },
+ "id": "evt_1ONJ5BDEQaroqDjsw0VZxItF",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 0,
+ "request": {
+ "id": "req_C4QsvtqC0MULT7",
+ "idempotency_key": "7e929cfa-04e8-4d96-859e-c862f9d8aa0c"
+ },
+ "type": "invoice.finalized"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "url": "/v1/events"
+}
diff --git a/corporate/tests/stripe_fixtures/non_sponsorship_billing--Event.list.5.json b/corporate/tests/stripe_fixtures/non_sponsorship_billing--Event.list.5.json
new file mode 100644
index 00000000000..6d922067afe
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/non_sponsorship_billing--Event.list.5.json
@@ -0,0 +1,6 @@
+{
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "url": "/v1/events"
+}
diff --git a/corporate/tests/stripe_fixtures/non_sponsorship_billing--Invoice.create.1.json b/corporate/tests/stripe_fixtures/non_sponsorship_billing--Invoice.create.1.json
new file mode 100644
index 00000000000..effea70934f
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/non_sponsorship_billing--Invoice.create.1.json
@@ -0,0 +1,208 @@
+{
+ "account_country": "US",
+ "account_name": "Kandra Labs, Inc.",
+ "account_tax_ids": null,
+ "amount_due": 0,
+ "amount_paid": 0,
+ "amount_remaining": 0,
+ "amount_shipping": 0,
+ "application": null,
+ "application_fee_amount": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "automatic_tax": {
+ "enabled": false,
+ "status": null
+ },
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "charge_automatically",
+ "created": 1702576343,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_PBgRA4C5R3pi4D",
+ "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": null,
+ "discount": null,
+ "discounts": [],
+ "due_date": null,
+ "effective_at": null,
+ "ending_balance": null,
+ "footer": null,
+ "from_invoice": null,
+ "hosted_invoice_url": null,
+ "id": "in_1ONJ59DEQaroqDjsUzP2pYN4",
+ "invoice_pdf": null,
+ "last_finalization_error": null,
+ "latest_revision": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 80000,
+ "amount_excluding_tax": 80000,
+ "currency": "usd",
+ "description": "Zulip Business",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "il_1ONJ59DEQaroqDjssw1k4VTb",
+ "invoice_item": "ii_1ONJ59DEQaroqDjsWrf7ze7y",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1701482271,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1OIiSpDEQaroqDjsgWEnTxtK",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_P6wL91VQYef5Zp",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 10,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "8000"
+ },
+ {
+ "amount": -80000,
+ "amount_excluding_tax": -80000,
+ "currency": "usd",
+ "description": "Payment (Card ending in 4242)",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "il_1ONJ59DEQaroqDjsM5QX68m5",
+ "invoice_item": "ii_1ONJ58DEQaroqDjs8GcLTLsv",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1702576342,
+ "start": 1702576342
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1700565834,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1OEs3aDEQaroqDjszVnZ9owE",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_OvY3hKgN66WIeP",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": -80000,
+ "unit_amount_decimal": "-80000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 1,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "-80000"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 2,
+ "url": "/v1/invoices/in_1ONJ59DEQaroqDjsUzP2pYN4/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": 1702579943,
+ "number": null,
+ "object": "invoice",
+ "on_behalf_of": null,
+ "paid": false,
+ "paid_out_of_band": false,
+ "payment_intent": null,
+ "payment_settings": {
+ "default_mandate": null,
+ "payment_method_options": null,
+ "payment_method_types": null
+ },
+ "period_end": 1702576343,
+ "period_start": 1702576343,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "quote": null,
+ "receipt_number": null,
+ "rendering": {
+ "amount_tax_display": null,
+ "pdf": {
+ "page_size": "auto"
+ }
+ },
+ "rendering_options": null,
+ "shipping_cost": null,
+ "shipping_details": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Business",
+ "status": "draft",
+ "status_transitions": {
+ "finalized_at": null,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subscription_details": {
+ "metadata": null
+ },
+ "subtotal": 0,
+ "subtotal_excluding_tax": 0,
+ "tax": null,
+ "test_clock": null,
+ "total": 0,
+ "total_discount_amounts": [],
+ "total_excluding_tax": 0,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": null
+}
diff --git a/corporate/tests/stripe_fixtures/non_sponsorship_billing--Invoice.finalize_invoice.1.json b/corporate/tests/stripe_fixtures/non_sponsorship_billing--Invoice.finalize_invoice.1.json
new file mode 100644
index 00000000000..b1d0b133398
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/non_sponsorship_billing--Invoice.finalize_invoice.1.json
@@ -0,0 +1,208 @@
+{
+ "account_country": "US",
+ "account_name": "Kandra Labs, Inc.",
+ "account_tax_ids": null,
+ "amount_due": 0,
+ "amount_paid": 0,
+ "amount_remaining": 0,
+ "amount_shipping": 0,
+ "application": null,
+ "application_fee_amount": null,
+ "attempt_count": 0,
+ "attempted": true,
+ "auto_advance": false,
+ "automatic_tax": {
+ "enabled": false,
+ "status": null
+ },
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "charge_automatically",
+ "created": 1702576343,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_PBgRA4C5R3pi4D",
+ "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": null,
+ "discount": null,
+ "discounts": [],
+ "due_date": null,
+ "effective_at": 1702576344,
+ "ending_balance": 0,
+ "footer": null,
+ "from_invoice": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_17vTkwDEQaroqDjs/test_YWNjdF8xN3ZUa3dERVFhcm9xRGpzLF9QQmdTSkNoaFdYRHpYT0E1QVJ1Y09WQ1lTQU9Lclk4LDkzMTE3MTQ00200ynvW9wzF?s=ap",
+ "id": "in_1ONJ59DEQaroqDjsUzP2pYN4",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_17vTkwDEQaroqDjs/test_YWNjdF8xN3ZUa3dERVFhcm9xRGpzLF9QQmdTSkNoaFdYRHpYT0E1QVJ1Y09WQ1lTQU9Lclk4LDkzMTE3MTQ00200ynvW9wzF/pdf?s=ap",
+ "last_finalization_error": null,
+ "latest_revision": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 80000,
+ "amount_excluding_tax": 80000,
+ "currency": "usd",
+ "description": "Zulip Business",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "il_1ONJ59DEQaroqDjssw1k4VTb",
+ "invoice_item": "ii_1ONJ59DEQaroqDjsWrf7ze7y",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1701482271,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1OIiSpDEQaroqDjsgWEnTxtK",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_P6wL91VQYef5Zp",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 10,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "8000"
+ },
+ {
+ "amount": -80000,
+ "amount_excluding_tax": -80000,
+ "currency": "usd",
+ "description": "Payment (Card ending in 4242)",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "il_1ONJ59DEQaroqDjsM5QX68m5",
+ "invoice_item": "ii_1ONJ58DEQaroqDjs8GcLTLsv",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1702576342,
+ "start": 1702576342
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1700565834,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1OEs3aDEQaroqDjszVnZ9owE",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_OvY3hKgN66WIeP",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": -80000,
+ "unit_amount_decimal": "-80000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 1,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "-80000"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 2,
+ "url": "/v1/invoices/in_1ONJ59DEQaroqDjsUzP2pYN4/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": null,
+ "number": "3F94EF3A-0001",
+ "object": "invoice",
+ "on_behalf_of": null,
+ "paid": true,
+ "paid_out_of_band": false,
+ "payment_intent": null,
+ "payment_settings": {
+ "default_mandate": null,
+ "payment_method_options": null,
+ "payment_method_types": null
+ },
+ "period_end": 1702576343,
+ "period_start": 1702576343,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "quote": null,
+ "receipt_number": null,
+ "rendering": {
+ "amount_tax_display": null,
+ "pdf": {
+ "page_size": "letter"
+ }
+ },
+ "rendering_options": null,
+ "shipping_cost": null,
+ "shipping_details": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Business",
+ "status": "paid",
+ "status_transitions": {
+ "finalized_at": 1702576344,
+ "marked_uncollectible_at": null,
+ "paid_at": 1702576344,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subscription_details": {
+ "metadata": null
+ },
+ "subtotal": 0,
+ "subtotal_excluding_tax": 0,
+ "tax": null,
+ "test_clock": null,
+ "total": 0,
+ "total_discount_amounts": [],
+ "total_excluding_tax": 0,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1702576344
+}
diff --git a/corporate/tests/stripe_fixtures/non_sponsorship_billing--Invoice.list.1.json b/corporate/tests/stripe_fixtures/non_sponsorship_billing--Invoice.list.1.json
new file mode 100644
index 00000000000..e39960ab725
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/non_sponsorship_billing--Invoice.list.1.json
@@ -0,0 +1,6 @@
+{
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "url": "/v1/invoices"
+}
diff --git a/corporate/tests/stripe_fixtures/non_sponsorship_billing--InvoiceItem.create.1.json b/corporate/tests/stripe_fixtures/non_sponsorship_billing--InvoiceItem.create.1.json
new file mode 100644
index 00000000000..ddb9d9e39e4
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/non_sponsorship_billing--InvoiceItem.create.1.json
@@ -0,0 +1,47 @@
+{
+ "amount": -80000,
+ "currency": "usd",
+ "customer": "cus_PBgRA4C5R3pi4D",
+ "date": 1702576342,
+ "description": "Payment (Card ending in 4242)",
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_1ONJ58DEQaroqDjs8GcLTLsv",
+ "invoice": null,
+ "livemode": false,
+ "metadata": {},
+ "object": "invoiceitem",
+ "period": {
+ "end": 1702576342,
+ "start": 1702576342
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1700565834,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1OEs3aDEQaroqDjszVnZ9owE",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_OvY3hKgN66WIeP",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": -80000,
+ "unit_amount_decimal": "-80000"
+ },
+ "proration": false,
+ "quantity": 1,
+ "subscription": null,
+ "tax_rates": [],
+ "test_clock": null,
+ "unit_amount": -80000,
+ "unit_amount_decimal": "-80000"
+}
diff --git a/corporate/tests/stripe_fixtures/non_sponsorship_billing--InvoiceItem.create.2.json b/corporate/tests/stripe_fixtures/non_sponsorship_billing--InvoiceItem.create.2.json
new file mode 100644
index 00000000000..a5dbe96af2c
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/non_sponsorship_billing--InvoiceItem.create.2.json
@@ -0,0 +1,47 @@
+{
+ "amount": 80000,
+ "currency": "usd",
+ "customer": "cus_PBgRA4C5R3pi4D",
+ "date": 1702576343,
+ "description": "Zulip Business",
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_1ONJ59DEQaroqDjsWrf7ze7y",
+ "invoice": null,
+ "livemode": false,
+ "metadata": {},
+ "object": "invoiceitem",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1701482271,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1OIiSpDEQaroqDjsgWEnTxtK",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_P6wL91VQYef5Zp",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 10,
+ "subscription": null,
+ "tax_rates": [],
+ "test_clock": null,
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+}
diff --git a/corporate/tests/stripe_fixtures/non_sponsorship_billing--PaymentIntent.create.1.json b/corporate/tests/stripe_fixtures/non_sponsorship_billing--PaymentIntent.create.1.json
new file mode 100644
index 00000000000..4e7ba877756
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/non_sponsorship_billing--PaymentIntent.create.1.json
@@ -0,0 +1,197 @@
+{
+ "amount": 80000,
+ "amount_capturable": 0,
+ "amount_details": {
+ "tip": {}
+ },
+ "amount_received": 80000,
+ "application": null,
+ "application_fee_amount": null,
+ "automatic_payment_methods": null,
+ "canceled_at": null,
+ "cancellation_reason": null,
+ "capture_method": "automatic",
+ "charges": {
+ "data": [
+ {
+ "amount": 80000,
+ "amount_captured": 80000,
+ "amount_refunded": 0,
+ "application": null,
+ "application_fee": null,
+ "application_fee_amount": null,
+ "balance_transaction": "txn_3ONJ56DEQaroqDjs0M2f9IAT",
+ "billing_details": {
+ "address": {
+ "city": null,
+ "country": null,
+ "line1": null,
+ "line2": null,
+ "postal_code": null,
+ "state": null
+ },
+ "email": null,
+ "name": null,
+ "phone": null
+ },
+ "calculated_statement_descriptor": "ZULIP BUSINESS",
+ "captured": true,
+ "created": 1702576341,
+ "currency": "usd",
+ "customer": "cus_PBgRA4C5R3pi4D",
+ "description": "Upgrade to Zulip Business, $80.0 x 10",
+ "destination": null,
+ "dispute": null,
+ "disputed": false,
+ "failure_balance_transaction": null,
+ "failure_code": null,
+ "failure_message": null,
+ "fraud_details": {},
+ "id": "ch_3ONJ56DEQaroqDjs0BpPKMXi",
+ "invoice": null,
+ "livemode": false,
+ "metadata": {
+ "billing_modality": "charge_automatically",
+ "billing_schedule": "1",
+ "license_management": "automatic",
+ "licenses": "10",
+ "plan_tier": "103",
+ "price_per_license": "8000",
+ "remote_realm_host": "zulip.testserver",
+ "remote_realm_user_email": "[email protected]",
+ "remote_realm_user_id": "1",
+ "seat_count": "10",
+ "type": "upgrade"
+ },
+ "object": "charge",
+ "on_behalf_of": null,
+ "order": null,
+ "outcome": {
+ "network_status": "approved_by_network",
+ "reason": null,
+ "risk_level": "normal",
+ "risk_score": 42,
+ "seller_message": "Payment complete.",
+ "type": "authorized"
+ },
+ "paid": true,
+ "payment_intent": "pi_3ONJ56DEQaroqDjs0GqTybKR",
+ "payment_method": "pm_1ONJ51DEQaroqDjs55u0UX9G",
+ "payment_method_details": {
+ "card": {
+ "amount_authorized": 80000,
+ "brand": "visa",
+ "checks": {
+ "address_line1_check": null,
+ "address_postal_code_check": null,
+ "cvc_check": "pass"
+ },
+ "country": "US",
+ "exp_month": 12,
+ "exp_year": 2024,
+ "extended_authorization": {
+ "status": "disabled"
+ },
+ "fingerprint": "9XKsMixKBi6kIIzd",
+ "funding": "credit",
+ "incremental_authorization": {
+ "status": "unavailable"
+ },
+ "installments": null,
+ "last4": "4242",
+ "mandate": null,
+ "multicapture": {
+ "status": "unavailable"
+ },
+ "network": "visa",
+ "network_token": {
+ "used": false
+ },
+ "overcapture": {
+ "maximum_amount_capturable": 80000,
+ "status": "unavailable"
+ },
+ "three_d_secure": null,
+ "wallet": null
+ },
+ "type": "card"
+ },
+ "receipt_email": "[email protected]",
+ "receipt_number": null,
+ "receipt_url": "https://pay.stripe.com/receipts/payment/CAcaFwoVYWNjdF8xN3ZUa3dERVFhcm9xRGpzKNWB7asGMgaQgUMl0uk6LBaI3EDlvb9GkU1rXPQWvth9c8efRC6OUx8tpZgICrb4ST6zwYP4VmG6ZRqq",
+ "refunded": false,
+ "refunds": {
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "total_count": 0,
+ "url": "/v1/charges/ch_3ONJ56DEQaroqDjs0BpPKMXi/refunds"
+ },
+ "review": null,
+ "shipping": null,
+ "source": null,
+ "source_transfer": null,
+ "statement_descriptor": "Zulip Business",
+ "statement_descriptor_suffix": null,
+ "status": "succeeded",
+ "transfer_data": null,
+ "transfer_group": null
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/charges?payment_intent=pi_3ONJ56DEQaroqDjs0GqTybKR"
+ },
+ "client_secret": "pi_3ONJ56DEQaroqDjs0GqTybKR_secret_fPt0ZuASHDpKHmov3pUovneYg",
+ "confirmation_method": "automatic",
+ "created": 1702576340,
+ "currency": "usd",
+ "customer": "cus_PBgRA4C5R3pi4D",
+ "description": "Upgrade to Zulip Business, $80.0 x 10",
+ "id": "pi_3ONJ56DEQaroqDjs0GqTybKR",
+ "invoice": null,
+ "last_payment_error": null,
+ "latest_charge": "ch_3ONJ56DEQaroqDjs0BpPKMXi",
+ "livemode": false,
+ "metadata": {
+ "billing_modality": "charge_automatically",
+ "billing_schedule": "1",
+ "license_management": "automatic",
+ "licenses": "10",
+ "plan_tier": "103",
+ "price_per_license": "8000",
+ "remote_realm_host": "zulip.testserver",
+ "remote_realm_user_email": "[email protected]",
+ "remote_realm_user_id": "1",
+ "seat_count": "10",
+ "type": "upgrade"
+ },
+ "next_action": null,
+ "object": "payment_intent",
+ "on_behalf_of": null,
+ "payment_method": "pm_1ONJ51DEQaroqDjs55u0UX9G",
+ "payment_method_configuration_details": null,
+ "payment_method_options": {
+ "card": {
+ "installments": null,
+ "mandate_options": null,
+ "network": null,
+ "request_three_d_secure": "automatic"
+ }
+ },
+ "payment_method_types": [
+ "card"
+ ],
+ "processing": null,
+ "receipt_email": "[email protected]",
+ "review": null,
+ "setup_future_usage": null,
+ "shipping": null,
+ "source": null,
+ "statement_descriptor": "Zulip Business",
+ "statement_descriptor_suffix": null,
+ "status": "succeeded",
+ "transfer_data": null,
+ "transfer_group": null
+}
diff --git a/corporate/tests/stripe_fixtures/non_sponsorship_billing--SetupIntent.create.1.json b/corporate/tests/stripe_fixtures/non_sponsorship_billing--SetupIntent.create.1.json
new file mode 100644
index 00000000000..bbed0c4ce85
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/non_sponsorship_billing--SetupIntent.create.1.json
@@ -0,0 +1,34 @@
+{
+ "application": null,
+ "automatic_payment_methods": null,
+ "cancellation_reason": null,
+ "client_secret": "seti_1ONJ51DEQaroqDjsZNLHHtQn_secret_PBgRmbfqmvy01Qdp2OcqIiVep8ZYauJ",
+ "created": 1702576335,
+ "customer": "cus_PBgRA4C5R3pi4D",
+ "description": null,
+ "flow_directions": null,
+ "id": "seti_1ONJ51DEQaroqDjsZNLHHtQn",
+ "last_setup_error": null,
+ "latest_attempt": "setatt_1ONJ51DEQaroqDjsi7EH4DD8",
+ "livemode": false,
+ "mandate": null,
+ "metadata": {},
+ "next_action": null,
+ "object": "setup_intent",
+ "on_behalf_of": null,
+ "payment_method": "pm_1ONJ51DEQaroqDjs55u0UX9G",
+ "payment_method_configuration_details": null,
+ "payment_method_options": {
+ "card": {
+ "mandate_options": null,
+ "network": null,
+ "request_three_d_secure": "automatic"
+ }
+ },
+ "payment_method_types": [
+ "card"
+ ],
+ "single_use_mandate": null,
+ "status": "succeeded",
+ "usage": "off_session"
+}
diff --git a/corporate/tests/stripe_fixtures/non_sponsorship_billing--SetupIntent.list.1.json b/corporate/tests/stripe_fixtures/non_sponsorship_billing--SetupIntent.list.1.json
new file mode 100644
index 00000000000..81f68138845
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/non_sponsorship_billing--SetupIntent.list.1.json
@@ -0,0 +1,41 @@
+{
+ "data": [
+ {
+ "application": null,
+ "automatic_payment_methods": null,
+ "cancellation_reason": null,
+ "client_secret": "seti_1ONJ50DEQaroqDjs4pap3aTQ_secret_PBgRHYUx24GJSskzKKwSuQLrKhYNeay",
+ "created": 1702576334,
+ "customer": "cus_PBgRA4C5R3pi4D",
+ "description": null,
+ "flow_directions": null,
+ "id": "seti_1ONJ50DEQaroqDjs4pap3aTQ",
+ "last_setup_error": null,
+ "latest_attempt": null,
+ "livemode": false,
+ "mandate": null,
+ "metadata": {},
+ "next_action": null,
+ "object": "setup_intent",
+ "on_behalf_of": null,
+ "payment_method": null,
+ "payment_method_configuration_details": null,
+ "payment_method_options": {
+ "card": {
+ "mandate_options": null,
+ "network": null,
+ "request_three_d_secure": "automatic"
+ }
+ },
+ "payment_method_types": [
+ "card"
+ ],
+ "single_use_mandate": null,
+ "status": "requires_payment_method",
+ "usage": "off_session"
+ }
+ ],
+ "has_more": true,
+ "object": "list",
+ "url": "/v1/setup_intents"
+}
diff --git a/corporate/tests/stripe_fixtures/non_sponsorship_billing--SetupIntent.retrieve.1.json b/corporate/tests/stripe_fixtures/non_sponsorship_billing--SetupIntent.retrieve.1.json
new file mode 100644
index 00000000000..bbed0c4ce85
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/non_sponsorship_billing--SetupIntent.retrieve.1.json
@@ -0,0 +1,34 @@
+{
+ "application": null,
+ "automatic_payment_methods": null,
+ "cancellation_reason": null,
+ "client_secret": "seti_1ONJ51DEQaroqDjsZNLHHtQn_secret_PBgRmbfqmvy01Qdp2OcqIiVep8ZYauJ",
+ "created": 1702576335,
+ "customer": "cus_PBgRA4C5R3pi4D",
+ "description": null,
+ "flow_directions": null,
+ "id": "seti_1ONJ51DEQaroqDjsZNLHHtQn",
+ "last_setup_error": null,
+ "latest_attempt": "setatt_1ONJ51DEQaroqDjsi7EH4DD8",
+ "livemode": false,
+ "mandate": null,
+ "metadata": {},
+ "next_action": null,
+ "object": "setup_intent",
+ "on_behalf_of": null,
+ "payment_method": "pm_1ONJ51DEQaroqDjs55u0UX9G",
+ "payment_method_configuration_details": null,
+ "payment_method_options": {
+ "card": {
+ "mandate_options": null,
+ "network": null,
+ "request_three_d_secure": "automatic"
+ }
+ },
+ "payment_method_types": [
+ "card"
+ ],
+ "single_use_mandate": null,
+ "status": "succeeded",
+ "usage": "off_session"
+}
diff --git a/corporate/tests/stripe_fixtures/non_sponsorship_billing--checkout.Session.create.1.json b/corporate/tests/stripe_fixtures/non_sponsorship_billing--checkout.Session.create.1.json
new file mode 100644
index 00000000000..13f92597f0f
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/non_sponsorship_billing--checkout.Session.create.1.json
@@ -0,0 +1,74 @@
+{
+ "after_expiration": null,
+ "allow_promotion_codes": null,
+ "amount_subtotal": null,
+ "amount_total": null,
+ "automatic_tax": {
+ "enabled": false,
+ "status": null
+ },
+ "billing_address_collection": null,
+ "cancel_url": "http://selfhosting.testserver/realm/8bb4095c-58a8-42b8-afd4-9d92e91691e5/upgrade/",
+ "client_reference_id": null,
+ "client_secret": null,
+ "consent": null,
+ "consent_collection": null,
+ "created": 1702576334,
+ "currency": null,
+ "currency_conversion": null,
+ "custom_fields": [],
+ "custom_text": {
+ "after_submit": null,
+ "shipping_address": null,
+ "submit": null,
+ "terms_of_service_acceptance": null
+ },
+ "customer": "cus_PBgRA4C5R3pi4D",
+ "customer_creation": null,
+ "customer_details": {
+ "address": null,
+ "email": "[email protected]",
+ "name": null,
+ "phone": null,
+ "tax_exempt": null,
+ "tax_ids": null
+ },
+ "customer_email": null,
+ "expires_at": 1702662734,
+ "id": "cs_test_c1qc1I3QN6VOVyLmmPYRt748pBxWTIgXj1XJRwQN5cD8HCNx5X6vq036GI",
+ "invoice": null,
+ "invoice_creation": null,
+ "livemode": false,
+ "locale": null,
+ "metadata": {
+ "remote_realm_user_id": "1",
+ "type": "card_update"
+ },
+ "mode": "setup",
+ "object": "checkout.session",
+ "payment_intent": null,
+ "payment_link": null,
+ "payment_method_collection": "always",
+ "payment_method_configuration_details": null,
+ "payment_method_options": {},
+ "payment_method_types": [
+ "card"
+ ],
+ "payment_status": "no_payment_required",
+ "phone_number_collection": {
+ "enabled": false
+ },
+ "recovered_from": null,
+ "setup_intent": "seti_1ONJ50DEQaroqDjs4pap3aTQ",
+ "shipping": null,
+ "shipping_address_collection": null,
+ "shipping_options": [],
+ "shipping_rate": null,
+ "status": "open",
+ "submit_type": null,
+ "subscription": null,
+ "success_url": "http://selfhosting.testserver/realm/8bb4095c-58a8-42b8-afd4-9d92e91691e5/billing/event_status?stripe_session_id={CHECKOUT_SESSION_ID}",
+ "total_details": null,
+ "ui_mode": "hosted",
+ "url": "https://checkout.stripe.com/c/pay/cs_test_c1qc1I3QN6VOVyLmmPYRt748pBxWTIgXj1XJRwQN5cD8HCNx5X6vq036GI#fidkdWxOYHwnPyd1blpxYHZxWl1UZjFOczZJXUE2PUpzUWNPV2ZpdlFzUCcpJ2N3amhWYHdzYHcnP3F3cGApJ2lkfGpwcVF8dWAnPyd2bGtiaWBaZmppcGhrJyknYGtkZ2lgVWlkZmBtamlhYHd2Jz9xd3BgeCUl"
+}
diff --git a/corporate/tests/stripe_fixtures/non_sponsorship_billing--checkout.Session.list.1.json b/corporate/tests/stripe_fixtures/non_sponsorship_billing--checkout.Session.list.1.json
new file mode 100644
index 00000000000..85feaa1cb21
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/non_sponsorship_billing--checkout.Session.list.1.json
@@ -0,0 +1,81 @@
+{
+ "data": [
+ {
+ "after_expiration": null,
+ "allow_promotion_codes": null,
+ "amount_subtotal": null,
+ "amount_total": null,
+ "automatic_tax": {
+ "enabled": false,
+ "status": null
+ },
+ "billing_address_collection": null,
+ "cancel_url": "http://selfhosting.testserver/realm/8bb4095c-58a8-42b8-afd4-9d92e91691e5/upgrade/",
+ "client_reference_id": null,
+ "client_secret": null,
+ "consent": null,
+ "consent_collection": null,
+ "created": 1702576334,
+ "currency": null,
+ "currency_conversion": null,
+ "custom_fields": [],
+ "custom_text": {
+ "after_submit": null,
+ "shipping_address": null,
+ "submit": null,
+ "terms_of_service_acceptance": null
+ },
+ "customer": "cus_PBgRA4C5R3pi4D",
+ "customer_creation": null,
+ "customer_details": {
+ "address": null,
+ "email": "[email protected]",
+ "name": null,
+ "phone": null,
+ "tax_exempt": null,
+ "tax_ids": null
+ },
+ "customer_email": null,
+ "expires_at": 1702662734,
+ "id": "cs_test_c1qc1I3QN6VOVyLmmPYRt748pBxWTIgXj1XJRwQN5cD8HCNx5X6vq036GI",
+ "invoice": null,
+ "invoice_creation": null,
+ "livemode": false,
+ "locale": null,
+ "metadata": {
+ "remote_realm_user_id": "1",
+ "type": "card_update"
+ },
+ "mode": "setup",
+ "object": "checkout.session",
+ "payment_intent": null,
+ "payment_link": null,
+ "payment_method_collection": "always",
+ "payment_method_configuration_details": null,
+ "payment_method_options": {},
+ "payment_method_types": [
+ "card"
+ ],
+ "payment_status": "no_payment_required",
+ "phone_number_collection": {
+ "enabled": false
+ },
+ "recovered_from": null,
+ "setup_intent": "seti_1ONJ50DEQaroqDjs4pap3aTQ",
+ "shipping": null,
+ "shipping_address_collection": null,
+ "shipping_options": [],
+ "shipping_rate": null,
+ "status": "open",
+ "submit_type": null,
+ "subscription": null,
+ "success_url": "http://selfhosting.testserver/realm/8bb4095c-58a8-42b8-afd4-9d92e91691e5/billing/event_status?stripe_session_id={CHECKOUT_SESSION_ID}",
+ "total_details": null,
+ "ui_mode": "hosted",
+ "url": "https://checkout.stripe.com/c/pay/cs_test_c1qc1I3QN6VOVyLmmPYRt748pBxWTIgXj1XJRwQN5cD8HCNx5X6vq036GI#fidkdWxOYHwnPyd1blpxYHZxWl1UZjFOczZJXUE2PUpzUWNPV2ZpdlFzUCcpJ2N3amhWYHdzYHcnP3F3cGApJ2lkfGpwcVF8dWAnPyd2bGtiaWBaZmppcGhrJyknYGtkZ2lgVWlkZmBtamlhYHd2Jz9xd3BgeCUl"
+ }
+ ],
+ "has_more": true,
+ "object": "list",
+ "url": "/v1/checkout/sessions"
+}
diff --git a/corporate/tests/test_stripe.py b/corporate/tests/test_stripe.py
index dafa7110501..275925d961f 100644
--- a/corporate/tests/test_stripe.py
+++ b/corporate/tests/test_stripe.py
@@ -34,6 +34,7 @@ import stripe.util
import time_machine
from django.conf import settings
from django.core import signing
+from django.test import override_settings
from django.urls.resolvers import get_resolver
from django.utils.crypto import get_random_string
from django.utils.timezone import now as timezone_now
@@ -96,7 +97,8 @@ from zerver.actions.create_user import (
)
from zerver.actions.realm_settings import do_deactivate_realm, do_reactivate_realm
from zerver.actions.users import do_deactivate_user
-from zerver.lib.test_classes import ZulipTestCase
+from zerver.lib.remote_server import send_server_data_to_push_bouncer
+from zerver.lib.test_classes import BouncerTestCase, ZulipTestCase
from zerver.lib.timestamp import datetime_to_timestamp, timestamp_to_datetime
from zerver.lib.utils import assert_is_not_none
from zerver.models import (
@@ -432,7 +434,9 @@ class StripeTestCase(ZulipTestCase):
hamlet.is_billing_admin = True
hamlet.save(update_fields=["is_billing_admin"])
- self.billing_session = RealmBillingSession(user=hamlet, realm=realm)
+ self.billing_session: Union[
+ RealmBillingSession, RemoteRealmBillingSession
+ ] = RealmBillingSession(user=hamlet, realm=realm)
def get_signed_seat_count_from_response(self, response: "TestHttpResponse") -> Optional[str]:
match = re.search(r"name=\"signed_seat_count\" value=\"(.+)\"", response.content.decode())
@@ -575,7 +579,14 @@ class StripeTestCase(ZulipTestCase):
**kwargs: Any,
) -> "TestHttpResponse":
if upgrade_page_response is None:
- upgrade_page_response = self.client_get("/upgrade/", {})
+ if self.billing_session.billing_base_url:
+ upgrade_page_response = self.client_get(
+ f"{self.billing_session.billing_base_url}/upgrade/", {}, subdomain="selfhosting"
+ )
+ else:
+ upgrade_page_response = self.client_get(
+ f"{self.billing_session.billing_base_url}/upgrade/", {}
+ )
params: Dict[str, Any] = {
"schedule": "annual",
"signed_seat_count": self.get_signed_seat_count_from_response(upgrade_page_response),
@@ -629,15 +640,22 @@ class StripeTestCase(ZulipTestCase):
self.send_stripe_webhook_events(last_event)
return upgrade_json_response
- def add_card_and_upgrade(self, user: UserProfile, **kwargs: Any) -> stripe.Customer:
+ def add_card_and_upgrade(
+ self, user: Optional[UserProfile] = None, **kwargs: Any
+ ) -> stripe.Customer:
# Add card
with time_machine.travel(self.now, tick=False):
self.add_card_to_customer_for_upgrade()
# Check that we correctly created a Customer object in Stripe
- stripe_customer = stripe_get_customer(
- assert_is_not_none(Customer.objects.get(realm=user.realm).stripe_customer_id)
- )
+ if user is not None:
+ stripe_customer = stripe_get_customer(
+ assert_is_not_none(Customer.objects.get(realm=user.realm).stripe_customer_id)
+ )
+ else:
+ customer = self.billing_session.get_customer()
+ assert customer is not None
+ stripe_customer = stripe_get_customer(assert_is_not_none(customer.stripe_customer_id))
self.assertTrue(stripe_customer_has_credit_card_as_default_payment_method(stripe_customer))
with time_machine.travel(self.now, tick=False):
@@ -714,7 +732,7 @@ class StripeTestCase(ZulipTestCase):
def client_billing_patch(self, url_suffix: str, info: Mapping[str, Any] = {}) -> Any:
url = f"/json{self.billing_session.billing_base_url}" + url_suffix
if self.billing_session.billing_base_url:
- response = self.client_patch(url, info, subdomain="selfhosting")
+ response = self.client_patch(url, info, subdomain="selfhosting") # nocoverage
else:
response = self.client_patch(url, info)
return response
@@ -5587,3 +5605,95 @@ class TestRemoteBillingWriteAuditLog(StripeTestCase):
assert_audit_log(
audit_log, None, support_admin, audit_log_class.CUSTOMER_PLAN_CREATED, event_time
)
+
+
+@override_settings(PUSH_NOTIFICATION_BOUNCER_URL="https://push.zulip.org.example.com")
+class TestRemoteRealmBillingFlow(StripeTestCase, BouncerTestCase):
+ @override
+ def setUp(self) -> None:
+ # We need to time travel to 2012-1-2 because super().setUp()
+ # creates users and changes roles with event_time=timezone_now().
+ # That affects the LicenseLedger queries as their event_time would
+ # be more recent than other operations we perform in this test.
+ with time_machine.travel(datetime(2012, 1, 2, 3, 4, 5, tzinfo=timezone.utc), tick=False):
+ super().setUp()
+
+ hamlet = self.example_user("hamlet")
+ remote_realm = RemoteRealm.objects.get(uuid=hamlet.realm.uuid)
+ self.billing_session = RemoteRealmBillingSession(remote_realm=remote_realm)
+
+ @responses.activate
+ @mock_stripe()
+ def test_non_sponsorship_billing(self, *mocks: Mock) -> None:
+ self.add_mock_response()
+ with time_machine.travel(self.now, tick=False):
+ send_server_data_to_push_bouncer(consider_usage_statistics=False)
+
+ self.login("hamlet")
+ hamlet = self.example_user("hamlet")
+
+ result = self.execute_remote_billing_authentication_flow(hamlet)
+ self.assertEqual(result.status_code, 302)
+ self.assertEqual(result["Location"], f"{self.billing_session.billing_base_url}/plans/")
+
+ # upgrade to business plan
+ with time_machine.travel(self.now, tick=False):
+ result = self.client_get(
+ f"{self.billing_session.billing_base_url}/upgrade/", subdomain="selfhosting"
+ )
+ self.assertEqual(result.status_code, 200)
+ self.assert_in_success_response(["Add card", "Purchase Zulip Business"], result)
+
+ self.assertFalse(Customer.objects.exists())
+ self.assertFalse(CustomerPlan.objects.exists())
+ self.assertFalse(LicenseLedger.objects.exists())
+
+ with time_machine.travel(self.now, tick=False):
+ stripe_customer = self.add_card_and_upgrade()
+
+ customer = Customer.objects.get(stripe_customer_id=stripe_customer.id)
+ plan = CustomerPlan.objects.get(customer=customer)
+ LicenseLedger.objects.get(plan=plan)
+
+ with time_machine.travel(self.now + timedelta(days=1), tick=False):
+ response = self.client_get(
+ f"{self.billing_session.billing_base_url}/billing/", subdomain="selfhosting"
+ )
+ for substring in [
+ "Zulip Business",
+ "Number of licenses",
+ "10 (managed automatically)",
+ "Your plan will automatically renew on",
+ "Visa ending in 4242",
+ "Update card",
+ ]:
+ self.assert_in_response(substring, response)
+
+ # Verify that change in user count updates LicenseLedger.
+ audit_log_count = RemoteRealmAuditLog.objects.count()
+ self.assertEqual(LicenseLedger.objects.count(), 1)
+
+ with time_machine.travel(self.now + timedelta(days=2), tick=False):
+ user_count = self.billing_session.current_count_for_billed_licenses(
+ self.now + timedelta(days=2)
+ )
+ for count in range(10):
+ do_create_user(
+ f"email {count}",
+ f"password {count}",
+ hamlet.realm,
+ "name",
+ role=UserProfile.ROLE_MEMBER,
+ acting_user=None,
+ )
+
+ with time_machine.travel(self.now + timedelta(days=3), tick=False):
+ send_server_data_to_push_bouncer(consider_usage_statistics=False)
+
+ self.assertEqual(
+ RemoteRealmAuditLog.objects.count(),
+ audit_log_count + 10,
+ )
+ latest_ledger = LicenseLedger.objects.last()
+ assert latest_ledger is not None
+ self.assertEqual(latest_ledger.licenses, user_count + 10)
diff --git a/corporate/views/billing_page.py b/corporate/views/billing_page.py
index 1f3076e9972..48ad663f6e4 100644
--- a/corporate/views/billing_page.py
+++ b/corporate/views/billing_page.py
@@ -99,7 +99,7 @@ def remote_realm_billing_page(
billing_session: RemoteRealmBillingSession,
*,
success_message: str = "",
-) -> HttpResponse: # nocoverage
+) -> HttpResponse:
realm_uuid = billing_session.remote_realm.uuid
context: Dict[str, Any] = {
# We wouldn't be here if user didn't have access.
@@ -109,11 +109,11 @@ def remote_realm_billing_page(
"billing_base_url": billing_session.billing_base_url,
}
- if billing_session.remote_realm.plan_type == RemoteRealm.PLAN_TYPE_COMMUNITY:
+ if billing_session.remote_realm.plan_type == RemoteRealm.PLAN_TYPE_COMMUNITY: # nocoverage
return HttpResponseRedirect(reverse("remote_realm_sponsorship_page", args=(realm_uuid,)))
customer = billing_session.get_customer()
- if customer is not None and customer.sponsorship_pending:
+ if customer is not None and customer.sponsorship_pending: # nocoverage
# Don't redirect to sponsorship page if the remote realm is on a paid plan or scheduled for an upgrade.
if (
not billing_session.on_paid_plan()
@@ -136,12 +136,12 @@ def remote_realm_billing_page(
RemoteRealm.PLAN_TYPE_SELF_MANAGED_LEGACY,
]
)
- ):
+ ): # nocoverage
return HttpResponseRedirect(reverse("remote_realm_plans_page", args=(realm_uuid,)))
try:
main_context = billing_session.get_billing_page_context()
- except MissingDataError:
+ except MissingDataError: # nocoverage
return billing_session.missing_data_error_page(request)
if main_context:
diff --git a/corporate/views/event_status.py b/corporate/views/event_status.py
index 54d87154450..16542bc8d7e 100644
--- a/corporate/views/event_status.py
+++ b/corporate/views/event_status.py
@@ -48,7 +48,7 @@ def remote_realm_event_status(
*,
stripe_session_id: Optional[str] = None,
stripe_payment_intent_id: Optional[str] = None,
-) -> HttpResponse: # nocoverage
+) -> HttpResponse:
event_status_request = EventStatusRequest(
stripe_session_id=stripe_session_id, stripe_payment_intent_id=stripe_payment_intent_id
)
diff --git a/corporate/views/session.py b/corporate/views/session.py
index f5ec1dcaa9f..0371ac07a2c 100644
--- a/corporate/views/session.py
+++ b/corporate/views/session.py
@@ -75,7 +75,7 @@ def start_card_update_stripe_session_for_remote_realm_upgrade(
billing_session: RemoteRealmBillingSession,
*,
manual_license_management: Json[bool] = False,
-) -> HttpResponse: # nocoverage
+) -> HttpResponse:
session_data = billing_session.create_card_update_session_for_upgrade(manual_license_management)
return json_success(
request,
diff --git a/corporate/views/upgrade.py b/corporate/views/upgrade.py
index eeda0f79946..74fc9cba79a 100644
--- a/corporate/views/upgrade.py
+++ b/corporate/views/upgrade.py
@@ -97,7 +97,7 @@ def remote_realm_upgrade(
),
licenses: Optional[int] = REQ(json_validator=check_int, default=None),
remote_server_plan_start_date: Optional[str] = REQ(default=None),
-) -> HttpResponse: # nocoverage
+) -> HttpResponse:
try:
upgrade_request = UpgradeRequest(
billing_modality=billing_modality,
@@ -112,7 +112,7 @@ def remote_realm_upgrade(
)
data = billing_session.do_upgrade(upgrade_request)
return json_success(request, data)
- except BillingError as e:
+ except BillingError as e: # nocoverage
billing_logger.warning(
"BillingError during upgrade: %s. remote_realm=%s (%s), billing_modality=%s, "
"schedule=%s, license_management=%s, licenses=%s",
@@ -125,7 +125,7 @@ def remote_realm_upgrade(
licenses,
)
raise e
- except Exception:
+ except Exception: # nocoverage
billing_logger.exception("Uncaught exception in billing:", stack_info=True)
error_message = BillingError.CONTACT_SUPPORT.format(email=settings.ZULIP_ADMINISTRATOR)
error_description = "uncaught exception during upgrade"
@@ -215,7 +215,7 @@ def remote_realm_upgrade_page(
*,
manual_license_management: Json[bool] = False,
success_message: str = "",
-) -> HttpResponse: # nocoverage
+) -> HttpResponse:
initial_upgrade_request = InitialUpgradeRequest(
manual_license_management=manual_license_management,
tier=CustomerPlan.TIER_SELF_HOSTED_BUSINESS,
@@ -223,10 +223,10 @@ def remote_realm_upgrade_page(
)
try:
redirect_url, context = billing_session.get_initial_upgrade_context(initial_upgrade_request)
- except MissingDataError:
+ except MissingDataError: # nocoverage
return billing_session.missing_data_error_page(request)
- if redirect_url:
+ if redirect_url: # nocoverage
return HttpResponseRedirect(redirect_url)
response = render(request, "corporate/upgrade.html", context=context)