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: Create LicenseLedger entry for guest user role changes.

Lauryn Menard4b954a42ef0a
diff --git a/corporate/tests/stripe_fixtures/invoice_for_additional_license--Customer.create.1.json b/corporate/tests/stripe_fixtures/invoice_for_additional_license--Customer.create.1.json
new file mode 100644
index 00000000000..6c14c62a23b
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/invoice_for_additional_license--Customer.create.1.json
@@ -0,0 +1,33 @@
+{
+ "address": null,
+ "balance": 0,
+ "created": 1000000000,
+ "currency": null,
+ "default_currency": null,
+ "default_source": null,
+ "delinquent": false,
+ "description": "zulip (Zulip Dev)",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "invoice_for_additional_license--Customer.create.1.json",
+ "invoice_prefix": "NORMALIZED",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": null,
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "realm_id": "1",
+ "realm_str": "zulip"
+ },
+ "name": null,
+ "next_invoice_sequence": 1,
+ "object": "customer",
+ "phone": null,
+ "preferred_locales": [],
+ "shipping": null,
+ "tax_exempt": "none",
+ "test_clock": null
+}
diff --git a/corporate/tests/stripe_fixtures/invoice_for_additional_license--Customer.modify.1.json b/corporate/tests/stripe_fixtures/invoice_for_additional_license--Customer.modify.1.json
new file mode 100644
index 00000000000..1952fdbaf0b
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/invoice_for_additional_license--Customer.modify.1.json
@@ -0,0 +1,33 @@
+{
+ "address": null,
+ "balance": 0,
+ "created": 1000000000,
+ "currency": null,
+ "default_currency": null,
+ "default_source": null,
+ "delinquent": false,
+ "description": "zulip (Zulip Dev)",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "invoice_for_additional_license--Customer.create.1.json",
+ "invoice_prefix": "NORMALIZED",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": "pm_NORMALIZED",
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "realm_id": "1",
+ "realm_str": "zulip"
+ },
+ "name": null,
+ "next_invoice_sequence": 1,
+ "object": "customer",
+ "phone": null,
+ "preferred_locales": [],
+ "shipping": null,
+ "tax_exempt": "none",
+ "test_clock": null
+}
diff --git a/corporate/tests/stripe_fixtures/invoice_for_additional_license--Customer.retrieve.1.json b/corporate/tests/stripe_fixtures/invoice_for_additional_license--Customer.retrieve.1.json
new file mode 100644
index 00000000000..8786897ce7f
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/invoice_for_additional_license--Customer.retrieve.1.json
@@ -0,0 +1,81 @@
+{
+ "address": null,
+ "balance": 0,
+ "created": 1000000000,
+ "currency": null,
+ "default_currency": null,
+ "default_source": null,
+ "delinquent": false,
+ "description": "zulip (Zulip Dev)",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "invoice_for_additional_license--Customer.create.1.json",
+ "invoice_prefix": "NORMALIZED",
+ "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": 9,
+ "exp_year": 2025,
+ "fingerprint": "NORMALIZED",
+ "funding": "credit",
+ "generated_from": null,
+ "last4": "4242",
+ "networks": {
+ "available": [
+ "visa"
+ ],
+ "preferred": null
+ },
+ "three_d_secure_usage": {
+ "supported": true
+ },
+ "wallet": null
+ },
+ "created": 1000000000,
+ "customer": "invoice_for_additional_license--Customer.create.1.json",
+ "id": "invoice_for_additional_license--Customer.retrieve.1.json",
+ "livemode": false,
+ "metadata": {},
+ "object": "payment_method",
+ "type": "card"
+ },
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "realm_id": "1",
+ "realm_str": "zulip"
+ },
+ "name": null,
+ "next_invoice_sequence": 1,
+ "object": "customer",
+ "phone": null,
+ "preferred_locales": [],
+ "shipping": null,
+ "tax_exempt": "none",
+ "test_clock": null
+}
diff --git a/corporate/tests/stripe_fixtures/invoice_for_additional_license--Customer.retrieve.2.json b/corporate/tests/stripe_fixtures/invoice_for_additional_license--Customer.retrieve.2.json
new file mode 100644
index 00000000000..8786897ce7f
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/invoice_for_additional_license--Customer.retrieve.2.json
@@ -0,0 +1,81 @@
+{
+ "address": null,
+ "balance": 0,
+ "created": 1000000000,
+ "currency": null,
+ "default_currency": null,
+ "default_source": null,
+ "delinquent": false,
+ "description": "zulip (Zulip Dev)",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "invoice_for_additional_license--Customer.create.1.json",
+ "invoice_prefix": "NORMALIZED",
+ "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": 9,
+ "exp_year": 2025,
+ "fingerprint": "NORMALIZED",
+ "funding": "credit",
+ "generated_from": null,
+ "last4": "4242",
+ "networks": {
+ "available": [
+ "visa"
+ ],
+ "preferred": null
+ },
+ "three_d_secure_usage": {
+ "supported": true
+ },
+ "wallet": null
+ },
+ "created": 1000000000,
+ "customer": "invoice_for_additional_license--Customer.create.1.json",
+ "id": "invoice_for_additional_license--Customer.retrieve.1.json",
+ "livemode": false,
+ "metadata": {},
+ "object": "payment_method",
+ "type": "card"
+ },
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "realm_id": "1",
+ "realm_str": "zulip"
+ },
+ "name": null,
+ "next_invoice_sequence": 1,
+ "object": "customer",
+ "phone": null,
+ "preferred_locales": [],
+ "shipping": null,
+ "tax_exempt": "none",
+ "test_clock": null
+}
diff --git a/corporate/tests/stripe_fixtures/invoice_for_additional_license--Customer.retrieve.3.json b/corporate/tests/stripe_fixtures/invoice_for_additional_license--Customer.retrieve.3.json
new file mode 100644
index 00000000000..8786897ce7f
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/invoice_for_additional_license--Customer.retrieve.3.json
@@ -0,0 +1,81 @@
+{
+ "address": null,
+ "balance": 0,
+ "created": 1000000000,
+ "currency": null,
+ "default_currency": null,
+ "default_source": null,
+ "delinquent": false,
+ "description": "zulip (Zulip Dev)",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "invoice_for_additional_license--Customer.create.1.json",
+ "invoice_prefix": "NORMALIZED",
+ "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": 9,
+ "exp_year": 2025,
+ "fingerprint": "NORMALIZED",
+ "funding": "credit",
+ "generated_from": null,
+ "last4": "4242",
+ "networks": {
+ "available": [
+ "visa"
+ ],
+ "preferred": null
+ },
+ "three_d_secure_usage": {
+ "supported": true
+ },
+ "wallet": null
+ },
+ "created": 1000000000,
+ "customer": "invoice_for_additional_license--Customer.create.1.json",
+ "id": "invoice_for_additional_license--Customer.retrieve.1.json",
+ "livemode": false,
+ "metadata": {},
+ "object": "payment_method",
+ "type": "card"
+ },
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "realm_id": "1",
+ "realm_str": "zulip"
+ },
+ "name": null,
+ "next_invoice_sequence": 1,
+ "object": "customer",
+ "phone": null,
+ "preferred_locales": [],
+ "shipping": null,
+ "tax_exempt": "none",
+ "test_clock": null
+}
diff --git a/corporate/tests/stripe_fixtures/invoice_for_additional_license--Customer.retrieve.4.json b/corporate/tests/stripe_fixtures/invoice_for_additional_license--Customer.retrieve.4.json
new file mode 100644
index 00000000000..8786897ce7f
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/invoice_for_additional_license--Customer.retrieve.4.json
@@ -0,0 +1,81 @@
+{
+ "address": null,
+ "balance": 0,
+ "created": 1000000000,
+ "currency": null,
+ "default_currency": null,
+ "default_source": null,
+ "delinquent": false,
+ "description": "zulip (Zulip Dev)",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "invoice_for_additional_license--Customer.create.1.json",
+ "invoice_prefix": "NORMALIZED",
+ "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": 9,
+ "exp_year": 2025,
+ "fingerprint": "NORMALIZED",
+ "funding": "credit",
+ "generated_from": null,
+ "last4": "4242",
+ "networks": {
+ "available": [
+ "visa"
+ ],
+ "preferred": null
+ },
+ "three_d_secure_usage": {
+ "supported": true
+ },
+ "wallet": null
+ },
+ "created": 1000000000,
+ "customer": "invoice_for_additional_license--Customer.create.1.json",
+ "id": "invoice_for_additional_license--Customer.retrieve.1.json",
+ "livemode": false,
+ "metadata": {},
+ "object": "payment_method",
+ "type": "card"
+ },
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "realm_id": "1",
+ "realm_str": "zulip"
+ },
+ "name": null,
+ "next_invoice_sequence": 1,
+ "object": "customer",
+ "phone": null,
+ "preferred_locales": [],
+ "shipping": null,
+ "tax_exempt": "none",
+ "test_clock": null
+}
diff --git a/corporate/tests/stripe_fixtures/invoice_for_additional_license--Event.list.1.json b/corporate/tests/stripe_fixtures/invoice_for_additional_license--Event.list.1.json
new file mode 100644
index 00000000000..53aac2039ae
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/invoice_for_additional_license--Event.list.1.json
@@ -0,0 +1,60 @@
+{
+ "data": [
+ {
+ "api_version": "2020-08-27",
+ "created": 1000000000,
+ "data": {
+ "object": {
+ "address": null,
+ "balance": 0,
+ "created": 1000000000,
+ "currency": null,
+ "default_currency": null,
+ "default_source": null,
+ "delinquent": false,
+ "description": "zulip (Zulip Dev)",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "invoice_for_additional_license--Customer.create.1.json",
+ "invoice_prefix": "NORMALIZED",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": "pm_NORMALIZED",
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "realm_id": "1",
+ "realm_str": "zulip"
+ },
+ "name": null,
+ "next_invoice_sequence": 1,
+ "object": "customer",
+ "phone": null,
+ "preferred_locales": [],
+ "shipping": null,
+ "tax_exempt": "none",
+ "test_clock": null
+ },
+ "previous_attributes": {
+ "invoice_settings": {
+ "default_payment_method": null
+ }
+ }
+ },
+ "id": "invoice_for_additional_license--Event.list.1.json",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 0,
+ "request": {
+ "id": "invoice_for_additional_license--Event.list.1.json",
+ "idempotency_key": "00000000-0000-0000-0000-000000000000"
+ },
+ "type": "customer.updated"
+ }
+ ],
+ "has_more": true,
+ "object": "list",
+ "url": "/v1/events"
+}
diff --git a/corporate/tests/stripe_fixtures/invoice_for_additional_license--Event.list.2.json b/corporate/tests/stripe_fixtures/invoice_for_additional_license--Event.list.2.json
new file mode 100644
index 00000000000..1fd21d2a131
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/invoice_for_additional_license--Event.list.2.json
@@ -0,0 +1,1095 @@
+{
+ "data": [
+ {
+ "api_version": "2020-08-27",
+ "created": 1000000000,
+ "data": {
+ "object": {
+ "amount": 48000,
+ "amount_capturable": 0,
+ "amount_details": {
+ "tip": {}
+ },
+ "amount_received": 48000,
+ "application": null,
+ "application_fee_amount": null,
+ "automatic_payment_methods": null,
+ "canceled_at": null,
+ "cancellation_reason": null,
+ "capture_method": "automatic",
+ "charges": {
+ "data": [
+ {
+ "amount": 48000,
+ "amount_captured": 48000,
+ "amount_refunded": 0,
+ "application": null,
+ "application_fee": null,
+ "application_fee_amount": null,
+ "balance_transaction": "txn_NORMALIZED",
+ "billing_details": {
+ "address": {
+ "city": "San Francisco",
+ "country": "US",
+ "line1": "123 Main St",
+ "line2": null,
+ "postal_code": "94105",
+ "state": "CA"
+ },
+ "email": null,
+ "name": "John Doe",
+ "phone": null
+ },
+ "calculated_statement_descriptor": "ZULIP CLOUD STANDARD",
+ "captured": true,
+ "created": 1000000000,
+ "currency": "usd",
+ "customer": "invoice_for_additional_license--Customer.create.1.json",
+ "description": "Payment for Invoice",
+ "destination": null,
+ "dispute": null,
+ "disputed": false,
+ "failure_balance_transaction": null,
+ "failure_code": null,
+ "failure_message": null,
+ "fraud_details": {},
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "invoice": "invoice_for_additional_license--Event.list.2.json",
+ "livemode": false,
+ "metadata": {},
+ "object": "charge",
+ "on_behalf_of": null,
+ "order": null,
+ "outcome": {
+ "network_status": "approved_by_network",
+ "reason": null,
+ "risk_level": "normal",
+ "risk_score": 0,
+ "seller_message": "Payment complete.",
+ "type": "authorized"
+ },
+ "paid": true,
+ "payment_intent": "invoice_for_additional_license--Event.list.2.json",
+ "payment_method": "pm_NORMALIZED",
+ "payment_method_details": {
+ "card": {
+ "amount_authorized": 48000,
+ "authorization_code": null,
+ "brand": "visa",
+ "checks": {
+ "address_line1_check": "pass",
+ "address_postal_code_check": "pass",
+ "cvc_check": "pass"
+ },
+ "country": "US",
+ "exp_month": 9,
+ "exp_year": 2025,
+ "extended_authorization": {
+ "status": "disabled"
+ },
+ "fingerprint": "NORMALIZED",
+ "funding": "credit",
+ "incremental_authorization": {
+ "status": "unavailable"
+ },
+ "installments": null,
+ "last4": "4242",
+ "mandate": null,
+ "multicapture": {
+ "status": "unavailable"
+ },
+ "network": "visa",
+ "network_token": {
+ "used": false
+ },
+ "overcapture": {
+ "maximum_amount_capturable": 48000,
+ "status": "unavailable"
+ },
+ "three_d_secure": null,
+ "wallet": null
+ },
+ "type": "card"
+ },
+ "receipt_email": "[email protected]",
+ "receipt_number": null,
+ "receipt_url": "https://pay.stripe.com/receipts/invoices/NORMALIZED?s=ap",
+ "refunded": false,
+ "refunds": {
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "total_count": 0,
+ "url": "/v1/charges/invoice_for_additional_license--Event.list.2.json/refunds"
+ },
+ "review": null,
+ "shipping": null,
+ "source": null,
+ "source_transfer": null,
+ "statement_descriptor": "Zulip Cloud Standard",
+ "statement_descriptor_suffix": null,
+ "status": "succeeded",
+ "transfer_data": null,
+ "transfer_group": null
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/charges?payment_intent=invoice_for_additional_license--Event.list.2.json"
+ },
+ "client_secret": "NORMALIZED",
+ "confirmation_method": "automatic",
+ "created": 1000000000,
+ "currency": "usd",
+ "customer": "invoice_for_additional_license--Customer.create.1.json",
+ "description": "Payment for Invoice",
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "invoice": "invoice_for_additional_license--Event.list.2.json",
+ "last_payment_error": null,
+ "latest_charge": "invoice_for_additional_license--Event.list.2.json",
+ "livemode": false,
+ "metadata": {},
+ "next_action": null,
+ "object": "payment_intent",
+ "on_behalf_of": null,
+ "payment_method": "pm_NORMALIZED",
+ "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 Standard",
+ "statement_descriptor_suffix": null,
+ "status": "succeeded",
+ "transfer_data": null,
+ "transfer_group": null
+ }
+ },
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 0,
+ "request": {
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "idempotency_key": "00000000-0000-0000-0000-000000000000"
+ },
+ "type": "payment_intent.succeeded"
+ },
+ {
+ "api_version": "2020-08-27",
+ "created": 1000000000,
+ "data": {
+ "object": {
+ "amount": 48000,
+ "amount_captured": 48000,
+ "amount_refunded": 0,
+ "application": null,
+ "application_fee": null,
+ "application_fee_amount": null,
+ "balance_transaction": "txn_NORMALIZED",
+ "billing_details": {
+ "address": {
+ "city": "San Francisco",
+ "country": "US",
+ "line1": "123 Main St",
+ "line2": null,
+ "postal_code": "94105",
+ "state": "CA"
+ },
+ "email": null,
+ "name": "John Doe",
+ "phone": null
+ },
+ "calculated_statement_descriptor": "ZULIP CLOUD STANDARD",
+ "captured": true,
+ "created": 1000000000,
+ "currency": "usd",
+ "customer": "invoice_for_additional_license--Customer.create.1.json",
+ "description": "Payment for Invoice",
+ "destination": null,
+ "dispute": null,
+ "disputed": false,
+ "failure_balance_transaction": null,
+ "failure_code": null,
+ "failure_message": null,
+ "fraud_details": {},
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "invoice": "invoice_for_additional_license--Event.list.2.json",
+ "livemode": false,
+ "metadata": {},
+ "object": "charge",
+ "on_behalf_of": null,
+ "order": null,
+ "outcome": {
+ "network_status": "approved_by_network",
+ "reason": null,
+ "risk_level": "normal",
+ "risk_score": 0,
+ "seller_message": "Payment complete.",
+ "type": "authorized"
+ },
+ "paid": true,
+ "payment_intent": "invoice_for_additional_license--Event.list.2.json",
+ "payment_method": "pm_NORMALIZED",
+ "payment_method_details": {
+ "card": {
+ "amount_authorized": 48000,
+ "authorization_code": null,
+ "brand": "visa",
+ "checks": {
+ "address_line1_check": "pass",
+ "address_postal_code_check": "pass",
+ "cvc_check": "pass"
+ },
+ "country": "US",
+ "exp_month": 9,
+ "exp_year": 2025,
+ "extended_authorization": {
+ "status": "disabled"
+ },
+ "fingerprint": "NORMALIZED",
+ "funding": "credit",
+ "incremental_authorization": {
+ "status": "unavailable"
+ },
+ "installments": null,
+ "last4": "4242",
+ "mandate": null,
+ "multicapture": {
+ "status": "unavailable"
+ },
+ "network": "visa",
+ "network_token": {
+ "used": false
+ },
+ "overcapture": {
+ "maximum_amount_capturable": 48000,
+ "status": "unavailable"
+ },
+ "three_d_secure": null,
+ "wallet": null
+ },
+ "type": "card"
+ },
+ "receipt_email": "[email protected]",
+ "receipt_number": null,
+ "receipt_url": "https://pay.stripe.com/receipts/invoices/NORMALIZED?s=ap",
+ "refunded": false,
+ "refunds": {
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "total_count": 0,
+ "url": "/v1/charges/invoice_for_additional_license--Event.list.2.json/refunds"
+ },
+ "review": null,
+ "shipping": null,
+ "source": null,
+ "source_transfer": null,
+ "statement_descriptor": "Zulip Cloud Standard",
+ "statement_descriptor_suffix": null,
+ "status": "succeeded",
+ "transfer_data": null,
+ "transfer_group": null
+ }
+ },
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 2,
+ "request": {
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "idempotency_key": "00000000-0000-0000-0000-000000000000"
+ },
+ "type": "charge.succeeded"
+ },
+ {
+ "api_version": "2020-08-27",
+ "created": 1000000000,
+ "data": {
+ "object": {
+ "account_country": "US",
+ "account_name": "Kandra Labs, Inc.",
+ "account_tax_ids": null,
+ "amount_due": 48000,
+ "amount_paid": 0,
+ "amount_remaining": 48000,
+ "amount_shipping": 0,
+ "application": null,
+ "application_fee_amount": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": false,
+ "automatic_tax": {
+ "enabled": false,
+ "liability": null,
+ "status": null
+ },
+ "automatically_finalizes_at": null,
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "charge_automatically",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "invoice_for_additional_license--Customer.create.1.json",
+ "customer_address": null,
+ "customer_email": "[email protected]",
+ "customer_name": null,
+ "customer_phone": null,
+ "customer_shipping": null,
+ "customer_tax_exempt": "none",
+ "customer_tax_ids": [],
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "discounts": [],
+ "due_date": null,
+ "effective_at": 1000000000,
+ "ending_balance": 0,
+ "footer": null,
+ "from_invoice": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED/test_NORMALIZED?s=ap",
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED/test_NORMALIZED/pdf?s=ap",
+ "issuer": {
+ "type": "self"
+ },
+ "last_finalization_error": null,
+ "latest_revision": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 48000,
+ "amount_excluding_tax": 48000,
+ "currency": "usd",
+ "description": "Zulip Cloud Standard",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "invoice": "invoice_for_additional_license--Event.list.2.json",
+ "invoice_item": "invoice_for_additional_license--Event.list.2.json",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_NORMALIZED",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 6,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "8000"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/invoice_for_additional_license--Event.list.2.json/lines"
+ },
+ "livemode": false,
+ "metadata": {
+ "billing_schedule": "1",
+ "current_plan_id": "None",
+ "license_management": "automatic",
+ "licenses": "6",
+ "on_free_trial": "False",
+ "plan_tier": "1",
+ "user_id": "10"
+ },
+ "next_payment_attempt": null,
+ "number": "NORMALIZED-0001",
+ "object": "invoice",
+ "on_behalf_of": null,
+ "paid": false,
+ "paid_out_of_band": false,
+ "payment_intent": "invoice_for_additional_license--Event.list.2.json",
+ "payment_settings": {
+ "default_mandate": null,
+ "payment_method_options": null,
+ "payment_method_types": null
+ },
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "quote": null,
+ "receipt_number": null,
+ "rendering": {
+ "amount_tax_display": null,
+ "pdf": {
+ "page_size": "letter"
+ }
+ },
+ "rendering_options": null,
+ "shipping_cost": null,
+ "shipping_details": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Cloud Standard",
+ "status": "open",
+ "status_transitions": {
+ "finalized_at": 1000000000,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subscription_details": {
+ "metadata": null
+ },
+ "subtotal": 48000,
+ "subtotal_excluding_tax": 48000,
+ "tax": null,
+ "test_clock": null,
+ "total": 48000,
+ "total_discount_amounts": [],
+ "total_excluding_tax": 48000,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": null
+ }
+ },
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 0,
+ "request": {
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "idempotency_key": "00000000-0000-0000-0000-000000000000"
+ },
+ "type": "invoice.finalized"
+ },
+ {
+ "api_version": "2020-08-27",
+ "created": 1000000000,
+ "data": {
+ "object": {
+ "account_country": "US",
+ "account_name": "Kandra Labs, Inc.",
+ "account_tax_ids": null,
+ "amount_due": 48000,
+ "amount_paid": 0,
+ "amount_remaining": 48000,
+ "amount_shipping": 0,
+ "application": null,
+ "application_fee_amount": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": false,
+ "automatic_tax": {
+ "enabled": false,
+ "liability": null,
+ "status": null
+ },
+ "automatically_finalizes_at": null,
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "charge_automatically",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "invoice_for_additional_license--Customer.create.1.json",
+ "customer_address": null,
+ "customer_email": "[email protected]",
+ "customer_name": null,
+ "customer_phone": null,
+ "customer_shipping": null,
+ "customer_tax_exempt": "none",
+ "customer_tax_ids": [],
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "discounts": [],
+ "due_date": null,
+ "effective_at": 1000000000,
+ "ending_balance": 0,
+ "footer": null,
+ "from_invoice": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED/test_NORMALIZED?s=ap",
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED/test_NORMALIZED/pdf?s=ap",
+ "issuer": {
+ "type": "self"
+ },
+ "last_finalization_error": null,
+ "latest_revision": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 48000,
+ "amount_excluding_tax": 48000,
+ "currency": "usd",
+ "description": "Zulip Cloud Standard",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "invoice": "invoice_for_additional_license--Event.list.2.json",
+ "invoice_item": "invoice_for_additional_license--Event.list.2.json",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_NORMALIZED",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 6,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "8000"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/invoice_for_additional_license--Event.list.2.json/lines"
+ },
+ "livemode": false,
+ "metadata": {
+ "billing_schedule": "1",
+ "current_plan_id": "None",
+ "license_management": "automatic",
+ "licenses": "6",
+ "on_free_trial": "False",
+ "plan_tier": "1",
+ "user_id": "10"
+ },
+ "next_payment_attempt": null,
+ "number": "NORMALIZED-0001",
+ "object": "invoice",
+ "on_behalf_of": null,
+ "paid": false,
+ "paid_out_of_band": false,
+ "payment_intent": "invoice_for_additional_license--Event.list.2.json",
+ "payment_settings": {
+ "default_mandate": null,
+ "payment_method_options": null,
+ "payment_method_types": null
+ },
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "quote": null,
+ "receipt_number": null,
+ "rendering": {
+ "amount_tax_display": null,
+ "pdf": {
+ "page_size": "letter"
+ }
+ },
+ "rendering_options": null,
+ "shipping_cost": null,
+ "shipping_details": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Cloud Standard",
+ "status": "open",
+ "status_transitions": {
+ "finalized_at": 1000000000,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subscription_details": {
+ "metadata": null
+ },
+ "subtotal": 48000,
+ "subtotal_excluding_tax": 48000,
+ "tax": null,
+ "test_clock": null,
+ "total": 48000,
+ "total_discount_amounts": [],
+ "total_excluding_tax": 48000,
+ "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": "invoice_for_additional_license--Event.list.2.json",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 0,
+ "request": {
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "idempotency_key": "00000000-0000-0000-0000-000000000000"
+ },
+ "type": "invoice.updated"
+ },
+ {
+ "api_version": "2020-08-27",
+ "created": 1000000000,
+ "data": {
+ "object": {
+ "amount": 48000,
+ "amount_capturable": 0,
+ "amount_details": {
+ "tip": {}
+ },
+ "amount_received": 0,
+ "application": null,
+ "application_fee_amount": null,
+ "automatic_payment_methods": null,
+ "canceled_at": null,
+ "cancellation_reason": null,
+ "capture_method": "automatic",
+ "charges": {
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "total_count": 0,
+ "url": "/v1/charges?payment_intent=invoice_for_additional_license--Event.list.2.json"
+ },
+ "client_secret": "NORMALIZED",
+ "confirmation_method": "automatic",
+ "created": 1000000000,
+ "currency": "usd",
+ "customer": "invoice_for_additional_license--Customer.create.1.json",
+ "description": "Payment for Invoice",
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "invoice": "invoice_for_additional_license--Event.list.2.json",
+ "last_payment_error": null,
+ "latest_charge": null,
+ "livemode": false,
+ "metadata": {},
+ "next_action": null,
+ "object": "payment_intent",
+ "on_behalf_of": null,
+ "payment_method": null,
+ "payment_method_configuration_details": null,
+ "payment_method_options": {
+ "card": {
+ "installments": null,
+ "mandate_options": null,
+ "network": null,
+ "request_three_d_secure": "automatic"
+ },
+ "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 Standard",
+ "statement_descriptor_suffix": null,
+ "status": "requires_payment_method",
+ "transfer_data": null,
+ "transfer_group": null
+ }
+ },
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 0,
+ "request": {
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "idempotency_key": "00000000-0000-0000-0000-000000000000"
+ },
+ "type": "payment_intent.created"
+ },
+ {
+ "api_version": "2020-08-27",
+ "created": 1000000000,
+ "data": {
+ "object": {
+ "account_country": "US",
+ "account_name": "Kandra Labs, Inc.",
+ "account_tax_ids": null,
+ "amount_due": 48000,
+ "amount_paid": 0,
+ "amount_remaining": 48000,
+ "amount_shipping": 0,
+ "application": null,
+ "application_fee_amount": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": false,
+ "automatic_tax": {
+ "enabled": false,
+ "liability": null,
+ "status": null
+ },
+ "automatically_finalizes_at": null,
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "charge_automatically",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "invoice_for_additional_license--Customer.create.1.json",
+ "customer_address": null,
+ "customer_email": "[email protected]",
+ "customer_name": null,
+ "customer_phone": null,
+ "customer_shipping": null,
+ "customer_tax_exempt": "none",
+ "customer_tax_ids": [],
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "discounts": [],
+ "due_date": null,
+ "effective_at": null,
+ "ending_balance": null,
+ "footer": null,
+ "from_invoice": null,
+ "hosted_invoice_url": null,
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "invoice_pdf": null,
+ "issuer": {
+ "type": "self"
+ },
+ "last_finalization_error": null,
+ "latest_revision": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 48000,
+ "amount_excluding_tax": 48000,
+ "currency": "usd",
+ "description": "Zulip Cloud Standard",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "invoice": "invoice_for_additional_license--Event.list.2.json",
+ "invoice_item": "invoice_for_additional_license--Event.list.2.json",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_NORMALIZED",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 6,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "8000"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/invoice_for_additional_license--Event.list.2.json/lines"
+ },
+ "livemode": false,
+ "metadata": {
+ "billing_schedule": "1",
+ "current_plan_id": "None",
+ "license_management": "automatic",
+ "licenses": "6",
+ "on_free_trial": "False",
+ "plan_tier": "1",
+ "user_id": "10"
+ },
+ "next_payment_attempt": null,
+ "number": null,
+ "object": "invoice",
+ "on_behalf_of": null,
+ "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": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "quote": null,
+ "receipt_number": null,
+ "rendering": {
+ "amount_tax_display": null,
+ "pdf": {
+ "page_size": "auto"
+ }
+ },
+ "rendering_options": null,
+ "shipping_cost": null,
+ "shipping_details": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Cloud Standard",
+ "status": "draft",
+ "status_transitions": {
+ "finalized_at": null,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subscription_details": {
+ "metadata": null
+ },
+ "subtotal": 48000,
+ "subtotal_excluding_tax": 48000,
+ "tax": null,
+ "test_clock": null,
+ "total": 48000,
+ "total_discount_amounts": [],
+ "total_excluding_tax": 48000,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": null
+ }
+ },
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 0,
+ "request": {
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "idempotency_key": "00000000-0000-0000-0000-000000000000"
+ },
+ "type": "invoice.created"
+ },
+ {
+ "api_version": "2020-08-27",
+ "created": 1000000000,
+ "data": {
+ "object": {
+ "amount": 48000,
+ "currency": "usd",
+ "customer": "invoice_for_additional_license--Customer.create.1.json",
+ "date": 1000000000,
+ "description": "Zulip Cloud Standard",
+ "discountable": false,
+ "discounts": [],
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "invoice": null,
+ "livemode": false,
+ "metadata": {},
+ "object": "invoiceitem",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_NORMALIZED",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 6,
+ "subscription": null,
+ "tax_rates": [],
+ "test_clock": null,
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ }
+ },
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 0,
+ "request": {
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "idempotency_key": "00000000-0000-0000-0000-000000000000"
+ },
+ "type": "invoiceitem.created"
+ },
+ {
+ "api_version": "2020-08-27",
+ "created": 1000000000,
+ "data": {
+ "object": {
+ "address": null,
+ "balance": 0,
+ "created": 1000000000,
+ "currency": "usd",
+ "default_currency": "usd",
+ "default_source": null,
+ "delinquent": false,
+ "description": "zulip (Zulip Dev)",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "invoice_for_additional_license--Customer.create.1.json",
+ "invoice_prefix": "NORMALIZED",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": "pm_NORMALIZED",
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "realm_id": "1",
+ "realm_str": "zulip"
+ },
+ "name": null,
+ "next_invoice_sequence": 1,
+ "object": "customer",
+ "phone": null,
+ "preferred_locales": [],
+ "shipping": null,
+ "tax_exempt": "none",
+ "test_clock": null
+ },
+ "previous_attributes": {
+ "currency": null,
+ "default_currency": null
+ }
+ },
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 0,
+ "request": {
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "idempotency_key": "00000000-0000-0000-0000-000000000000"
+ },
+ "type": "customer.updated"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "url": "/v1/events"
+}
diff --git a/corporate/tests/stripe_fixtures/invoice_for_additional_license--Event.list.3.json b/corporate/tests/stripe_fixtures/invoice_for_additional_license--Event.list.3.json
new file mode 100644
index 00000000000..eeca41eb5ab
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/invoice_for_additional_license--Event.list.3.json
@@ -0,0 +1,580 @@
+{
+ "data": [
+ {
+ "api_version": "2020-08-27",
+ "created": 1000000000,
+ "data": {
+ "object": {
+ "account_country": "US",
+ "account_name": "Kandra Labs, Inc.",
+ "account_tax_ids": null,
+ "amount_due": 48000,
+ "amount_paid": 48000,
+ "amount_remaining": 0,
+ "amount_shipping": 0,
+ "application": null,
+ "application_fee_amount": null,
+ "attempt_count": 1,
+ "attempted": true,
+ "auto_advance": false,
+ "automatic_tax": {
+ "enabled": false,
+ "liability": null,
+ "status": null
+ },
+ "automatically_finalizes_at": null,
+ "billing_reason": "manual",
+ "charge": "ch_NORMALIZED",
+ "collection_method": "charge_automatically",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_NORMALIZED",
+ "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": 1000000000,
+ "ending_balance": 0,
+ "footer": null,
+ "from_invoice": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED/test_NORMALIZED?s=ap",
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED/test_NORMALIZED/pdf?s=ap",
+ "issuer": {
+ "type": "self"
+ },
+ "last_finalization_error": null,
+ "latest_revision": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 48000,
+ "amount_excluding_tax": 48000,
+ "currency": "usd",
+ "description": "Zulip Cloud Standard",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "invoice": "invoice_for_additional_license--Event.list.2.json",
+ "invoice_item": "ii_NORMALIZED",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_NORMALIZED",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 6,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "8000"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/invoice_for_additional_license--Event.list.2.json/lines"
+ },
+ "livemode": false,
+ "metadata": {
+ "billing_schedule": "1",
+ "current_plan_id": "None",
+ "license_management": "automatic",
+ "licenses": "6",
+ "on_free_trial": "False",
+ "plan_tier": "1",
+ "user_id": "10"
+ },
+ "next_payment_attempt": null,
+ "number": "NORMALIZED",
+ "object": "invoice",
+ "on_behalf_of": null,
+ "paid": true,
+ "paid_out_of_band": false,
+ "payment_intent": "pi_NORMALIZED",
+ "payment_settings": {
+ "default_mandate": null,
+ "payment_method_options": null,
+ "payment_method_types": null
+ },
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "quote": null,
+ "receipt_number": null,
+ "rendering": {
+ "amount_tax_display": null,
+ "pdf": {
+ "page_size": "letter"
+ }
+ },
+ "rendering_options": null,
+ "shipping_cost": null,
+ "shipping_details": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Cloud Standard",
+ "status": "paid",
+ "status_transitions": {
+ "finalized_at": 1000000000,
+ "marked_uncollectible_at": null,
+ "paid_at": 1000000000,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subscription_details": {
+ "metadata": null
+ },
+ "subtotal": 48000,
+ "subtotal_excluding_tax": 48000,
+ "tax": null,
+ "test_clock": null,
+ "total": 48000,
+ "total_discount_amounts": [],
+ "total_excluding_tax": 48000,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1000000000
+ }
+ },
+ "id": "invoice_for_additional_license--Event.list.3.json",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 1,
+ "request": {
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "idempotency_key": "00000000-0000-0000-0000-000000000000"
+ },
+ "type": "invoice.payment_succeeded"
+ },
+ {
+ "api_version": "2020-08-27",
+ "created": 1000000000,
+ "data": {
+ "object": {
+ "account_country": "US",
+ "account_name": "Kandra Labs, Inc.",
+ "account_tax_ids": null,
+ "amount_due": 48000,
+ "amount_paid": 48000,
+ "amount_remaining": 0,
+ "amount_shipping": 0,
+ "application": null,
+ "application_fee_amount": null,
+ "attempt_count": 1,
+ "attempted": true,
+ "auto_advance": false,
+ "automatic_tax": {
+ "enabled": false,
+ "liability": null,
+ "status": null
+ },
+ "automatically_finalizes_at": null,
+ "billing_reason": "manual",
+ "charge": "ch_NORMALIZED",
+ "collection_method": "charge_automatically",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_NORMALIZED",
+ "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": 1000000000,
+ "ending_balance": 0,
+ "footer": null,
+ "from_invoice": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED/test_NORMALIZED?s=ap",
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED/test_NORMALIZED/pdf?s=ap",
+ "issuer": {
+ "type": "self"
+ },
+ "last_finalization_error": null,
+ "latest_revision": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 48000,
+ "amount_excluding_tax": 48000,
+ "currency": "usd",
+ "description": "Zulip Cloud Standard",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "invoice": "invoice_for_additional_license--Event.list.2.json",
+ "invoice_item": "ii_NORMALIZED",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_NORMALIZED",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 6,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "8000"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/invoice_for_additional_license--Event.list.2.json/lines"
+ },
+ "livemode": false,
+ "metadata": {
+ "billing_schedule": "1",
+ "current_plan_id": "None",
+ "license_management": "automatic",
+ "licenses": "6",
+ "on_free_trial": "False",
+ "plan_tier": "1",
+ "user_id": "10"
+ },
+ "next_payment_attempt": null,
+ "number": "NORMALIZED",
+ "object": "invoice",
+ "on_behalf_of": null,
+ "paid": true,
+ "paid_out_of_band": false,
+ "payment_intent": "pi_NORMALIZED",
+ "payment_settings": {
+ "default_mandate": null,
+ "payment_method_options": null,
+ "payment_method_types": null
+ },
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "quote": null,
+ "receipt_number": null,
+ "rendering": {
+ "amount_tax_display": null,
+ "pdf": {
+ "page_size": "letter"
+ }
+ },
+ "rendering_options": null,
+ "shipping_cost": null,
+ "shipping_details": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Cloud Standard",
+ "status": "paid",
+ "status_transitions": {
+ "finalized_at": 1000000000,
+ "marked_uncollectible_at": null,
+ "paid_at": 1000000000,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subscription_details": {
+ "metadata": null
+ },
+ "subtotal": 48000,
+ "subtotal_excluding_tax": 48000,
+ "tax": null,
+ "test_clock": null,
+ "total": 48000,
+ "total_discount_amounts": [],
+ "total_excluding_tax": 48000,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1000000000
+ }
+ },
+ "id": "invoice_for_additional_license--Event.list.3.json",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 0,
+ "request": {
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "idempotency_key": "00000000-0000-0000-0000-000000000000"
+ },
+ "type": "invoice.paid"
+ },
+ {
+ "api_version": "2020-08-27",
+ "created": 1000000000,
+ "data": {
+ "object": {
+ "account_country": "US",
+ "account_name": "Kandra Labs, Inc.",
+ "account_tax_ids": null,
+ "amount_due": 48000,
+ "amount_paid": 48000,
+ "amount_remaining": 0,
+ "amount_shipping": 0,
+ "application": null,
+ "application_fee_amount": null,
+ "attempt_count": 1,
+ "attempted": true,
+ "auto_advance": false,
+ "automatic_tax": {
+ "enabled": false,
+ "liability": null,
+ "status": null
+ },
+ "automatically_finalizes_at": null,
+ "billing_reason": "manual",
+ "charge": "ch_NORMALIZED",
+ "collection_method": "charge_automatically",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_NORMALIZED",
+ "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": 1000000000,
+ "ending_balance": 0,
+ "footer": null,
+ "from_invoice": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED/test_NORMALIZED?s=ap",
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED/test_NORMALIZED/pdf?s=ap",
+ "issuer": {
+ "type": "self"
+ },
+ "last_finalization_error": null,
+ "latest_revision": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 48000,
+ "amount_excluding_tax": 48000,
+ "currency": "usd",
+ "description": "Zulip Cloud Standard",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "invoice": "invoice_for_additional_license--Event.list.2.json",
+ "invoice_item": "ii_NORMALIZED",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_NORMALIZED",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 6,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "8000"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/invoice_for_additional_license--Event.list.2.json/lines"
+ },
+ "livemode": false,
+ "metadata": {
+ "billing_schedule": "1",
+ "current_plan_id": "None",
+ "license_management": "automatic",
+ "licenses": "6",
+ "on_free_trial": "False",
+ "plan_tier": "1",
+ "user_id": "10"
+ },
+ "next_payment_attempt": null,
+ "number": "NORMALIZED",
+ "object": "invoice",
+ "on_behalf_of": null,
+ "paid": true,
+ "paid_out_of_band": false,
+ "payment_intent": "pi_NORMALIZED",
+ "payment_settings": {
+ "default_mandate": null,
+ "payment_method_options": null,
+ "payment_method_types": null
+ },
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "quote": null,
+ "receipt_number": null,
+ "rendering": {
+ "amount_tax_display": null,
+ "pdf": {
+ "page_size": "letter"
+ }
+ },
+ "rendering_options": null,
+ "shipping_cost": null,
+ "shipping_details": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Cloud Standard",
+ "status": "paid",
+ "status_transitions": {
+ "finalized_at": 1000000000,
+ "marked_uncollectible_at": null,
+ "paid_at": 1000000000,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subscription_details": {
+ "metadata": null
+ },
+ "subtotal": 48000,
+ "subtotal_excluding_tax": 48000,
+ "tax": null,
+ "test_clock": null,
+ "total": 48000,
+ "total_discount_amounts": [],
+ "total_excluding_tax": 48000,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1000000000
+ },
+ "previous_attributes": {
+ "amount_paid": 0,
+ "amount_remaining": 48000,
+ "attempt_count": 0,
+ "attempted": false,
+ "charge": null,
+ "paid": false,
+ "status": "open",
+ "status_transitions": {
+ "paid_at": null
+ }
+ }
+ },
+ "id": "invoice_for_additional_license--Event.list.3.json",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 0,
+ "request": {
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "idempotency_key": "00000000-0000-0000-0000-000000000000"
+ },
+ "type": "invoice.updated"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "url": "/v1/events"
+}
diff --git a/corporate/tests/stripe_fixtures/invoice_for_additional_license--Event.list.4.json b/corporate/tests/stripe_fixtures/invoice_for_additional_license--Event.list.4.json
new file mode 100644
index 00000000000..6d922067afe
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/invoice_for_additional_license--Event.list.4.json
@@ -0,0 +1,6 @@
+{
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "url": "/v1/events"
+}
diff --git a/corporate/tests/stripe_fixtures/invoice_for_additional_license--Invoice.create.1.json b/corporate/tests/stripe_fixtures/invoice_for_additional_license--Invoice.create.1.json
new file mode 100644
index 00000000000..154b2f4f028
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/invoice_for_additional_license--Invoice.create.1.json
@@ -0,0 +1,172 @@
+{
+ "account_country": "US",
+ "account_name": "Kandra Labs, Inc.",
+ "account_tax_ids": null,
+ "amount_due": 48000,
+ "amount_paid": 0,
+ "amount_remaining": 48000,
+ "amount_shipping": 0,
+ "application": null,
+ "application_fee_amount": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": false,
+ "automatic_tax": {
+ "enabled": false,
+ "liability": null,
+ "status": null
+ },
+ "automatically_finalizes_at": null,
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "charge_automatically",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_NORMALIZED",
+ "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": "invoice_for_additional_license--Event.list.2.json",
+ "invoice_pdf": null,
+ "issuer": {
+ "type": "self"
+ },
+ "last_finalization_error": null,
+ "latest_revision": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 48000,
+ "amount_excluding_tax": 48000,
+ "currency": "usd",
+ "description": "Zulip Cloud Standard",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "invoice": "invoice_for_additional_license--Event.list.2.json",
+ "invoice_item": "ii_NORMALIZED",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_NORMALIZED",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 6,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "8000"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/invoice_for_additional_license--Event.list.2.json/lines"
+ },
+ "livemode": false,
+ "metadata": {
+ "billing_schedule": "1",
+ "current_plan_id": "None",
+ "license_management": "automatic",
+ "licenses": "6",
+ "on_free_trial": "False",
+ "plan_tier": "1",
+ "user_id": "10"
+ },
+ "next_payment_attempt": null,
+ "number": null,
+ "object": "invoice",
+ "on_behalf_of": null,
+ "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": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "quote": null,
+ "receipt_number": null,
+ "rendering": {
+ "amount_tax_display": null,
+ "pdf": {
+ "page_size": "auto"
+ }
+ },
+ "rendering_options": null,
+ "shipping_cost": null,
+ "shipping_details": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Cloud Standard",
+ "status": "draft",
+ "status_transitions": {
+ "finalized_at": null,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subscription_details": {
+ "metadata": null
+ },
+ "subtotal": 48000,
+ "subtotal_excluding_tax": 48000,
+ "tax": null,
+ "test_clock": null,
+ "total": 48000,
+ "total_discount_amounts": [],
+ "total_excluding_tax": 48000,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": null
+}
diff --git a/corporate/tests/stripe_fixtures/invoice_for_additional_license--Invoice.create.2.json b/corporate/tests/stripe_fixtures/invoice_for_additional_license--Invoice.create.2.json
new file mode 100644
index 00000000000..f107931315b
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/invoice_for_additional_license--Invoice.create.2.json
@@ -0,0 +1,164 @@
+{
+ "account_country": "US",
+ "account_name": "Kandra Labs, Inc.",
+ "account_tax_ids": null,
+ "amount_due": 7781,
+ "amount_paid": 0,
+ "amount_remaining": 7781,
+ "amount_shipping": 0,
+ "application": null,
+ "application_fee_amount": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "automatic_tax": {
+ "enabled": false,
+ "liability": null,
+ "status": null
+ },
+ "automatically_finalizes_at": 1000000000,
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "charge_automatically",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_NORMALIZED",
+ "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": "invoice_for_additional_license--Invoice.create.2.json",
+ "invoice_pdf": null,
+ "issuer": {
+ "type": "self"
+ },
+ "last_finalization_error": null,
+ "latest_revision": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 7781,
+ "amount_excluding_tax": 7781,
+ "currency": "usd",
+ "description": "Additional license (Jan 12, 2012 - Jan 2, 2013)",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "invoice_for_additional_license--Invoice.create.2.json",
+ "invoice": "invoice_for_additional_license--Invoice.create.2.json",
+ "invoice_item": "ii_NORMALIZED",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1326337445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "invoice_for_additional_license--Invoice.create.2.json",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_NORMALIZED",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 7781,
+ "unit_amount_decimal": "7781"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 1,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "7781"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/invoice_for_additional_license--Invoice.create.2.json/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": 1000000000,
+ "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": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "quote": null,
+ "receipt_number": null,
+ "rendering": {
+ "amount_tax_display": null,
+ "pdf": {
+ "page_size": "auto"
+ }
+ },
+ "rendering_options": null,
+ "shipping_cost": null,
+ "shipping_details": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Cloud Standard",
+ "status": "draft",
+ "status_transitions": {
+ "finalized_at": null,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subscription_details": {
+ "metadata": null
+ },
+ "subtotal": 7781,
+ "subtotal_excluding_tax": 7781,
+ "tax": null,
+ "test_clock": null,
+ "total": 7781,
+ "total_discount_amounts": [],
+ "total_excluding_tax": 7781,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": null
+}
diff --git a/corporate/tests/stripe_fixtures/invoice_for_additional_license--Invoice.finalize_invoice.1.json b/corporate/tests/stripe_fixtures/invoice_for_additional_license--Invoice.finalize_invoice.1.json
new file mode 100644
index 00000000000..ade48396b9a
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/invoice_for_additional_license--Invoice.finalize_invoice.1.json
@@ -0,0 +1,172 @@
+{
+ "account_country": "US",
+ "account_name": "Kandra Labs, Inc.",
+ "account_tax_ids": null,
+ "amount_due": 48000,
+ "amount_paid": 0,
+ "amount_remaining": 48000,
+ "amount_shipping": 0,
+ "application": null,
+ "application_fee_amount": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": false,
+ "automatic_tax": {
+ "enabled": false,
+ "liability": null,
+ "status": null
+ },
+ "automatically_finalizes_at": null,
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "charge_automatically",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_NORMALIZED",
+ "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": 1000000000,
+ "ending_balance": 0,
+ "footer": null,
+ "from_invoice": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED/test_NORMALIZED?s=ap",
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED/test_NORMALIZED/pdf?s=ap",
+ "issuer": {
+ "type": "self"
+ },
+ "last_finalization_error": null,
+ "latest_revision": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 48000,
+ "amount_excluding_tax": 48000,
+ "currency": "usd",
+ "description": "Zulip Cloud Standard",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "invoice": "invoice_for_additional_license--Event.list.2.json",
+ "invoice_item": "ii_NORMALIZED",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_NORMALIZED",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 6,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "8000"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/invoice_for_additional_license--Event.list.2.json/lines"
+ },
+ "livemode": false,
+ "metadata": {
+ "billing_schedule": "1",
+ "current_plan_id": "None",
+ "license_management": "automatic",
+ "licenses": "6",
+ "on_free_trial": "False",
+ "plan_tier": "1",
+ "user_id": "10"
+ },
+ "next_payment_attempt": null,
+ "number": "NORMALIZED",
+ "object": "invoice",
+ "on_behalf_of": null,
+ "paid": false,
+ "paid_out_of_band": false,
+ "payment_intent": "pi_NORMALIZED",
+ "payment_settings": {
+ "default_mandate": null,
+ "payment_method_options": null,
+ "payment_method_types": null
+ },
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "quote": null,
+ "receipt_number": null,
+ "rendering": {
+ "amount_tax_display": null,
+ "pdf": {
+ "page_size": "letter"
+ }
+ },
+ "rendering_options": null,
+ "shipping_cost": null,
+ "shipping_details": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Cloud Standard",
+ "status": "open",
+ "status_transitions": {
+ "finalized_at": 1000000000,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subscription_details": {
+ "metadata": null
+ },
+ "subtotal": 48000,
+ "subtotal_excluding_tax": 48000,
+ "tax": null,
+ "test_clock": null,
+ "total": 48000,
+ "total_discount_amounts": [],
+ "total_excluding_tax": 48000,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": null
+}
diff --git a/corporate/tests/stripe_fixtures/invoice_for_additional_license--Invoice.finalize_invoice.2.json b/corporate/tests/stripe_fixtures/invoice_for_additional_license--Invoice.finalize_invoice.2.json
new file mode 100644
index 00000000000..7fa6ea2ca21
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/invoice_for_additional_license--Invoice.finalize_invoice.2.json
@@ -0,0 +1,164 @@
+{
+ "account_country": "US",
+ "account_name": "Kandra Labs, Inc.",
+ "account_tax_ids": null,
+ "amount_due": 7781,
+ "amount_paid": 0,
+ "amount_remaining": 7781,
+ "amount_shipping": 0,
+ "application": null,
+ "application_fee_amount": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "automatic_tax": {
+ "enabled": false,
+ "liability": null,
+ "status": null
+ },
+ "automatically_finalizes_at": null,
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "charge_automatically",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_NORMALIZED",
+ "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": 1000000000,
+ "ending_balance": 0,
+ "footer": null,
+ "from_invoice": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED/test_NORMALIZED?s=ap",
+ "id": "invoice_for_additional_license--Invoice.create.2.json",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED/test_NORMALIZED/pdf?s=ap",
+ "issuer": {
+ "type": "self"
+ },
+ "last_finalization_error": null,
+ "latest_revision": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 7781,
+ "amount_excluding_tax": 7781,
+ "currency": "usd",
+ "description": "Additional license (Jan 12, 2012 - Jan 2, 2013)",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "invoice_for_additional_license--Invoice.create.2.json",
+ "invoice": "invoice_for_additional_license--Invoice.create.2.json",
+ "invoice_item": "ii_NORMALIZED",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1326337445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "invoice_for_additional_license--Invoice.create.2.json",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_NORMALIZED",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 7781,
+ "unit_amount_decimal": "7781"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 1,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "7781"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/invoice_for_additional_license--Invoice.create.2.json/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": 1000000000,
+ "number": "NORMALIZED",
+ "object": "invoice",
+ "on_behalf_of": null,
+ "paid": false,
+ "paid_out_of_band": false,
+ "payment_intent": "pi_NORMALIZED",
+ "payment_settings": {
+ "default_mandate": null,
+ "payment_method_options": null,
+ "payment_method_types": null
+ },
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "quote": null,
+ "receipt_number": null,
+ "rendering": {
+ "amount_tax_display": null,
+ "pdf": {
+ "page_size": "letter"
+ }
+ },
+ "rendering_options": null,
+ "shipping_cost": null,
+ "shipping_details": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Cloud Standard",
+ "status": "open",
+ "status_transitions": {
+ "finalized_at": 1000000000,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subscription_details": {
+ "metadata": null
+ },
+ "subtotal": 7781,
+ "subtotal_excluding_tax": 7781,
+ "tax": null,
+ "test_clock": null,
+ "total": 7781,
+ "total_discount_amounts": [],
+ "total_excluding_tax": 7781,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": null
+}
diff --git a/corporate/tests/stripe_fixtures/invoice_for_additional_license--Invoice.list.1.json b/corporate/tests/stripe_fixtures/invoice_for_additional_license--Invoice.list.1.json
new file mode 100644
index 00000000000..e39960ab725
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/invoice_for_additional_license--Invoice.list.1.json
@@ -0,0 +1,6 @@
+{
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "url": "/v1/invoices"
+}
diff --git a/corporate/tests/stripe_fixtures/invoice_for_additional_license--Invoice.list.2.json b/corporate/tests/stripe_fixtures/invoice_for_additional_license--Invoice.list.2.json
new file mode 100644
index 00000000000..c22851d5310
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/invoice_for_additional_license--Invoice.list.2.json
@@ -0,0 +1,343 @@
+{
+ "data": [
+ {
+ "account_country": "US",
+ "account_name": "Kandra Labs, Inc.",
+ "account_tax_ids": null,
+ "amount_due": 7781,
+ "amount_paid": 0,
+ "amount_remaining": 7781,
+ "amount_shipping": 0,
+ "application": null,
+ "application_fee_amount": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "automatic_tax": {
+ "enabled": false,
+ "liability": null,
+ "status": null
+ },
+ "automatically_finalizes_at": null,
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "charge_automatically",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_NORMALIZED",
+ "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": 1000000000,
+ "ending_balance": 0,
+ "footer": null,
+ "from_invoice": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED/test_NORMALIZED?s=ap",
+ "id": "invoice_for_additional_license--Invoice.create.2.json",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED/test_NORMALIZED/pdf?s=ap",
+ "issuer": {
+ "type": "self"
+ },
+ "last_finalization_error": null,
+ "latest_revision": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 7781,
+ "amount_excluding_tax": 7781,
+ "currency": "usd",
+ "description": "Additional license (Jan 12, 2012 - Jan 2, 2013)",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "invoice_for_additional_license--Invoice.create.2.json",
+ "invoice": "invoice_for_additional_license--Invoice.create.2.json",
+ "invoice_item": "ii_NORMALIZED",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1326337445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "invoice_for_additional_license--Invoice.create.2.json",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_NORMALIZED",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 7781,
+ "unit_amount_decimal": "7781"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 1,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "7781"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/invoice_for_additional_license--Invoice.create.2.json/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": 1000000000,
+ "number": "NORMALIZED",
+ "object": "invoice",
+ "on_behalf_of": null,
+ "paid": false,
+ "paid_out_of_band": false,
+ "payment_intent": "pi_NORMALIZED",
+ "payment_settings": {
+ "default_mandate": null,
+ "payment_method_options": null,
+ "payment_method_types": null
+ },
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "quote": null,
+ "receipt_number": null,
+ "rendering": {
+ "amount_tax_display": null,
+ "pdf": {
+ "page_size": "letter"
+ }
+ },
+ "rendering_options": null,
+ "shipping_cost": null,
+ "shipping_details": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Cloud Standard",
+ "status": "open",
+ "status_transitions": {
+ "finalized_at": 1000000000,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subscription_details": {
+ "metadata": null
+ },
+ "subtotal": 7781,
+ "subtotal_excluding_tax": 7781,
+ "tax": null,
+ "test_clock": null,
+ "total": 7781,
+ "total_discount_amounts": [],
+ "total_excluding_tax": 7781,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": null
+ },
+ {
+ "account_country": "US",
+ "account_name": "Kandra Labs, Inc.",
+ "account_tax_ids": null,
+ "amount_due": 48000,
+ "amount_paid": 48000,
+ "amount_remaining": 0,
+ "amount_shipping": 0,
+ "application": null,
+ "application_fee_amount": null,
+ "attempt_count": 1,
+ "attempted": true,
+ "auto_advance": false,
+ "automatic_tax": {
+ "enabled": false,
+ "liability": null,
+ "status": null
+ },
+ "automatically_finalizes_at": null,
+ "billing_reason": "manual",
+ "charge": "ch_NORMALIZED",
+ "collection_method": "charge_automatically",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_NORMALIZED",
+ "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": 1000000000,
+ "ending_balance": 0,
+ "footer": null,
+ "from_invoice": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED/test_NORMALIZED?s=ap",
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED/test_NORMALIZED/pdf?s=ap",
+ "issuer": {
+ "type": "self"
+ },
+ "last_finalization_error": null,
+ "latest_revision": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 48000,
+ "amount_excluding_tax": 48000,
+ "currency": "usd",
+ "description": "Zulip Cloud Standard",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "invoice": "invoice_for_additional_license--Event.list.2.json",
+ "invoice_item": "ii_NORMALIZED",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_NORMALIZED",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 6,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "8000"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/invoice_for_additional_license--Event.list.2.json/lines"
+ },
+ "livemode": false,
+ "metadata": {
+ "billing_schedule": "1",
+ "current_plan_id": "None",
+ "license_management": "automatic",
+ "licenses": "6",
+ "on_free_trial": "False",
+ "plan_tier": "1",
+ "user_id": "10"
+ },
+ "next_payment_attempt": null,
+ "number": "NORMALIZED",
+ "object": "invoice",
+ "on_behalf_of": null,
+ "paid": true,
+ "paid_out_of_band": false,
+ "payment_intent": "pi_NORMALIZED",
+ "payment_settings": {
+ "default_mandate": null,
+ "payment_method_options": null,
+ "payment_method_types": null
+ },
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "quote": null,
+ "receipt_number": null,
+ "rendering": {
+ "amount_tax_display": null,
+ "pdf": {
+ "page_size": "letter"
+ }
+ },
+ "rendering_options": null,
+ "shipping_cost": null,
+ "shipping_details": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Cloud Standard",
+ "status": "paid",
+ "status_transitions": {
+ "finalized_at": 1000000000,
+ "marked_uncollectible_at": null,
+ "paid_at": 1000000000,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subscription_details": {
+ "metadata": null
+ },
+ "subtotal": 48000,
+ "subtotal_excluding_tax": 48000,
+ "tax": null,
+ "test_clock": null,
+ "total": 48000,
+ "total_discount_amounts": [],
+ "total_excluding_tax": 48000,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1000000000
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "url": "/v1/invoices"
+}
diff --git a/corporate/tests/stripe_fixtures/invoice_for_additional_license--Invoice.pay.1.json b/corporate/tests/stripe_fixtures/invoice_for_additional_license--Invoice.pay.1.json
new file mode 100644
index 00000000000..03de03e4a76
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/invoice_for_additional_license--Invoice.pay.1.json
@@ -0,0 +1,172 @@
+{
+ "account_country": "US",
+ "account_name": "Kandra Labs, Inc.",
+ "account_tax_ids": null,
+ "amount_due": 48000,
+ "amount_paid": 48000,
+ "amount_remaining": 0,
+ "amount_shipping": 0,
+ "application": null,
+ "application_fee_amount": null,
+ "attempt_count": 1,
+ "attempted": true,
+ "auto_advance": false,
+ "automatic_tax": {
+ "enabled": false,
+ "liability": null,
+ "status": null
+ },
+ "automatically_finalizes_at": null,
+ "billing_reason": "manual",
+ "charge": "ch_NORMALIZED",
+ "collection_method": "charge_automatically",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_NORMALIZED",
+ "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": 1000000000,
+ "ending_balance": 0,
+ "footer": null,
+ "from_invoice": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED/test_NORMALIZED?s=ap",
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED/test_NORMALIZED/pdf?s=ap",
+ "issuer": {
+ "type": "self"
+ },
+ "last_finalization_error": null,
+ "latest_revision": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 48000,
+ "amount_excluding_tax": 48000,
+ "currency": "usd",
+ "description": "Zulip Cloud Standard",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "invoice": "invoice_for_additional_license--Event.list.2.json",
+ "invoice_item": "ii_NORMALIZED",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_NORMALIZED",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 6,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "8000"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/invoice_for_additional_license--Event.list.2.json/lines"
+ },
+ "livemode": false,
+ "metadata": {
+ "billing_schedule": "1",
+ "current_plan_id": "None",
+ "license_management": "automatic",
+ "licenses": "6",
+ "on_free_trial": "False",
+ "plan_tier": "1",
+ "user_id": "10"
+ },
+ "next_payment_attempt": null,
+ "number": "NORMALIZED",
+ "object": "invoice",
+ "on_behalf_of": null,
+ "paid": true,
+ "paid_out_of_band": false,
+ "payment_intent": "pi_NORMALIZED",
+ "payment_settings": {
+ "default_mandate": null,
+ "payment_method_options": null,
+ "payment_method_types": null
+ },
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "quote": null,
+ "receipt_number": null,
+ "rendering": {
+ "amount_tax_display": null,
+ "pdf": {
+ "page_size": "letter"
+ }
+ },
+ "rendering_options": null,
+ "shipping_cost": null,
+ "shipping_details": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Cloud Standard",
+ "status": "paid",
+ "status_transitions": {
+ "finalized_at": 1000000000,
+ "marked_uncollectible_at": null,
+ "paid_at": 1000000000,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subscription_details": {
+ "metadata": null
+ },
+ "subtotal": 48000,
+ "subtotal_excluding_tax": 48000,
+ "tax": null,
+ "test_clock": null,
+ "total": 48000,
+ "total_discount_amounts": [],
+ "total_excluding_tax": 48000,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1000000000
+}
diff --git a/corporate/tests/stripe_fixtures/invoice_for_additional_license--InvoiceItem.create.1.json b/corporate/tests/stripe_fixtures/invoice_for_additional_license--InvoiceItem.create.1.json
new file mode 100644
index 00000000000..d27445a28eb
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/invoice_for_additional_license--InvoiceItem.create.1.json
@@ -0,0 +1,47 @@
+{
+ "amount": 48000,
+ "currency": "usd",
+ "customer": "cus_NORMALIZED",
+ "date": 1000000000,
+ "description": "Zulip Cloud Standard",
+ "discountable": false,
+ "discounts": [],
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "invoice": null,
+ "livemode": false,
+ "metadata": {},
+ "object": "invoiceitem",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "invoice_for_additional_license--Event.list.2.json",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_NORMALIZED",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 6,
+ "subscription": null,
+ "tax_rates": [],
+ "test_clock": null,
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+}
diff --git a/corporate/tests/stripe_fixtures/invoice_for_additional_license--InvoiceItem.create.2.json b/corporate/tests/stripe_fixtures/invoice_for_additional_license--InvoiceItem.create.2.json
new file mode 100644
index 00000000000..679d1f09a14
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/invoice_for_additional_license--InvoiceItem.create.2.json
@@ -0,0 +1,47 @@
+{
+ "amount": 7781,
+ "currency": "usd",
+ "customer": "cus_NORMALIZED",
+ "date": 1000000000,
+ "description": "Additional license (Jan 12, 2012 - Jan 2, 2013)",
+ "discountable": false,
+ "discounts": [],
+ "id": "invoice_for_additional_license--InvoiceItem.create.2.json",
+ "invoice": null,
+ "livemode": false,
+ "metadata": {},
+ "object": "invoiceitem",
+ "period": {
+ "end": 1357095845,
+ "start": 1326337445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "invoice_for_additional_license--Invoice.create.2.json",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_NORMALIZED",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 7781,
+ "unit_amount_decimal": "7781"
+ },
+ "proration": false,
+ "quantity": 1,
+ "subscription": null,
+ "tax_rates": [],
+ "test_clock": null,
+ "unit_amount": 7781,
+ "unit_amount_decimal": "7781"
+}
diff --git a/corporate/tests/stripe_fixtures/invoice_for_additional_license--PaymentMethod.create.1.json b/corporate/tests/stripe_fixtures/invoice_for_additional_license--PaymentMethod.create.1.json
new file mode 100644
index 00000000000..3d2ee375352
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/invoice_for_additional_license--PaymentMethod.create.1.json
@@ -0,0 +1,49 @@
+{
+ "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": 9,
+ "exp_year": 2025,
+ "fingerprint": "NORMALIZED",
+ "funding": "credit",
+ "generated_from": null,
+ "last4": "4242",
+ "networks": {
+ "available": [
+ "visa"
+ ],
+ "preferred": null
+ },
+ "three_d_secure_usage": {
+ "supported": true
+ },
+ "wallet": null
+ },
+ "created": 1000000000,
+ "customer": null,
+ "id": "invoice_for_additional_license--Customer.retrieve.1.json",
+ "livemode": false,
+ "metadata": {},
+ "object": "payment_method",
+ "type": "card"
+}
diff --git a/corporate/tests/stripe_fixtures/invoice_for_additional_license--SetupIntent.create.1.json b/corporate/tests/stripe_fixtures/invoice_for_additional_license--SetupIntent.create.1.json
new file mode 100644
index 00000000000..b32f4523210
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/invoice_for_additional_license--SetupIntent.create.1.json
@@ -0,0 +1,34 @@
+{
+ "application": null,
+ "automatic_payment_methods": null,
+ "cancellation_reason": null,
+ "client_secret": "NORMALIZED",
+ "created": 1000000000,
+ "customer": "cus_NORMALIZED",
+ "description": null,
+ "flow_directions": null,
+ "id": "invoice_for_additional_license--SetupIntent.create.1.json",
+ "last_setup_error": null,
+ "latest_attempt": "setatt_NORMALIZED",
+ "livemode": false,
+ "mandate": null,
+ "metadata": {},
+ "next_action": null,
+ "object": "setup_intent",
+ "on_behalf_of": null,
+ "payment_method": "pm_NORMALIZED",
+ "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/invoice_for_additional_license--SetupIntent.list.1.json b/corporate/tests/stripe_fixtures/invoice_for_additional_license--SetupIntent.list.1.json
new file mode 100644
index 00000000000..a4125be5ff1
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/invoice_for_additional_license--SetupIntent.list.1.json
@@ -0,0 +1,41 @@
+{
+ "data": [
+ {
+ "application": null,
+ "automatic_payment_methods": null,
+ "cancellation_reason": null,
+ "client_secret": "NORMALIZED",
+ "created": 1000000000,
+ "customer": "cus_NORMALIZED",
+ "description": null,
+ "flow_directions": null,
+ "id": "invoice_for_additional_license--SetupIntent.list.1.json",
+ "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/invoice_for_additional_license--SetupIntent.retrieve.1.json b/corporate/tests/stripe_fixtures/invoice_for_additional_license--SetupIntent.retrieve.1.json
new file mode 100644
index 00000000000..b32f4523210
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/invoice_for_additional_license--SetupIntent.retrieve.1.json
@@ -0,0 +1,34 @@
+{
+ "application": null,
+ "automatic_payment_methods": null,
+ "cancellation_reason": null,
+ "client_secret": "NORMALIZED",
+ "created": 1000000000,
+ "customer": "cus_NORMALIZED",
+ "description": null,
+ "flow_directions": null,
+ "id": "invoice_for_additional_license--SetupIntent.create.1.json",
+ "last_setup_error": null,
+ "latest_attempt": "setatt_NORMALIZED",
+ "livemode": false,
+ "mandate": null,
+ "metadata": {},
+ "next_action": null,
+ "object": "setup_intent",
+ "on_behalf_of": null,
+ "payment_method": "pm_NORMALIZED",
+ "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/invoice_for_additional_license--checkout.Session.create.1.json b/corporate/tests/stripe_fixtures/invoice_for_additional_license--checkout.Session.create.1.json
new file mode 100644
index 00000000000..f6a3542d49f
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/invoice_for_additional_license--checkout.Session.create.1.json
@@ -0,0 +1,80 @@
+{
+ "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,
+ "consent": null,
+ "consent_collection": null,
+ "created": 1000000000,
+ "currency": null,
+ "currency_conversion": null,
+ "custom_fields": [],
+ "custom_text": {
+ "after_submit": null,
+ "shipping_address": null,
+ "submit": null,
+ "terms_of_service_acceptance": null
+ },
+ "customer": "cus_NORMALIZED",
+ "customer_creation": null,
+ "customer_details": {
+ "address": null,
+ "email": "[email protected]",
+ "name": null,
+ "phone": null,
+ "tax_exempt": null,
+ "tax_ids": null
+ },
+ "customer_email": null,
+ "expires_at": 1000000000,
+ "id": "invoice_for_additional_license--checkout.Session.create.1.json",
+ "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_NORMALIZED",
+ "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_NORMALIZED"
+}
diff --git a/corporate/tests/stripe_fixtures/invoice_for_additional_license--checkout.Session.list.1.json b/corporate/tests/stripe_fixtures/invoice_for_additional_license--checkout.Session.list.1.json
new file mode 100644
index 00000000000..50197cf0e68
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/invoice_for_additional_license--checkout.Session.list.1.json
@@ -0,0 +1,87 @@
+{
+ "data": [
+ {
+ "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,
+ "consent": null,
+ "consent_collection": null,
+ "created": 1000000000,
+ "currency": null,
+ "currency_conversion": null,
+ "custom_fields": [],
+ "custom_text": {
+ "after_submit": null,
+ "shipping_address": null,
+ "submit": null,
+ "terms_of_service_acceptance": null
+ },
+ "customer": "cus_NORMALIZED",
+ "customer_creation": null,
+ "customer_details": {
+ "address": null,
+ "email": "[email protected]",
+ "name": null,
+ "phone": null,
+ "tax_exempt": null,
+ "tax_ids": null
+ },
+ "customer_email": null,
+ "expires_at": 1000000000,
+ "id": "invoice_for_additional_license--checkout.Session.create.1.json",
+ "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_NORMALIZED",
+ "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_NORMALIZED"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "url": "/v1/checkout/sessions"
+}
diff --git a/corporate/tests/test_stripe.py b/corporate/tests/test_stripe.py
index 73f8801f882..a181098bc24 100644
--- a/corporate/tests/test_stripe.py
+++ b/corporate/tests/test_stripe.py
@@ -86,7 +86,7 @@ from zerver.actions.create_user import (
do_reactivate_user,
)
from zerver.actions.realm_settings import do_deactivate_realm, do_reactivate_realm
-from zerver.actions.users import do_deactivate_user
+from zerver.actions.users import do_change_user_role, do_deactivate_user
from zerver.lib.remote_server import send_server_data_to_push_bouncer
from zerver.lib.test_classes import ZulipTestCase
from zerver.lib.test_helpers import activate_push_notification_service
@@ -5713,6 +5713,19 @@ class LicenseLedgerTest(StripeTestCase):
do_reactivate_user(user, acting_user=None)
# Not a proper use of do_activate_mirror_dummy_user, but fine for this test
do_activate_mirror_dummy_user(user, acting_user=None)
+ # Add a guest user
+ guest = do_create_user(
+ "guest_email",
+ "guest_password",
+ get_realm("zulip"),
+ "guest_name",
+ role=UserProfile.ROLE_GUEST,
+ acting_user=None,
+ )
+ # Change guest user role to member
+ do_change_user_role(guest, UserProfile.ROLE_MEMBER, acting_user=None)
+ # Change again to moderator, no LicenseLedger created
+ do_change_user_role(guest, UserProfile.ROLE_MODERATOR, acting_user=None)
ledger_entries = list(
LicenseLedger.objects.values_list(
"is_renewal", "licenses", "licenses_at_next_renewal"
@@ -5726,6 +5739,8 @@ class LicenseLedgerTest(StripeTestCase):
(False, self.seat_count + 1, self.seat_count),
(False, self.seat_count + 1, self.seat_count + 1),
(False, self.seat_count + 1, self.seat_count + 1),
+ (False, self.seat_count + 1, self.seat_count + 1),
+ (False, self.seat_count + 2, self.seat_count + 2),
],
)
@@ -5897,6 +5912,52 @@ class InvoiceTest(StripeTestCase):
assert plan is not None
self.assertEqual(plan.next_invoice_date, self.next_month + timedelta(days=29))
+ @mock_stripe()
+ def test_invoice_for_additional_license(self, *mocks: Mock) -> None:
+ user = self.example_user("hamlet")
+ self.login_user(user)
+ with time_machine.travel(self.now, tick=False):
+ self.add_card_and_upgrade(user)
+ plan = CustomerPlan.objects.first()
+ assert plan is not None
+ self.assertEqual(plan.next_invoice_date, self.next_month)
+ assert plan.customer.realm is not None
+ realm = plan.customer.realm
+
+ # Adding a guest user and then changing their role to member
+ # should invoice for a pro-rated license at the next invoice
+ # date on a plan with annual billing.
+ with time_machine.travel(self.now + timedelta(days=5), tick=False):
+ user = do_create_user(
+ "email",
+ "password",
+ realm,
+ "name",
+ role=UserProfile.ROLE_GUEST,
+ acting_user=None,
+ )
+
+ with time_machine.travel(self.now + timedelta(days=10), tick=False):
+ do_change_user_role(user, UserProfile.ROLE_MEMBER, acting_user=None)
+
+ billing_session = RealmBillingSession(realm=realm)
+ billing_session.invoice_plan(plan, self.next_month)
+ plan = CustomerPlan.objects.first()
+ assert plan is not None
+ self.assertEqual(plan.next_invoice_date, self.next_month + timedelta(days=29))
+ stripe_customer_id = plan.customer.stripe_customer_id
+ assert stripe_customer_id is not None
+ [invoice0, invoice1] = iter(stripe.Invoice.list(customer=stripe_customer_id))
+ self.assertIsNotNone(invoice0.status_transitions.finalized_at)
+ [item0] = iter(invoice0.lines)
+ line_item_params = {
+ "amount": int(8000 * (1 - ((366 - 356) / 366)) + 0.5),
+ "description": "Additional license (Jan 12, 2012 - Jan 2, 2013)",
+ "quantity": 1,
+ }
+ for key, value in line_item_params.items():
+ self.assertEqual(item0.get(key), value)
+
class TestTestClasses(ZulipTestCase):
def test_subscribe_realm_to_manual_license_management_plan(self) -> None:
diff --git a/zerver/actions/users.py b/zerver/actions/users.py
index dac70866242..28a17975c42 100644
--- a/zerver/actions/users.py
+++ b/zerver/actions/users.py
@@ -472,6 +472,10 @@ def do_change_user_role(
},
)
maybe_enqueue_audit_log_upload(user_profile.realm)
+ if settings.BILLING_ENABLED and UserProfile.ROLE_GUEST in [old_value, value]:
+ billing_session = RealmBillingSession(user=user_profile, realm=user_profile.realm)
+ billing_session.update_license_ledger_if_needed(timezone_now())
+
event = dict(
type="realm_user", op="update", person=dict(user_id=user_profile.id, role=user_profile.role)
)