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.

stripe: Add some test for self hosted free trial.

Aman Agrawal02a4b3ce621d
diff --git a/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial--Customer.create.1.json b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial--Customer.create.1.json
new file mode 100644
index 00000000000..77a2471e08a
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial--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.testserver 7e03b36e-47d",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_NORMALIZED0001",
+ "invoice_prefix": "NORMA01",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": null,
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "remote_realm_host": "zulip.testserver",
+ "remote_realm_uuid": "7e03b36e-47d3-4ef5-8685-afdebf09cc57"
+ },
+ "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/upgrade_user_to_basic_plan_free_trial--Customer.modify.1.json b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial--Customer.modify.1.json
new file mode 100644
index 00000000000..0739827503d
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial--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.testserver 7e03b36e-47d",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_NORMALIZED0001",
+ "invoice_prefix": "NORMA01",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": "pm_1OWtmuDEQaroqDjsxmOdrHMd",
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "remote_realm_host": "zulip.testserver",
+ "remote_realm_uuid": "7e03b36e-47d3-4ef5-8685-afdebf09cc57"
+ },
+ "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/upgrade_user_to_basic_plan_free_trial--Customer.retrieve.1.json b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial--Customer.retrieve.1.json
new file mode 100644
index 00000000000..3f74a873ed0
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial--Customer.retrieve.1.json
@@ -0,0 +1,79 @@
+{
+ "address": null,
+ "balance": 0,
+ "created": 1000000000,
+ "currency": null,
+ "default_currency": null,
+ "default_source": null,
+ "delinquent": false,
+ "description": "zulip.testserver 7e03b36e-47d",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_NORMALIZED0001",
+ "invoice_prefix": "NORMA01",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": {
+ "billing_details": {
+ "address": {
+ "city": null,
+ "country": null,
+ "line1": null,
+ "line2": null,
+ "postal_code": null,
+ "state": null
+ },
+ "email": null,
+ "name": null,
+ "phone": null
+ },
+ "card": {
+ "brand": "visa",
+ "checks": {
+ "address_line1_check": null,
+ "address_postal_code_check": null,
+ "cvc_check": "pass"
+ },
+ "country": "US",
+ "exp_month": 1,
+ "exp_year": 2025,
+ "fingerprint": "NORMALIZED000001",
+ "funding": "credit",
+ "generated_from": null,
+ "last4": "4242",
+ "networks": {
+ "available": [
+ "visa"
+ ],
+ "preferred": null
+ },
+ "three_d_secure_usage": {
+ "supported": true
+ },
+ "wallet": null
+ },
+ "created": 1000000000,
+ "customer": "cus_NORMALIZED0001",
+ "id": "pm_1OWtmuDEQaroqDjsxmOdrHMd",
+ "livemode": false,
+ "metadata": {},
+ "object": "payment_method",
+ "type": "card"
+ },
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "remote_realm_host": "zulip.testserver",
+ "remote_realm_uuid": "7e03b36e-47d3-4ef5-8685-afdebf09cc57"
+ },
+ "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/upgrade_user_to_basic_plan_free_trial--Customer.retrieve.2.json b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial--Customer.retrieve.2.json
new file mode 100644
index 00000000000..3f74a873ed0
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial--Customer.retrieve.2.json
@@ -0,0 +1,79 @@
+{
+ "address": null,
+ "balance": 0,
+ "created": 1000000000,
+ "currency": null,
+ "default_currency": null,
+ "default_source": null,
+ "delinquent": false,
+ "description": "zulip.testserver 7e03b36e-47d",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_NORMALIZED0001",
+ "invoice_prefix": "NORMA01",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": {
+ "billing_details": {
+ "address": {
+ "city": null,
+ "country": null,
+ "line1": null,
+ "line2": null,
+ "postal_code": null,
+ "state": null
+ },
+ "email": null,
+ "name": null,
+ "phone": null
+ },
+ "card": {
+ "brand": "visa",
+ "checks": {
+ "address_line1_check": null,
+ "address_postal_code_check": null,
+ "cvc_check": "pass"
+ },
+ "country": "US",
+ "exp_month": 1,
+ "exp_year": 2025,
+ "fingerprint": "NORMALIZED000001",
+ "funding": "credit",
+ "generated_from": null,
+ "last4": "4242",
+ "networks": {
+ "available": [
+ "visa"
+ ],
+ "preferred": null
+ },
+ "three_d_secure_usage": {
+ "supported": true
+ },
+ "wallet": null
+ },
+ "created": 1000000000,
+ "customer": "cus_NORMALIZED0001",
+ "id": "pm_1OWtmuDEQaroqDjsxmOdrHMd",
+ "livemode": false,
+ "metadata": {},
+ "object": "payment_method",
+ "type": "card"
+ },
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "remote_realm_host": "zulip.testserver",
+ "remote_realm_uuid": "7e03b36e-47d3-4ef5-8685-afdebf09cc57"
+ },
+ "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/upgrade_user_to_basic_plan_free_trial--Customer.retrieve.3.json b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial--Customer.retrieve.3.json
new file mode 100644
index 00000000000..3f74a873ed0
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial--Customer.retrieve.3.json
@@ -0,0 +1,79 @@
+{
+ "address": null,
+ "balance": 0,
+ "created": 1000000000,
+ "currency": null,
+ "default_currency": null,
+ "default_source": null,
+ "delinquent": false,
+ "description": "zulip.testserver 7e03b36e-47d",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_NORMALIZED0001",
+ "invoice_prefix": "NORMA01",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": {
+ "billing_details": {
+ "address": {
+ "city": null,
+ "country": null,
+ "line1": null,
+ "line2": null,
+ "postal_code": null,
+ "state": null
+ },
+ "email": null,
+ "name": null,
+ "phone": null
+ },
+ "card": {
+ "brand": "visa",
+ "checks": {
+ "address_line1_check": null,
+ "address_postal_code_check": null,
+ "cvc_check": "pass"
+ },
+ "country": "US",
+ "exp_month": 1,
+ "exp_year": 2025,
+ "fingerprint": "NORMALIZED000001",
+ "funding": "credit",
+ "generated_from": null,
+ "last4": "4242",
+ "networks": {
+ "available": [
+ "visa"
+ ],
+ "preferred": null
+ },
+ "three_d_secure_usage": {
+ "supported": true
+ },
+ "wallet": null
+ },
+ "created": 1000000000,
+ "customer": "cus_NORMALIZED0001",
+ "id": "pm_1OWtmuDEQaroqDjsxmOdrHMd",
+ "livemode": false,
+ "metadata": {},
+ "object": "payment_method",
+ "type": "card"
+ },
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "remote_realm_host": "zulip.testserver",
+ "remote_realm_uuid": "7e03b36e-47d3-4ef5-8685-afdebf09cc57"
+ },
+ "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/upgrade_user_to_basic_plan_free_trial--Customer.retrieve.4.json b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial--Customer.retrieve.4.json
new file mode 100644
index 00000000000..3f74a873ed0
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial--Customer.retrieve.4.json
@@ -0,0 +1,79 @@
+{
+ "address": null,
+ "balance": 0,
+ "created": 1000000000,
+ "currency": null,
+ "default_currency": null,
+ "default_source": null,
+ "delinquent": false,
+ "description": "zulip.testserver 7e03b36e-47d",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_NORMALIZED0001",
+ "invoice_prefix": "NORMA01",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": {
+ "billing_details": {
+ "address": {
+ "city": null,
+ "country": null,
+ "line1": null,
+ "line2": null,
+ "postal_code": null,
+ "state": null
+ },
+ "email": null,
+ "name": null,
+ "phone": null
+ },
+ "card": {
+ "brand": "visa",
+ "checks": {
+ "address_line1_check": null,
+ "address_postal_code_check": null,
+ "cvc_check": "pass"
+ },
+ "country": "US",
+ "exp_month": 1,
+ "exp_year": 2025,
+ "fingerprint": "NORMALIZED000001",
+ "funding": "credit",
+ "generated_from": null,
+ "last4": "4242",
+ "networks": {
+ "available": [
+ "visa"
+ ],
+ "preferred": null
+ },
+ "three_d_secure_usage": {
+ "supported": true
+ },
+ "wallet": null
+ },
+ "created": 1000000000,
+ "customer": "cus_NORMALIZED0001",
+ "id": "pm_1OWtmuDEQaroqDjsxmOdrHMd",
+ "livemode": false,
+ "metadata": {},
+ "object": "payment_method",
+ "type": "card"
+ },
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "remote_realm_host": "zulip.testserver",
+ "remote_realm_uuid": "7e03b36e-47d3-4ef5-8685-afdebf09cc57"
+ },
+ "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/upgrade_user_to_basic_plan_free_trial--Customer.retrieve.5.json b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial--Customer.retrieve.5.json
new file mode 100644
index 00000000000..3f74a873ed0
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial--Customer.retrieve.5.json
@@ -0,0 +1,79 @@
+{
+ "address": null,
+ "balance": 0,
+ "created": 1000000000,
+ "currency": null,
+ "default_currency": null,
+ "default_source": null,
+ "delinquent": false,
+ "description": "zulip.testserver 7e03b36e-47d",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_NORMALIZED0001",
+ "invoice_prefix": "NORMA01",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": {
+ "billing_details": {
+ "address": {
+ "city": null,
+ "country": null,
+ "line1": null,
+ "line2": null,
+ "postal_code": null,
+ "state": null
+ },
+ "email": null,
+ "name": null,
+ "phone": null
+ },
+ "card": {
+ "brand": "visa",
+ "checks": {
+ "address_line1_check": null,
+ "address_postal_code_check": null,
+ "cvc_check": "pass"
+ },
+ "country": "US",
+ "exp_month": 1,
+ "exp_year": 2025,
+ "fingerprint": "NORMALIZED000001",
+ "funding": "credit",
+ "generated_from": null,
+ "last4": "4242",
+ "networks": {
+ "available": [
+ "visa"
+ ],
+ "preferred": null
+ },
+ "three_d_secure_usage": {
+ "supported": true
+ },
+ "wallet": null
+ },
+ "created": 1000000000,
+ "customer": "cus_NORMALIZED0001",
+ "id": "pm_1OWtmuDEQaroqDjsxmOdrHMd",
+ "livemode": false,
+ "metadata": {},
+ "object": "payment_method",
+ "type": "card"
+ },
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "remote_realm_host": "zulip.testserver",
+ "remote_realm_uuid": "7e03b36e-47d3-4ef5-8685-afdebf09cc57"
+ },
+ "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/upgrade_user_to_basic_plan_free_trial--Customer.retrieve.6.json b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial--Customer.retrieve.6.json
new file mode 100644
index 00000000000..3f74a873ed0
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial--Customer.retrieve.6.json
@@ -0,0 +1,79 @@
+{
+ "address": null,
+ "balance": 0,
+ "created": 1000000000,
+ "currency": null,
+ "default_currency": null,
+ "default_source": null,
+ "delinquent": false,
+ "description": "zulip.testserver 7e03b36e-47d",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_NORMALIZED0001",
+ "invoice_prefix": "NORMA01",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": {
+ "billing_details": {
+ "address": {
+ "city": null,
+ "country": null,
+ "line1": null,
+ "line2": null,
+ "postal_code": null,
+ "state": null
+ },
+ "email": null,
+ "name": null,
+ "phone": null
+ },
+ "card": {
+ "brand": "visa",
+ "checks": {
+ "address_line1_check": null,
+ "address_postal_code_check": null,
+ "cvc_check": "pass"
+ },
+ "country": "US",
+ "exp_month": 1,
+ "exp_year": 2025,
+ "fingerprint": "NORMALIZED000001",
+ "funding": "credit",
+ "generated_from": null,
+ "last4": "4242",
+ "networks": {
+ "available": [
+ "visa"
+ ],
+ "preferred": null
+ },
+ "three_d_secure_usage": {
+ "supported": true
+ },
+ "wallet": null
+ },
+ "created": 1000000000,
+ "customer": "cus_NORMALIZED0001",
+ "id": "pm_1OWtmuDEQaroqDjsxmOdrHMd",
+ "livemode": false,
+ "metadata": {},
+ "object": "payment_method",
+ "type": "card"
+ },
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "remote_realm_host": "zulip.testserver",
+ "remote_realm_uuid": "7e03b36e-47d3-4ef5-8685-afdebf09cc57"
+ },
+ "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/upgrade_user_to_basic_plan_free_trial--Event.list.1.json b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial--Event.list.1.json
new file mode 100644
index 00000000000..eff54fca4f2
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial--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.testserver 7e03b36e-47d",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_NORMALIZED0001",
+ "invoice_prefix": "NORMA01",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": "pm_1OWtmuDEQaroqDjsxmOdrHMd",
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "remote_realm_host": "zulip.testserver",
+ "remote_realm_uuid": "7e03b36e-47d3-4ef5-8685-afdebf09cc57"
+ },
+ "name": null,
+ "next_invoice_sequence": 1,
+ "object": "customer",
+ "phone": null,
+ "preferred_locales": [],
+ "shipping": null,
+ "tax_exempt": "none",
+ "test_clock": null
+ },
+ "previous_attributes": {
+ "invoice_settings": {
+ "default_payment_method": null
+ }
+ }
+ },
+ "id": "evt_1OWtmwDEQaroqDjs5MtejMwJ",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 0,
+ "request": {
+ "id": "req_NORMALIZED0001",
+ "idempotency_key": "2d796c74-471e-4dc5-a45c-0484bd3fe501"
+ },
+ "type": "customer.updated"
+ }
+ ],
+ "has_more": true,
+ "object": "list",
+ "url": "/v1/events"
+}
diff --git a/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial--Invoice.list.1.json b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial--Invoice.list.1.json
new file mode 100644
index 00000000000..e39960ab725
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial--Invoice.list.1.json
@@ -0,0 +1,6 @@
+{
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "url": "/v1/invoices"
+}
diff --git a/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial--SetupIntent.create.1.json b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial--SetupIntent.create.1.json
new file mode 100644
index 00000000000..2219ab370d4
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial--SetupIntent.create.1.json
@@ -0,0 +1,34 @@
+{
+ "application": null,
+ "automatic_payment_methods": null,
+ "cancellation_reason": null,
+ "client_secret": "seti_1OWtmuDEQaroqDjs1OLGwfF5_secret_PLayX52SwAhBdCC28yM5RXQVUUfoS14",
+ "created": 1000000000,
+ "customer": "cus_NORMALIZED0001",
+ "description": null,
+ "flow_directions": null,
+ "id": "seti_1OWtmuDEQaroqDjs1OLGwfF5",
+ "last_setup_error": null,
+ "latest_attempt": "setatt_1OWtmuDEQaroqDjsGyP8Djil",
+ "livemode": false,
+ "mandate": null,
+ "metadata": {},
+ "next_action": null,
+ "object": "setup_intent",
+ "on_behalf_of": null,
+ "payment_method": "pm_1OWtmuDEQaroqDjsxmOdrHMd",
+ "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/upgrade_user_to_basic_plan_free_trial--SetupIntent.list.1.json b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial--SetupIntent.list.1.json
new file mode 100644
index 00000000000..be47c72ce5a
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial--SetupIntent.list.1.json
@@ -0,0 +1,41 @@
+{
+ "data": [
+ {
+ "application": null,
+ "automatic_payment_methods": null,
+ "cancellation_reason": null,
+ "client_secret": "seti_1OWtmtDEQaroqDjsu7uFy3pV_secret_PLayoENB6IppSDlNR922rIHdQjRND9A",
+ "created": 1000000000,
+ "customer": "cus_NORMALIZED0001",
+ "description": null,
+ "flow_directions": null,
+ "id": "seti_1OWtmtDEQaroqDjsu7uFy3pV",
+ "last_setup_error": null,
+ "latest_attempt": null,
+ "livemode": false,
+ "mandate": null,
+ "metadata": {},
+ "next_action": null,
+ "object": "setup_intent",
+ "on_behalf_of": null,
+ "payment_method": null,
+ "payment_method_configuration_details": null,
+ "payment_method_options": {
+ "card": {
+ "mandate_options": null,
+ "network": null,
+ "request_three_d_secure": "automatic"
+ }
+ },
+ "payment_method_types": [
+ "card"
+ ],
+ "single_use_mandate": null,
+ "status": "requires_payment_method",
+ "usage": "off_session"
+ }
+ ],
+ "has_more": true,
+ "object": "list",
+ "url": "/v1/setup_intents"
+}
diff --git a/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial--SetupIntent.retrieve.1.json b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial--SetupIntent.retrieve.1.json
new file mode 100644
index 00000000000..2219ab370d4
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial--SetupIntent.retrieve.1.json
@@ -0,0 +1,34 @@
+{
+ "application": null,
+ "automatic_payment_methods": null,
+ "cancellation_reason": null,
+ "client_secret": "seti_1OWtmuDEQaroqDjs1OLGwfF5_secret_PLayX52SwAhBdCC28yM5RXQVUUfoS14",
+ "created": 1000000000,
+ "customer": "cus_NORMALIZED0001",
+ "description": null,
+ "flow_directions": null,
+ "id": "seti_1OWtmuDEQaroqDjs1OLGwfF5",
+ "last_setup_error": null,
+ "latest_attempt": "setatt_1OWtmuDEQaroqDjsGyP8Djil",
+ "livemode": false,
+ "mandate": null,
+ "metadata": {},
+ "next_action": null,
+ "object": "setup_intent",
+ "on_behalf_of": null,
+ "payment_method": "pm_1OWtmuDEQaroqDjsxmOdrHMd",
+ "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/upgrade_user_to_basic_plan_free_trial--checkout.Session.create.1.json b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial--checkout.Session.create.1.json
new file mode 100644
index 00000000000..94180f723ed
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial--checkout.Session.create.1.json
@@ -0,0 +1,74 @@
+{
+ "after_expiration": null,
+ "allow_promotion_codes": null,
+ "amount_subtotal": null,
+ "amount_total": null,
+ "automatic_tax": {
+ "enabled": false,
+ "status": null
+ },
+ "billing_address_collection": null,
+ "cancel_url": "http://selfhosting.testserver/realm/7e03b36e-47d3-4ef5-8685-afdebf09cc57/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_NORMALIZED0001",
+ "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": "cs_test_NORMALIZED01ZwRgq6jYGJKKHBs3JUk7hgzX0QKkniXxPMRJyAqNS8ja3t",
+ "invoice": null,
+ "invoice_creation": null,
+ "livemode": false,
+ "locale": null,
+ "metadata": {
+ "remote_realm_user_id": "1",
+ "type": "card_update"
+ },
+ "mode": "setup",
+ "object": "checkout.session",
+ "payment_intent": null,
+ "payment_link": null,
+ "payment_method_collection": "always",
+ "payment_method_configuration_details": null,
+ "payment_method_options": {},
+ "payment_method_types": [
+ "card"
+ ],
+ "payment_status": "no_payment_required",
+ "phone_number_collection": {
+ "enabled": false
+ },
+ "recovered_from": null,
+ "setup_intent": "seti_1OWtmtDEQaroqDjsu7uFy3pV",
+ "shipping": null,
+ "shipping_address_collection": null,
+ "shipping_options": [],
+ "shipping_rate": null,
+ "status": "open",
+ "submit_type": null,
+ "subscription": null,
+ "success_url": "http://selfhosting.testserver/realm/7e03b36e-47d3-4ef5-8685-afdebf09cc57/billing/event_status?stripe_session_id={CHECKOUT_SESSION_ID}",
+ "total_details": null,
+ "ui_mode": "hosted",
+ "url": "https://checkout.stripe.com/c/pay/cs_test_NORMALIZED01ZwRgq6jYGJKKHBs3JUk7hgzX0QKkniXxPMRJyAqNS8ja3t#fid1d2BpamRhQ2prcSc%2FJ1ZqcHdmYCVWZGt2JVV3aicpJ2R1bE5gfCc%2FJ3VuWnFgdnFaXVRmMU5zNkldQTY9SnNRY09XZml2UXNQJyknY3dqaFZgd3Ngdyc%2FcXdwYCknaWR8anBxUXx1YCc%2FJ3Zsa2JpYFpmamlwaGsnKSdga2RnaWBVaWRmYG1qaWFgd3YnP3F3cGB4JSUl"
+}
diff --git a/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial--checkout.Session.list.1.json b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial--checkout.Session.list.1.json
new file mode 100644
index 00000000000..1f2d6213a36
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial--checkout.Session.list.1.json
@@ -0,0 +1,81 @@
+{
+ "data": [
+ {
+ "after_expiration": null,
+ "allow_promotion_codes": null,
+ "amount_subtotal": null,
+ "amount_total": null,
+ "automatic_tax": {
+ "enabled": false,
+ "status": null
+ },
+ "billing_address_collection": null,
+ "cancel_url": "http://selfhosting.testserver/realm/7e03b36e-47d3-4ef5-8685-afdebf09cc57/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_NORMALIZED0001",
+ "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": "cs_test_NORMALIZED01ZwRgq6jYGJKKHBs3JUk7hgzX0QKkniXxPMRJyAqNS8ja3t",
+ "invoice": null,
+ "invoice_creation": null,
+ "livemode": false,
+ "locale": null,
+ "metadata": {
+ "remote_realm_user_id": "1",
+ "type": "card_update"
+ },
+ "mode": "setup",
+ "object": "checkout.session",
+ "payment_intent": null,
+ "payment_link": null,
+ "payment_method_collection": "always",
+ "payment_method_configuration_details": null,
+ "payment_method_options": {},
+ "payment_method_types": [
+ "card"
+ ],
+ "payment_status": "no_payment_required",
+ "phone_number_collection": {
+ "enabled": false
+ },
+ "recovered_from": null,
+ "setup_intent": "seti_1OWtmtDEQaroqDjsu7uFy3pV",
+ "shipping": null,
+ "shipping_address_collection": null,
+ "shipping_options": [],
+ "shipping_rate": null,
+ "status": "open",
+ "submit_type": null,
+ "subscription": null,
+ "success_url": "http://selfhosting.testserver/realm/7e03b36e-47d3-4ef5-8685-afdebf09cc57/billing/event_status?stripe_session_id={CHECKOUT_SESSION_ID}",
+ "total_details": null,
+ "ui_mode": "hosted",
+ "url": "https://checkout.stripe.com/c/pay/cs_test_NORMALIZED01ZwRgq6jYGJKKHBs3JUk7hgzX0QKkniXxPMRJyAqNS8ja3t#fid1d2BpamRhQ2prcSc%2FJ1ZqcHdmYCVWZGt2JVV3aicpJ2R1bE5gfCc%2FJ3VuWnFgdnFaXVRmMU5zNkldQTY9SnNRY09XZml2UXNQJyknY3dqaFZgd3Ngdyc%2FcXdwYCknaWR8anBxUXx1YCc%2FJ3Zsa2JpYFpmamlwaGsnKSdga2RnaWBVaWRmYG1qaWFgd3YnP3F3cGB4JSUl"
+ }
+ ],
+ "has_more": true,
+ "object": "list",
+ "url": "/v1/checkout/sessions"
+}
diff --git a/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial_remote_server--Customer.create.1.json b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial_remote_server--Customer.create.1.json
new file mode 100644
index 00000000000..3d6b9bc66c1
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial_remote_server--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": "demo.example.com 6cde5f7a-1f7",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_NORMALIZED0001",
+ "invoice_prefix": "NORMA01",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": null,
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "remote_server_str": "demo.example.com 6cde5f7a-1f7",
+ "remote_server_uuid": "6cde5f7a-1f7e-4978-9716-49f69ebfc9fe"
+ },
+ "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/upgrade_user_to_basic_plan_free_trial_remote_server--Customer.modify.1.json b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial_remote_server--Customer.modify.1.json
new file mode 100644
index 00000000000..248e076e8d8
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial_remote_server--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": "demo.example.com 6cde5f7a-1f7",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_NORMALIZED0001",
+ "invoice_prefix": "NORMA01",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": "pm_1OWtnhDEQaroqDjsZxHwLqGK",
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "remote_server_str": "demo.example.com 6cde5f7a-1f7",
+ "remote_server_uuid": "6cde5f7a-1f7e-4978-9716-49f69ebfc9fe"
+ },
+ "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/upgrade_user_to_basic_plan_free_trial_remote_server--Customer.retrieve.1.json b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial_remote_server--Customer.retrieve.1.json
new file mode 100644
index 00000000000..fa89ed6f981
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial_remote_server--Customer.retrieve.1.json
@@ -0,0 +1,79 @@
+{
+ "address": null,
+ "balance": 0,
+ "created": 1000000000,
+ "currency": null,
+ "default_currency": null,
+ "default_source": null,
+ "delinquent": false,
+ "description": "demo.example.com 6cde5f7a-1f7",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_NORMALIZED0001",
+ "invoice_prefix": "NORMA01",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": {
+ "billing_details": {
+ "address": {
+ "city": null,
+ "country": null,
+ "line1": null,
+ "line2": null,
+ "postal_code": null,
+ "state": null
+ },
+ "email": null,
+ "name": null,
+ "phone": null
+ },
+ "card": {
+ "brand": "visa",
+ "checks": {
+ "address_line1_check": null,
+ "address_postal_code_check": null,
+ "cvc_check": "pass"
+ },
+ "country": "US",
+ "exp_month": 1,
+ "exp_year": 2025,
+ "fingerprint": "NORMALIZED000001",
+ "funding": "credit",
+ "generated_from": null,
+ "last4": "4242",
+ "networks": {
+ "available": [
+ "visa"
+ ],
+ "preferred": null
+ },
+ "three_d_secure_usage": {
+ "supported": true
+ },
+ "wallet": null
+ },
+ "created": 1000000000,
+ "customer": "cus_NORMALIZED0001",
+ "id": "pm_1OWtnhDEQaroqDjsZxHwLqGK",
+ "livemode": false,
+ "metadata": {},
+ "object": "payment_method",
+ "type": "card"
+ },
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "remote_server_str": "demo.example.com 6cde5f7a-1f7",
+ "remote_server_uuid": "6cde5f7a-1f7e-4978-9716-49f69ebfc9fe"
+ },
+ "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/upgrade_user_to_basic_plan_free_trial_remote_server--Customer.retrieve.2.json b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial_remote_server--Customer.retrieve.2.json
new file mode 100644
index 00000000000..fa89ed6f981
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial_remote_server--Customer.retrieve.2.json
@@ -0,0 +1,79 @@
+{
+ "address": null,
+ "balance": 0,
+ "created": 1000000000,
+ "currency": null,
+ "default_currency": null,
+ "default_source": null,
+ "delinquent": false,
+ "description": "demo.example.com 6cde5f7a-1f7",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_NORMALIZED0001",
+ "invoice_prefix": "NORMA01",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": {
+ "billing_details": {
+ "address": {
+ "city": null,
+ "country": null,
+ "line1": null,
+ "line2": null,
+ "postal_code": null,
+ "state": null
+ },
+ "email": null,
+ "name": null,
+ "phone": null
+ },
+ "card": {
+ "brand": "visa",
+ "checks": {
+ "address_line1_check": null,
+ "address_postal_code_check": null,
+ "cvc_check": "pass"
+ },
+ "country": "US",
+ "exp_month": 1,
+ "exp_year": 2025,
+ "fingerprint": "NORMALIZED000001",
+ "funding": "credit",
+ "generated_from": null,
+ "last4": "4242",
+ "networks": {
+ "available": [
+ "visa"
+ ],
+ "preferred": null
+ },
+ "three_d_secure_usage": {
+ "supported": true
+ },
+ "wallet": null
+ },
+ "created": 1000000000,
+ "customer": "cus_NORMALIZED0001",
+ "id": "pm_1OWtnhDEQaroqDjsZxHwLqGK",
+ "livemode": false,
+ "metadata": {},
+ "object": "payment_method",
+ "type": "card"
+ },
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "remote_server_str": "demo.example.com 6cde5f7a-1f7",
+ "remote_server_uuid": "6cde5f7a-1f7e-4978-9716-49f69ebfc9fe"
+ },
+ "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/upgrade_user_to_basic_plan_free_trial_remote_server--Customer.retrieve.3.json b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial_remote_server--Customer.retrieve.3.json
new file mode 100644
index 00000000000..fa89ed6f981
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial_remote_server--Customer.retrieve.3.json
@@ -0,0 +1,79 @@
+{
+ "address": null,
+ "balance": 0,
+ "created": 1000000000,
+ "currency": null,
+ "default_currency": null,
+ "default_source": null,
+ "delinquent": false,
+ "description": "demo.example.com 6cde5f7a-1f7",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_NORMALIZED0001",
+ "invoice_prefix": "NORMA01",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": {
+ "billing_details": {
+ "address": {
+ "city": null,
+ "country": null,
+ "line1": null,
+ "line2": null,
+ "postal_code": null,
+ "state": null
+ },
+ "email": null,
+ "name": null,
+ "phone": null
+ },
+ "card": {
+ "brand": "visa",
+ "checks": {
+ "address_line1_check": null,
+ "address_postal_code_check": null,
+ "cvc_check": "pass"
+ },
+ "country": "US",
+ "exp_month": 1,
+ "exp_year": 2025,
+ "fingerprint": "NORMALIZED000001",
+ "funding": "credit",
+ "generated_from": null,
+ "last4": "4242",
+ "networks": {
+ "available": [
+ "visa"
+ ],
+ "preferred": null
+ },
+ "three_d_secure_usage": {
+ "supported": true
+ },
+ "wallet": null
+ },
+ "created": 1000000000,
+ "customer": "cus_NORMALIZED0001",
+ "id": "pm_1OWtnhDEQaroqDjsZxHwLqGK",
+ "livemode": false,
+ "metadata": {},
+ "object": "payment_method",
+ "type": "card"
+ },
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "remote_server_str": "demo.example.com 6cde5f7a-1f7",
+ "remote_server_uuid": "6cde5f7a-1f7e-4978-9716-49f69ebfc9fe"
+ },
+ "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/upgrade_user_to_basic_plan_free_trial_remote_server--Customer.retrieve.4.json b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial_remote_server--Customer.retrieve.4.json
new file mode 100644
index 00000000000..fa89ed6f981
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial_remote_server--Customer.retrieve.4.json
@@ -0,0 +1,79 @@
+{
+ "address": null,
+ "balance": 0,
+ "created": 1000000000,
+ "currency": null,
+ "default_currency": null,
+ "default_source": null,
+ "delinquent": false,
+ "description": "demo.example.com 6cde5f7a-1f7",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_NORMALIZED0001",
+ "invoice_prefix": "NORMA01",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": {
+ "billing_details": {
+ "address": {
+ "city": null,
+ "country": null,
+ "line1": null,
+ "line2": null,
+ "postal_code": null,
+ "state": null
+ },
+ "email": null,
+ "name": null,
+ "phone": null
+ },
+ "card": {
+ "brand": "visa",
+ "checks": {
+ "address_line1_check": null,
+ "address_postal_code_check": null,
+ "cvc_check": "pass"
+ },
+ "country": "US",
+ "exp_month": 1,
+ "exp_year": 2025,
+ "fingerprint": "NORMALIZED000001",
+ "funding": "credit",
+ "generated_from": null,
+ "last4": "4242",
+ "networks": {
+ "available": [
+ "visa"
+ ],
+ "preferred": null
+ },
+ "three_d_secure_usage": {
+ "supported": true
+ },
+ "wallet": null
+ },
+ "created": 1000000000,
+ "customer": "cus_NORMALIZED0001",
+ "id": "pm_1OWtnhDEQaroqDjsZxHwLqGK",
+ "livemode": false,
+ "metadata": {},
+ "object": "payment_method",
+ "type": "card"
+ },
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "remote_server_str": "demo.example.com 6cde5f7a-1f7",
+ "remote_server_uuid": "6cde5f7a-1f7e-4978-9716-49f69ebfc9fe"
+ },
+ "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/upgrade_user_to_basic_plan_free_trial_remote_server--Customer.retrieve.5.json b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial_remote_server--Customer.retrieve.5.json
new file mode 100644
index 00000000000..fa89ed6f981
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial_remote_server--Customer.retrieve.5.json
@@ -0,0 +1,79 @@
+{
+ "address": null,
+ "balance": 0,
+ "created": 1000000000,
+ "currency": null,
+ "default_currency": null,
+ "default_source": null,
+ "delinquent": false,
+ "description": "demo.example.com 6cde5f7a-1f7",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_NORMALIZED0001",
+ "invoice_prefix": "NORMA01",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": {
+ "billing_details": {
+ "address": {
+ "city": null,
+ "country": null,
+ "line1": null,
+ "line2": null,
+ "postal_code": null,
+ "state": null
+ },
+ "email": null,
+ "name": null,
+ "phone": null
+ },
+ "card": {
+ "brand": "visa",
+ "checks": {
+ "address_line1_check": null,
+ "address_postal_code_check": null,
+ "cvc_check": "pass"
+ },
+ "country": "US",
+ "exp_month": 1,
+ "exp_year": 2025,
+ "fingerprint": "NORMALIZED000001",
+ "funding": "credit",
+ "generated_from": null,
+ "last4": "4242",
+ "networks": {
+ "available": [
+ "visa"
+ ],
+ "preferred": null
+ },
+ "three_d_secure_usage": {
+ "supported": true
+ },
+ "wallet": null
+ },
+ "created": 1000000000,
+ "customer": "cus_NORMALIZED0001",
+ "id": "pm_1OWtnhDEQaroqDjsZxHwLqGK",
+ "livemode": false,
+ "metadata": {},
+ "object": "payment_method",
+ "type": "card"
+ },
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "remote_server_str": "demo.example.com 6cde5f7a-1f7",
+ "remote_server_uuid": "6cde5f7a-1f7e-4978-9716-49f69ebfc9fe"
+ },
+ "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/upgrade_user_to_basic_plan_free_trial_remote_server--Customer.retrieve.6.json b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial_remote_server--Customer.retrieve.6.json
new file mode 100644
index 00000000000..fa89ed6f981
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial_remote_server--Customer.retrieve.6.json
@@ -0,0 +1,79 @@
+{
+ "address": null,
+ "balance": 0,
+ "created": 1000000000,
+ "currency": null,
+ "default_currency": null,
+ "default_source": null,
+ "delinquent": false,
+ "description": "demo.example.com 6cde5f7a-1f7",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_NORMALIZED0001",
+ "invoice_prefix": "NORMA01",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": {
+ "billing_details": {
+ "address": {
+ "city": null,
+ "country": null,
+ "line1": null,
+ "line2": null,
+ "postal_code": null,
+ "state": null
+ },
+ "email": null,
+ "name": null,
+ "phone": null
+ },
+ "card": {
+ "brand": "visa",
+ "checks": {
+ "address_line1_check": null,
+ "address_postal_code_check": null,
+ "cvc_check": "pass"
+ },
+ "country": "US",
+ "exp_month": 1,
+ "exp_year": 2025,
+ "fingerprint": "NORMALIZED000001",
+ "funding": "credit",
+ "generated_from": null,
+ "last4": "4242",
+ "networks": {
+ "available": [
+ "visa"
+ ],
+ "preferred": null
+ },
+ "three_d_secure_usage": {
+ "supported": true
+ },
+ "wallet": null
+ },
+ "created": 1000000000,
+ "customer": "cus_NORMALIZED0001",
+ "id": "pm_1OWtnhDEQaroqDjsZxHwLqGK",
+ "livemode": false,
+ "metadata": {},
+ "object": "payment_method",
+ "type": "card"
+ },
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "remote_server_str": "demo.example.com 6cde5f7a-1f7",
+ "remote_server_uuid": "6cde5f7a-1f7e-4978-9716-49f69ebfc9fe"
+ },
+ "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/upgrade_user_to_basic_plan_free_trial_remote_server--Event.list.1.json b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial_remote_server--Event.list.1.json
new file mode 100644
index 00000000000..f7dc7fd6443
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial_remote_server--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": "demo.example.com 6cde5f7a-1f7",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_NORMALIZED0001",
+ "invoice_prefix": "NORMA01",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": "pm_1OWtnhDEQaroqDjsZxHwLqGK",
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "remote_server_str": "demo.example.com 6cde5f7a-1f7",
+ "remote_server_uuid": "6cde5f7a-1f7e-4978-9716-49f69ebfc9fe"
+ },
+ "name": null,
+ "next_invoice_sequence": 1,
+ "object": "customer",
+ "phone": null,
+ "preferred_locales": [],
+ "shipping": null,
+ "tax_exempt": "none",
+ "test_clock": null
+ },
+ "previous_attributes": {
+ "invoice_settings": {
+ "default_payment_method": null
+ }
+ }
+ },
+ "id": "evt_1OWtnjDEQaroqDjslHFF0u3I",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 0,
+ "request": {
+ "id": "req_NORMALIZED0001",
+ "idempotency_key": "d74e6262-a3df-4384-845e-334fd5997bd9"
+ },
+ "type": "customer.updated"
+ }
+ ],
+ "has_more": true,
+ "object": "list",
+ "url": "/v1/events"
+}
diff --git a/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial_remote_server--Invoice.list.1.json b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial_remote_server--Invoice.list.1.json
new file mode 100644
index 00000000000..e39960ab725
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial_remote_server--Invoice.list.1.json
@@ -0,0 +1,6 @@
+{
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "url": "/v1/invoices"
+}
diff --git a/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial_remote_server--SetupIntent.create.1.json b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial_remote_server--SetupIntent.create.1.json
new file mode 100644
index 00000000000..3b2628ef9a8
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial_remote_server--SetupIntent.create.1.json
@@ -0,0 +1,34 @@
+{
+ "application": null,
+ "automatic_payment_methods": null,
+ "cancellation_reason": null,
+ "client_secret": "seti_1OWtnhDEQaroqDjsvkf4tB7V_secret_PLazo09wnVjc9pNvTYrDZookvKJ5PKc",
+ "created": 1000000000,
+ "customer": "cus_NORMALIZED0001",
+ "description": null,
+ "flow_directions": null,
+ "id": "seti_1OWtnhDEQaroqDjsvkf4tB7V",
+ "last_setup_error": null,
+ "latest_attempt": "setatt_1OWtnhDEQaroqDjsH93uH4xk",
+ "livemode": false,
+ "mandate": null,
+ "metadata": {},
+ "next_action": null,
+ "object": "setup_intent",
+ "on_behalf_of": null,
+ "payment_method": "pm_1OWtnhDEQaroqDjsZxHwLqGK",
+ "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/upgrade_user_to_basic_plan_free_trial_remote_server--SetupIntent.list.1.json b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial_remote_server--SetupIntent.list.1.json
new file mode 100644
index 00000000000..6d5bfa596ae
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial_remote_server--SetupIntent.list.1.json
@@ -0,0 +1,41 @@
+{
+ "data": [
+ {
+ "application": null,
+ "automatic_payment_methods": null,
+ "cancellation_reason": null,
+ "client_secret": "seti_1OWtngDEQaroqDjsnHZK5Zcg_secret_PLazZ55KBPPO40HS2dkTPujUZI8Fcv6",
+ "created": 1000000000,
+ "customer": "cus_NORMALIZED0001",
+ "description": null,
+ "flow_directions": null,
+ "id": "seti_1OWtngDEQaroqDjsnHZK5Zcg",
+ "last_setup_error": null,
+ "latest_attempt": null,
+ "livemode": false,
+ "mandate": null,
+ "metadata": {},
+ "next_action": null,
+ "object": "setup_intent",
+ "on_behalf_of": null,
+ "payment_method": null,
+ "payment_method_configuration_details": null,
+ "payment_method_options": {
+ "card": {
+ "mandate_options": null,
+ "network": null,
+ "request_three_d_secure": "automatic"
+ }
+ },
+ "payment_method_types": [
+ "card"
+ ],
+ "single_use_mandate": null,
+ "status": "requires_payment_method",
+ "usage": "off_session"
+ }
+ ],
+ "has_more": true,
+ "object": "list",
+ "url": "/v1/setup_intents"
+}
diff --git a/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial_remote_server--SetupIntent.retrieve.1.json b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial_remote_server--SetupIntent.retrieve.1.json
new file mode 100644
index 00000000000..3b2628ef9a8
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial_remote_server--SetupIntent.retrieve.1.json
@@ -0,0 +1,34 @@
+{
+ "application": null,
+ "automatic_payment_methods": null,
+ "cancellation_reason": null,
+ "client_secret": "seti_1OWtnhDEQaroqDjsvkf4tB7V_secret_PLazo09wnVjc9pNvTYrDZookvKJ5PKc",
+ "created": 1000000000,
+ "customer": "cus_NORMALIZED0001",
+ "description": null,
+ "flow_directions": null,
+ "id": "seti_1OWtnhDEQaroqDjsvkf4tB7V",
+ "last_setup_error": null,
+ "latest_attempt": "setatt_1OWtnhDEQaroqDjsH93uH4xk",
+ "livemode": false,
+ "mandate": null,
+ "metadata": {},
+ "next_action": null,
+ "object": "setup_intent",
+ "on_behalf_of": null,
+ "payment_method": "pm_1OWtnhDEQaroqDjsZxHwLqGK",
+ "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/upgrade_user_to_basic_plan_free_trial_remote_server--checkout.Session.create.1.json b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial_remote_server--checkout.Session.create.1.json
new file mode 100644
index 00000000000..8bb27ab45a5
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial_remote_server--checkout.Session.create.1.json
@@ -0,0 +1,74 @@
+{
+ "after_expiration": null,
+ "allow_promotion_codes": null,
+ "amount_subtotal": null,
+ "amount_total": null,
+ "automatic_tax": {
+ "enabled": false,
+ "status": null
+ },
+ "billing_address_collection": null,
+ "cancel_url": "http://selfhosting.testserver/server/6cde5f7a-1f7e-4978-9716-49f69ebfc9fe/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_NORMALIZED0001",
+ "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": "cs_test_NORMALIZED01PfWq8xYJfr3wWp6YY9gTEp8T2zLOAePoCl5AwAsjNSQmDP",
+ "invoice": null,
+ "invoice_creation": null,
+ "livemode": false,
+ "locale": null,
+ "metadata": {
+ "remote_server_user_id": "1",
+ "type": "card_update"
+ },
+ "mode": "setup",
+ "object": "checkout.session",
+ "payment_intent": null,
+ "payment_link": null,
+ "payment_method_collection": "always",
+ "payment_method_configuration_details": null,
+ "payment_method_options": {},
+ "payment_method_types": [
+ "card"
+ ],
+ "payment_status": "no_payment_required",
+ "phone_number_collection": {
+ "enabled": false
+ },
+ "recovered_from": null,
+ "setup_intent": "seti_1OWtngDEQaroqDjsnHZK5Zcg",
+ "shipping": null,
+ "shipping_address_collection": null,
+ "shipping_options": [],
+ "shipping_rate": null,
+ "status": "open",
+ "submit_type": null,
+ "subscription": null,
+ "success_url": "http://selfhosting.testserver/server/6cde5f7a-1f7e-4978-9716-49f69ebfc9fe/billing/event_status?stripe_session_id={CHECKOUT_SESSION_ID}",
+ "total_details": null,
+ "ui_mode": "hosted",
+ "url": "https://checkout.stripe.com/c/pay/cs_test_NORMALIZED01PfWq8xYJfr3wWp6YY9gTEp8T2zLOAePoCl5AwAsjNSQmDP#fid1d2BpamRhQ2prcSc%2FJ1ZqcHdmYCVWZGt2JVV3aicpJ2R1bE5gfCc%2FJ3VuWnFgdnFaXVRmMU5zNkldQTY9SnNRY09XZml2UXNQJyknY3dqaFZgd3Ngdyc%2FcXdwYCknaWR8anBxUXx1YCc%2FJ3Zsa2JpYFpmamlwaGsnKSdga2RnaWBVaWRmYG1qaWFgd3YnP3F3cGB4JSUl"
+}
diff --git a/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial_remote_server--checkout.Session.list.1.json b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial_remote_server--checkout.Session.list.1.json
new file mode 100644
index 00000000000..11f2f3dc186
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/upgrade_user_to_basic_plan_free_trial_remote_server--checkout.Session.list.1.json
@@ -0,0 +1,81 @@
+{
+ "data": [
+ {
+ "after_expiration": null,
+ "allow_promotion_codes": null,
+ "amount_subtotal": null,
+ "amount_total": null,
+ "automatic_tax": {
+ "enabled": false,
+ "status": null
+ },
+ "billing_address_collection": null,
+ "cancel_url": "http://selfhosting.testserver/server/6cde5f7a-1f7e-4978-9716-49f69ebfc9fe/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_NORMALIZED0001",
+ "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": "cs_test_NORMALIZED01PfWq8xYJfr3wWp6YY9gTEp8T2zLOAePoCl5AwAsjNSQmDP",
+ "invoice": null,
+ "invoice_creation": null,
+ "livemode": false,
+ "locale": null,
+ "metadata": {
+ "remote_server_user_id": "1",
+ "type": "card_update"
+ },
+ "mode": "setup",
+ "object": "checkout.session",
+ "payment_intent": null,
+ "payment_link": null,
+ "payment_method_collection": "always",
+ "payment_method_configuration_details": null,
+ "payment_method_options": {},
+ "payment_method_types": [
+ "card"
+ ],
+ "payment_status": "no_payment_required",
+ "phone_number_collection": {
+ "enabled": false
+ },
+ "recovered_from": null,
+ "setup_intent": "seti_1OWtngDEQaroqDjsnHZK5Zcg",
+ "shipping": null,
+ "shipping_address_collection": null,
+ "shipping_options": [],
+ "shipping_rate": null,
+ "status": "open",
+ "submit_type": null,
+ "subscription": null,
+ "success_url": "http://selfhosting.testserver/server/6cde5f7a-1f7e-4978-9716-49f69ebfc9fe/billing/event_status?stripe_session_id={CHECKOUT_SESSION_ID}",
+ "total_details": null,
+ "ui_mode": "hosted",
+ "url": "https://checkout.stripe.com/c/pay/cs_test_NORMALIZED01PfWq8xYJfr3wWp6YY9gTEp8T2zLOAePoCl5AwAsjNSQmDP#fid1d2BpamRhQ2prcSc%2FJ1ZqcHdmYCVWZGt2JVV3aicpJ2R1bE5gfCc%2FJ3VuWnFgdnFaXVRmMU5zNkldQTY9SnNRY09XZml2UXNQJyknY3dqaFZgd3Ngdyc%2FcXdwYCknaWR8anBxUXx1YCc%2FJ3Zsa2JpYFpmamlwaGsnKSdga2RnaWBVaWRmYG1qaWFgd3YnP3F3cGB4JSUl"
+ }
+ ],
+ "has_more": true,
+ "object": "list",
+ "url": "/v1/checkout/sessions"
+}
diff --git a/corporate/tests/test_stripe.py b/corporate/tests/test_stripe.py
index 223f624a187..e48193a64da 100644
--- a/corporate/tests/test_stripe.py
+++ b/corporate/tests/test_stripe.py
@@ -625,7 +625,8 @@ class StripeTestCase(ZulipTestCase):
# Return early if the upgrade request failed.
return upgrade_json_response
- if invoice or not talk_to_stripe or is_free_trial_offer_enabled(False):
+ is_self_hosted_billing = not isinstance(self.billing_session, RealmBillingSession)
+ if invoice or not talk_to_stripe or is_free_trial_offer_enabled(is_self_hosted_billing):
# Upgrade already happened for free trial, invoice realms or schedule
# upgrade for legacy remote servers.
return upgrade_json_response
@@ -5750,6 +5751,41 @@ class TestRemoteRealmBillingFlow(StripeTestCase, RemoteRealmBillingTestCase):
result,
)
+ # Same result even with free trial enabled for self hosted customers since we don't
+ # offer free trial for business plan.
+ with self.settings(SELF_HOSTING_FREE_TRIAL_DAYS=30):
+ with time_machine.travel(self.now, tick=False):
+ result = self.client_get(
+ f"{self.billing_session.billing_base_url}/upgrade/", subdomain="selfhosting"
+ )
+
+ self.assert_in_success_response(
+ [
+ "Minimum purchase for",
+ f"{min_licenses} licenses",
+ "Add card",
+ "Purchase Zulip Business",
+ ],
+ result,
+ )
+
+ # Check that cloud free trials don't affect self hosted customers.
+ with self.settings(CLOUD_FREE_TRIAL_DAYS=30):
+ with time_machine.travel(self.now, tick=False):
+ result = self.client_get(
+ f"{self.billing_session.billing_base_url}/upgrade/", subdomain="selfhosting"
+ )
+
+ self.assert_in_success_response(
+ [
+ "Minimum purchase for",
+ f"{min_licenses} licenses",
+ "Add card",
+ "Purchase Zulip Business",
+ ],
+ result,
+ )
+
self.assertFalse(Customer.objects.exists())
self.assertFalse(CustomerPlan.objects.exists())
self.assertFalse(LicenseLedger.objects.exists())
@@ -5821,6 +5857,138 @@ class TestRemoteRealmBillingFlow(StripeTestCase, RemoteRealmBillingTestCase):
]:
self.assert_in_response(substring, response)
+ @responses.activate
+ @mock_stripe()
+ def test_upgrade_user_to_basic_plan_free_trial(self, *mocks: Mock) -> None:
+ with self.settings(SELF_HOSTING_FREE_TRIAL_DAYS=30):
+ self.login("hamlet")
+ hamlet = self.example_user("hamlet")
+
+ self.add_mock_response()
+ realm_user_count = UserProfile.objects.filter(
+ realm=hamlet.realm, is_bot=False, is_active=True
+ ).count()
+ self.assertEqual(realm_user_count, 11)
+
+ with time_machine.travel(self.now, tick=False):
+ send_server_data_to_push_bouncer(consider_usage_statistics=False)
+
+ result = self.execute_remote_billing_authentication_flow(hamlet)
+ self.assertEqual(result.status_code, 302)
+ self.assertEqual(result["Location"], f"{self.billing_session.billing_base_url}/plans/")
+
+ # upgrade to basic plan
+ with time_machine.travel(self.now, tick=False):
+ result = self.client_get(
+ f"{self.billing_session.billing_base_url}/upgrade/?tier={CustomerPlan.TIER_SELF_HOSTED_BASIC}",
+ subdomain="selfhosting",
+ )
+ self.assertEqual(result.status_code, 200)
+
+ min_licenses = self.billing_session.min_licenses_for_plan(
+ CustomerPlan.TIER_SELF_HOSTED_BASIC
+ )
+ self.assertEqual(min_licenses, 6)
+ flat_discount, flat_discounted_months = self.billing_session.get_flat_discount_info()
+ self.assertEqual(flat_discounted_months, 12)
+
+ self.assert_in_success_response(
+ [
+ "Start free trial",
+ "Zulip Basic",
+ "Due",
+ "on February 1, 2012",
+ f"{min_licenses}",
+ "Add card",
+ "Start 30-day free trial",
+ ],
+ result,
+ )
+
+ self.assertFalse(Customer.objects.exists())
+ self.assertFalse(CustomerPlan.objects.exists())
+ self.assertFalse(LicenseLedger.objects.exists())
+
+ with time_machine.travel(self.now, tick=False):
+ stripe_customer = self.add_card_and_upgrade(
+ tier=CustomerPlan.TIER_SELF_HOSTED_BASIC, schedule="monthly"
+ )
+
+ self.assertEqual(PaymentIntent.objects.count(), 0)
+ customer = Customer.objects.get(stripe_customer_id=stripe_customer.id)
+ plan = CustomerPlan.objects.get(customer=customer)
+ LicenseLedger.objects.get(plan=plan)
+
+ with time_machine.travel(self.now + timedelta(days=1), tick=False):
+ response = self.client_get(
+ f"{self.billing_session.billing_base_url}/billing/", subdomain="selfhosting"
+ )
+ for substring in [
+ "Zulip Basic",
+ "(free trial)",
+ "Number of licenses",
+ f"{realm_user_count} (managed automatically)",
+ "February 1, 2012",
+ "Your plan will automatically renew on",
+ f"${3.5 * realm_user_count - flat_discount // 100 * 1:,.2f}",
+ "Visa ending in 4242",
+ "Update card",
+ ]:
+ self.assert_in_response(substring, response)
+
+ # Verify that change in user count updates LicenseLedger.
+ audit_log_count = RemoteRealmAuditLog.objects.count()
+ self.assertEqual(LicenseLedger.objects.count(), 1)
+
+ with time_machine.travel(self.now + timedelta(days=2), tick=False):
+ for count in range(realm_user_count, min_licenses + 10):
+ do_create_user(
+ f"email {count}",
+ f"password {count}",
+ hamlet.realm,
+ "name",
+ role=UserProfile.ROLE_MEMBER,
+ acting_user=None,
+ )
+
+ with time_machine.travel(self.now + timedelta(days=3), tick=False):
+ send_server_data_to_push_bouncer(consider_usage_statistics=False)
+
+ self.assertEqual(
+ RemoteRealmAuditLog.objects.count(),
+ min_licenses + 10 - realm_user_count + audit_log_count,
+ )
+ latest_ledger = LicenseLedger.objects.last()
+ assert latest_ledger is not None
+ self.assertEqual(latest_ledger.licenses, min_licenses + 10)
+
+ with time_machine.travel(self.now + timedelta(days=1), tick=False):
+ response = self.client_get(
+ f"{self.billing_session.billing_base_url}/billing/", subdomain="selfhosting"
+ )
+
+ self.assertEqual(latest_ledger.licenses, min_licenses + 10)
+ for substring in [
+ "Zulip Basic",
+ "Number of licenses",
+ f"{latest_ledger.licenses} (managed automatically)",
+ "February 1, 2012",
+ "Your plan will automatically renew on",
+ f"${3.5 * latest_ledger.licenses - flat_discount // 100 * 1:,.2f}",
+ "Visa ending in 4242",
+ "Update card",
+ ]:
+ self.assert_in_response(substring, response)
+
+ # Check minimum licenses is 0 after flat discounted months is over.
+ customer.flat_discounted_months = 0
+ customer.save(update_fields=["flat_discounted_months"])
+ self.assertEqual(
+ self.billing_session.min_licenses_for_plan(CustomerPlan.TIER_SELF_HOSTED_BASIC), 1
+ )
+
+ # TODO: Add test for invoice generation once that's implemented.
+
@responses.activate
@mock_stripe()
def test_upgrade_user_to_monthly_basic_plan(self, *mocks: Mock) -> None:
@@ -6265,6 +6433,14 @@ class TestRemoteServerBillingFlow(StripeTestCase, RemoteServerTestCase):
self.assertEqual(result.status_code, 200)
self.assert_in_success_response(["Add card", "Purchase Zulip Business"], result)
+ # Same result even with free trial enabled for self hosted customers since we don't
+ # offer free trial for business plan.
+ with self.settings(SELF_HOSTING_FREE_TRIAL_DAYS=30):
+ with time_machine.travel(self.now, tick=False):
+ result = self.client_get(f"{billing_base_url}/upgrade/", subdomain="selfhosting")
+
+ self.assert_in_success_response(["Add card", "Purchase Zulip Business"], result)
+
self.assertFalse(Customer.objects.exists())
self.assertFalse(CustomerPlan.objects.exists())
self.assertFalse(LicenseLedger.objects.exists())
@@ -6553,6 +6729,138 @@ class TestRemoteServerBillingFlow(StripeTestCase, RemoteServerTestCase):
f"INFO:corporate.stripe:Change plan status: Customer.id: {customer.id}, CustomerPlan.id: {customer_plan.id}, status: {CustomerPlan.ACTIVE}",
)
+ @responses.activate
+ @mock_stripe()
+ def test_upgrade_user_to_basic_plan_free_trial_remote_server(self, *mocks: Mock) -> None:
+ with self.settings(SELF_HOSTING_FREE_TRIAL_DAYS=30):
+ self.login("hamlet")
+ hamlet = self.example_user("hamlet")
+
+ self.add_mock_response()
+ realm_user_count = UserProfile.objects.filter(is_bot=False, is_active=True).count()
+ self.assertEqual(realm_user_count, 18)
+
+ with time_machine.travel(self.now, tick=False):
+ send_server_data_to_push_bouncer(consider_usage_statistics=False)
+
+ result = self.execute_remote_billing_authentication_flow(
+ hamlet.delivery_email, hamlet.full_name
+ )
+ self.assertEqual(result.status_code, 302)
+ self.assertEqual(result["Location"], f"{self.billing_session.billing_base_url}/plans/")
+
+ # upgrade to basic plan
+ with time_machine.travel(self.now, tick=False):
+ result = self.client_get(
+ f"{self.billing_session.billing_base_url}/upgrade/?tier={CustomerPlan.TIER_SELF_HOSTED_BASIC}",
+ subdomain="selfhosting",
+ )
+ self.assertEqual(result.status_code, 200)
+
+ min_licenses = self.billing_session.min_licenses_for_plan(
+ CustomerPlan.TIER_SELF_HOSTED_BASIC
+ )
+ self.assertEqual(min_licenses, 6)
+ flat_discount, flat_discounted_months = self.billing_session.get_flat_discount_info()
+ self.assertEqual(flat_discounted_months, 12)
+
+ self.assert_in_success_response(
+ [
+ "Start free trial",
+ "Zulip Basic",
+ "Due",
+ "on February 1, 2012",
+ f"{min_licenses}",
+ "Add card",
+ "Start 30-day free trial",
+ ],
+ result,
+ )
+
+ self.assertFalse(Customer.objects.exists())
+ self.assertFalse(CustomerPlan.objects.exists())
+ self.assertFalse(LicenseLedger.objects.exists())
+
+ with time_machine.travel(self.now, tick=False):
+ stripe_customer = self.add_card_and_upgrade(
+ tier=CustomerPlan.TIER_SELF_HOSTED_BASIC, schedule="monthly"
+ )
+ self.assertEqual(PaymentIntent.objects.count(), 0)
+
+ customer = Customer.objects.get(stripe_customer_id=stripe_customer.id)
+ plan = CustomerPlan.objects.get(customer=customer)
+ LicenseLedger.objects.get(plan=plan)
+
+ with time_machine.travel(self.now + timedelta(days=1), tick=False):
+ response = self.client_get(
+ f"{self.billing_session.billing_base_url}/billing/", subdomain="selfhosting"
+ )
+ for substring in [
+ "Zulip Basic",
+ "(free trial)",
+ "Number of licenses",
+ f"{realm_user_count} (managed automatically)",
+ "February 1, 2012",
+ "Your plan will automatically renew on",
+ f"${3.5 * realm_user_count - flat_discount // 100 * 1:,.2f}",
+ "Visa ending in 4242",
+ "Update card",
+ ]:
+ self.assert_in_response(substring, response)
+
+ # Verify that change in user count updates LicenseLedger.
+ audit_log_count = RemoteRealmAuditLog.objects.count()
+ self.assertEqual(LicenseLedger.objects.count(), 1)
+
+ with time_machine.travel(self.now + timedelta(days=2), tick=False):
+ for count in range(realm_user_count, realm_user_count + 10):
+ do_create_user(
+ f"email {count}",
+ f"password {count}",
+ hamlet.realm,
+ "name",
+ role=UserProfile.ROLE_MEMBER,
+ acting_user=None,
+ )
+
+ with time_machine.travel(self.now + timedelta(days=3), tick=False):
+ send_server_data_to_push_bouncer(consider_usage_statistics=False)
+
+ self.assertEqual(
+ RemoteRealmAuditLog.objects.count(),
+ audit_log_count + 10,
+ )
+ latest_ledger = LicenseLedger.objects.last()
+ assert latest_ledger is not None
+ self.assertEqual(latest_ledger.licenses, 28)
+
+ with time_machine.travel(self.now + timedelta(days=1), tick=False):
+ response = self.client_get(
+ f"{self.billing_session.billing_base_url}/billing/", subdomain="selfhosting"
+ )
+
+ self.assertEqual(latest_ledger.licenses, 28)
+ for substring in [
+ "Zulip Basic",
+ "Number of licenses",
+ f"{latest_ledger.licenses} (managed automatically)",
+ "February 1, 2012",
+ "Your plan will automatically renew on",
+ f"${3.5 * latest_ledger.licenses - flat_discount // 100 * 1:,.2f}",
+ "Visa ending in 4242",
+ "Update card",
+ ]:
+ self.assert_in_response(substring, response)
+
+ # Check minimum licenses is 0 after flat discounted months is over.
+ customer.flat_discounted_months = 0
+ customer.save(update_fields=["flat_discounted_months"])
+ self.assertEqual(
+ self.billing_session.min_licenses_for_plan(CustomerPlan.TIER_SELF_HOSTED_BASIC), 1
+ )
+
+ # TODO: Add test for invoice generation once that's implemented.
+
@responses.activate
@mock_stripe()
def test_upgrade_user_to_monthly_basic_plan(self, *mocks: Mock) -> None: