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.

billing: Use customer.minimum_licenses for minimum plan check.

Lauryn Menardadd58e379555
diff --git a/corporate/lib/stripe.py b/corporate/lib/stripe.py
index 30019a884e6..2a0d2ebd863 100644
--- a/corporate/lib/stripe.py
+++ b/corporate/lib/stripe.py
@@ -2250,7 +2250,7 @@ class BillingSession(ABC):
return # nocoverage
min_licenses = self.min_licenses_for_plan(plan.tier)
- if min_licenses > renewal_license_count: # nocoverage
+ if min_licenses > renewal_license_count:
# If we are renewing less licenses than the minimum required for the plan, we need to
# adjust `license_at_next_renewal` for the customer.
raise BillingError(
@@ -2891,7 +2891,9 @@ class BillingSession(ABC):
) -> int:
customer = self.get_customer()
if customer is not None and customer.minimum_licenses:
- assert customer.monthly_discounted_price or customer.annual_discounted_price
+ # This could be either because the customer has a fixed
+ # monthly_discounted_price or annual_discounted_price, or
+ # because we wanted to override their minimum.
return customer.minimum_licenses
if tier == CustomerPlan.TIER_SELF_HOSTED_BASIC:
diff --git a/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Customer.create.1.json b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Customer.create.1.json
new file mode 100644
index 00000000000..2a662ab8645
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Customer.create.1.json
@@ -0,0 +1,33 @@
+{
+ "address": null,
+ "balance": 0,
+ "created": 1740080507,
+ "currency": null,
+ "default_currency": null,
+ "default_source": null,
+ "delinquent": false,
+ "description": "zulip (Zulip Dev)",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_RoIDdmj3lHKt7D",
+ "invoice_prefix": "A984DE48",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": null,
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "realm_id": "2",
+ "realm_str": "zulip"
+ },
+ "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/customer_minimum_licenses_for_plan--Customer.modify.1.json b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Customer.modify.1.json
new file mode 100644
index 00000000000..3860e5d037d
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Customer.modify.1.json
@@ -0,0 +1,33 @@
+{
+ "address": null,
+ "balance": 0,
+ "created": 1740080507,
+ "currency": null,
+ "default_currency": null,
+ "default_source": null,
+ "delinquent": false,
+ "description": "zulip (Zulip Dev)",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_RoIDdmj3lHKt7D",
+ "invoice_prefix": "A984DE48",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": "pm_1Qufd3DEQaroqDjsvPgCjrpD",
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "realm_id": "2",
+ "realm_str": "zulip"
+ },
+ "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/customer_minimum_licenses_for_plan--Customer.retrieve.1.json b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Customer.retrieve.1.json
new file mode 100644
index 00000000000..86a6ab8d750
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Customer.retrieve.1.json
@@ -0,0 +1,82 @@
+{
+ "address": null,
+ "balance": 0,
+ "created": 1740080507,
+ "currency": null,
+ "default_currency": null,
+ "default_source": null,
+ "delinquent": false,
+ "description": "zulip (Zulip Dev)",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_RoIDdmj3lHKt7D",
+ "invoice_prefix": "A984DE48",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": {
+ "allow_redisplay": "unspecified",
+ "billing_details": {
+ "address": {
+ "city": "San Francisco",
+ "country": "US",
+ "line1": "123 Main St",
+ "line2": null,
+ "postal_code": "94105",
+ "state": "CA"
+ },
+ "email": null,
+ "name": "John Doe",
+ "phone": null
+ },
+ "card": {
+ "brand": "visa",
+ "checks": {
+ "address_line1_check": "pass",
+ "address_postal_code_check": "pass",
+ "cvc_check": "pass"
+ },
+ "country": "US",
+ "display_brand": "visa",
+ "exp_month": 2,
+ "exp_year": 2026,
+ "fingerprint": "9XKsMixKBi6kIIzd",
+ "funding": "credit",
+ "generated_from": null,
+ "last4": "4242",
+ "networks": {
+ "available": [
+ "visa"
+ ],
+ "preferred": null
+ },
+ "regulated_status": "unregulated",
+ "three_d_secure_usage": {
+ "supported": true
+ },
+ "wallet": null
+ },
+ "created": 1740080510,
+ "customer": "cus_RoIDdmj3lHKt7D",
+ "id": "pm_1Qufd3DEQaroqDjsvPgCjrpD",
+ "livemode": false,
+ "metadata": {},
+ "object": "payment_method",
+ "type": "card"
+ },
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "realm_id": "2",
+ "realm_str": "zulip"
+ },
+ "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/customer_minimum_licenses_for_plan--Customer.retrieve.2.json b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Customer.retrieve.2.json
new file mode 100644
index 00000000000..86a6ab8d750
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Customer.retrieve.2.json
@@ -0,0 +1,82 @@
+{
+ "address": null,
+ "balance": 0,
+ "created": 1740080507,
+ "currency": null,
+ "default_currency": null,
+ "default_source": null,
+ "delinquent": false,
+ "description": "zulip (Zulip Dev)",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_RoIDdmj3lHKt7D",
+ "invoice_prefix": "A984DE48",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": {
+ "allow_redisplay": "unspecified",
+ "billing_details": {
+ "address": {
+ "city": "San Francisco",
+ "country": "US",
+ "line1": "123 Main St",
+ "line2": null,
+ "postal_code": "94105",
+ "state": "CA"
+ },
+ "email": null,
+ "name": "John Doe",
+ "phone": null
+ },
+ "card": {
+ "brand": "visa",
+ "checks": {
+ "address_line1_check": "pass",
+ "address_postal_code_check": "pass",
+ "cvc_check": "pass"
+ },
+ "country": "US",
+ "display_brand": "visa",
+ "exp_month": 2,
+ "exp_year": 2026,
+ "fingerprint": "9XKsMixKBi6kIIzd",
+ "funding": "credit",
+ "generated_from": null,
+ "last4": "4242",
+ "networks": {
+ "available": [
+ "visa"
+ ],
+ "preferred": null
+ },
+ "regulated_status": "unregulated",
+ "three_d_secure_usage": {
+ "supported": true
+ },
+ "wallet": null
+ },
+ "created": 1740080510,
+ "customer": "cus_RoIDdmj3lHKt7D",
+ "id": "pm_1Qufd3DEQaroqDjsvPgCjrpD",
+ "livemode": false,
+ "metadata": {},
+ "object": "payment_method",
+ "type": "card"
+ },
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "realm_id": "2",
+ "realm_str": "zulip"
+ },
+ "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/customer_minimum_licenses_for_plan--Customer.retrieve.3.json b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Customer.retrieve.3.json
new file mode 100644
index 00000000000..86a6ab8d750
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Customer.retrieve.3.json
@@ -0,0 +1,82 @@
+{
+ "address": null,
+ "balance": 0,
+ "created": 1740080507,
+ "currency": null,
+ "default_currency": null,
+ "default_source": null,
+ "delinquent": false,
+ "description": "zulip (Zulip Dev)",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_RoIDdmj3lHKt7D",
+ "invoice_prefix": "A984DE48",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": {
+ "allow_redisplay": "unspecified",
+ "billing_details": {
+ "address": {
+ "city": "San Francisco",
+ "country": "US",
+ "line1": "123 Main St",
+ "line2": null,
+ "postal_code": "94105",
+ "state": "CA"
+ },
+ "email": null,
+ "name": "John Doe",
+ "phone": null
+ },
+ "card": {
+ "brand": "visa",
+ "checks": {
+ "address_line1_check": "pass",
+ "address_postal_code_check": "pass",
+ "cvc_check": "pass"
+ },
+ "country": "US",
+ "display_brand": "visa",
+ "exp_month": 2,
+ "exp_year": 2026,
+ "fingerprint": "9XKsMixKBi6kIIzd",
+ "funding": "credit",
+ "generated_from": null,
+ "last4": "4242",
+ "networks": {
+ "available": [
+ "visa"
+ ],
+ "preferred": null
+ },
+ "regulated_status": "unregulated",
+ "three_d_secure_usage": {
+ "supported": true
+ },
+ "wallet": null
+ },
+ "created": 1740080510,
+ "customer": "cus_RoIDdmj3lHKt7D",
+ "id": "pm_1Qufd3DEQaroqDjsvPgCjrpD",
+ "livemode": false,
+ "metadata": {},
+ "object": "payment_method",
+ "type": "card"
+ },
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "realm_id": "2",
+ "realm_str": "zulip"
+ },
+ "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/customer_minimum_licenses_for_plan--Customer.retrieve.4.json b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Customer.retrieve.4.json
new file mode 100644
index 00000000000..86a6ab8d750
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Customer.retrieve.4.json
@@ -0,0 +1,82 @@
+{
+ "address": null,
+ "balance": 0,
+ "created": 1740080507,
+ "currency": null,
+ "default_currency": null,
+ "default_source": null,
+ "delinquent": false,
+ "description": "zulip (Zulip Dev)",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_RoIDdmj3lHKt7D",
+ "invoice_prefix": "A984DE48",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": {
+ "allow_redisplay": "unspecified",
+ "billing_details": {
+ "address": {
+ "city": "San Francisco",
+ "country": "US",
+ "line1": "123 Main St",
+ "line2": null,
+ "postal_code": "94105",
+ "state": "CA"
+ },
+ "email": null,
+ "name": "John Doe",
+ "phone": null
+ },
+ "card": {
+ "brand": "visa",
+ "checks": {
+ "address_line1_check": "pass",
+ "address_postal_code_check": "pass",
+ "cvc_check": "pass"
+ },
+ "country": "US",
+ "display_brand": "visa",
+ "exp_month": 2,
+ "exp_year": 2026,
+ "fingerprint": "9XKsMixKBi6kIIzd",
+ "funding": "credit",
+ "generated_from": null,
+ "last4": "4242",
+ "networks": {
+ "available": [
+ "visa"
+ ],
+ "preferred": null
+ },
+ "regulated_status": "unregulated",
+ "three_d_secure_usage": {
+ "supported": true
+ },
+ "wallet": null
+ },
+ "created": 1740080510,
+ "customer": "cus_RoIDdmj3lHKt7D",
+ "id": "pm_1Qufd3DEQaroqDjsvPgCjrpD",
+ "livemode": false,
+ "metadata": {},
+ "object": "payment_method",
+ "type": "card"
+ },
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "realm_id": "2",
+ "realm_str": "zulip"
+ },
+ "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/customer_minimum_licenses_for_plan--Customer.retrieve.5.json b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Customer.retrieve.5.json
new file mode 100644
index 00000000000..86a6ab8d750
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Customer.retrieve.5.json
@@ -0,0 +1,82 @@
+{
+ "address": null,
+ "balance": 0,
+ "created": 1740080507,
+ "currency": null,
+ "default_currency": null,
+ "default_source": null,
+ "delinquent": false,
+ "description": "zulip (Zulip Dev)",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_RoIDdmj3lHKt7D",
+ "invoice_prefix": "A984DE48",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": {
+ "allow_redisplay": "unspecified",
+ "billing_details": {
+ "address": {
+ "city": "San Francisco",
+ "country": "US",
+ "line1": "123 Main St",
+ "line2": null,
+ "postal_code": "94105",
+ "state": "CA"
+ },
+ "email": null,
+ "name": "John Doe",
+ "phone": null
+ },
+ "card": {
+ "brand": "visa",
+ "checks": {
+ "address_line1_check": "pass",
+ "address_postal_code_check": "pass",
+ "cvc_check": "pass"
+ },
+ "country": "US",
+ "display_brand": "visa",
+ "exp_month": 2,
+ "exp_year": 2026,
+ "fingerprint": "9XKsMixKBi6kIIzd",
+ "funding": "credit",
+ "generated_from": null,
+ "last4": "4242",
+ "networks": {
+ "available": [
+ "visa"
+ ],
+ "preferred": null
+ },
+ "regulated_status": "unregulated",
+ "three_d_secure_usage": {
+ "supported": true
+ },
+ "wallet": null
+ },
+ "created": 1740080510,
+ "customer": "cus_RoIDdmj3lHKt7D",
+ "id": "pm_1Qufd3DEQaroqDjsvPgCjrpD",
+ "livemode": false,
+ "metadata": {},
+ "object": "payment_method",
+ "type": "card"
+ },
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "realm_id": "2",
+ "realm_str": "zulip"
+ },
+ "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/customer_minimum_licenses_for_plan--Event.list.1.json b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Event.list.1.json
new file mode 100644
index 00000000000..de16beaa52a
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Event.list.1.json
@@ -0,0 +1,60 @@
+{
+ "data": [
+ {
+ "api_version": "2020-08-27",
+ "created": 1740080512,
+ "data": {
+ "object": {
+ "address": null,
+ "balance": 0,
+ "created": 1740080507,
+ "currency": null,
+ "default_currency": null,
+ "default_source": null,
+ "delinquent": false,
+ "description": "zulip (Zulip Dev)",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_RoIDdmj3lHKt7D",
+ "invoice_prefix": "A984DE48",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": "pm_1Qufd3DEQaroqDjsvPgCjrpD",
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "realm_id": "2",
+ "realm_str": "zulip"
+ },
+ "name": null,
+ "next_invoice_sequence": 1,
+ "object": "customer",
+ "phone": null,
+ "preferred_locales": [],
+ "shipping": null,
+ "tax_exempt": "none",
+ "test_clock": null
+ },
+ "previous_attributes": {
+ "invoice_settings": {
+ "default_payment_method": null
+ }
+ }
+ },
+ "id": "evt_1Qufd6DEQaroqDjs8yzct3hC",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 0,
+ "request": {
+ "id": "req_8VGMYQpBpoBjRU",
+ "idempotency_key": "8ce9e9c1-77a7-4fd4-9c81-fb13bd73ef01"
+ },
+ "type": "customer.updated"
+ }
+ ],
+ "has_more": true,
+ "object": "list",
+ "url": "/v1/events"
+}
diff --git a/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Event.list.2.json b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Event.list.2.json
new file mode 100644
index 00000000000..5a52eb250c2
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Event.list.2.json
@@ -0,0 +1,988 @@
+{
+ "data": [
+ {
+ "api_version": "2020-08-27",
+ "created": 1740080519,
+ "data": {
+ "object": {
+ "amount": 72000,
+ "amount_capturable": 0,
+ "amount_details": {
+ "tip": {}
+ },
+ "amount_received": 72000,
+ "application": null,
+ "application_fee_amount": null,
+ "automatic_payment_methods": null,
+ "canceled_at": null,
+ "cancellation_reason": null,
+ "capture_method": "automatic",
+ "charges": {
+ "data": [
+ {
+ "amount": 72000,
+ "amount_captured": 72000,
+ "amount_refunded": 0,
+ "application": null,
+ "application_fee": null,
+ "application_fee_amount": null,
+ "balance_transaction": "txn_3QufdADEQaroqDjs0mrWSQso",
+ "billing_details": {
+ "address": {
+ "city": "San Francisco",
+ "country": "US",
+ "line1": "123 Main St",
+ "line2": null,
+ "postal_code": "94105",
+ "state": "CA"
+ },
+ "email": null,
+ "name": "John Doe",
+ "phone": null
+ },
+ "calculated_statement_descriptor": "ZULIP CLOUD PLUS",
+ "captured": true,
+ "created": 1740080517,
+ "currency": "usd",
+ "customer": "cus_RoIDdmj3lHKt7D",
+ "description": "Payment for Invoice",
+ "destination": null,
+ "dispute": null,
+ "disputed": false,
+ "failure_balance_transaction": null,
+ "failure_code": null,
+ "failure_message": null,
+ "fraud_details": {},
+ "id": "ch_3QufdADEQaroqDjs0bDYCSyl",
+ "invoice": "in_1Qufd9DEQaroqDjsDvbu5rW2",
+ "livemode": false,
+ "metadata": {},
+ "object": "charge",
+ "on_behalf_of": null,
+ "order": null,
+ "outcome": {
+ "advice_code": null,
+ "network_advice_code": null,
+ "network_decline_code": null,
+ "network_status": "approved_by_network",
+ "reason": null,
+ "risk_level": "normal",
+ "risk_score": 39,
+ "seller_message": "Payment complete.",
+ "type": "authorized"
+ },
+ "paid": true,
+ "payment_intent": "pi_3QufdADEQaroqDjs0K88fqLj",
+ "payment_method": "pm_1Qufd3DEQaroqDjsvPgCjrpD",
+ "payment_method_details": {
+ "card": {
+ "amount_authorized": 72000,
+ "authorization_code": null,
+ "brand": "visa",
+ "checks": {
+ "address_line1_check": "pass",
+ "address_postal_code_check": "pass",
+ "cvc_check": "pass"
+ },
+ "country": "US",
+ "exp_month": 2,
+ "exp_year": 2026,
+ "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
+ },
+ "network_transaction_id": "578875115771051",
+ "overcapture": {
+ "maximum_amount_capturable": 72000,
+ "status": "unavailable"
+ },
+ "regulated_status": "unregulated",
+ "three_d_secure": null,
+ "wallet": null
+ },
+ "type": "card"
+ },
+ "radar_options": {},
+ "receipt_email": "[email protected]",
+ "receipt_number": null,
+ "receipt_url": "https://pay.stripe.com/receipts/invoices/CAcaFwoVYWNjdF8xN3ZUa3dERVFhcm9xRGpzKIeL3r0GMgYFPkWas886LBYGYWRXJjNYieLXC_cfmBxW0KLC7VnGfxudrsBwKtkPHnCz_N-llhnzPkAs?s=ap",
+ "refunded": false,
+ "refunds": {
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "total_count": 0,
+ "url": "/v1/charges/ch_3QufdADEQaroqDjs0bDYCSyl/refunds"
+ },
+ "review": null,
+ "shipping": null,
+ "source": null,
+ "source_transfer": null,
+ "statement_descriptor": "Zulip Cloud Plus",
+ "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_3QufdADEQaroqDjs0K88fqLj"
+ },
+ "client_secret": "pi_3QufdADEQaroqDjs0K88fqLj_secret_hLnXQqV5aT988T7QYiFHfyzch",
+ "confirmation_method": "automatic",
+ "created": 1740080516,
+ "currency": "usd",
+ "customer": "cus_RoIDdmj3lHKt7D",
+ "description": "Payment for Invoice",
+ "id": "pi_3QufdADEQaroqDjs0K88fqLj",
+ "invoice": "in_1Qufd9DEQaroqDjsDvbu5rW2",
+ "last_payment_error": null,
+ "latest_charge": "ch_3QufdADEQaroqDjs0bDYCSyl",
+ "livemode": false,
+ "metadata": {},
+ "next_action": null,
+ "object": "payment_intent",
+ "on_behalf_of": null,
+ "payment_method": "pm_1Qufd3DEQaroqDjsvPgCjrpD",
+ "payment_method_configuration_details": null,
+ "payment_method_options": {
+ "card": {
+ "installments": null,
+ "mandate_options": null,
+ "network": null,
+ "request_three_d_secure": "automatic"
+ },
+ "cashapp": {}
+ },
+ "payment_method_types": [
+ "card",
+ "cashapp"
+ ],
+ "processing": null,
+ "receipt_email": "[email protected]",
+ "review": null,
+ "setup_future_usage": null,
+ "shipping": null,
+ "source": null,
+ "statement_descriptor": "Zulip Cloud Plus",
+ "statement_descriptor_suffix": null,
+ "status": "succeeded",
+ "transfer_data": null,
+ "transfer_group": null
+ }
+ },
+ "id": "evt_3QufdADEQaroqDjs0NrFNHvb",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 2,
+ "request": {
+ "id": "req_Az3j4bgbMfFvdK",
+ "idempotency_key": "b3ecd8cb-9cff-451d-bc49-0cc7cf144e35"
+ },
+ "type": "payment_intent.succeeded"
+ },
+ {
+ "api_version": "2020-08-27",
+ "created": 1740080516,
+ "data": {
+ "object": {
+ "account_country": "US",
+ "account_name": "Kandra Labs, Inc.",
+ "account_tax_ids": null,
+ "amount_due": 72000,
+ "amount_paid": 0,
+ "amount_remaining": 72000,
+ "amount_shipping": 0,
+ "application": null,
+ "application_fee_amount": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": false,
+ "automatic_tax": {
+ "disabled_reason": null,
+ "enabled": false,
+ "liability": null,
+ "status": null
+ },
+ "automatically_finalizes_at": null,
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "charge_automatically",
+ "created": 1740080515,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_RoIDdmj3lHKt7D",
+ "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": 1740080515,
+ "ending_balance": 0,
+ "footer": null,
+ "from_invoice": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_17vTkwDEQaroqDjs/test_YWNjdF8xN3ZUa3dERVFhcm9xRGpzLF9Sb0lEc01LdTZjY1hlNjBRN21UTWdGSGhFNlVUbHZZLDEzMDYyMTMxNg0200pNDWiupe?s=ap",
+ "id": "in_1Qufd9DEQaroqDjsDvbu5rW2",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_17vTkwDEQaroqDjs/test_YWNjdF8xN3ZUa3dERVFhcm9xRGpzLF9Sb0lEc01LdTZjY1hlNjBRN21UTWdGSGhFNlVUbHZZLDEzMDYyMTMxNg0200pNDWiupe/pdf?s=ap",
+ "issuer": {
+ "type": "self"
+ },
+ "last_finalization_error": null,
+ "latest_revision": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 72000,
+ "amount_excluding_tax": 72000,
+ "currency": "usd",
+ "description": "Zulip Cloud Plus",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "il_1Qufd8DEQaroqDjsQQpSSXbF",
+ "invoice": "in_1Qufd9DEQaroqDjsDvbu5rW2",
+ "invoice_item": "ii_1Qufd8DEQaroqDjsXOoGvTdx",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "pretax_credit_amounts": [],
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1722230793,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1Phm6PDEQaroqDjsHR9eMJZ4",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_QYtuRwnhi1w0Ui",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 12000,
+ "unit_amount_decimal": "12000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 6,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "12000"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/in_1Qufd9DEQaroqDjsDvbu5rW2/lines"
+ },
+ "livemode": false,
+ "metadata": {
+ "billing_schedule": "1",
+ "current_plan_id": "None",
+ "license_management": "automatic",
+ "licenses": "6",
+ "on_free_trial": "False",
+ "plan_tier": "2",
+ "user_id": "10"
+ },
+ "next_payment_attempt": null,
+ "number": "A984DE48-0001",
+ "object": "invoice",
+ "on_behalf_of": null,
+ "paid": false,
+ "paid_out_of_band": false,
+ "payment_intent": "pi_3QufdADEQaroqDjs0K88fqLj",
+ "payment_settings": {
+ "default_mandate": null,
+ "payment_method_options": null,
+ "payment_method_types": null
+ },
+ "period_end": 1740080515,
+ "period_start": 1740080515,
+ "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"
+ },
+ "template": null,
+ "template_version": null
+ },
+ "rendering_options": null,
+ "shipping_cost": null,
+ "shipping_details": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Cloud Plus",
+ "status": "open",
+ "status_transitions": {
+ "finalized_at": 1740080515,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subscription_details": {
+ "metadata": null
+ },
+ "subtotal": 72000,
+ "subtotal_excluding_tax": 72000,
+ "tax": null,
+ "test_clock": null,
+ "total": 72000,
+ "total_discount_amounts": [],
+ "total_excluding_tax": 72000,
+ "total_pretax_credit_amounts": [],
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": null
+ }
+ },
+ "id": "evt_1QufdADEQaroqDjsq8jTSHkc",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 0,
+ "request": {
+ "id": "req_KHY5E0j154fhOo",
+ "idempotency_key": "c4bba3f6-321b-49df-a4af-dcc9f28be627"
+ },
+ "type": "invoice.finalized"
+ },
+ {
+ "api_version": "2020-08-27",
+ "created": 1740080516,
+ "data": {
+ "object": {
+ "account_country": "US",
+ "account_name": "Kandra Labs, Inc.",
+ "account_tax_ids": null,
+ "amount_due": 72000,
+ "amount_paid": 0,
+ "amount_remaining": 72000,
+ "amount_shipping": 0,
+ "application": null,
+ "application_fee_amount": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": false,
+ "automatic_tax": {
+ "disabled_reason": null,
+ "enabled": false,
+ "liability": null,
+ "status": null
+ },
+ "automatically_finalizes_at": null,
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "charge_automatically",
+ "created": 1740080515,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_RoIDdmj3lHKt7D",
+ "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": 1740080515,
+ "ending_balance": 0,
+ "footer": null,
+ "from_invoice": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_17vTkwDEQaroqDjs/test_YWNjdF8xN3ZUa3dERVFhcm9xRGpzLF9Sb0lEc01LdTZjY1hlNjBRN21UTWdGSGhFNlVUbHZZLDEzMDYyMTMxNg0200pNDWiupe?s=ap",
+ "id": "in_1Qufd9DEQaroqDjsDvbu5rW2",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_17vTkwDEQaroqDjs/test_YWNjdF8xN3ZUa3dERVFhcm9xRGpzLF9Sb0lEc01LdTZjY1hlNjBRN21UTWdGSGhFNlVUbHZZLDEzMDYyMTMxNg0200pNDWiupe/pdf?s=ap",
+ "issuer": {
+ "type": "self"
+ },
+ "last_finalization_error": null,
+ "latest_revision": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 72000,
+ "amount_excluding_tax": 72000,
+ "currency": "usd",
+ "description": "Zulip Cloud Plus",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "il_1Qufd8DEQaroqDjsQQpSSXbF",
+ "invoice": "in_1Qufd9DEQaroqDjsDvbu5rW2",
+ "invoice_item": "ii_1Qufd8DEQaroqDjsXOoGvTdx",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "pretax_credit_amounts": [],
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1722230793,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1Phm6PDEQaroqDjsHR9eMJZ4",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_QYtuRwnhi1w0Ui",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 12000,
+ "unit_amount_decimal": "12000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 6,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "12000"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/in_1Qufd9DEQaroqDjsDvbu5rW2/lines"
+ },
+ "livemode": false,
+ "metadata": {
+ "billing_schedule": "1",
+ "current_plan_id": "None",
+ "license_management": "automatic",
+ "licenses": "6",
+ "on_free_trial": "False",
+ "plan_tier": "2",
+ "user_id": "10"
+ },
+ "next_payment_attempt": null,
+ "number": "A984DE48-0001",
+ "object": "invoice",
+ "on_behalf_of": null,
+ "paid": false,
+ "paid_out_of_band": false,
+ "payment_intent": "pi_3QufdADEQaroqDjs0K88fqLj",
+ "payment_settings": {
+ "default_mandate": null,
+ "payment_method_options": null,
+ "payment_method_types": null
+ },
+ "period_end": 1740080515,
+ "period_start": 1740080515,
+ "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"
+ },
+ "template": null,
+ "template_version": null
+ },
+ "rendering_options": null,
+ "shipping_cost": null,
+ "shipping_details": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Cloud Plus",
+ "status": "open",
+ "status_transitions": {
+ "finalized_at": 1740080515,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subscription_details": {
+ "metadata": null
+ },
+ "subtotal": 72000,
+ "subtotal_excluding_tax": 72000,
+ "tax": null,
+ "test_clock": null,
+ "total": 72000,
+ "total_discount_amounts": [],
+ "total_excluding_tax": 72000,
+ "total_pretax_credit_amounts": [],
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": null
+ },
+ "previous_attributes": {
+ "effective_at": null,
+ "ending_balance": null,
+ "hosted_invoice_url": null,
+ "invoice_pdf": null,
+ "number": null,
+ "payment_intent": null,
+ "rendering": {
+ "pdf": {
+ "page_size": "auto"
+ }
+ },
+ "status": "draft",
+ "status_transitions": {
+ "finalized_at": null
+ }
+ }
+ },
+ "id": "evt_1QufdADEQaroqDjsvO1fikPF",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 0,
+ "request": {
+ "id": "req_KHY5E0j154fhOo",
+ "idempotency_key": "c4bba3f6-321b-49df-a4af-dcc9f28be627"
+ },
+ "type": "invoice.updated"
+ },
+ {
+ "api_version": "2020-08-27",
+ "created": 1740080516,
+ "data": {
+ "object": {
+ "amount": 72000,
+ "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_3QufdADEQaroqDjs0K88fqLj"
+ },
+ "client_secret": "pi_3QufdADEQaroqDjs0K88fqLj_secret_hLnXQqV5aT988T7QYiFHfyzch",
+ "confirmation_method": "automatic",
+ "created": 1740080516,
+ "currency": "usd",
+ "customer": "cus_RoIDdmj3lHKt7D",
+ "description": "Payment for Invoice",
+ "id": "pi_3QufdADEQaroqDjs0K88fqLj",
+ "invoice": "in_1Qufd9DEQaroqDjsDvbu5rW2",
+ "last_payment_error": null,
+ "latest_charge": null,
+ "livemode": false,
+ "metadata": {},
+ "next_action": null,
+ "object": "payment_intent",
+ "on_behalf_of": null,
+ "payment_method": null,
+ "payment_method_configuration_details": null,
+ "payment_method_options": {
+ "card": {
+ "installments": null,
+ "mandate_options": null,
+ "network": null,
+ "request_three_d_secure": "automatic"
+ },
+ "cashapp": {}
+ },
+ "payment_method_types": [
+ "card",
+ "cashapp"
+ ],
+ "processing": null,
+ "receipt_email": "[email protected]",
+ "review": null,
+ "setup_future_usage": null,
+ "shipping": null,
+ "source": null,
+ "statement_descriptor": "Zulip Cloud Plus",
+ "statement_descriptor_suffix": null,
+ "status": "requires_payment_method",
+ "transfer_data": null,
+ "transfer_group": null
+ }
+ },
+ "id": "evt_3QufdADEQaroqDjs0xBi4JBJ",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 0,
+ "request": {
+ "id": "req_KHY5E0j154fhOo",
+ "idempotency_key": "c4bba3f6-321b-49df-a4af-dcc9f28be627"
+ },
+ "type": "payment_intent.created"
+ },
+ {
+ "api_version": "2020-08-27",
+ "created": 1740080515,
+ "data": {
+ "object": {
+ "account_country": "US",
+ "account_name": "Kandra Labs, Inc.",
+ "account_tax_ids": null,
+ "amount_due": 72000,
+ "amount_paid": 0,
+ "amount_remaining": 72000,
+ "amount_shipping": 0,
+ "application": null,
+ "application_fee_amount": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": false,
+ "automatic_tax": {
+ "disabled_reason": null,
+ "enabled": false,
+ "liability": null,
+ "status": null
+ },
+ "automatically_finalizes_at": null,
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "charge_automatically",
+ "created": 1740080515,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_RoIDdmj3lHKt7D",
+ "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_1Qufd9DEQaroqDjsDvbu5rW2",
+ "invoice_pdf": null,
+ "issuer": {
+ "type": "self"
+ },
+ "last_finalization_error": null,
+ "latest_revision": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 72000,
+ "amount_excluding_tax": 72000,
+ "currency": "usd",
+ "description": "Zulip Cloud Plus",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "il_1Qufd8DEQaroqDjsQQpSSXbF",
+ "invoice": "in_1Qufd9DEQaroqDjsDvbu5rW2",
+ "invoice_item": "ii_1Qufd8DEQaroqDjsXOoGvTdx",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "pretax_credit_amounts": [],
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1722230793,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1Phm6PDEQaroqDjsHR9eMJZ4",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_QYtuRwnhi1w0Ui",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 12000,
+ "unit_amount_decimal": "12000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 6,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "12000"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/in_1Qufd9DEQaroqDjsDvbu5rW2/lines"
+ },
+ "livemode": false,
+ "metadata": {
+ "billing_schedule": "1",
+ "current_plan_id": "None",
+ "license_management": "automatic",
+ "licenses": "6",
+ "on_free_trial": "False",
+ "plan_tier": "2",
+ "user_id": "10"
+ },
+ "next_payment_attempt": null,
+ "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": 1740080515,
+ "period_start": 1740080515,
+ "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"
+ },
+ "template": null,
+ "template_version": null
+ },
+ "rendering_options": null,
+ "shipping_cost": null,
+ "shipping_details": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Cloud Plus",
+ "status": "draft",
+ "status_transitions": {
+ "finalized_at": null,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subscription_details": {
+ "metadata": null
+ },
+ "subtotal": 72000,
+ "subtotal_excluding_tax": 72000,
+ "tax": null,
+ "test_clock": null,
+ "total": 72000,
+ "total_discount_amounts": [],
+ "total_excluding_tax": 72000,
+ "total_pretax_credit_amounts": [],
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": null
+ }
+ },
+ "id": "evt_1Qufd9DEQaroqDjssrzdGMe1",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 0,
+ "request": {
+ "id": "req_tuQxKdbzhDd70P",
+ "idempotency_key": "8e2675ae-1280-4269-bd67-10291f694d10"
+ },
+ "type": "invoice.created"
+ },
+ {
+ "api_version": "2020-08-27",
+ "created": 1740080514,
+ "data": {
+ "object": {
+ "amount": 72000,
+ "currency": "usd",
+ "customer": "cus_RoIDdmj3lHKt7D",
+ "date": 1740080514,
+ "description": "Zulip Cloud Plus",
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_1Qufd8DEQaroqDjsXOoGvTdx",
+ "invoice": null,
+ "livemode": false,
+ "metadata": {},
+ "object": "invoiceitem",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1722230793,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1Phm6PDEQaroqDjsHR9eMJZ4",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_QYtuRwnhi1w0Ui",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 12000,
+ "unit_amount_decimal": "12000"
+ },
+ "proration": false,
+ "quantity": 6,
+ "subscription": null,
+ "tax_rates": [],
+ "test_clock": null,
+ "unit_amount": 12000,
+ "unit_amount_decimal": "12000"
+ }
+ },
+ "id": "evt_1Qufd8DEQaroqDjspFzO1TG0",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 0,
+ "request": {
+ "id": "req_xfv8xTFVxVhD2J",
+ "idempotency_key": "b541e684-0d8a-45e8-a466-9ade2710102e"
+ },
+ "type": "invoiceitem.created"
+ },
+ {
+ "api_version": "2020-08-27",
+ "created": 1740080514,
+ "data": {
+ "object": {
+ "address": null,
+ "balance": 0,
+ "created": 1740080507,
+ "currency": "usd",
+ "default_currency": "usd",
+ "default_source": null,
+ "delinquent": false,
+ "description": "zulip (Zulip Dev)",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_RoIDdmj3lHKt7D",
+ "invoice_prefix": "A984DE48",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": "pm_1Qufd3DEQaroqDjsvPgCjrpD",
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "realm_id": "2",
+ "realm_str": "zulip"
+ },
+ "name": null,
+ "next_invoice_sequence": 1,
+ "object": "customer",
+ "phone": null,
+ "preferred_locales": [],
+ "shipping": null,
+ "tax_exempt": "none",
+ "test_clock": null
+ },
+ "previous_attributes": {
+ "currency": null,
+ "default_currency": null
+ }
+ },
+ "id": "evt_1Qufd8DEQaroqDjsMLyGES7M",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 0,
+ "request": {
+ "id": "req_xfv8xTFVxVhD2J",
+ "idempotency_key": "b541e684-0d8a-45e8-a466-9ade2710102e"
+ },
+ "type": "customer.updated"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "url": "/v1/events"
+}
diff --git a/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Event.list.3.json b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Event.list.3.json
new file mode 100644
index 00000000000..697e77f11ba
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Event.list.3.json
@@ -0,0 +1,595 @@
+{
+ "data": [
+ {
+ "api_version": "2020-08-27",
+ "created": 1740080519,
+ "data": {
+ "object": {
+ "account_country": "US",
+ "account_name": "Kandra Labs, Inc.",
+ "account_tax_ids": null,
+ "amount_due": 72000,
+ "amount_paid": 72000,
+ "amount_remaining": 0,
+ "amount_shipping": 0,
+ "application": null,
+ "application_fee_amount": null,
+ "attempt_count": 1,
+ "attempted": true,
+ "auto_advance": false,
+ "automatic_tax": {
+ "disabled_reason": null,
+ "enabled": false,
+ "liability": null,
+ "status": null
+ },
+ "automatically_finalizes_at": null,
+ "billing_reason": "manual",
+ "charge": "ch_3QufdADEQaroqDjs0bDYCSyl",
+ "collection_method": "charge_automatically",
+ "created": 1740080515,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_RoIDdmj3lHKt7D",
+ "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": 1740080515,
+ "ending_balance": 0,
+ "footer": null,
+ "from_invoice": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_17vTkwDEQaroqDjs/test_YWNjdF8xN3ZUa3dERVFhcm9xRGpzLF9Sb0lEc01LdTZjY1hlNjBRN21UTWdGSGhFNlVUbHZZLDEzMDYyMTMyMA0200vWgEgP59?s=ap",
+ "id": "in_1Qufd9DEQaroqDjsDvbu5rW2",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_17vTkwDEQaroqDjs/test_YWNjdF8xN3ZUa3dERVFhcm9xRGpzLF9Sb0lEc01LdTZjY1hlNjBRN21UTWdGSGhFNlVUbHZZLDEzMDYyMTMyMA0200vWgEgP59/pdf?s=ap",
+ "issuer": {
+ "type": "self"
+ },
+ "last_finalization_error": null,
+ "latest_revision": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 72000,
+ "amount_excluding_tax": 72000,
+ "currency": "usd",
+ "description": "Zulip Cloud Plus",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "il_1Qufd8DEQaroqDjsQQpSSXbF",
+ "invoice": "in_1Qufd9DEQaroqDjsDvbu5rW2",
+ "invoice_item": "ii_1Qufd8DEQaroqDjsXOoGvTdx",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "pretax_credit_amounts": [],
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1722230793,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1Phm6PDEQaroqDjsHR9eMJZ4",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_QYtuRwnhi1w0Ui",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 12000,
+ "unit_amount_decimal": "12000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 6,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "12000"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/in_1Qufd9DEQaroqDjsDvbu5rW2/lines"
+ },
+ "livemode": false,
+ "metadata": {
+ "billing_schedule": "1",
+ "current_plan_id": "None",
+ "license_management": "automatic",
+ "licenses": "6",
+ "on_free_trial": "False",
+ "plan_tier": "2",
+ "user_id": "10"
+ },
+ "next_payment_attempt": null,
+ "number": "A984DE48-0001",
+ "object": "invoice",
+ "on_behalf_of": null,
+ "paid": true,
+ "paid_out_of_band": false,
+ "payment_intent": "pi_3QufdADEQaroqDjs0K88fqLj",
+ "payment_settings": {
+ "default_mandate": null,
+ "payment_method_options": null,
+ "payment_method_types": null
+ },
+ "period_end": 1740080515,
+ "period_start": 1740080515,
+ "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"
+ },
+ "template": null,
+ "template_version": null
+ },
+ "rendering_options": null,
+ "shipping_cost": null,
+ "shipping_details": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Cloud Plus",
+ "status": "paid",
+ "status_transitions": {
+ "finalized_at": 1740080515,
+ "marked_uncollectible_at": null,
+ "paid_at": 1740080517,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subscription_details": {
+ "metadata": null
+ },
+ "subtotal": 72000,
+ "subtotal_excluding_tax": 72000,
+ "tax": null,
+ "test_clock": null,
+ "total": 72000,
+ "total_discount_amounts": [],
+ "total_excluding_tax": 72000,
+ "total_pretax_credit_amounts": [],
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1740080515
+ }
+ },
+ "id": "evt_1QufdEDEQaroqDjseBLOHfNx",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 2,
+ "request": {
+ "id": "req_Az3j4bgbMfFvdK",
+ "idempotency_key": "b3ecd8cb-9cff-451d-bc49-0cc7cf144e35"
+ },
+ "type": "invoice.payment_succeeded"
+ },
+ {
+ "api_version": "2020-08-27",
+ "created": 1740080519,
+ "data": {
+ "object": {
+ "account_country": "US",
+ "account_name": "Kandra Labs, Inc.",
+ "account_tax_ids": null,
+ "amount_due": 72000,
+ "amount_paid": 72000,
+ "amount_remaining": 0,
+ "amount_shipping": 0,
+ "application": null,
+ "application_fee_amount": null,
+ "attempt_count": 1,
+ "attempted": true,
+ "auto_advance": false,
+ "automatic_tax": {
+ "disabled_reason": null,
+ "enabled": false,
+ "liability": null,
+ "status": null
+ },
+ "automatically_finalizes_at": null,
+ "billing_reason": "manual",
+ "charge": "ch_3QufdADEQaroqDjs0bDYCSyl",
+ "collection_method": "charge_automatically",
+ "created": 1740080515,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_RoIDdmj3lHKt7D",
+ "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": 1740080515,
+ "ending_balance": 0,
+ "footer": null,
+ "from_invoice": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_17vTkwDEQaroqDjs/test_YWNjdF8xN3ZUa3dERVFhcm9xRGpzLF9Sb0lEc01LdTZjY1hlNjBRN21UTWdGSGhFNlVUbHZZLDEzMDYyMTMyMA0200vWgEgP59?s=ap",
+ "id": "in_1Qufd9DEQaroqDjsDvbu5rW2",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_17vTkwDEQaroqDjs/test_YWNjdF8xN3ZUa3dERVFhcm9xRGpzLF9Sb0lEc01LdTZjY1hlNjBRN21UTWdGSGhFNlVUbHZZLDEzMDYyMTMyMA0200vWgEgP59/pdf?s=ap",
+ "issuer": {
+ "type": "self"
+ },
+ "last_finalization_error": null,
+ "latest_revision": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 72000,
+ "amount_excluding_tax": 72000,
+ "currency": "usd",
+ "description": "Zulip Cloud Plus",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "il_1Qufd8DEQaroqDjsQQpSSXbF",
+ "invoice": "in_1Qufd9DEQaroqDjsDvbu5rW2",
+ "invoice_item": "ii_1Qufd8DEQaroqDjsXOoGvTdx",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "pretax_credit_amounts": [],
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1722230793,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1Phm6PDEQaroqDjsHR9eMJZ4",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_QYtuRwnhi1w0Ui",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 12000,
+ "unit_amount_decimal": "12000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 6,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "12000"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/in_1Qufd9DEQaroqDjsDvbu5rW2/lines"
+ },
+ "livemode": false,
+ "metadata": {
+ "billing_schedule": "1",
+ "current_plan_id": "None",
+ "license_management": "automatic",
+ "licenses": "6",
+ "on_free_trial": "False",
+ "plan_tier": "2",
+ "user_id": "10"
+ },
+ "next_payment_attempt": null,
+ "number": "A984DE48-0001",
+ "object": "invoice",
+ "on_behalf_of": null,
+ "paid": true,
+ "paid_out_of_band": false,
+ "payment_intent": "pi_3QufdADEQaroqDjs0K88fqLj",
+ "payment_settings": {
+ "default_mandate": null,
+ "payment_method_options": null,
+ "payment_method_types": null
+ },
+ "period_end": 1740080515,
+ "period_start": 1740080515,
+ "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"
+ },
+ "template": null,
+ "template_version": null
+ },
+ "rendering_options": null,
+ "shipping_cost": null,
+ "shipping_details": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Cloud Plus",
+ "status": "paid",
+ "status_transitions": {
+ "finalized_at": 1740080515,
+ "marked_uncollectible_at": null,
+ "paid_at": 1740080517,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subscription_details": {
+ "metadata": null
+ },
+ "subtotal": 72000,
+ "subtotal_excluding_tax": 72000,
+ "tax": null,
+ "test_clock": null,
+ "total": 72000,
+ "total_discount_amounts": [],
+ "total_excluding_tax": 72000,
+ "total_pretax_credit_amounts": [],
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1740080515
+ }
+ },
+ "id": "evt_1QufdEDEQaroqDjs1zGATUKu",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 2,
+ "request": {
+ "id": "req_Az3j4bgbMfFvdK",
+ "idempotency_key": "b3ecd8cb-9cff-451d-bc49-0cc7cf144e35"
+ },
+ "type": "invoice.paid"
+ },
+ {
+ "api_version": "2020-08-27",
+ "created": 1740080519,
+ "data": {
+ "object": {
+ "account_country": "US",
+ "account_name": "Kandra Labs, Inc.",
+ "account_tax_ids": null,
+ "amount_due": 72000,
+ "amount_paid": 72000,
+ "amount_remaining": 0,
+ "amount_shipping": 0,
+ "application": null,
+ "application_fee_amount": null,
+ "attempt_count": 1,
+ "attempted": true,
+ "auto_advance": false,
+ "automatic_tax": {
+ "disabled_reason": null,
+ "enabled": false,
+ "liability": null,
+ "status": null
+ },
+ "automatically_finalizes_at": null,
+ "billing_reason": "manual",
+ "charge": "ch_3QufdADEQaroqDjs0bDYCSyl",
+ "collection_method": "charge_automatically",
+ "created": 1740080515,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_RoIDdmj3lHKt7D",
+ "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": 1740080515,
+ "ending_balance": 0,
+ "footer": null,
+ "from_invoice": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_17vTkwDEQaroqDjs/test_YWNjdF8xN3ZUa3dERVFhcm9xRGpzLF9Sb0lEc01LdTZjY1hlNjBRN21UTWdGSGhFNlVUbHZZLDEzMDYyMTMxOQ0200JI4Bl51G?s=ap",
+ "id": "in_1Qufd9DEQaroqDjsDvbu5rW2",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_17vTkwDEQaroqDjs/test_YWNjdF8xN3ZUa3dERVFhcm9xRGpzLF9Sb0lEc01LdTZjY1hlNjBRN21UTWdGSGhFNlVUbHZZLDEzMDYyMTMxOQ0200JI4Bl51G/pdf?s=ap",
+ "issuer": {
+ "type": "self"
+ },
+ "last_finalization_error": null,
+ "latest_revision": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 72000,
+ "amount_excluding_tax": 72000,
+ "currency": "usd",
+ "description": "Zulip Cloud Plus",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "il_1Qufd8DEQaroqDjsQQpSSXbF",
+ "invoice": "in_1Qufd9DEQaroqDjsDvbu5rW2",
+ "invoice_item": "ii_1Qufd8DEQaroqDjsXOoGvTdx",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "pretax_credit_amounts": [],
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1722230793,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1Phm6PDEQaroqDjsHR9eMJZ4",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_QYtuRwnhi1w0Ui",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 12000,
+ "unit_amount_decimal": "12000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 6,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "12000"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/in_1Qufd9DEQaroqDjsDvbu5rW2/lines"
+ },
+ "livemode": false,
+ "metadata": {
+ "billing_schedule": "1",
+ "current_plan_id": "None",
+ "license_management": "automatic",
+ "licenses": "6",
+ "on_free_trial": "False",
+ "plan_tier": "2",
+ "user_id": "10"
+ },
+ "next_payment_attempt": null,
+ "number": "A984DE48-0001",
+ "object": "invoice",
+ "on_behalf_of": null,
+ "paid": true,
+ "paid_out_of_band": false,
+ "payment_intent": "pi_3QufdADEQaroqDjs0K88fqLj",
+ "payment_settings": {
+ "default_mandate": null,
+ "payment_method_options": null,
+ "payment_method_types": null
+ },
+ "period_end": 1740080515,
+ "period_start": 1740080515,
+ "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"
+ },
+ "template": null,
+ "template_version": null
+ },
+ "rendering_options": null,
+ "shipping_cost": null,
+ "shipping_details": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Cloud Plus",
+ "status": "paid",
+ "status_transitions": {
+ "finalized_at": 1740080515,
+ "marked_uncollectible_at": null,
+ "paid_at": 1740080517,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subscription_details": {
+ "metadata": null
+ },
+ "subtotal": 72000,
+ "subtotal_excluding_tax": 72000,
+ "tax": null,
+ "test_clock": null,
+ "total": 72000,
+ "total_discount_amounts": [],
+ "total_excluding_tax": 72000,
+ "total_pretax_credit_amounts": [],
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1740080515
+ },
+ "previous_attributes": {
+ "amount_paid": 0,
+ "amount_remaining": 72000,
+ "attempt_count": 0,
+ "attempted": false,
+ "charge": null,
+ "paid": false,
+ "status": "open",
+ "status_transitions": {
+ "paid_at": null
+ }
+ }
+ },
+ "id": "evt_1QufdDDEQaroqDjswZ21SQHW",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 0,
+ "request": {
+ "id": "req_Az3j4bgbMfFvdK",
+ "idempotency_key": "b3ecd8cb-9cff-451d-bc49-0cc7cf144e35"
+ },
+ "type": "invoice.updated"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "url": "/v1/events"
+}
diff --git a/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Event.list.4.json b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Event.list.4.json
new file mode 100644
index 00000000000..6d922067afe
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Event.list.4.json
@@ -0,0 +1,6 @@
+{
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "url": "/v1/events"
+}
diff --git a/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Invoice.create.1.json b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Invoice.create.1.json
new file mode 100644
index 00000000000..6aeef0a6d2a
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Invoice.create.1.json
@@ -0,0 +1,177 @@
+{
+ "account_country": "US",
+ "account_name": "Kandra Labs, Inc.",
+ "account_tax_ids": null,
+ "amount_due": 72000,
+ "amount_paid": 0,
+ "amount_remaining": 72000,
+ "amount_shipping": 0,
+ "application": null,
+ "application_fee_amount": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": false,
+ "automatic_tax": {
+ "disabled_reason": null,
+ "enabled": false,
+ "liability": null,
+ "status": null
+ },
+ "automatically_finalizes_at": null,
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "charge_automatically",
+ "created": 1740080515,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_RoIDdmj3lHKt7D",
+ "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_1Qufd9DEQaroqDjsDvbu5rW2",
+ "invoice_pdf": null,
+ "issuer": {
+ "type": "self"
+ },
+ "last_finalization_error": null,
+ "latest_revision": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 72000,
+ "amount_excluding_tax": 72000,
+ "currency": "usd",
+ "description": "Zulip Cloud Plus",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "il_1Qufd8DEQaroqDjsQQpSSXbF",
+ "invoice": "in_1Qufd9DEQaroqDjsDvbu5rW2",
+ "invoice_item": "ii_1Qufd8DEQaroqDjsXOoGvTdx",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "pretax_credit_amounts": [],
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1722230793,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1Phm6PDEQaroqDjsHR9eMJZ4",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_QYtuRwnhi1w0Ui",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 12000,
+ "unit_amount_decimal": "12000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 6,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "12000"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/in_1Qufd9DEQaroqDjsDvbu5rW2/lines"
+ },
+ "livemode": false,
+ "metadata": {
+ "billing_schedule": "1",
+ "current_plan_id": "None",
+ "license_management": "automatic",
+ "licenses": "6",
+ "on_free_trial": "False",
+ "plan_tier": "2",
+ "user_id": "10"
+ },
+ "next_payment_attempt": null,
+ "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": 1740080515,
+ "period_start": 1740080515,
+ "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"
+ },
+ "template": null,
+ "template_version": null
+ },
+ "rendering_options": null,
+ "shipping_cost": null,
+ "shipping_details": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Cloud Plus",
+ "status": "draft",
+ "status_transitions": {
+ "finalized_at": null,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subscription_details": {
+ "metadata": null
+ },
+ "subtotal": 72000,
+ "subtotal_excluding_tax": 72000,
+ "tax": null,
+ "test_clock": null,
+ "total": 72000,
+ "total_discount_amounts": [],
+ "total_excluding_tax": 72000,
+ "total_pretax_credit_amounts": [],
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": null
+}
diff --git a/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Invoice.create.2.json b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Invoice.create.2.json
new file mode 100644
index 00000000000..54895b704f2
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Invoice.create.2.json
@@ -0,0 +1,169 @@
+{
+ "account_country": "US",
+ "account_name": "Kandra Labs, Inc.",
+ "account_tax_ids": null,
+ "amount_due": 72000,
+ "amount_paid": 0,
+ "amount_remaining": 72000,
+ "amount_shipping": 0,
+ "application": null,
+ "application_fee_amount": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "automatic_tax": {
+ "disabled_reason": null,
+ "enabled": false,
+ "liability": null,
+ "status": null
+ },
+ "automatically_finalizes_at": 1740339722,
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "charge_automatically",
+ "created": 1740080521,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_RoIDdmj3lHKt7D",
+ "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_1QufdFDEQaroqDjsCUXY098h",
+ "invoice_pdf": null,
+ "issuer": {
+ "type": "self"
+ },
+ "last_finalization_error": null,
+ "latest_revision": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 72000,
+ "amount_excluding_tax": 72000,
+ "currency": "usd",
+ "description": "Zulip Cloud Plus - renewal",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "il_1QufdFDEQaroqDjsjImpAGat",
+ "invoice": "in_1QufdFDEQaroqDjsCUXY098h",
+ "invoice_item": "ii_1QufdFDEQaroqDjsl50uvK38",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1388631845,
+ "start": 1357095845
+ },
+ "plan": null,
+ "pretax_credit_amounts": [],
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1722230568,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1Phm2mDEQaroqDjsG8ObTVQ3",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_QYtppn7atzHY0n",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 12000,
+ "unit_amount_decimal": "12000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 6,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "12000"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/in_1QufdFDEQaroqDjsCUXY098h/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": 1740084121,
+ "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": 1740080521,
+ "period_start": 1740080521,
+ "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"
+ },
+ "template": null,
+ "template_version": null
+ },
+ "rendering_options": null,
+ "shipping_cost": null,
+ "shipping_details": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Cloud Plus",
+ "status": "draft",
+ "status_transitions": {
+ "finalized_at": null,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subscription_details": {
+ "metadata": null
+ },
+ "subtotal": 72000,
+ "subtotal_excluding_tax": 72000,
+ "tax": null,
+ "test_clock": null,
+ "total": 72000,
+ "total_discount_amounts": [],
+ "total_excluding_tax": 72000,
+ "total_pretax_credit_amounts": [],
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": null
+}
diff --git a/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Invoice.finalize_invoice.1.json b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Invoice.finalize_invoice.1.json
new file mode 100644
index 00000000000..4e303a72b8d
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Invoice.finalize_invoice.1.json
@@ -0,0 +1,177 @@
+{
+ "account_country": "US",
+ "account_name": "Kandra Labs, Inc.",
+ "account_tax_ids": null,
+ "amount_due": 72000,
+ "amount_paid": 0,
+ "amount_remaining": 72000,
+ "amount_shipping": 0,
+ "application": null,
+ "application_fee_amount": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": false,
+ "automatic_tax": {
+ "disabled_reason": null,
+ "enabled": false,
+ "liability": null,
+ "status": null
+ },
+ "automatically_finalizes_at": null,
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "charge_automatically",
+ "created": 1740080515,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_RoIDdmj3lHKt7D",
+ "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": 1740080515,
+ "ending_balance": 0,
+ "footer": null,
+ "from_invoice": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_17vTkwDEQaroqDjs/test_YWNjdF8xN3ZUa3dERVFhcm9xRGpzLF9Sb0lEc01LdTZjY1hlNjBRN21UTWdGSGhFNlVUbHZZLDEzMDYyMTMxNg0200pNDWiupe?s=ap",
+ "id": "in_1Qufd9DEQaroqDjsDvbu5rW2",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_17vTkwDEQaroqDjs/test_YWNjdF8xN3ZUa3dERVFhcm9xRGpzLF9Sb0lEc01LdTZjY1hlNjBRN21UTWdGSGhFNlVUbHZZLDEzMDYyMTMxNg0200pNDWiupe/pdf?s=ap",
+ "issuer": {
+ "type": "self"
+ },
+ "last_finalization_error": null,
+ "latest_revision": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 72000,
+ "amount_excluding_tax": 72000,
+ "currency": "usd",
+ "description": "Zulip Cloud Plus",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "il_1Qufd8DEQaroqDjsQQpSSXbF",
+ "invoice": "in_1Qufd9DEQaroqDjsDvbu5rW2",
+ "invoice_item": "ii_1Qufd8DEQaroqDjsXOoGvTdx",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "pretax_credit_amounts": [],
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1722230793,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1Phm6PDEQaroqDjsHR9eMJZ4",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_QYtuRwnhi1w0Ui",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 12000,
+ "unit_amount_decimal": "12000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 6,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "12000"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/in_1Qufd9DEQaroqDjsDvbu5rW2/lines"
+ },
+ "livemode": false,
+ "metadata": {
+ "billing_schedule": "1",
+ "current_plan_id": "None",
+ "license_management": "automatic",
+ "licenses": "6",
+ "on_free_trial": "False",
+ "plan_tier": "2",
+ "user_id": "10"
+ },
+ "next_payment_attempt": null,
+ "number": "A984DE48-0001",
+ "object": "invoice",
+ "on_behalf_of": null,
+ "paid": false,
+ "paid_out_of_band": false,
+ "payment_intent": "pi_3QufdADEQaroqDjs0K88fqLj",
+ "payment_settings": {
+ "default_mandate": null,
+ "payment_method_options": null,
+ "payment_method_types": null
+ },
+ "period_end": 1740080515,
+ "period_start": 1740080515,
+ "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"
+ },
+ "template": null,
+ "template_version": null
+ },
+ "rendering_options": null,
+ "shipping_cost": null,
+ "shipping_details": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Cloud Plus",
+ "status": "open",
+ "status_transitions": {
+ "finalized_at": 1740080515,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subscription_details": {
+ "metadata": null
+ },
+ "subtotal": 72000,
+ "subtotal_excluding_tax": 72000,
+ "tax": null,
+ "test_clock": null,
+ "total": 72000,
+ "total_discount_amounts": [],
+ "total_excluding_tax": 72000,
+ "total_pretax_credit_amounts": [],
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": null
+}
diff --git a/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Invoice.finalize_invoice.2.json b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Invoice.finalize_invoice.2.json
new file mode 100644
index 00000000000..01a237f2670
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Invoice.finalize_invoice.2.json
@@ -0,0 +1,169 @@
+{
+ "account_country": "US",
+ "account_name": "Kandra Labs, Inc.",
+ "account_tax_ids": null,
+ "amount_due": 72000,
+ "amount_paid": 0,
+ "amount_remaining": 72000,
+ "amount_shipping": 0,
+ "application": null,
+ "application_fee_amount": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "automatic_tax": {
+ "disabled_reason": null,
+ "enabled": false,
+ "liability": null,
+ "status": null
+ },
+ "automatically_finalizes_at": null,
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "charge_automatically",
+ "created": 1740080521,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_RoIDdmj3lHKt7D",
+ "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": 1740080521,
+ "ending_balance": 0,
+ "footer": null,
+ "from_invoice": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_17vTkwDEQaroqDjs/test_YWNjdF8xN3ZUa3dERVFhcm9xRGpzLF9Sb0lEVVdXWXNaZ3JRWVFpaDlnUVNubngzNHNXV0RNLDEzMDYyMTMyMg0200nfWyilz4?s=ap",
+ "id": "in_1QufdFDEQaroqDjsCUXY098h",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_17vTkwDEQaroqDjs/test_YWNjdF8xN3ZUa3dERVFhcm9xRGpzLF9Sb0lEVVdXWXNaZ3JRWVFpaDlnUVNubngzNHNXV0RNLDEzMDYyMTMyMg0200nfWyilz4/pdf?s=ap",
+ "issuer": {
+ "type": "self"
+ },
+ "last_finalization_error": null,
+ "latest_revision": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 72000,
+ "amount_excluding_tax": 72000,
+ "currency": "usd",
+ "description": "Zulip Cloud Plus - renewal",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "il_1QufdFDEQaroqDjsjImpAGat",
+ "invoice": "in_1QufdFDEQaroqDjsCUXY098h",
+ "invoice_item": "ii_1QufdFDEQaroqDjsl50uvK38",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1388631845,
+ "start": 1357095845
+ },
+ "plan": null,
+ "pretax_credit_amounts": [],
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1722230568,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1Phm2mDEQaroqDjsG8ObTVQ3",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_QYtppn7atzHY0n",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 12000,
+ "unit_amount_decimal": "12000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 6,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "12000"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/in_1QufdFDEQaroqDjsCUXY098h/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": 1740084121,
+ "number": "A984DE48-0002",
+ "object": "invoice",
+ "on_behalf_of": null,
+ "paid": false,
+ "paid_out_of_band": false,
+ "payment_intent": "pi_3QufdGDEQaroqDjs0HXshhY4",
+ "payment_settings": {
+ "default_mandate": null,
+ "payment_method_options": null,
+ "payment_method_types": null
+ },
+ "period_end": 1740080521,
+ "period_start": 1740080521,
+ "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"
+ },
+ "template": null,
+ "template_version": null
+ },
+ "rendering_options": null,
+ "shipping_cost": null,
+ "shipping_details": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Cloud Plus",
+ "status": "open",
+ "status_transitions": {
+ "finalized_at": 1740080521,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subscription_details": {
+ "metadata": null
+ },
+ "subtotal": 72000,
+ "subtotal_excluding_tax": 72000,
+ "tax": null,
+ "test_clock": null,
+ "total": 72000,
+ "total_discount_amounts": [],
+ "total_excluding_tax": 72000,
+ "total_pretax_credit_amounts": [],
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": null
+}
diff --git a/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Invoice.list.1.json b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Invoice.list.1.json
new file mode 100644
index 00000000000..e39960ab725
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Invoice.list.1.json
@@ -0,0 +1,6 @@
+{
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "url": "/v1/invoices"
+}
diff --git a/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Invoice.list.2.json b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Invoice.list.2.json
new file mode 100644
index 00000000000..bfa82bd5744
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Invoice.list.2.json
@@ -0,0 +1,353 @@
+{
+ "data": [
+ {
+ "account_country": "US",
+ "account_name": "Kandra Labs, Inc.",
+ "account_tax_ids": null,
+ "amount_due": 72000,
+ "amount_paid": 0,
+ "amount_remaining": 72000,
+ "amount_shipping": 0,
+ "application": null,
+ "application_fee_amount": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "automatic_tax": {
+ "disabled_reason": null,
+ "enabled": false,
+ "liability": null,
+ "status": null
+ },
+ "automatically_finalizes_at": null,
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "charge_automatically",
+ "created": 1740080521,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_RoIDdmj3lHKt7D",
+ "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": 1740080521,
+ "ending_balance": 0,
+ "footer": null,
+ "from_invoice": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_17vTkwDEQaroqDjs/test_YWNjdF8xN3ZUa3dERVFhcm9xRGpzLF9Sb0lEVVdXWXNaZ3JRWVFpaDlnUVNubngzNHNXV0RNLDEzMDYyMTMyMw0200EwlB5Z81?s=ap",
+ "id": "in_1QufdFDEQaroqDjsCUXY098h",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_17vTkwDEQaroqDjs/test_YWNjdF8xN3ZUa3dERVFhcm9xRGpzLF9Sb0lEVVdXWXNaZ3JRWVFpaDlnUVNubngzNHNXV0RNLDEzMDYyMTMyMw0200EwlB5Z81/pdf?s=ap",
+ "issuer": {
+ "type": "self"
+ },
+ "last_finalization_error": null,
+ "latest_revision": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 72000,
+ "amount_excluding_tax": 72000,
+ "currency": "usd",
+ "description": "Zulip Cloud Plus - renewal",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "il_1QufdFDEQaroqDjsjImpAGat",
+ "invoice": "in_1QufdFDEQaroqDjsCUXY098h",
+ "invoice_item": "ii_1QufdFDEQaroqDjsl50uvK38",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1388631845,
+ "start": 1357095845
+ },
+ "plan": null,
+ "pretax_credit_amounts": [],
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1722230568,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1Phm2mDEQaroqDjsG8ObTVQ3",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_QYtppn7atzHY0n",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 12000,
+ "unit_amount_decimal": "12000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 6,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "12000"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/in_1QufdFDEQaroqDjsCUXY098h/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": 1740084121,
+ "number": "A984DE48-0002",
+ "object": "invoice",
+ "on_behalf_of": null,
+ "paid": false,
+ "paid_out_of_band": false,
+ "payment_intent": "pi_3QufdGDEQaroqDjs0HXshhY4",
+ "payment_settings": {
+ "default_mandate": null,
+ "payment_method_options": null,
+ "payment_method_types": null
+ },
+ "period_end": 1740080521,
+ "period_start": 1740080521,
+ "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"
+ },
+ "template": null,
+ "template_version": null
+ },
+ "rendering_options": null,
+ "shipping_cost": null,
+ "shipping_details": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Cloud Plus",
+ "status": "open",
+ "status_transitions": {
+ "finalized_at": 1740080521,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subscription_details": {
+ "metadata": null
+ },
+ "subtotal": 72000,
+ "subtotal_excluding_tax": 72000,
+ "tax": null,
+ "test_clock": null,
+ "total": 72000,
+ "total_discount_amounts": [],
+ "total_excluding_tax": 72000,
+ "total_pretax_credit_amounts": [],
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": null
+ },
+ {
+ "account_country": "US",
+ "account_name": "Kandra Labs, Inc.",
+ "account_tax_ids": null,
+ "amount_due": 72000,
+ "amount_paid": 72000,
+ "amount_remaining": 0,
+ "amount_shipping": 0,
+ "application": null,
+ "application_fee_amount": null,
+ "attempt_count": 1,
+ "attempted": true,
+ "auto_advance": false,
+ "automatic_tax": {
+ "disabled_reason": null,
+ "enabled": false,
+ "liability": null,
+ "status": null
+ },
+ "automatically_finalizes_at": null,
+ "billing_reason": "manual",
+ "charge": "ch_3QufdADEQaroqDjs0bDYCSyl",
+ "collection_method": "charge_automatically",
+ "created": 1740080515,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_RoIDdmj3lHKt7D",
+ "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": 1740080515,
+ "ending_balance": 0,
+ "footer": null,
+ "from_invoice": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_17vTkwDEQaroqDjs/test_YWNjdF8xN3ZUa3dERVFhcm9xRGpzLF9Sb0lEc01LdTZjY1hlNjBRN21UTWdGSGhFNlVUbHZZLDEzMDYyMTMyMw0200GN8TQC40?s=ap",
+ "id": "in_1Qufd9DEQaroqDjsDvbu5rW2",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_17vTkwDEQaroqDjs/test_YWNjdF8xN3ZUa3dERVFhcm9xRGpzLF9Sb0lEc01LdTZjY1hlNjBRN21UTWdGSGhFNlVUbHZZLDEzMDYyMTMyMw0200GN8TQC40/pdf?s=ap",
+ "issuer": {
+ "type": "self"
+ },
+ "last_finalization_error": null,
+ "latest_revision": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 72000,
+ "amount_excluding_tax": 72000,
+ "currency": "usd",
+ "description": "Zulip Cloud Plus",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "il_1Qufd8DEQaroqDjsQQpSSXbF",
+ "invoice": "in_1Qufd9DEQaroqDjsDvbu5rW2",
+ "invoice_item": "ii_1Qufd8DEQaroqDjsXOoGvTdx",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "pretax_credit_amounts": [],
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1722230793,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1Phm6PDEQaroqDjsHR9eMJZ4",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_QYtuRwnhi1w0Ui",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 12000,
+ "unit_amount_decimal": "12000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 6,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "12000"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/in_1Qufd9DEQaroqDjsDvbu5rW2/lines"
+ },
+ "livemode": false,
+ "metadata": {
+ "billing_schedule": "1",
+ "current_plan_id": "None",
+ "license_management": "automatic",
+ "licenses": "6",
+ "on_free_trial": "False",
+ "plan_tier": "2",
+ "user_id": "10"
+ },
+ "next_payment_attempt": null,
+ "number": "A984DE48-0001",
+ "object": "invoice",
+ "on_behalf_of": null,
+ "paid": true,
+ "paid_out_of_band": false,
+ "payment_intent": "pi_3QufdADEQaroqDjs0K88fqLj",
+ "payment_settings": {
+ "default_mandate": null,
+ "payment_method_options": null,
+ "payment_method_types": null
+ },
+ "period_end": 1740080515,
+ "period_start": 1740080515,
+ "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"
+ },
+ "template": null,
+ "template_version": null
+ },
+ "rendering_options": null,
+ "shipping_cost": null,
+ "shipping_details": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Cloud Plus",
+ "status": "paid",
+ "status_transitions": {
+ "finalized_at": 1740080515,
+ "marked_uncollectible_at": null,
+ "paid_at": 1740080517,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subscription_details": {
+ "metadata": null
+ },
+ "subtotal": 72000,
+ "subtotal_excluding_tax": 72000,
+ "tax": null,
+ "test_clock": null,
+ "total": 72000,
+ "total_discount_amounts": [],
+ "total_excluding_tax": 72000,
+ "total_pretax_credit_amounts": [],
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1740080515
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "url": "/v1/invoices"
+}
diff --git a/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Invoice.pay.1.json b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Invoice.pay.1.json
new file mode 100644
index 00000000000..47df97ffae4
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--Invoice.pay.1.json
@@ -0,0 +1,177 @@
+{
+ "account_country": "US",
+ "account_name": "Kandra Labs, Inc.",
+ "account_tax_ids": null,
+ "amount_due": 72000,
+ "amount_paid": 72000,
+ "amount_remaining": 0,
+ "amount_shipping": 0,
+ "application": null,
+ "application_fee_amount": null,
+ "attempt_count": 1,
+ "attempted": true,
+ "auto_advance": false,
+ "automatic_tax": {
+ "disabled_reason": null,
+ "enabled": false,
+ "liability": null,
+ "status": null
+ },
+ "automatically_finalizes_at": null,
+ "billing_reason": "manual",
+ "charge": "ch_3QufdADEQaroqDjs0bDYCSyl",
+ "collection_method": "charge_automatically",
+ "created": 1740080515,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_RoIDdmj3lHKt7D",
+ "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": 1740080515,
+ "ending_balance": 0,
+ "footer": null,
+ "from_invoice": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_17vTkwDEQaroqDjs/test_YWNjdF8xN3ZUa3dERVFhcm9xRGpzLF9Sb0lEc01LdTZjY1hlNjBRN21UTWdGSGhFNlVUbHZZLDEzMDYyMTMxOQ0200JI4Bl51G?s=ap",
+ "id": "in_1Qufd9DEQaroqDjsDvbu5rW2",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_17vTkwDEQaroqDjs/test_YWNjdF8xN3ZUa3dERVFhcm9xRGpzLF9Sb0lEc01LdTZjY1hlNjBRN21UTWdGSGhFNlVUbHZZLDEzMDYyMTMxOQ0200JI4Bl51G/pdf?s=ap",
+ "issuer": {
+ "type": "self"
+ },
+ "last_finalization_error": null,
+ "latest_revision": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 72000,
+ "amount_excluding_tax": 72000,
+ "currency": "usd",
+ "description": "Zulip Cloud Plus",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "il_1Qufd8DEQaroqDjsQQpSSXbF",
+ "invoice": "in_1Qufd9DEQaroqDjsDvbu5rW2",
+ "invoice_item": "ii_1Qufd8DEQaroqDjsXOoGvTdx",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "pretax_credit_amounts": [],
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1722230793,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1Phm6PDEQaroqDjsHR9eMJZ4",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_QYtuRwnhi1w0Ui",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 12000,
+ "unit_amount_decimal": "12000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 6,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "12000"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/in_1Qufd9DEQaroqDjsDvbu5rW2/lines"
+ },
+ "livemode": false,
+ "metadata": {
+ "billing_schedule": "1",
+ "current_plan_id": "None",
+ "license_management": "automatic",
+ "licenses": "6",
+ "on_free_trial": "False",
+ "plan_tier": "2",
+ "user_id": "10"
+ },
+ "next_payment_attempt": null,
+ "number": "A984DE48-0001",
+ "object": "invoice",
+ "on_behalf_of": null,
+ "paid": true,
+ "paid_out_of_band": false,
+ "payment_intent": "pi_3QufdADEQaroqDjs0K88fqLj",
+ "payment_settings": {
+ "default_mandate": null,
+ "payment_method_options": null,
+ "payment_method_types": null
+ },
+ "period_end": 1740080515,
+ "period_start": 1740080515,
+ "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"
+ },
+ "template": null,
+ "template_version": null
+ },
+ "rendering_options": null,
+ "shipping_cost": null,
+ "shipping_details": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Cloud Plus",
+ "status": "paid",
+ "status_transitions": {
+ "finalized_at": 1740080515,
+ "marked_uncollectible_at": null,
+ "paid_at": 1740080517,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subscription_details": {
+ "metadata": null
+ },
+ "subtotal": 72000,
+ "subtotal_excluding_tax": 72000,
+ "tax": null,
+ "test_clock": null,
+ "total": 72000,
+ "total_discount_amounts": [],
+ "total_excluding_tax": 72000,
+ "total_pretax_credit_amounts": [],
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1740080515
+}
diff --git a/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--InvoiceItem.create.1.json b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--InvoiceItem.create.1.json
new file mode 100644
index 00000000000..b5cb0d51097
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--InvoiceItem.create.1.json
@@ -0,0 +1,47 @@
+{
+ "amount": 72000,
+ "currency": "usd",
+ "customer": "cus_RoIDdmj3lHKt7D",
+ "date": 1740080514,
+ "description": "Zulip Cloud Plus",
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_1Qufd8DEQaroqDjsXOoGvTdx",
+ "invoice": null,
+ "livemode": false,
+ "metadata": {},
+ "object": "invoiceitem",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1722230793,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1Phm6PDEQaroqDjsHR9eMJZ4",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_QYtuRwnhi1w0Ui",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 12000,
+ "unit_amount_decimal": "12000"
+ },
+ "proration": false,
+ "quantity": 6,
+ "subscription": null,
+ "tax_rates": [],
+ "test_clock": null,
+ "unit_amount": 12000,
+ "unit_amount_decimal": "12000"
+}
diff --git a/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--InvoiceItem.create.2.json b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--InvoiceItem.create.2.json
new file mode 100644
index 00000000000..97ef2e4953f
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--InvoiceItem.create.2.json
@@ -0,0 +1,47 @@
+{
+ "amount": 72000,
+ "currency": "usd",
+ "customer": "cus_RoIDdmj3lHKt7D",
+ "date": 1740080521,
+ "description": "Zulip Cloud Plus - renewal",
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_1QufdFDEQaroqDjsl50uvK38",
+ "invoice": null,
+ "livemode": false,
+ "metadata": {},
+ "object": "invoiceitem",
+ "period": {
+ "end": 1388631845,
+ "start": 1357095845
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1722230568,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1Phm2mDEQaroqDjsG8ObTVQ3",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_QYtppn7atzHY0n",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 12000,
+ "unit_amount_decimal": "12000"
+ },
+ "proration": false,
+ "quantity": 6,
+ "subscription": null,
+ "tax_rates": [],
+ "test_clock": null,
+ "unit_amount": 12000,
+ "unit_amount_decimal": "12000"
+}
diff --git a/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--PaymentMethod.create.1.json b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--PaymentMethod.create.1.json
new file mode 100644
index 00000000000..45c43b22937
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--PaymentMethod.create.1.json
@@ -0,0 +1,50 @@
+{
+ "allow_redisplay": "unspecified",
+ "billing_details": {
+ "address": {
+ "city": "San Francisco",
+ "country": "US",
+ "line1": "123 Main St",
+ "line2": null,
+ "postal_code": "94105",
+ "state": "CA"
+ },
+ "email": null,
+ "name": "John Doe",
+ "phone": null
+ },
+ "card": {
+ "brand": "visa",
+ "checks": {
+ "address_line1_check": "unchecked",
+ "address_postal_code_check": "unchecked",
+ "cvc_check": "unchecked"
+ },
+ "country": "US",
+ "display_brand": "visa",
+ "exp_month": 2,
+ "exp_year": 2026,
+ "fingerprint": "9XKsMixKBi6kIIzd",
+ "funding": "credit",
+ "generated_from": null,
+ "last4": "4242",
+ "networks": {
+ "available": [
+ "visa"
+ ],
+ "preferred": null
+ },
+ "regulated_status": "unregulated",
+ "three_d_secure_usage": {
+ "supported": true
+ },
+ "wallet": null
+ },
+ "created": 1740080510,
+ "customer": null,
+ "id": "pm_1Qufd3DEQaroqDjsvPgCjrpD",
+ "livemode": false,
+ "metadata": {},
+ "object": "payment_method",
+ "type": "card"
+}
diff --git a/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--SetupIntent.create.1.json b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--SetupIntent.create.1.json
new file mode 100644
index 00000000000..548a8f2877a
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--SetupIntent.create.1.json
@@ -0,0 +1,34 @@
+{
+ "application": null,
+ "automatic_payment_methods": null,
+ "cancellation_reason": null,
+ "client_secret": "seti_1Qufd4DEQaroqDjs17IFanr1_secret_RoIDocR7YiFOGSvkQ2PUFQGeGeBhcXg",
+ "created": 1740080510,
+ "customer": "cus_RoIDdmj3lHKt7D",
+ "description": null,
+ "flow_directions": null,
+ "id": "seti_1Qufd4DEQaroqDjs17IFanr1",
+ "last_setup_error": null,
+ "latest_attempt": "setatt_1Qufd4DEQaroqDjsR5gPa7mX",
+ "livemode": false,
+ "mandate": null,
+ "metadata": {},
+ "next_action": null,
+ "object": "setup_intent",
+ "on_behalf_of": null,
+ "payment_method": "pm_1Qufd3DEQaroqDjsvPgCjrpD",
+ "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/customer_minimum_licenses_for_plan--SetupIntent.list.1.json b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--SetupIntent.list.1.json
new file mode 100644
index 00000000000..e16a9ce4c2f
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--SetupIntent.list.1.json
@@ -0,0 +1,41 @@
+{
+ "data": [
+ {
+ "application": null,
+ "automatic_payment_methods": null,
+ "cancellation_reason": null,
+ "client_secret": "seti_1Qufd2DEQaroqDjsGi59ek4c_secret_RoIDujxJf74h3tiTRe6fT7XZp8Jekui",
+ "created": 1740080508,
+ "customer": "cus_RoIDdmj3lHKt7D",
+ "description": null,
+ "flow_directions": null,
+ "id": "seti_1Qufd2DEQaroqDjsGi59ek4c",
+ "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": false,
+ "object": "list",
+ "url": "/v1/setup_intents"
+}
diff --git a/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--SetupIntent.retrieve.1.json b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--SetupIntent.retrieve.1.json
new file mode 100644
index 00000000000..548a8f2877a
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--SetupIntent.retrieve.1.json
@@ -0,0 +1,34 @@
+{
+ "application": null,
+ "automatic_payment_methods": null,
+ "cancellation_reason": null,
+ "client_secret": "seti_1Qufd4DEQaroqDjs17IFanr1_secret_RoIDocR7YiFOGSvkQ2PUFQGeGeBhcXg",
+ "created": 1740080510,
+ "customer": "cus_RoIDdmj3lHKt7D",
+ "description": null,
+ "flow_directions": null,
+ "id": "seti_1Qufd4DEQaroqDjs17IFanr1",
+ "last_setup_error": null,
+ "latest_attempt": "setatt_1Qufd4DEQaroqDjsR5gPa7mX",
+ "livemode": false,
+ "mandate": null,
+ "metadata": {},
+ "next_action": null,
+ "object": "setup_intent",
+ "on_behalf_of": null,
+ "payment_method": "pm_1Qufd3DEQaroqDjsvPgCjrpD",
+ "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/customer_minimum_licenses_for_plan--checkout.Session.create.1.json b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--checkout.Session.create.1.json
new file mode 100644
index 00000000000..36967fe854d
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--checkout.Session.create.1.json
@@ -0,0 +1,85 @@
+{
+ "adaptive_pricing": null,
+ "after_expiration": null,
+ "allow_promotion_codes": null,
+ "amount_subtotal": null,
+ "amount_total": null,
+ "automatic_tax": {
+ "enabled": false,
+ "liability": null,
+ "status": null
+ },
+ "billing_address_collection": "required",
+ "cancel_url": "http://zulip.testserver/upgrade/?manual_license_management=false&tier=1",
+ "client_reference_id": null,
+ "client_secret": null,
+ "collected_information": {
+ "shipping_details": null
+ },
+ "consent": null,
+ "consent_collection": null,
+ "created": 1740080508,
+ "currency": null,
+ "currency_conversion": null,
+ "custom_fields": [],
+ "custom_text": {
+ "after_submit": null,
+ "shipping_address": null,
+ "submit": null,
+ "terms_of_service_acceptance": null
+ },
+ "customer": "cus_RoIDdmj3lHKt7D",
+ "customer_creation": null,
+ "customer_details": {
+ "address": null,
+ "email": "[email protected]",
+ "name": null,
+ "phone": null,
+ "tax_exempt": null,
+ "tax_ids": null
+ },
+ "customer_email": null,
+ "discounts": null,
+ "expires_at": 1740166908,
+ "id": "cs_test_c1idTTx38NASfFfwpi9tQgBlY66gwRUMXvVWtrUTFMDvdSEFHzaSlT5QMv",
+ "invoice": null,
+ "invoice_creation": null,
+ "livemode": false,
+ "locale": null,
+ "metadata": {
+ "type": "card_update",
+ "user_id": "10"
+ },
+ "mode": "setup",
+ "object": "checkout.session",
+ "payment_intent": null,
+ "payment_link": null,
+ "payment_method_collection": "always",
+ "payment_method_configuration_details": null,
+ "payment_method_options": {
+ "card": {
+ "request_three_d_secure": "automatic"
+ }
+ },
+ "payment_method_types": [
+ "card"
+ ],
+ "payment_status": "no_payment_required",
+ "phone_number_collection": {
+ "enabled": false
+ },
+ "recovered_from": null,
+ "saved_payment_method_options": null,
+ "setup_intent": "seti_1Qufd2DEQaroqDjsGi59ek4c",
+ "shipping": null,
+ "shipping_address_collection": null,
+ "shipping_options": [],
+ "shipping_rate": null,
+ "status": "open",
+ "submit_type": null,
+ "subscription": null,
+ "success_url": "http://zulip.testserver/billing/event_status/?stripe_session_id={CHECKOUT_SESSION_ID}",
+ "total_details": null,
+ "ui_mode": "hosted",
+ "url": "https://checkout.stripe.com/c/pay/cs_test_c1idTTx38NASfFfwpi9tQgBlY66gwRUMXvVWtrUTFMDvdSEFHzaSlT5QMv#fid1d2BpamRhQ2prcSc%2FJ1ZqcHdmYCVWZGt2JVV3aicpJ2R1bE5gfCc%2FJ3VuWnFgdnFaXVRmMU5zNkldQTY9SnNRY09XZml2UXNQJyknY3dqaFZgd3Ngdyc%2FcXdwYCknaWR8anBxUXx1YCc%2FJ3Zsa2JpYFpmamlwaGsnKSdga2RnaWBVaWRmYG1qaWFgd3YnP3F3cGB4JSUl"
+}
diff --git a/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--checkout.Session.list.1.json b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--checkout.Session.list.1.json
new file mode 100644
index 00000000000..35be6e0173a
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/customer_minimum_licenses_for_plan--checkout.Session.list.1.json
@@ -0,0 +1,92 @@
+{
+ "data": [
+ {
+ "adaptive_pricing": null,
+ "after_expiration": null,
+ "allow_promotion_codes": null,
+ "amount_subtotal": null,
+ "amount_total": null,
+ "automatic_tax": {
+ "enabled": false,
+ "liability": null,
+ "status": null
+ },
+ "billing_address_collection": "required",
+ "cancel_url": "http://zulip.testserver/upgrade/?manual_license_management=false&tier=1",
+ "client_reference_id": null,
+ "client_secret": null,
+ "collected_information": {
+ "shipping_details": null
+ },
+ "consent": null,
+ "consent_collection": null,
+ "created": 1740080508,
+ "currency": null,
+ "currency_conversion": null,
+ "custom_fields": [],
+ "custom_text": {
+ "after_submit": null,
+ "shipping_address": null,
+ "submit": null,
+ "terms_of_service_acceptance": null
+ },
+ "customer": "cus_RoIDdmj3lHKt7D",
+ "customer_creation": null,
+ "customer_details": {
+ "address": null,
+ "email": "[email protected]",
+ "name": null,
+ "phone": null,
+ "tax_exempt": null,
+ "tax_ids": null
+ },
+ "customer_email": null,
+ "discounts": null,
+ "expires_at": 1740166908,
+ "id": "cs_test_c1idTTx38NASfFfwpi9tQgBlY66gwRUMXvVWtrUTFMDvdSEFHzaSlT5QMv",
+ "invoice": null,
+ "invoice_creation": null,
+ "livemode": false,
+ "locale": null,
+ "metadata": {
+ "type": "card_update",
+ "user_id": "10"
+ },
+ "mode": "setup",
+ "object": "checkout.session",
+ "payment_intent": null,
+ "payment_link": null,
+ "payment_method_collection": "always",
+ "payment_method_configuration_details": null,
+ "payment_method_options": {
+ "card": {
+ "request_three_d_secure": "automatic"
+ }
+ },
+ "payment_method_types": [
+ "card"
+ ],
+ "payment_status": "no_payment_required",
+ "phone_number_collection": {
+ "enabled": false
+ },
+ "recovered_from": null,
+ "saved_payment_method_options": null,
+ "setup_intent": "seti_1Qufd2DEQaroqDjsGi59ek4c",
+ "shipping": null,
+ "shipping_address_collection": null,
+ "shipping_options": [],
+ "shipping_rate": null,
+ "status": "open",
+ "submit_type": null,
+ "subscription": null,
+ "success_url": "http://zulip.testserver/billing/event_status/?stripe_session_id={CHECKOUT_SESSION_ID}",
+ "total_details": null,
+ "ui_mode": "hosted",
+ "url": "https://checkout.stripe.com/c/pay/cs_test_c1idTTx38NASfFfwpi9tQgBlY66gwRUMXvVWtrUTFMDvdSEFHzaSlT5QMv#fid1d2BpamRhQ2prcSc%2FJ1ZqcHdmYCVWZGt2JVV3aicpJ2R1bE5gfCc%2FJ3VuWnFgdnFaXVRmMU5zNkldQTY9SnNRY09XZml2UXNQJyknY3dqaFZgd3Ngdyc%2FcXdwYCknaWR8anBxUXx1YCc%2FJ3Zsa2JpYFpmamlwaGsnKSdga2RnaWBVaWRmYG1qaWFgd3YnP3F3cGB4JSUl"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "url": "/v1/checkout/sessions"
+}
diff --git a/corporate/tests/test_stripe.py b/corporate/tests/test_stripe.py
index c9b81f2bc02..1d75f92999c 100644
--- a/corporate/tests/test_stripe.py
+++ b/corporate/tests/test_stripe.py
@@ -2128,6 +2128,60 @@ class StripeTest(StripeTestCase):
self.assertEqual(ledger_entry.licenses, minimum_for_plan_tier)
self.assertEqual(ledger_entry.licenses_at_next_renewal, minimum_for_plan_tier)
+ @mock_stripe()
+ def test_customer_minimum_licenses_for_plan(self, *mocks: Mock) -> None:
+ hamlet = self.example_user("hamlet")
+ self.login_user(hamlet)
+ # We set set a 1 license minimum the initial upgrade.
+ minimum_for_plan_tier = 1
+ with (
+ patch(
+ "corporate.lib.stripe.BillingSession.min_licenses_for_plan",
+ return_value=minimum_for_plan_tier,
+ ),
+ ):
+ self.add_card_and_upgrade(hamlet, tier=CustomerPlan.TIER_CLOUD_PLUS)
+
+ customer = Customer.objects.first()
+ assert customer is not None
+ assert customer.stripe_customer_id is not None
+ # Check LicenseLedger has the current seat count.
+ ledger_entry = LicenseLedger.objects.last()
+ assert ledger_entry is not None
+ self.assertEqual(ledger_entry.licenses, self.seat_count)
+ self.assertEqual(ledger_entry.licenses_at_next_renewal, self.seat_count)
+
+ # We manually set customer.minimum_licenses to the current seat count,
+ # which is below the general Plus plan minimum licenses.
+ customer.minimum_licenses = self.seat_count
+ customer.save()
+
+ # Next year, they are still invoiced for the current seat count.
+ invoice_plans_as_needed(self.next_year)
+ # Check both invoices (initial and renewal)
+ [invoice0, invoice1] = iter(stripe.Invoice.list(customer=customer.stripe_customer_id))
+ self.assertEqual(
+ [12000 * self.seat_count],
+ [item.amount for item in invoice0.lines],
+ )
+ self.assertEqual(
+ [12000 * self.seat_count],
+ [item.amount for item in invoice1.lines],
+ )
+
+ # Without the minimum_licenses set on the customer, a BillingError is raised when
+ # invoicing plans.
+ customer.minimum_licenses = None
+ customer.save()
+
+ with self.assertRaises(BillingError) as context:
+ invoice_plans_as_needed(self.next_year + timedelta(days=366))
+ error_message = context.exception.error_description
+ self.assertEqual(
+ error_message,
+ "Renewal licenses (6) less than minimum licenses (10) required for plan Zulip Cloud Plus.",
+ )
+
def test_upgrade_with_tampered_seat_count(self) -> None:
hamlet = self.example_user("hamlet")
self.login_user(hamlet)