Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
test_stripe: Add legacy remote server schedule upgrade E2E test.
Prakhar Pratyushf278e21c7aa5
diff --git a/corporate/tests/stripe_fixtures/upgrade_legacy_plan--Customer.create.1.json b/corporate/tests/stripe_fixtures/upgrade_legacy_plan--Customer.create.1.jsonnew file mode 100644index 00000000000..3d6b9bc66c1--- /dev/null+++ b/corporate/tests/stripe_fixtures/upgrade_legacy_plan--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_legacy_plan--Customer.modify.1.json b/corporate/tests/stripe_fixtures/upgrade_legacy_plan--Customer.modify.1.jsonnew file mode 100644index 00000000000..8eb8ed75216--- /dev/null+++ b/corporate/tests/stripe_fixtures/upgrade_legacy_plan--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_1OOxuEDEQaroqDjsiM1weVRN",+ "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_legacy_plan--Customer.retrieve.1.json b/corporate/tests/stripe_fixtures/upgrade_legacy_plan--Customer.retrieve.1.jsonnew file mode 100644index 00000000000..627cebb8792--- /dev/null+++ b/corporate/tests/stripe_fixtures/upgrade_legacy_plan--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": 12,+ "exp_year": 2024,+ "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_1OOxuEDEQaroqDjsiM1weVRN",+ "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_legacy_plan--Customer.retrieve.2.json b/corporate/tests/stripe_fixtures/upgrade_legacy_plan--Customer.retrieve.2.jsonnew file mode 100644index 00000000000..627cebb8792--- /dev/null+++ b/corporate/tests/stripe_fixtures/upgrade_legacy_plan--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": 12,+ "exp_year": 2024,+ "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_1OOxuEDEQaroqDjsiM1weVRN",+ "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_legacy_plan--Customer.retrieve.3.json b/corporate/tests/stripe_fixtures/upgrade_legacy_plan--Customer.retrieve.3.jsonnew file mode 100644index 00000000000..627cebb8792--- /dev/null+++ b/corporate/tests/stripe_fixtures/upgrade_legacy_plan--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": 12,+ "exp_year": 2024,+ "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_1OOxuEDEQaroqDjsiM1weVRN",+ "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_legacy_plan--Customer.retrieve.4.json b/corporate/tests/stripe_fixtures/upgrade_legacy_plan--Customer.retrieve.4.jsonnew file mode 100644index 00000000000..627cebb8792--- /dev/null+++ b/corporate/tests/stripe_fixtures/upgrade_legacy_plan--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": 12,+ "exp_year": 2024,+ "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_1OOxuEDEQaroqDjsiM1weVRN",+ "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_legacy_plan--Customer.retrieve.5.json b/corporate/tests/stripe_fixtures/upgrade_legacy_plan--Customer.retrieve.5.jsonnew file mode 100644index 00000000000..627cebb8792--- /dev/null+++ b/corporate/tests/stripe_fixtures/upgrade_legacy_plan--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": 12,+ "exp_year": 2024,+ "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_1OOxuEDEQaroqDjsiM1weVRN",+ "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_legacy_plan--Customer.retrieve.6.json b/corporate/tests/stripe_fixtures/upgrade_legacy_plan--Customer.retrieve.6.jsonnew file mode 100644index 00000000000..627cebb8792--- /dev/null+++ b/corporate/tests/stripe_fixtures/upgrade_legacy_plan--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": 12,+ "exp_year": 2024,+ "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_1OOxuEDEQaroqDjsiM1weVRN",+ "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_legacy_plan--Invoice.list.1.json b/corporate/tests/stripe_fixtures/upgrade_legacy_plan--Invoice.list.1.jsonnew file mode 100644index 00000000000..e39960ab725--- /dev/null+++ b/corporate/tests/stripe_fixtures/upgrade_legacy_plan--Invoice.list.1.json@@ -0,0 +1,6 @@+{+ "data": [],+ "has_more": false,+ "object": "list",+ "url": "/v1/invoices"+}diff --git a/corporate/tests/stripe_fixtures/upgrade_legacy_plan--SetupIntent.create.1.json b/corporate/tests/stripe_fixtures/upgrade_legacy_plan--SetupIntent.create.1.jsonnew file mode 100644index 00000000000..c00c853dd81--- /dev/null+++ b/corporate/tests/stripe_fixtures/upgrade_legacy_plan--SetupIntent.create.1.json@@ -0,0 +1,34 @@+{+ "application": null,+ "automatic_payment_methods": null,+ "cancellation_reason": null,+ "client_secret": "seti_1OOxuEDEQaroqDjsaNjxVE5k_secret_PDOhQTS9UrXmI0rDzcSybLFWhAkSdEs",+ "created": 1000000000,+ "customer": "cus_NORMALIZED0001",+ "description": null,+ "flow_directions": null,+ "id": "seti_1OOxuEDEQaroqDjsaNjxVE5k",+ "last_setup_error": null,+ "latest_attempt": "setatt_1OOxuEDEQaroqDjsRh4dnzh2",+ "livemode": false,+ "mandate": null,+ "metadata": {},+ "next_action": null,+ "object": "setup_intent",+ "on_behalf_of": null,+ "payment_method": "pm_1OOxuEDEQaroqDjsiM1weVRN",+ "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_legacy_plan--SetupIntent.list.1.json b/corporate/tests/stripe_fixtures/upgrade_legacy_plan--SetupIntent.list.1.jsonnew file mode 100644index 00000000000..07261c6f3a0--- /dev/null+++ b/corporate/tests/stripe_fixtures/upgrade_legacy_plan--SetupIntent.list.1.json@@ -0,0 +1,41 @@+{+ "data": [+ {+ "application": null,+ "automatic_payment_methods": null,+ "cancellation_reason": null,+ "client_secret": "seti_1OOxuDDEQaroqDjs0GCV0FMz_secret_PDOhYgMKe0e07H7AXifPFX8xAMCNSgT",+ "created": 1000000000,+ "customer": "cus_NORMALIZED0001",+ "description": null,+ "flow_directions": null,+ "id": "seti_1OOxuDDEQaroqDjs0GCV0FMz",+ "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_legacy_plan--SetupIntent.retrieve.1.json b/corporate/tests/stripe_fixtures/upgrade_legacy_plan--SetupIntent.retrieve.1.jsonnew file mode 100644index 00000000000..c00c853dd81--- /dev/null+++ b/corporate/tests/stripe_fixtures/upgrade_legacy_plan--SetupIntent.retrieve.1.json@@ -0,0 +1,34 @@+{+ "application": null,+ "automatic_payment_methods": null,+ "cancellation_reason": null,+ "client_secret": "seti_1OOxuEDEQaroqDjsaNjxVE5k_secret_PDOhQTS9UrXmI0rDzcSybLFWhAkSdEs",+ "created": 1000000000,+ "customer": "cus_NORMALIZED0001",+ "description": null,+ "flow_directions": null,+ "id": "seti_1OOxuEDEQaroqDjsaNjxVE5k",+ "last_setup_error": null,+ "latest_attempt": "setatt_1OOxuEDEQaroqDjsRh4dnzh2",+ "livemode": false,+ "mandate": null,+ "metadata": {},+ "next_action": null,+ "object": "setup_intent",+ "on_behalf_of": null,+ "payment_method": "pm_1OOxuEDEQaroqDjsiM1weVRN",+ "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_legacy_plan--checkout.Session.create.1.json b/corporate/tests/stripe_fixtures/upgrade_legacy_plan--checkout.Session.create.1.jsonnew file mode 100644index 00000000000..f151a7d554b--- /dev/null+++ b/corporate/tests/stripe_fixtures/upgrade_legacy_plan--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_NORMALIZED01ipLasegPD8WTJGg8RcngQyOSZ17ANCEalfCK5L2lkZXaA8",+ "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_1OOxuDDEQaroqDjs0GCV0FMz",+ "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_NORMALIZED01ipLasegPD8WTJGg8RcngQyOSZ17ANCEalfCK5L2lkZXaA8#fid1d2BpamRhQ2prcSc%2FJ1ZqcHdmYCVWZGt2JVV3aicpJ2R1bE5gfCc%2FJ3VuWnFgdnFaXVRmMU5zNkldQTY9SnNRY09XZml2UXNQJyknY3dqaFZgd3Ngdyc%2FcXdwYCknaWR8anBxUXx1YCc%2FJ3Zsa2JpYFpmamlwaGsnKSdga2RnaWBVaWRmYG1qaWFgd3YnP3F3cGB4JSUl"+}diff --git a/corporate/tests/stripe_fixtures/upgrade_legacy_plan--checkout.Session.list.1.json b/corporate/tests/stripe_fixtures/upgrade_legacy_plan--checkout.Session.list.1.jsonnew file mode 100644index 00000000000..8bc8cb038e6--- /dev/null+++ b/corporate/tests/stripe_fixtures/upgrade_legacy_plan--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_NORMALIZED01ipLasegPD8WTJGg8RcngQyOSZ17ANCEalfCK5L2lkZXaA8",+ "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_1OOxuDDEQaroqDjs0GCV0FMz",+ "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_NORMALIZED01ipLasegPD8WTJGg8RcngQyOSZ17ANCEalfCK5L2lkZXaA8#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.pyindex bd575c76f4e..c2cd404dae4 100644--- a/corporate/tests/test_stripe.py+++ b/corporate/tests/test_stripe.py@@ -603,6 +603,12 @@ class StripeTestCase(ZulipTestCase):license_management="automatic",)+ remote_server_plan_start_date = kwargs.get("remote_server_plan_start_date", None)+ if remote_server_plan_start_date:+ params.update(+ remote_server_plan_start_date=remote_server_plan_start_date,+ )+params.update(kwargs)for key in del_args:if key in params:@@ -618,7 +624,8 @@ class StripeTestCase(ZulipTestCase):return upgrade_json_responseif invoice or not talk_to_stripe or is_free_trial_offer_enabled(False):- # Upgrade already happened for free trial or invoice realms.+ # Upgrade already happened for free trial, invoice realms or schedule+ # upgrade for legacy remote servers.return upgrade_json_responselast_stripe_payment_intent = PaymentIntent.objects.last()@@ -6091,3 +6098,94 @@ class TestRemoteServerBillingFlow(StripeTestCase, RemoteServerTestCase):# Check sponsorship approved banner.result = self.client_get(f"{billing_base_url}/sponsorship/", subdomain="selfhosting")self.assert_in_success_response(["Zulip is sponsoring a free", "Community"], result)++ @responses.activate+ @mock_stripe()+ def test_upgrade_legacy_plan(self, *mocks: Mock) -> None:+ # Upload data+ with time_machine.travel(self.now, tick=False):+ self.add_mock_response()+ send_server_data_to_push_bouncer(consider_usage_statistics=False)++ # Migrate server to legacy plan.+ with time_machine.travel(self.now, tick=False):+ start_date = timezone_now()+ end_date = add_months(start_date, months=3)+ self.billing_session.migrate_customer_to_legacy_plan(start_date, end_date)++ customer = self.billing_session.get_customer()+ assert customer is not None+ customer_plan = get_current_plan_by_customer(customer)+ assert customer_plan is not None+ self.assertEqual(customer_plan.tier, CustomerPlan.TIER_SELF_HOSTED_LEGACY)+ self.assertEqual(customer_plan.status, CustomerPlan.ACTIVE)++ self.login("hamlet")+ hamlet = self.example_user("hamlet")+ billing_base_url = self.billing_session.billing_base_url++ # Login+ with time_machine.travel(self.now, tick=False):+ result = self.execute_remote_billing_authentication_flow(+ hamlet.delivery_email, hamlet.full_name, expect_tos=True, confirm_tos=True+ )+ self.assertEqual(result.status_code, 302)+ self.assertEqual(result["Location"], f"{billing_base_url}/plans/")++ # Visit '/upgrade'+ with time_machine.travel(self.now, tick=False):+ result = self.client_get(f"{billing_base_url}/upgrade/", subdomain="selfhosting")+ self.assertEqual(result.status_code, 200)+ self.assert_in_success_response(["Add card", "Schedule upgrade to Zulip Business"], result)++ # Add card and schedule upgrade+ with time_machine.travel(self.now, tick=False):+ self.add_card_and_upgrade(+ remote_server_plan_start_date="billing_cycle_end_date", talk_to_stripe=False+ )+ customer_plan.refresh_from_db()+ self.assertEqual(customer_plan.status, CustomerPlan.SWITCH_PLAN_TIER_AT_PLAN_END)+ self.assertEqual(customer_plan.end_date, end_date)+ new_customer_plan = self.billing_session.get_next_plan(customer_plan)+ assert new_customer_plan is not None+ self.assertEqual(new_customer_plan.tier, CustomerPlan.TIER_SELF_HOSTED_BUSINESS)+ self.assertEqual(new_customer_plan.billing_cycle_anchor, end_date)++ server_user_count = UserProfile.objects.filter(is_bot=False, is_active=True).count()++ # Visit billing page+ with time_machine.travel(self.now, tick=False):+ response = self.client_get(f"{billing_base_url}/billing/", subdomain="selfhosting")+ for substring in [+ "(legacy plan)",+ f"This is a legacy plan that ends on {end_date.strftime('%B %d, %Y')}",+ f"Your plan will automatically upgrade to Zulip Business on {end_date.strftime('%B %d, %Y')}",+ f"Expected charge: <strong>${80 * server_user_count:,.2f}</strong>",+ "Visa ending in 4242",+ "Update card",+ ]:+ self.assert_in_response(substring, response)++ # Login again+ result = self.execute_remote_billing_authentication_flow(+ hamlet.delivery_email, hamlet.full_name, expect_tos=False, confirm_tos=False+ )+ self.assertEqual(result.status_code, 302)+ self.assertEqual(result["Location"], f"{billing_base_url}/billing/")++ # Downgrade+ with self.assertLogs("corporate.stripe", "INFO") as m:+ with time_machine.travel(self.now + timedelta(days=7), tick=False):+ response = self.client_billing_patch(+ "/billing/plan",+ {"status": CustomerPlan.ACTIVE},+ )+ self.assert_json_success(response)+ self.assertEqual(+ m.output[0],+ f"INFO:corporate.stripe:Change plan status: Customer.id: {customer.id}, CustomerPlan.id: {new_customer_plan.id}, status: {CustomerPlan.ENDED}",+ )+ self.assertEqual(+ m.output[1],+ f"INFO:corporate.stripe:Change plan status: Customer.id: {customer.id}, CustomerPlan.id: {customer_plan.id}, status: {CustomerPlan.ACTIVE}",+ )