Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
billing: Allow user to switch between billing frequencies.
Aman Agrawal69d8442ab41e
diff --git a/corporate/lib/stripe.py b/corporate/lib/stripe.pyindex feef2bdeaaf..16dbba1f756 100644--- a/corporate/lib/stripe.py+++ b/corporate/lib/stripe.py@@ -461,6 +461,7 @@ class AuditLogEventType(Enum):SPONSORSHIP_PENDING_STATUS_CHANGED = 6BILLING_METHOD_CHANGED = 7CUSTOMER_SWITCHED_FROM_MONTHLY_TO_ANNUAL_PLAN = 8+ CUSTOMER_SWITCHED_FROM_ANNUAL_TO_MONTHLY_PLAN = 9class BillingSessionAuditLogEventError(Exception):@@ -1015,6 +1016,54 @@ class BillingSession(ABC):)return new_plan, new_plan_ledger_entry+ if plan.status == CustomerPlan.SWITCH_TO_MONTHLY_AT_END_OF_CYCLE:+ if plan.fixed_price is not None: # nocoverage+ raise BillingError("Customer is already on monthly fixed plan.")++ plan.status = CustomerPlan.ENDED+ plan.save(update_fields=["status"])++ discount = plan.customer.default_discount or plan.discount+ _, _, _, price_per_license = compute_plan_parameters(+ tier=plan.tier,+ automanage_licenses=plan.automanage_licenses,+ billing_schedule=CustomerPlan.MONTHLY,+ discount=plan.discount,+ )++ new_plan = CustomerPlan.objects.create(+ customer=plan.customer,+ billing_schedule=CustomerPlan.MONTHLY,+ automanage_licenses=plan.automanage_licenses,+ charge_automatically=plan.charge_automatically,+ price_per_license=price_per_license,+ discount=discount,+ billing_cycle_anchor=next_billing_cycle,+ tier=plan.tier,+ status=CustomerPlan.ACTIVE,+ next_invoice_date=next_billing_cycle,+ invoiced_through=None,+ invoicing_status=CustomerPlan.INITIAL_INVOICE_TO_BE_SENT,+ )++ new_plan_ledger_entry = LicenseLedger.objects.create(+ plan=new_plan,+ is_renewal=True,+ event_time=next_billing_cycle,+ licenses=licenses_at_next_renewal,+ licenses_at_next_renewal=licenses_at_next_renewal,+ )++ self.write_to_audit_log(+ event_type=AuditLogEventType.CUSTOMER_SWITCHED_FROM_ANNUAL_TO_MONTHLY_PLAN,+ event_time=event_time,+ extra_data={+ "annual_plan_id": plan.id,+ "monthly_plan_id": new_plan.id,+ },+ )+ return new_plan, new_plan_ledger_entry+if plan.status == CustomerPlan.SWITCH_NOW_FROM_STANDARD_TO_PLUS:standard_plan = planstandard_plan.end_date = next_billing_cycle@@ -1079,8 +1128,12 @@ class BillingSession(ABC):switch_to_annual_at_end_of_cycle = (plan.status == CustomerPlan.SWITCH_TO_ANNUAL_AT_END_OF_CYCLE)+ switch_to_monthly_at_end_of_cycle = (+ plan.status == CustomerPlan.SWITCH_TO_MONTHLY_AT_END_OF_CYCLE+ )licenses = last_ledger_entry.licenseslicenses_at_next_renewal = last_ledger_entry.licenses_at_next_renewal+ assert licenses_at_next_renewal is not Noneseat_count = self.current_count_for_billed_licenses()# Should do this in JavaScript, using the user's time zone@@ -1092,7 +1145,30 @@ class BillingSession(ABC):dt=start_of_next_billing_cycle(plan, now))- renewal_cents = renewal_amount(plan, now, last_ledger_entry)+ billing_frequency = CustomerPlan.BILLING_SCHEDULES[plan.billing_schedule]++ if switch_to_annual_at_end_of_cycle:+ annual_price_per_license = get_price_per_license(+ plan.tier, CustomerPlan.ANNUAL, customer.default_discount+ )+ renewal_cents = annual_price_per_license * licenses_at_next_renewal+ price_per_license = format_money(annual_price_per_license / 12)+ elif switch_to_monthly_at_end_of_cycle:+ monthly_price_per_license = get_price_per_license(+ plan.tier, CustomerPlan.MONTHLY, customer.default_discount+ )+ renewal_cents = monthly_price_per_license * licenses_at_next_renewal+ price_per_license = format_money(monthly_price_per_license)+ else:+ renewal_cents = renewal_amount(plan, now, last_ledger_entry)++ if plan.price_per_license is None:+ price_per_license = ""+ elif billing_frequency == "Annual":+ price_per_license = format_money(plan.price_per_license / 12)+ else:+ price_per_license = format_money(plan.price_per_license)+charge_automatically = plan.charge_automaticallyassert customer.stripe_customer_id is not None # for mypystripe_customer = stripe_get_customer(customer.stripe_customer_id)@@ -1107,15 +1183,6 @@ class BillingSession(ABC):else None)- billing_frequency = CustomerPlan.BILLING_SCHEDULES[plan.billing_schedule]-- if plan.price_per_license is None:- price_per_license = ""- elif billing_frequency == "Annual":- price_per_license = format_money(plan.price_per_license / 12)- else:- price_per_license = format_money(plan.price_per_license)-context = {"plan_name": plan.name,"has_active_plan": True,@@ -1123,6 +1190,7 @@ class BillingSession(ABC):"downgrade_at_end_of_cycle": downgrade_at_end_of_cycle,"automanage_licenses": plan.automanage_licenses,"switch_to_annual_at_end_of_cycle": switch_to_annual_at_end_of_cycle,+ "switch_to_monthly_at_end_of_cycle": switch_to_monthly_at_end_of_cycle,"licenses": licenses,"licenses_at_next_renewal": licenses_at_next_renewal,"seat_count": seat_count,@@ -1245,6 +1313,8 @@ class RealmBillingSession(BillingSession):return RealmAuditLog.REALM_BILLING_METHOD_CHANGEDelif event_type is AuditLogEventType.CUSTOMER_SWITCHED_FROM_MONTHLY_TO_ANNUAL_PLAN:return RealmAuditLog.CUSTOMER_SWITCHED_FROM_MONTHLY_TO_ANNUAL_PLAN+ elif event_type is AuditLogEventType.CUSTOMER_SWITCHED_FROM_ANNUAL_TO_MONTHLY_PLAN:+ return RealmAuditLog.CUSTOMER_SWITCHED_FROM_ANNUAL_TO_MONTHLY_PLANelse:raise BillingSessionAuditLogEventError(event_type)diff --git a/corporate/models.py b/corporate/models.pyindex 50749aec9c5..7d6c0cf53bc 100644--- a/corporate/models.py+++ b/corporate/models.py@@ -260,6 +260,7 @@ class CustomerPlan(models.Model):FREE_TRIAL = 3SWITCH_TO_ANNUAL_AT_END_OF_CYCLE = 4SWITCH_NOW_FROM_STANDARD_TO_PLUS = 5+ SWITCH_TO_MONTHLY_AT_END_OF_CYCLE = 6# "Live" plans should have a value < LIVE_STATUS_THRESHOLD.# There should be at most one live plan per customer.LIVE_STATUS_THRESHOLD = 10diff --git a/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Customer.create.1.json b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Customer.create.1.jsonnew file mode 100644index 00000000000..593a07ed0c8--- /dev/null+++ b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Customer.create.1.json@@ -0,0 +1,33 @@+{+ "address": null,+ "balance": 0,+ "created": 1000000000,+ "currency": null,+ "default_currency": null,+ "default_source": null,+ "delinquent": false,+ "description": "zulip (Zulip Dev)",+ "discount": null,+ "email": "[email protected]",+ "id": "cus_NORMALIZED0001",+ "invoice_prefix": "NORMA01",+ "invoice_settings": {+ "custom_fields": null,+ "default_payment_method": null,+ "footer": null,+ "rendering_options": null+ },+ "livemode": false,+ "metadata": {+ "realm_id": "1",+ "realm_str": "zulip"+ },+ "name": null,+ "next_invoice_sequence": 1,+ "object": "customer",+ "phone": null,+ "preferred_locales": [],+ "shipping": null,+ "tax_exempt": "none",+ "test_clock": null+}diff --git a/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Customer.modify.1.json b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Customer.modify.1.jsonnew file mode 100644index 00000000000..70e18e4dedc--- /dev/null+++ b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Customer.modify.1.json@@ -0,0 +1,33 @@+{+ "address": null,+ "balance": 0,+ "created": 1000000000,+ "currency": null,+ "default_currency": null,+ "default_source": null,+ "delinquent": false,+ "description": "zulip (Zulip Dev)",+ "discount": null,+ "email": "[email protected]",+ "id": "cus_NORMALIZED0001",+ "invoice_prefix": "NORMA01",+ "invoice_settings": {+ "custom_fields": null,+ "default_payment_method": "pm_1OEq5XDEQaroqDjsE08QDOEc",+ "footer": null,+ "rendering_options": null+ },+ "livemode": false,+ "metadata": {+ "realm_id": "1",+ "realm_str": "zulip"+ },+ "name": null,+ "next_invoice_sequence": 1,+ "object": "customer",+ "phone": null,+ "preferred_locales": [],+ "shipping": null,+ "tax_exempt": "none",+ "test_clock": null+}diff --git a/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Customer.retrieve.1.json b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Customer.retrieve.1.jsonnew file mode 100644index 00000000000..049143480bf--- /dev/null+++ b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--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 (Zulip Dev)",+ "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": 11,+ "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_1OEq5XDEQaroqDjsE08QDOEc",+ "livemode": false,+ "metadata": {},+ "object": "payment_method",+ "type": "card"+ },+ "footer": null,+ "rendering_options": null+ },+ "livemode": false,+ "metadata": {+ "realm_id": "1",+ "realm_str": "zulip"+ },+ "name": null,+ "next_invoice_sequence": 1,+ "object": "customer",+ "phone": null,+ "preferred_locales": [],+ "shipping": null,+ "tax_exempt": "none",+ "test_clock": null+}diff --git a/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Customer.retrieve.2.json b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Customer.retrieve.2.jsonnew file mode 100644index 00000000000..049143480bf--- /dev/null+++ b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--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 (Zulip Dev)",+ "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": 11,+ "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_1OEq5XDEQaroqDjsE08QDOEc",+ "livemode": false,+ "metadata": {},+ "object": "payment_method",+ "type": "card"+ },+ "footer": null,+ "rendering_options": null+ },+ "livemode": false,+ "metadata": {+ "realm_id": "1",+ "realm_str": "zulip"+ },+ "name": null,+ "next_invoice_sequence": 1,+ "object": "customer",+ "phone": null,+ "preferred_locales": [],+ "shipping": null,+ "tax_exempt": "none",+ "test_clock": null+}diff --git a/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Customer.retrieve.3.json b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Customer.retrieve.3.jsonnew file mode 100644index 00000000000..049143480bf--- /dev/null+++ b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--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 (Zulip Dev)",+ "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": 11,+ "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_1OEq5XDEQaroqDjsE08QDOEc",+ "livemode": false,+ "metadata": {},+ "object": "payment_method",+ "type": "card"+ },+ "footer": null,+ "rendering_options": null+ },+ "livemode": false,+ "metadata": {+ "realm_id": "1",+ "realm_str": "zulip"+ },+ "name": null,+ "next_invoice_sequence": 1,+ "object": "customer",+ "phone": null,+ "preferred_locales": [],+ "shipping": null,+ "tax_exempt": "none",+ "test_clock": null+}diff --git a/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Customer.retrieve.4.json b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Customer.retrieve.4.jsonnew file mode 100644index 00000000000..049143480bf--- /dev/null+++ b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--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 (Zulip Dev)",+ "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": 11,+ "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_1OEq5XDEQaroqDjsE08QDOEc",+ "livemode": false,+ "metadata": {},+ "object": "payment_method",+ "type": "card"+ },+ "footer": null,+ "rendering_options": null+ },+ "livemode": false,+ "metadata": {+ "realm_id": "1",+ "realm_str": "zulip"+ },+ "name": null,+ "next_invoice_sequence": 1,+ "object": "customer",+ "phone": null,+ "preferred_locales": [],+ "shipping": null,+ "tax_exempt": "none",+ "test_clock": null+}diff --git a/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Customer.retrieve.5.json b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Customer.retrieve.5.jsonnew file mode 100644index 00000000000..f4095e98b0f--- /dev/null+++ b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Customer.retrieve.5.json@@ -0,0 +1,79 @@+{+ "address": null,+ "balance": 0,+ "created": 1000000000,+ "currency": "usd",+ "default_currency": "usd",+ "default_source": null,+ "delinquent": false,+ "description": "zulip (Zulip Dev)",+ "discount": null,+ "email": "[email protected]",+ "id": "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": 11,+ "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_1OEq5XDEQaroqDjsE08QDOEc",+ "livemode": false,+ "metadata": {},+ "object": "payment_method",+ "type": "card"+ },+ "footer": null,+ "rendering_options": null+ },+ "livemode": false,+ "metadata": {+ "realm_id": "1",+ "realm_str": "zulip"+ },+ "name": null,+ "next_invoice_sequence": 2,+ "object": "customer",+ "phone": null,+ "preferred_locales": [],+ "shipping": null,+ "tax_exempt": "none",+ "test_clock": null+}diff --git a/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Customer.retrieve.6.json b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Customer.retrieve.6.jsonnew file mode 100644index 00000000000..36d640d850b--- /dev/null+++ b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Customer.retrieve.6.json@@ -0,0 +1,79 @@+{+ "address": null,+ "balance": 0,+ "created": 1000000000,+ "currency": "usd",+ "default_currency": "usd",+ "default_source": null,+ "delinquent": false,+ "description": "zulip (Zulip Dev)",+ "discount": null,+ "email": "[email protected]",+ "id": "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": 11,+ "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_1OEq5XDEQaroqDjsE08QDOEc",+ "livemode": false,+ "metadata": {},+ "object": "payment_method",+ "type": "card"+ },+ "footer": null,+ "rendering_options": null+ },+ "livemode": false,+ "metadata": {+ "realm_id": "1",+ "realm_str": "zulip"+ },+ "name": null,+ "next_invoice_sequence": 4,+ "object": "customer",+ "phone": null,+ "preferred_locales": [],+ "shipping": null,+ "tax_exempt": "none",+ "test_clock": null+}diff --git a/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Event.list.1.json b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Event.list.1.jsonnew file mode 100644index 00000000000..76b84b37c1e--- /dev/null+++ b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Event.list.1.json@@ -0,0 +1,60 @@+{+ "data": [+ {+ "api_version": "2020-08-27",+ "created": 1000000000,+ "data": {+ "object": {+ "address": null,+ "balance": 0,+ "created": 1000000000,+ "currency": null,+ "default_currency": null,+ "default_source": null,+ "delinquent": false,+ "description": "zulip (Zulip Dev)",+ "discount": null,+ "email": "[email protected]",+ "id": "cus_NORMALIZED0001",+ "invoice_prefix": "NORMA01",+ "invoice_settings": {+ "custom_fields": null,+ "default_payment_method": "pm_1OEq5XDEQaroqDjsE08QDOEc",+ "footer": null,+ "rendering_options": null+ },+ "livemode": false,+ "metadata": {+ "realm_id": "1",+ "realm_str": "zulip"+ },+ "name": null,+ "next_invoice_sequence": 1,+ "object": "customer",+ "phone": null,+ "preferred_locales": [],+ "shipping": null,+ "tax_exempt": "none",+ "test_clock": null+ },+ "previous_attributes": {+ "invoice_settings": {+ "default_payment_method": null+ }+ }+ },+ "id": "evt_1OEq5ZDEQaroqDjsEJKsLs0r",+ "livemode": false,+ "object": "event",+ "pending_webhooks": 0,+ "request": {+ "id": "req_NORMALIZED0001",+ "idempotency_key": "f075917c-6107-4011-a7f1-3900567a0cf3"+ },+ "type": "customer.updated"+ }+ ],+ "has_more": true,+ "object": "list",+ "url": "/v1/events"+}diff --git a/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Event.list.2.json b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Event.list.2.jsonnew file mode 100644index 00000000000..69fb066ade7--- /dev/null+++ b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Event.list.2.json@@ -0,0 +1,358 @@+{+ "data": [+ {+ "api_version": "2020-08-27",+ "created": 1000000000,+ "data": {+ "object": {+ "amount": 48000,+ "amount_capturable": 0,+ "amount_details": {+ "tip": {}+ },+ "amount_received": 48000,+ "application": null,+ "application_fee_amount": null,+ "automatic_payment_methods": null,+ "canceled_at": null,+ "cancellation_reason": null,+ "capture_method": "automatic",+ "charges": {+ "data": [+ {+ "amount": 48000,+ "amount_captured": 48000,+ "amount_refunded": 0,+ "application": null,+ "application_fee": null,+ "application_fee_amount": null,+ "balance_transaction": "txn_NORMALIZED00000000000001",+ "billing_details": {+ "address": {+ "city": null,+ "country": null,+ "line1": null,+ "line2": null,+ "postal_code": null,+ "state": null+ },+ "email": null,+ "name": null,+ "phone": null+ },+ "calculated_statement_descriptor": "ZULIP CLOUD STANDARD",+ "captured": true,+ "created": 1000000000,+ "currency": "usd",+ "customer": "cus_NORMALIZED0001",+ "description": "Upgrade to Zulip Cloud Standard, $80.0 x 6",+ "destination": null,+ "dispute": null,+ "disputed": false,+ "failure_balance_transaction": null,+ "failure_code": null,+ "failure_message": null,+ "fraud_details": {},+ "id": "ch_NORMALIZED00000000000001",+ "invoice": null,+ "livemode": false,+ "metadata": {+ "billing_modality": "charge_automatically",+ "billing_schedule": "1",+ "license_management": "automatic",+ "licenses": "6",+ "price_per_license": "8000",+ "realm_id": "1",+ "realm_str": "zulip",+ "seat_count": "6",+ "type": "upgrade",+ "user_email": "[email protected]",+ "user_id": "10"+ },+ "object": "charge",+ "on_behalf_of": null,+ "order": null,+ "outcome": {+ "network_status": "approved_by_network",+ "reason": null,+ "risk_level": "normal",+ "risk_score": 0,+ "seller_message": "Payment complete.",+ "type": "authorized"+ },+ "paid": true,+ "payment_intent": "pi_NORMALIZED00000000000001",+ "payment_method": "pm_1OEq5XDEQaroqDjsE08QDOEc",+ "payment_method_details": {+ "card": {+ "amount_authorized": 48000,+ "brand": "visa",+ "checks": {+ "address_line1_check": null,+ "address_postal_code_check": null,+ "cvc_check": "pass"+ },+ "country": "US",+ "exp_month": 11,+ "exp_year": 2024,+ "extended_authorization": {+ "status": "disabled"+ },+ "fingerprint": "NORMALIZED000001",+ "funding": "credit",+ "incremental_authorization": {+ "status": "unavailable"+ },+ "installments": null,+ "last4": "4242",+ "mandate": null,+ "multicapture": {+ "status": "unavailable"+ },+ "network": "visa",+ "network_token": {+ "used": false+ },+ "overcapture": {+ "maximum_amount_capturable": 48000,+ "status": "unavailable"+ },+ "three_d_secure": null,+ "wallet": null+ },+ "type": "card"+ },+ "receipt_email": "[email protected]",+ "receipt_number": null,+ "receipt_url": "https://pay.stripe.com/receipts/payment/CAcaFwoVYWNjdF8xN3ZUa3dERVFhcm9xRGpzKMHr8aoGMgaB7ndHIWY6LBbt4fIv9uULX3iAQ3ITUxBjEfR4v5vgsE2Dx8n__dQfhoovzSy-sMB17iU8",+ "refunded": false,+ "refunds": {+ "data": [],+ "has_more": false,+ "object": "list",+ "total_count": 0,+ "url": "/v1/charges/ch_NORMALIZED00000000000001/refunds"+ },+ "review": null,+ "shipping": null,+ "source": null,+ "source_transfer": null,+ "statement_descriptor": "Zulip Cloud Standard",+ "statement_descriptor_suffix": null,+ "status": "succeeded",+ "transfer_data": null,+ "transfer_group": null+ }+ ],+ "has_more": false,+ "object": "list",+ "total_count": 1,+ "url": "/v1/charges?payment_intent=pi_NORMALIZED00000000000001"+ },+ "client_secret": "pi_NORMALIZED00000000000001_secret_eYLA3D7ohAqPQ59UJVTA8WDnu",+ "confirmation_method": "automatic",+ "created": 1000000000,+ "currency": "usd",+ "customer": "cus_NORMALIZED0001",+ "description": "Upgrade to Zulip Cloud Standard, $80.0 x 6",+ "id": "pi_NORMALIZED00000000000001",+ "invoice": null,+ "last_payment_error": null,+ "latest_charge": "ch_NORMALIZED00000000000001",+ "livemode": false,+ "metadata": {+ "billing_modality": "charge_automatically",+ "billing_schedule": "1",+ "license_management": "automatic",+ "licenses": "6",+ "price_per_license": "8000",+ "realm_id": "1",+ "realm_str": "zulip",+ "seat_count": "6",+ "type": "upgrade",+ "user_email": "[email protected]",+ "user_id": "10"+ },+ "next_action": null,+ "object": "payment_intent",+ "on_behalf_of": null,+ "payment_method": "pm_1OEq5XDEQaroqDjsE08QDOEc",+ "payment_method_configuration_details": null,+ "payment_method_options": {+ "card": {+ "installments": null,+ "mandate_options": null,+ "network": null,+ "request_three_d_secure": "automatic"+ }+ },+ "payment_method_types": [+ "card"+ ],+ "processing": null,+ "receipt_email": "[email protected]",+ "review": null,+ "setup_future_usage": null,+ "shipping": null,+ "source": null,+ "statement_descriptor": "Zulip Cloud Standard",+ "statement_descriptor_suffix": null,+ "status": "succeeded",+ "transfer_data": null,+ "transfer_group": null+ }+ },+ "id": "evt_3OEq5bDEQaroqDjs0GVlV7cm",+ "livemode": false,+ "object": "event",+ "pending_webhooks": 2,+ "request": {+ "id": "req_NORMALIZED0002",+ "idempotency_key": "74e177da-210b-4ba4-834e-9a9b6cd47a6d"+ },+ "type": "payment_intent.succeeded"+ },+ {+ "api_version": "2020-08-27",+ "created": 1000000000,+ "data": {+ "object": {+ "amount": 48000,+ "amount_captured": 48000,+ "amount_refunded": 0,+ "application": null,+ "application_fee": null,+ "application_fee_amount": null,+ "balance_transaction": "txn_NORMALIZED00000000000001",+ "billing_details": {+ "address": {+ "city": null,+ "country": null,+ "line1": null,+ "line2": null,+ "postal_code": null,+ "state": null+ },+ "email": null,+ "name": null,+ "phone": null+ },+ "calculated_statement_descriptor": "ZULIP CLOUD STANDARD",+ "captured": true,+ "created": 1000000000,+ "currency": "usd",+ "customer": "cus_NORMALIZED0001",+ "description": "Upgrade to Zulip Cloud Standard, $80.0 x 6",+ "destination": null,+ "dispute": null,+ "disputed": false,+ "failure_balance_transaction": null,+ "failure_code": null,+ "failure_message": null,+ "fraud_details": {},+ "id": "ch_NORMALIZED00000000000001",+ "invoice": null,+ "livemode": false,+ "metadata": {+ "billing_modality": "charge_automatically",+ "billing_schedule": "1",+ "license_management": "automatic",+ "licenses": "6",+ "price_per_license": "8000",+ "realm_id": "1",+ "realm_str": "zulip",+ "seat_count": "6",+ "type": "upgrade",+ "user_email": "[email protected]",+ "user_id": "10"+ },+ "object": "charge",+ "on_behalf_of": null,+ "order": null,+ "outcome": {+ "network_status": "approved_by_network",+ "reason": null,+ "risk_level": "normal",+ "risk_score": 0,+ "seller_message": "Payment complete.",+ "type": "authorized"+ },+ "paid": true,+ "payment_intent": "pi_NORMALIZED00000000000001",+ "payment_method": "pm_1OEq5XDEQaroqDjsE08QDOEc",+ "payment_method_details": {+ "card": {+ "amount_authorized": 48000,+ "brand": "visa",+ "checks": {+ "address_line1_check": null,+ "address_postal_code_check": null,+ "cvc_check": "pass"+ },+ "country": "US",+ "exp_month": 11,+ "exp_year": 2024,+ "extended_authorization": {+ "status": "disabled"+ },+ "fingerprint": "NORMALIZED000001",+ "funding": "credit",+ "incremental_authorization": {+ "status": "unavailable"+ },+ "installments": null,+ "last4": "4242",+ "mandate": null,+ "multicapture": {+ "status": "unavailable"+ },+ "network": "visa",+ "network_token": {+ "used": false+ },+ "overcapture": {+ "maximum_amount_capturable": 48000,+ "status": "unavailable"+ },+ "three_d_secure": null,+ "wallet": null+ },+ "type": "card"+ },+ "receipt_email": "[email protected]",+ "receipt_number": null,+ "receipt_url": "https://pay.stripe.com/receipts/payment/CAcaFwoVYWNjdF8xN3ZUa3dERVFhcm9xRGpzKMDr8aoGMga861mxCk86LBb-QNhgLvRaBt4V1jAfen2hnXFCSVdIEg2sDvElTmeWr4uVfm7In6gyoFei",+ "refunded": false,+ "refunds": {+ "data": [],+ "has_more": false,+ "object": "list",+ "total_count": 0,+ "url": "/v1/charges/ch_NORMALIZED00000000000001/refunds"+ },+ "review": null,+ "shipping": null,+ "source": null,+ "source_transfer": null,+ "statement_descriptor": "Zulip Cloud Standard",+ "statement_descriptor_suffix": null,+ "status": "succeeded",+ "transfer_data": null,+ "transfer_group": null+ }+ },+ "id": "evt_3OEq5bDEQaroqDjs0Apqej5g",+ "livemode": false,+ "object": "event",+ "pending_webhooks": 0,+ "request": {+ "id": "req_NORMALIZED0002",+ "idempotency_key": "74e177da-210b-4ba4-834e-9a9b6cd47a6d"+ },+ "type": "charge.succeeded"+ }+ ],+ "has_more": false,+ "object": "list",+ "url": "/v1/events"+}diff --git a/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Event.list.3.json b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Event.list.3.jsonnew file mode 100644index 00000000000..5ff0e56721f--- /dev/null+++ b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Event.list.3.json@@ -0,0 +1,650 @@+{+ "data": [+ {+ "api_version": "2020-08-27",+ "created": 1000000000,+ "data": {+ "object": {+ "account_country": "US",+ "account_name": "Kandra Labs, Inc.",+ "account_tax_ids": null,+ "amount_due": 0,+ "amount_paid": 0,+ "amount_remaining": 0,+ "amount_shipping": 0,+ "application": null,+ "application_fee_amount": null,+ "attempt_count": 0,+ "attempted": true,+ "auto_advance": false,+ "automatic_tax": {+ "enabled": false,+ "status": null+ },+ "billing_reason": "manual",+ "charge": null,+ "collection_method": "charge_automatically",+ "created": 1000000000,+ "currency": "usd",+ "custom_fields": null,+ "customer": "cus_NORMALIZED0001",+ "customer_address": null,+ "customer_email": "[email protected]",+ "customer_name": null,+ "customer_phone": null,+ "customer_shipping": null,+ "customer_tax_exempt": "none",+ "customer_tax_ids": [],+ "default_payment_method": null,+ "default_source": null,+ "default_tax_rates": [],+ "description": null,+ "discount": null,+ "discounts": [],+ "due_date": null,+ "effective_at": 1000000000,+ "ending_balance": 0,+ "footer": null,+ "from_invoice": null,+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/test_NORMALIZED01a3dERVFhcm9xRGpzLF9QMnZ4UWJoMFB1eExidGNGWUQyNEtmR2h3dGU0MUNwLDkxMDk5MDc102003eiBMKW1?s=ap",+ "id": "in_NORMALIZED00000000000001",+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/test_NORMALIZED01a3dERVFhcm9xRGpzLF9QMnZ4UWJoMFB1eExidGNGWUQyNEtmR2h3dGU0MUNwLDkxMDk5MDc102003eiBMKW1/pdf?s=ap",+ "last_finalization_error": null,+ "latest_revision": null,+ "lines": {+ "data": [+ {+ "amount": 48000,+ "amount_excluding_tax": 48000,+ "currency": "usd",+ "description": "Zulip Cloud Standard",+ "discount_amounts": [],+ "discountable": false,+ "discounts": [],+ "id": "il_NORMALIZED00000000000001",+ "invoice_item": "ii_NORMALIZED00000000000001",+ "livemode": false,+ "metadata": {},+ "object": "line_item",+ "period": {+ "end": 1357095845,+ "start": 1325473445+ },+ "plan": null,+ "price": {+ "active": false,+ "billing_scheme": "per_unit",+ "created": 1000000000,+ "currency": "usd",+ "custom_unit_amount": null,+ "id": "price_NORMALIZED00000000000001",+ "livemode": false,+ "lookup_key": null,+ "metadata": {},+ "nickname": null,+ "object": "price",+ "product": "prod_NORMALIZED0001",+ "recurring": null,+ "tax_behavior": "unspecified",+ "tiers_mode": null,+ "transform_quantity": null,+ "type": "one_time",+ "unit_amount": 8000,+ "unit_amount_decimal": "8000"+ },+ "proration": false,+ "proration_details": {+ "credited_items": null+ },+ "quantity": 6,+ "subscription": null,+ "tax_amounts": [],+ "tax_rates": [],+ "type": "invoiceitem",+ "unit_amount_excluding_tax": "8000"+ },+ {+ "amount": -48000,+ "amount_excluding_tax": -48000,+ "currency": "usd",+ "description": "Payment (Card ending in 4242)",+ "discount_amounts": [],+ "discountable": false,+ "discounts": [],+ "id": "il_NORMALIZED00000000000002",+ "invoice_item": "ii_NORMALIZED00000000000002",+ "livemode": false,+ "metadata": {},+ "object": "line_item",+ "period": {+ "end": 1000000000,+ "start": 1000000000+ },+ "plan": null,+ "price": {+ "active": false,+ "billing_scheme": "per_unit",+ "created": 1000000000,+ "currency": "usd",+ "custom_unit_amount": null,+ "id": "price_NORMALIZED00000000000002",+ "livemode": false,+ "lookup_key": null,+ "metadata": {},+ "nickname": null,+ "object": "price",+ "product": "prod_NORMALIZED0002",+ "recurring": null,+ "tax_behavior": "unspecified",+ "tiers_mode": null,+ "transform_quantity": null,+ "type": "one_time",+ "unit_amount": -48000,+ "unit_amount_decimal": "-48000"+ },+ "proration": false,+ "proration_details": {+ "credited_items": null+ },+ "quantity": 1,+ "subscription": null,+ "tax_amounts": [],+ "tax_rates": [],+ "type": "invoiceitem",+ "unit_amount_excluding_tax": "-48000"+ }+ ],+ "has_more": false,+ "object": "list",+ "total_count": 2,+ "url": "/v1/invoices/in_NORMALIZED00000000000001/lines"+ },+ "livemode": false,+ "metadata": {},+ "next_payment_attempt": null,+ "number": "NORMALI-0001",+ "object": "invoice",+ "on_behalf_of": null,+ "paid": true,+ "paid_out_of_band": false,+ "payment_intent": null,+ "payment_settings": {+ "default_mandate": null,+ "payment_method_options": null,+ "payment_method_types": null+ },+ "period_end": 1000000000,+ "period_start": 1000000000,+ "post_payment_credit_notes_amount": 0,+ "pre_payment_credit_notes_amount": 0,+ "quote": null,+ "receipt_number": null,+ "rendering": {+ "amount_tax_display": null,+ "pdf": {+ "page_size": "letter"+ }+ },+ "rendering_options": null,+ "shipping_cost": null,+ "shipping_details": null,+ "starting_balance": 0,+ "statement_descriptor": "Zulip Cloud Standard",+ "status": "paid",+ "status_transitions": {+ "finalized_at": 1000000000,+ "marked_uncollectible_at": null,+ "paid_at": 1000000000,+ "voided_at": null+ },+ "subscription": null,+ "subscription_details": {+ "metadata": null+ },+ "subtotal": 0,+ "subtotal_excluding_tax": 0,+ "tax": null,+ "test_clock": null,+ "total": 0,+ "total_discount_amounts": [],+ "total_excluding_tax": 0,+ "total_tax_amounts": [],+ "transfer_data": null,+ "webhooks_delivered_at": null+ },+ "previous_attributes": {+ "attempted": false,+ "auto_advance": true,+ "effective_at": null,+ "ending_balance": null,+ "hosted_invoice_url": null,+ "invoice_pdf": null,+ "next_payment_attempt": 1000000000,+ "number": null,+ "paid": false,+ "rendering": {+ "pdf": {+ "page_size": "auto"+ }+ },+ "status": "draft",+ "status_transitions": {+ "finalized_at": null,+ "paid_at": null+ }+ }+ },+ "id": "evt_1OEq5fDEQaroqDjsWArRk6q8",+ "livemode": false,+ "object": "event",+ "pending_webhooks": 2,+ "request": {+ "id": "req_NORMALIZED0003",+ "idempotency_key": "998fe9a6-b299-42f9-81a0-012a1c081160"+ },+ "type": "invoice.updated"+ },+ {+ "api_version": "2020-08-27",+ "created": 1000000000,+ "data": {+ "object": {+ "account_country": "US",+ "account_name": "Kandra Labs, Inc.",+ "account_tax_ids": null,+ "amount_due": 0,+ "amount_paid": 0,+ "amount_remaining": 0,+ "amount_shipping": 0,+ "application": null,+ "application_fee_amount": null,+ "attempt_count": 0,+ "attempted": false,+ "auto_advance": true,+ "automatic_tax": {+ "enabled": false,+ "status": null+ },+ "billing_reason": "manual",+ "charge": null,+ "collection_method": "charge_automatically",+ "created": 1000000000,+ "currency": "usd",+ "custom_fields": null,+ "customer": "cus_NORMALIZED0001",+ "customer_address": null,+ "customer_email": "[email protected]",+ "customer_name": null,+ "customer_phone": null,+ "customer_shipping": null,+ "customer_tax_exempt": "none",+ "customer_tax_ids": [],+ "default_payment_method": null,+ "default_source": null,+ "default_tax_rates": [],+ "description": null,+ "discount": null,+ "discounts": [],+ "due_date": null,+ "effective_at": null,+ "ending_balance": null,+ "footer": null,+ "from_invoice": null,+ "hosted_invoice_url": null,+ "id": "in_NORMALIZED00000000000001",+ "invoice_pdf": null,+ "last_finalization_error": null,+ "latest_revision": null,+ "lines": {+ "data": [+ {+ "amount": 48000,+ "amount_excluding_tax": 48000,+ "currency": "usd",+ "description": "Zulip Cloud Standard",+ "discount_amounts": [],+ "discountable": false,+ "discounts": [],+ "id": "il_NORMALIZED00000000000001",+ "invoice_item": "ii_NORMALIZED00000000000001",+ "livemode": false,+ "metadata": {},+ "object": "line_item",+ "period": {+ "end": 1357095845,+ "start": 1325473445+ },+ "plan": null,+ "price": {+ "active": false,+ "billing_scheme": "per_unit",+ "created": 1000000000,+ "currency": "usd",+ "custom_unit_amount": null,+ "id": "price_NORMALIZED00000000000001",+ "livemode": false,+ "lookup_key": null,+ "metadata": {},+ "nickname": null,+ "object": "price",+ "product": "prod_NORMALIZED0001",+ "recurring": null,+ "tax_behavior": "unspecified",+ "tiers_mode": null,+ "transform_quantity": null,+ "type": "one_time",+ "unit_amount": 8000,+ "unit_amount_decimal": "8000"+ },+ "proration": false,+ "proration_details": {+ "credited_items": null+ },+ "quantity": 6,+ "subscription": null,+ "tax_amounts": [],+ "tax_rates": [],+ "type": "invoiceitem",+ "unit_amount_excluding_tax": "8000"+ },+ {+ "amount": -48000,+ "amount_excluding_tax": -48000,+ "currency": "usd",+ "description": "Payment (Card ending in 4242)",+ "discount_amounts": [],+ "discountable": false,+ "discounts": [],+ "id": "il_NORMALIZED00000000000002",+ "invoice_item": "ii_NORMALIZED00000000000002",+ "livemode": false,+ "metadata": {},+ "object": "line_item",+ "period": {+ "end": 1000000000,+ "start": 1000000000+ },+ "plan": null,+ "price": {+ "active": false,+ "billing_scheme": "per_unit",+ "created": 1000000000,+ "currency": "usd",+ "custom_unit_amount": null,+ "id": "price_NORMALIZED00000000000002",+ "livemode": false,+ "lookup_key": null,+ "metadata": {},+ "nickname": null,+ "object": "price",+ "product": "prod_NORMALIZED0002",+ "recurring": null,+ "tax_behavior": "unspecified",+ "tiers_mode": null,+ "transform_quantity": null,+ "type": "one_time",+ "unit_amount": -48000,+ "unit_amount_decimal": "-48000"+ },+ "proration": false,+ "proration_details": {+ "credited_items": null+ },+ "quantity": 1,+ "subscription": null,+ "tax_amounts": [],+ "tax_rates": [],+ "type": "invoiceitem",+ "unit_amount_excluding_tax": "-48000"+ }+ ],+ "has_more": false,+ "object": "list",+ "total_count": 2,+ "url": "/v1/invoices/in_NORMALIZED00000000000001/lines"+ },+ "livemode": false,+ "metadata": {},+ "next_payment_attempt": 1000000000,+ "number": null,+ "object": "invoice",+ "on_behalf_of": null,+ "paid": false,+ "paid_out_of_band": false,+ "payment_intent": null,+ "payment_settings": {+ "default_mandate": null,+ "payment_method_options": null,+ "payment_method_types": null+ },+ "period_end": 1000000000,+ "period_start": 1000000000,+ "post_payment_credit_notes_amount": 0,+ "pre_payment_credit_notes_amount": 0,+ "quote": null,+ "receipt_number": null,+ "rendering": {+ "amount_tax_display": null,+ "pdf": {+ "page_size": "auto"+ }+ },+ "rendering_options": null,+ "shipping_cost": null,+ "shipping_details": null,+ "starting_balance": 0,+ "statement_descriptor": "Zulip Cloud Standard",+ "status": "draft",+ "status_transitions": {+ "finalized_at": null,+ "marked_uncollectible_at": null,+ "paid_at": null,+ "voided_at": null+ },+ "subscription": null,+ "subscription_details": {+ "metadata": null+ },+ "subtotal": 0,+ "subtotal_excluding_tax": 0,+ "tax": null,+ "test_clock": null,+ "total": 0,+ "total_discount_amounts": [],+ "total_excluding_tax": 0,+ "total_tax_amounts": [],+ "transfer_data": null,+ "webhooks_delivered_at": null+ }+ },+ "id": "evt_1OEq5eDEQaroqDjslKf0xsiV",+ "livemode": false,+ "object": "event",+ "pending_webhooks": 0,+ "request": {+ "id": "req_NORMALIZED0004",+ "idempotency_key": "819ad06a-6d2b-474b-8a0a-0645f9768b9d"+ },+ "type": "invoice.created"+ },+ {+ "api_version": "2020-08-27",+ "created": 1000000000,+ "data": {+ "object": {+ "amount": 48000,+ "currency": "usd",+ "customer": "cus_NORMALIZED0001",+ "date": 1000000000,+ "description": "Zulip Cloud Standard",+ "discountable": false,+ "discounts": [],+ "id": "ii_NORMALIZED00000000000001",+ "invoice": null,+ "livemode": false,+ "metadata": {},+ "object": "invoiceitem",+ "period": {+ "end": 1357095845,+ "start": 1325473445+ },+ "plan": null,+ "price": {+ "active": false,+ "billing_scheme": "per_unit",+ "created": 1000000000,+ "currency": "usd",+ "custom_unit_amount": null,+ "id": "price_NORMALIZED00000000000001",+ "livemode": false,+ "lookup_key": null,+ "metadata": {},+ "nickname": null,+ "object": "price",+ "product": "prod_NORMALIZED0001",+ "recurring": null,+ "tax_behavior": "unspecified",+ "tiers_mode": null,+ "transform_quantity": null,+ "type": "one_time",+ "unit_amount": 8000,+ "unit_amount_decimal": "8000"+ },+ "proration": false,+ "quantity": 6,+ "subscription": null,+ "tax_rates": [],+ "test_clock": null,+ "unit_amount": 8000,+ "unit_amount_decimal": "8000"+ }+ },+ "id": "evt_1OEq5eDEQaroqDjszB9DmLdY",+ "livemode": false,+ "object": "event",+ "pending_webhooks": 0,+ "request": {+ "id": "req_NORMALIZED0005",+ "idempotency_key": "43a03928-5872-41ed-bdd0-c4d99a8d449e"+ },+ "type": "invoiceitem.created"+ },+ {+ "api_version": "2020-08-27",+ "created": 1000000000,+ "data": {+ "object": {+ "amount": -48000,+ "currency": "usd",+ "customer": "cus_NORMALIZED0001",+ "date": 1000000000,+ "description": "Payment (Card ending in 4242)",+ "discountable": false,+ "discounts": [],+ "id": "ii_NORMALIZED00000000000002",+ "invoice": null,+ "livemode": false,+ "metadata": {},+ "object": "invoiceitem",+ "period": {+ "end": 1000000000,+ "start": 1000000000+ },+ "plan": null,+ "price": {+ "active": false,+ "billing_scheme": "per_unit",+ "created": 1000000000,+ "currency": "usd",+ "custom_unit_amount": null,+ "id": "price_NORMALIZED00000000000002",+ "livemode": false,+ "lookup_key": null,+ "metadata": {},+ "nickname": null,+ "object": "price",+ "product": "prod_NORMALIZED0002",+ "recurring": null,+ "tax_behavior": "unspecified",+ "tiers_mode": null,+ "transform_quantity": null,+ "type": "one_time",+ "unit_amount": -48000,+ "unit_amount_decimal": "-48000"+ },+ "proration": false,+ "quantity": 1,+ "subscription": null,+ "tax_rates": [],+ "test_clock": null,+ "unit_amount": -48000,+ "unit_amount_decimal": "-48000"+ }+ },+ "id": "evt_1OEq5dDEQaroqDjsuW06CT0j",+ "livemode": false,+ "object": "event",+ "pending_webhooks": 0,+ "request": {+ "id": "req_NORMALIZED0006",+ "idempotency_key": "06a87593-f2ae-4eb0-aa0e-83fbc9f15b07"+ },+ "type": "invoiceitem.created"+ },+ {+ "api_version": "2020-08-27",+ "created": 1000000000,+ "data": {+ "object": {+ "address": null,+ "balance": 0,+ "created": 1000000000,+ "currency": "usd",+ "default_currency": "usd",+ "default_source": null,+ "delinquent": false,+ "description": "zulip (Zulip Dev)",+ "discount": null,+ "email": "[email protected]",+ "id": "cus_NORMALIZED0001",+ "invoice_prefix": "NORMA01",+ "invoice_settings": {+ "custom_fields": null,+ "default_payment_method": "pm_1OEq5XDEQaroqDjsE08QDOEc",+ "footer": null,+ "rendering_options": null+ },+ "livemode": false,+ "metadata": {+ "realm_id": "1",+ "realm_str": "zulip"+ },+ "name": null,+ "next_invoice_sequence": 1,+ "object": "customer",+ "phone": null,+ "preferred_locales": [],+ "shipping": null,+ "tax_exempt": "none",+ "test_clock": null+ },+ "previous_attributes": {+ "currency": null,+ "default_currency": null+ }+ },+ "id": "evt_1OEq5dDEQaroqDjsIaYH1D59",+ "livemode": false,+ "object": "event",+ "pending_webhooks": 0,+ "request": {+ "id": "req_NORMALIZED0006",+ "idempotency_key": "06a87593-f2ae-4eb0-aa0e-83fbc9f15b07"+ },+ "type": "customer.updated"+ }+ ],+ "has_more": false,+ "object": "list",+ "url": "/v1/events"+}diff --git a/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Event.list.4.json b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Event.list.4.jsonnew file mode 100644index 00000000000..d3131822f96--- /dev/null+++ b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Event.list.4.json@@ -0,0 +1,453 @@+{+ "data": [+ {+ "api_version": "2020-08-27",+ "created": 1000000000,+ "data": {+ "object": {+ "account_country": "US",+ "account_name": "Kandra Labs, Inc.",+ "account_tax_ids": null,+ "amount_due": 0,+ "amount_paid": 0,+ "amount_remaining": 0,+ "amount_shipping": 0,+ "application": null,+ "application_fee_amount": null,+ "attempt_count": 0,+ "attempted": true,+ "auto_advance": false,+ "automatic_tax": {+ "enabled": false,+ "status": null+ },+ "billing_reason": "manual",+ "charge": null,+ "collection_method": "charge_automatically",+ "created": 1000000000,+ "currency": "usd",+ "custom_fields": null,+ "customer": "cus_NORMALIZED0001",+ "customer_address": null,+ "customer_email": "[email protected]",+ "customer_name": null,+ "customer_phone": null,+ "customer_shipping": null,+ "customer_tax_exempt": "none",+ "customer_tax_ids": [],+ "default_payment_method": null,+ "default_source": null,+ "default_tax_rates": [],+ "description": null,+ "discount": null,+ "discounts": [],+ "due_date": null,+ "effective_at": 1000000000,+ "ending_balance": 0,+ "footer": null,+ "from_invoice": null,+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/test_NORMALIZED01a3dERVFhcm9xRGpzLF9QMnZ4UWJoMFB1eExidGNGWUQyNEtmR2h3dGU0MUNwLDkxMDk5MDc20200mD76fW0N?s=ap",+ "id": "in_NORMALIZED00000000000001",+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/test_NORMALIZED01a3dERVFhcm9xRGpzLF9QMnZ4UWJoMFB1eExidGNGWUQyNEtmR2h3dGU0MUNwLDkxMDk5MDc20200mD76fW0N/pdf?s=ap",+ "last_finalization_error": null,+ "latest_revision": null,+ "lines": {+ "data": [+ {+ "amount": 48000,+ "amount_excluding_tax": 48000,+ "currency": "usd",+ "description": "Zulip Cloud Standard",+ "discount_amounts": [],+ "discountable": false,+ "discounts": [],+ "id": "il_NORMALIZED00000000000001",+ "invoice_item": "ii_NORMALIZED00000000000001",+ "livemode": false,+ "metadata": {},+ "object": "line_item",+ "period": {+ "end": 1357095845,+ "start": 1325473445+ },+ "plan": null,+ "price": {+ "active": false,+ "billing_scheme": "per_unit",+ "created": 1000000000,+ "currency": "usd",+ "custom_unit_amount": null,+ "id": "price_NORMALIZED00000000000001",+ "livemode": false,+ "lookup_key": null,+ "metadata": {},+ "nickname": null,+ "object": "price",+ "product": "prod_NORMALIZED0001",+ "recurring": null,+ "tax_behavior": "unspecified",+ "tiers_mode": null,+ "transform_quantity": null,+ "type": "one_time",+ "unit_amount": 8000,+ "unit_amount_decimal": "8000"+ },+ "proration": false,+ "proration_details": {+ "credited_items": null+ },+ "quantity": 6,+ "subscription": null,+ "tax_amounts": [],+ "tax_rates": [],+ "type": "invoiceitem",+ "unit_amount_excluding_tax": "8000"+ },+ {+ "amount": -48000,+ "amount_excluding_tax": -48000,+ "currency": "usd",+ "description": "Payment (Card ending in 4242)",+ "discount_amounts": [],+ "discountable": false,+ "discounts": [],+ "id": "il_NORMALIZED00000000000002",+ "invoice_item": "ii_NORMALIZED00000000000002",+ "livemode": false,+ "metadata": {},+ "object": "line_item",+ "period": {+ "end": 1000000000,+ "start": 1000000000+ },+ "plan": null,+ "price": {+ "active": false,+ "billing_scheme": "per_unit",+ "created": 1000000000,+ "currency": "usd",+ "custom_unit_amount": null,+ "id": "price_NORMALIZED00000000000002",+ "livemode": false,+ "lookup_key": null,+ "metadata": {},+ "nickname": null,+ "object": "price",+ "product": "prod_NORMALIZED0002",+ "recurring": null,+ "tax_behavior": "unspecified",+ "tiers_mode": null,+ "transform_quantity": null,+ "type": "one_time",+ "unit_amount": -48000,+ "unit_amount_decimal": "-48000"+ },+ "proration": false,+ "proration_details": {+ "credited_items": null+ },+ "quantity": 1,+ "subscription": null,+ "tax_amounts": [],+ "tax_rates": [],+ "type": "invoiceitem",+ "unit_amount_excluding_tax": "-48000"+ }+ ],+ "has_more": false,+ "object": "list",+ "total_count": 2,+ "url": "/v1/invoices/in_NORMALIZED00000000000001/lines"+ },+ "livemode": false,+ "metadata": {},+ "next_payment_attempt": null,+ "number": "NORMALI-0002",+ "object": "invoice",+ "on_behalf_of": null,+ "paid": true,+ "paid_out_of_band": false,+ "payment_intent": null,+ "payment_settings": {+ "default_mandate": null,+ "payment_method_options": null,+ "payment_method_types": null+ },+ "period_end": 1000000000,+ "period_start": 1000000000,+ "post_payment_credit_notes_amount": 0,+ "pre_payment_credit_notes_amount": 0,+ "quote": null,+ "receipt_number": null,+ "rendering": {+ "amount_tax_display": null,+ "pdf": {+ "page_size": "letter"+ }+ },+ "rendering_options": null,+ "shipping_cost": null,+ "shipping_details": null,+ "starting_balance": 0,+ "statement_descriptor": "Zulip Cloud Standard",+ "status": "paid",+ "status_transitions": {+ "finalized_at": 1000000000,+ "marked_uncollectible_at": null,+ "paid_at": 1000000000,+ "voided_at": null+ },+ "subscription": null,+ "subscription_details": {+ "metadata": null+ },+ "subtotal": 0,+ "subtotal_excluding_tax": 0,+ "tax": null,+ "test_clock": null,+ "total": 0,+ "total_discount_amounts": [],+ "total_excluding_tax": 0,+ "total_tax_amounts": [],+ "transfer_data": null,+ "webhooks_delivered_at": null+ }+ },+ "id": "evt_1OEq5gDEQaroqDjsT5YnYD1e",+ "livemode": false,+ "object": "event",+ "pending_webhooks": 2,+ "request": {+ "id": "req_NORMALIZED0003",+ "idempotency_key": "998fe9a6-b299-42f9-81a0-012a1c081160"+ },+ "type": "invoice.paid"+ },+ {+ "api_version": "2020-08-27",+ "created": 1000000000,+ "data": {+ "object": {+ "account_country": "US",+ "account_name": "Kandra Labs, Inc.",+ "account_tax_ids": null,+ "amount_due": 0,+ "amount_paid": 0,+ "amount_remaining": 0,+ "amount_shipping": 0,+ "application": null,+ "application_fee_amount": null,+ "attempt_count": 0,+ "attempted": true,+ "auto_advance": false,+ "automatic_tax": {+ "enabled": false,+ "status": null+ },+ "billing_reason": "manual",+ "charge": null,+ "collection_method": "charge_automatically",+ "created": 1000000000,+ "currency": "usd",+ "custom_fields": null,+ "customer": "cus_NORMALIZED0001",+ "customer_address": null,+ "customer_email": "[email protected]",+ "customer_name": null,+ "customer_phone": null,+ "customer_shipping": null,+ "customer_tax_exempt": "none",+ "customer_tax_ids": [],+ "default_payment_method": null,+ "default_source": null,+ "default_tax_rates": [],+ "description": null,+ "discount": null,+ "discounts": [],+ "due_date": null,+ "effective_at": 1000000000,+ "ending_balance": 0,+ "footer": null,+ "from_invoice": null,+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/test_NORMALIZED01a3dERVFhcm9xRGpzLF9QMnZ4UWJoMFB1eExidGNGWUQyNEtmR2h3dGU0MUNwLDkxMDk5MDc102003eiBMKW1?s=ap",+ "id": "in_NORMALIZED00000000000001",+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/test_NORMALIZED01a3dERVFhcm9xRGpzLF9QMnZ4UWJoMFB1eExidGNGWUQyNEtmR2h3dGU0MUNwLDkxMDk5MDc102003eiBMKW1/pdf?s=ap",+ "last_finalization_error": null,+ "latest_revision": null,+ "lines": {+ "data": [+ {+ "amount": 48000,+ "amount_excluding_tax": 48000,+ "currency": "usd",+ "description": "Zulip Cloud Standard",+ "discount_amounts": [],+ "discountable": false,+ "discounts": [],+ "id": "il_NORMALIZED00000000000001",+ "invoice_item": "ii_NORMALIZED00000000000001",+ "livemode": false,+ "metadata": {},+ "object": "line_item",+ "period": {+ "end": 1357095845,+ "start": 1325473445+ },+ "plan": null,+ "price": {+ "active": false,+ "billing_scheme": "per_unit",+ "created": 1000000000,+ "currency": "usd",+ "custom_unit_amount": null,+ "id": "price_NORMALIZED00000000000001",+ "livemode": false,+ "lookup_key": null,+ "metadata": {},+ "nickname": null,+ "object": "price",+ "product": "prod_NORMALIZED0001",+ "recurring": null,+ "tax_behavior": "unspecified",+ "tiers_mode": null,+ "transform_quantity": null,+ "type": "one_time",+ "unit_amount": 8000,+ "unit_amount_decimal": "8000"+ },+ "proration": false,+ "proration_details": {+ "credited_items": null+ },+ "quantity": 6,+ "subscription": null,+ "tax_amounts": [],+ "tax_rates": [],+ "type": "invoiceitem",+ "unit_amount_excluding_tax": "8000"+ },+ {+ "amount": -48000,+ "amount_excluding_tax": -48000,+ "currency": "usd",+ "description": "Payment (Card ending in 4242)",+ "discount_amounts": [],+ "discountable": false,+ "discounts": [],+ "id": "il_NORMALIZED00000000000002",+ "invoice_item": "ii_NORMALIZED00000000000002",+ "livemode": false,+ "metadata": {},+ "object": "line_item",+ "period": {+ "end": 1000000000,+ "start": 1000000000+ },+ "plan": null,+ "price": {+ "active": false,+ "billing_scheme": "per_unit",+ "created": 1000000000,+ "currency": "usd",+ "custom_unit_amount": null,+ "id": "price_NORMALIZED00000000000002",+ "livemode": false,+ "lookup_key": null,+ "metadata": {},+ "nickname": null,+ "object": "price",+ "product": "prod_NORMALIZED0002",+ "recurring": null,+ "tax_behavior": "unspecified",+ "tiers_mode": null,+ "transform_quantity": null,+ "type": "one_time",+ "unit_amount": -48000,+ "unit_amount_decimal": "-48000"+ },+ "proration": false,+ "proration_details": {+ "credited_items": null+ },+ "quantity": 1,+ "subscription": null,+ "tax_amounts": [],+ "tax_rates": [],+ "type": "invoiceitem",+ "unit_amount_excluding_tax": "-48000"+ }+ ],+ "has_more": false,+ "object": "list",+ "total_count": 2,+ "url": "/v1/invoices/in_NORMALIZED00000000000001/lines"+ },+ "livemode": false,+ "metadata": {},+ "next_payment_attempt": null,+ "number": "NORMALI-0002",+ "object": "invoice",+ "on_behalf_of": null,+ "paid": true,+ "paid_out_of_band": false,+ "payment_intent": null,+ "payment_settings": {+ "default_mandate": null,+ "payment_method_options": null,+ "payment_method_types": null+ },+ "period_end": 1000000000,+ "period_start": 1000000000,+ "post_payment_credit_notes_amount": 0,+ "pre_payment_credit_notes_amount": 0,+ "quote": null,+ "receipt_number": null,+ "rendering": {+ "amount_tax_display": null,+ "pdf": {+ "page_size": "letter"+ }+ },+ "rendering_options": null,+ "shipping_cost": null,+ "shipping_details": null,+ "starting_balance": 0,+ "statement_descriptor": "Zulip Cloud Standard",+ "status": "paid",+ "status_transitions": {+ "finalized_at": 1000000000,+ "marked_uncollectible_at": null,+ "paid_at": 1000000000,+ "voided_at": null+ },+ "subscription": null,+ "subscription_details": {+ "metadata": null+ },+ "subtotal": 0,+ "subtotal_excluding_tax": 0,+ "tax": null,+ "test_clock": null,+ "total": 0,+ "total_discount_amounts": [],+ "total_excluding_tax": 0,+ "total_tax_amounts": [],+ "transfer_data": null,+ "webhooks_delivered_at": null+ }+ },+ "id": "evt_1OEq5fDEQaroqDjsu38jvcsk",+ "livemode": false,+ "object": "event",+ "pending_webhooks": 0,+ "request": {+ "id": "req_NORMALIZED0003",+ "idempotency_key": "998fe9a6-b299-42f9-81a0-012a1c081160"+ },+ "type": "invoice.finalized"+ }+ ],+ "has_more": false,+ "object": "list",+ "url": "/v1/events"+}diff --git a/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Event.list.5.json b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Event.list.5.jsonnew file mode 100644index 00000000000..90c385a6042--- /dev/null+++ b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Event.list.5.json@@ -0,0 +1,230 @@+{+ "data": [+ {+ "api_version": "2020-08-27",+ "created": 1000000000,+ "data": {+ "object": {+ "account_country": "US",+ "account_name": "Kandra Labs, Inc.",+ "account_tax_ids": null,+ "amount_due": 0,+ "amount_paid": 0,+ "amount_remaining": 0,+ "amount_shipping": 0,+ "application": null,+ "application_fee_amount": null,+ "attempt_count": 0,+ "attempted": true,+ "auto_advance": false,+ "automatic_tax": {+ "enabled": false,+ "status": null+ },+ "billing_reason": "manual",+ "charge": null,+ "collection_method": "charge_automatically",+ "created": 1000000000,+ "currency": "usd",+ "custom_fields": null,+ "customer": "cus_NORMALIZED0001",+ "customer_address": null,+ "customer_email": "[email protected]",+ "customer_name": null,+ "customer_phone": null,+ "customer_shipping": null,+ "customer_tax_exempt": "none",+ "customer_tax_ids": [],+ "default_payment_method": null,+ "default_source": null,+ "default_tax_rates": [],+ "description": null,+ "discount": null,+ "discounts": [],+ "due_date": null,+ "effective_at": 1000000000,+ "ending_balance": 0,+ "footer": null,+ "from_invoice": null,+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/test_NORMALIZED01a3dERVFhcm9xRGpzLF9QMnZ4UWJoMFB1eExidGNGWUQyNEtmR2h3dGU0MUNwLDkxMDk5MDc20200mD76fW0N?s=ap",+ "id": "in_NORMALIZED00000000000001",+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/test_NORMALIZED01a3dERVFhcm9xRGpzLF9QMnZ4UWJoMFB1eExidGNGWUQyNEtmR2h3dGU0MUNwLDkxMDk5MDc20200mD76fW0N/pdf?s=ap",+ "last_finalization_error": null,+ "latest_revision": null,+ "lines": {+ "data": [+ {+ "amount": 48000,+ "amount_excluding_tax": 48000,+ "currency": "usd",+ "description": "Zulip Cloud Standard",+ "discount_amounts": [],+ "discountable": false,+ "discounts": [],+ "id": "il_NORMALIZED00000000000001",+ "invoice_item": "ii_NORMALIZED00000000000001",+ "livemode": false,+ "metadata": {},+ "object": "line_item",+ "period": {+ "end": 1357095845,+ "start": 1325473445+ },+ "plan": null,+ "price": {+ "active": false,+ "billing_scheme": "per_unit",+ "created": 1000000000,+ "currency": "usd",+ "custom_unit_amount": null,+ "id": "price_NORMALIZED00000000000001",+ "livemode": false,+ "lookup_key": null,+ "metadata": {},+ "nickname": null,+ "object": "price",+ "product": "prod_NORMALIZED0001",+ "recurring": null,+ "tax_behavior": "unspecified",+ "tiers_mode": null,+ "transform_quantity": null,+ "type": "one_time",+ "unit_amount": 8000,+ "unit_amount_decimal": "8000"+ },+ "proration": false,+ "proration_details": {+ "credited_items": null+ },+ "quantity": 6,+ "subscription": null,+ "tax_amounts": [],+ "tax_rates": [],+ "type": "invoiceitem",+ "unit_amount_excluding_tax": "8000"+ },+ {+ "amount": -48000,+ "amount_excluding_tax": -48000,+ "currency": "usd",+ "description": "Payment (Card ending in 4242)",+ "discount_amounts": [],+ "discountable": false,+ "discounts": [],+ "id": "il_NORMALIZED00000000000002",+ "invoice_item": "ii_NORMALIZED00000000000002",+ "livemode": false,+ "metadata": {},+ "object": "line_item",+ "period": {+ "end": 1000000000,+ "start": 1000000000+ },+ "plan": null,+ "price": {+ "active": false,+ "billing_scheme": "per_unit",+ "created": 1000000000,+ "currency": "usd",+ "custom_unit_amount": null,+ "id": "price_NORMALIZED00000000000002",+ "livemode": false,+ "lookup_key": null,+ "metadata": {},+ "nickname": null,+ "object": "price",+ "product": "prod_NORMALIZED0002",+ "recurring": null,+ "tax_behavior": "unspecified",+ "tiers_mode": null,+ "transform_quantity": null,+ "type": "one_time",+ "unit_amount": -48000,+ "unit_amount_decimal": "-48000"+ },+ "proration": false,+ "proration_details": {+ "credited_items": null+ },+ "quantity": 1,+ "subscription": null,+ "tax_amounts": [],+ "tax_rates": [],+ "type": "invoiceitem",+ "unit_amount_excluding_tax": "-48000"+ }+ ],+ "has_more": false,+ "object": "list",+ "total_count": 2,+ "url": "/v1/invoices/in_NORMALIZED00000000000001/lines"+ },+ "livemode": false,+ "metadata": {},+ "next_payment_attempt": null,+ "number": "NORMALI-0002",+ "object": "invoice",+ "on_behalf_of": null,+ "paid": true,+ "paid_out_of_band": false,+ "payment_intent": null,+ "payment_settings": {+ "default_mandate": null,+ "payment_method_options": null,+ "payment_method_types": null+ },+ "period_end": 1000000000,+ "period_start": 1000000000,+ "post_payment_credit_notes_amount": 0,+ "pre_payment_credit_notes_amount": 0,+ "quote": null,+ "receipt_number": null,+ "rendering": {+ "amount_tax_display": null,+ "pdf": {+ "page_size": "letter"+ }+ },+ "rendering_options": null,+ "shipping_cost": null,+ "shipping_details": null,+ "starting_balance": 0,+ "statement_descriptor": "Zulip Cloud Standard",+ "status": "paid",+ "status_transitions": {+ "finalized_at": 1000000000,+ "marked_uncollectible_at": null,+ "paid_at": 1000000000,+ "voided_at": null+ },+ "subscription": null,+ "subscription_details": {+ "metadata": null+ },+ "subtotal": 0,+ "subtotal_excluding_tax": 0,+ "tax": null,+ "test_clock": null,+ "total": 0,+ "total_discount_amounts": [],+ "total_excluding_tax": 0,+ "total_tax_amounts": [],+ "transfer_data": null,+ "webhooks_delivered_at": null+ }+ },+ "id": "evt_1OEq5gDEQaroqDjsPgWXbdfk",+ "livemode": false,+ "object": "event",+ "pending_webhooks": 0,+ "request": {+ "id": "req_NORMALIZED0003",+ "idempotency_key": "998fe9a6-b299-42f9-81a0-012a1c081160"+ },+ "type": "invoice.payment_succeeded"+ }+ ],+ "has_more": false,+ "object": "list",+ "url": "/v1/events"+}diff --git a/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Event.list.6.json b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Event.list.6.jsonnew file mode 100644index 00000000000..6d922067afe--- /dev/null+++ b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Event.list.6.json@@ -0,0 +1,6 @@+{+ "data": [],+ "has_more": false,+ "object": "list",+ "url": "/v1/events"+}diff --git a/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Invoice.create.1.json b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Invoice.create.1.jsonnew file mode 100644index 00000000000..ee4c6393e41--- /dev/null+++ b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Invoice.create.1.json@@ -0,0 +1,208 @@+{+ "account_country": "US",+ "account_name": "Kandra Labs, Inc.",+ "account_tax_ids": null,+ "amount_due": 0,+ "amount_paid": 0,+ "amount_remaining": 0,+ "amount_shipping": 0,+ "application": null,+ "application_fee_amount": null,+ "attempt_count": 0,+ "attempted": false,+ "auto_advance": true,+ "automatic_tax": {+ "enabled": false,+ "status": null+ },+ "billing_reason": "manual",+ "charge": null,+ "collection_method": "charge_automatically",+ "created": 1000000000,+ "currency": "usd",+ "custom_fields": null,+ "customer": "cus_NORMALIZED0001",+ "customer_address": null,+ "customer_email": "[email protected]",+ "customer_name": null,+ "customer_phone": null,+ "customer_shipping": null,+ "customer_tax_exempt": "none",+ "customer_tax_ids": [],+ "default_payment_method": null,+ "default_source": null,+ "default_tax_rates": [],+ "description": null,+ "discount": null,+ "discounts": [],+ "due_date": null,+ "effective_at": null,+ "ending_balance": null,+ "footer": null,+ "from_invoice": null,+ "hosted_invoice_url": null,+ "id": "in_NORMALIZED00000000000001",+ "invoice_pdf": null,+ "last_finalization_error": null,+ "latest_revision": null,+ "lines": {+ "data": [+ {+ "amount": 48000,+ "amount_excluding_tax": 48000,+ "currency": "usd",+ "description": "Zulip Cloud Standard",+ "discount_amounts": [],+ "discountable": false,+ "discounts": [],+ "id": "il_NORMALIZED00000000000001",+ "invoice_item": "ii_NORMALIZED00000000000001",+ "livemode": false,+ "metadata": {},+ "object": "line_item",+ "period": {+ "end": 1357095845,+ "start": 1325473445+ },+ "plan": null,+ "price": {+ "active": false,+ "billing_scheme": "per_unit",+ "created": 1000000000,+ "currency": "usd",+ "custom_unit_amount": null,+ "id": "price_NORMALIZED00000000000001",+ "livemode": false,+ "lookup_key": null,+ "metadata": {},+ "nickname": null,+ "object": "price",+ "product": "prod_NORMALIZED0001",+ "recurring": null,+ "tax_behavior": "unspecified",+ "tiers_mode": null,+ "transform_quantity": null,+ "type": "one_time",+ "unit_amount": 8000,+ "unit_amount_decimal": "8000"+ },+ "proration": false,+ "proration_details": {+ "credited_items": null+ },+ "quantity": 6,+ "subscription": null,+ "tax_amounts": [],+ "tax_rates": [],+ "type": "invoiceitem",+ "unit_amount_excluding_tax": "8000"+ },+ {+ "amount": -48000,+ "amount_excluding_tax": -48000,+ "currency": "usd",+ "description": "Payment (Card ending in 4242)",+ "discount_amounts": [],+ "discountable": false,+ "discounts": [],+ "id": "il_NORMALIZED00000000000002",+ "invoice_item": "ii_NORMALIZED00000000000002",+ "livemode": false,+ "metadata": {},+ "object": "line_item",+ "period": {+ "end": 1000000000,+ "start": 1000000000+ },+ "plan": null,+ "price": {+ "active": false,+ "billing_scheme": "per_unit",+ "created": 1000000000,+ "currency": "usd",+ "custom_unit_amount": null,+ "id": "price_NORMALIZED00000000000002",+ "livemode": false,+ "lookup_key": null,+ "metadata": {},+ "nickname": null,+ "object": "price",+ "product": "prod_NORMALIZED0002",+ "recurring": null,+ "tax_behavior": "unspecified",+ "tiers_mode": null,+ "transform_quantity": null,+ "type": "one_time",+ "unit_amount": -48000,+ "unit_amount_decimal": "-48000"+ },+ "proration": false,+ "proration_details": {+ "credited_items": null+ },+ "quantity": 1,+ "subscription": null,+ "tax_amounts": [],+ "tax_rates": [],+ "type": "invoiceitem",+ "unit_amount_excluding_tax": "-48000"+ }+ ],+ "has_more": false,+ "object": "list",+ "total_count": 2,+ "url": "/v1/invoices/in_NORMALIZED00000000000001/lines"+ },+ "livemode": false,+ "metadata": {},+ "next_payment_attempt": 1000000000,+ "number": null,+ "object": "invoice",+ "on_behalf_of": null,+ "paid": false,+ "paid_out_of_band": false,+ "payment_intent": null,+ "payment_settings": {+ "default_mandate": null,+ "payment_method_options": null,+ "payment_method_types": null+ },+ "period_end": 1000000000,+ "period_start": 1000000000,+ "post_payment_credit_notes_amount": 0,+ "pre_payment_credit_notes_amount": 0,+ "quote": null,+ "receipt_number": null,+ "rendering": {+ "amount_tax_display": null,+ "pdf": {+ "page_size": "auto"+ }+ },+ "rendering_options": null,+ "shipping_cost": null,+ "shipping_details": null,+ "starting_balance": 0,+ "statement_descriptor": "Zulip Cloud Standard",+ "status": "draft",+ "status_transitions": {+ "finalized_at": null,+ "marked_uncollectible_at": null,+ "paid_at": null,+ "voided_at": null+ },+ "subscription": null,+ "subscription_details": {+ "metadata": null+ },+ "subtotal": 0,+ "subtotal_excluding_tax": 0,+ "tax": null,+ "test_clock": null,+ "total": 0,+ "total_discount_amounts": [],+ "total_excluding_tax": 0,+ "total_tax_amounts": [],+ "transfer_data": null,+ "webhooks_delivered_at": null+}diff --git a/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Invoice.create.2.json b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Invoice.create.2.jsonnew file mode 100644index 00000000000..196b4cf17c6--- /dev/null+++ b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Invoice.create.2.json@@ -0,0 +1,208 @@+{+ "account_country": "US",+ "account_name": "Kandra Labs, Inc.",+ "account_tax_ids": null,+ "amount_due": 148610,+ "amount_paid": 0,+ "amount_remaining": 148610,+ "amount_shipping": 0,+ "application": null,+ "application_fee_amount": null,+ "attempt_count": 0,+ "attempted": false,+ "auto_advance": true,+ "automatic_tax": {+ "enabled": false,+ "status": null+ },+ "billing_reason": "manual",+ "charge": null,+ "collection_method": "charge_automatically",+ "created": 1000000000,+ "currency": "usd",+ "custom_fields": null,+ "customer": "cus_NORMALIZED0001",+ "customer_address": null,+ "customer_email": "[email protected]",+ "customer_name": null,+ "customer_phone": null,+ "customer_shipping": null,+ "customer_tax_exempt": "none",+ "customer_tax_ids": [],+ "default_payment_method": null,+ "default_source": null,+ "default_tax_rates": [],+ "description": null,+ "discount": null,+ "discounts": [],+ "due_date": null,+ "effective_at": null,+ "ending_balance": null,+ "footer": null,+ "from_invoice": null,+ "hosted_invoice_url": null,+ "id": "in_NORMALIZED00000000000002",+ "invoice_pdf": null,+ "last_finalization_error": null,+ "latest_revision": null,+ "lines": {+ "data": [+ {+ "amount": 36610,+ "amount_excluding_tax": 36610,+ "currency": "usd",+ "description": "Additional license (Feb 2, 2012 - Jan 2, 2013)",+ "discount_amounts": [],+ "discountable": false,+ "discounts": [],+ "id": "il_NORMALIZED00000000000003",+ "invoice_item": "ii_NORMALIZED00000000000003",+ "livemode": false,+ "metadata": {},+ "object": "line_item",+ "period": {+ "end": 1357095845,+ "start": 1328151845+ },+ "plan": null,+ "price": {+ "active": false,+ "billing_scheme": "per_unit",+ "created": 1000000000,+ "currency": "usd",+ "custom_unit_amount": null,+ "id": "price_NORMALIZED00000000000003",+ "livemode": false,+ "lookup_key": null,+ "metadata": {},+ "nickname": null,+ "object": "price",+ "product": "prod_NORMALIZED0003",+ "recurring": null,+ "tax_behavior": "unspecified",+ "tiers_mode": null,+ "transform_quantity": null,+ "type": "one_time",+ "unit_amount": 7322,+ "unit_amount_decimal": "7322"+ },+ "proration": false,+ "proration_details": {+ "credited_items": null+ },+ "quantity": 5,+ "subscription": null,+ "tax_amounts": [],+ "tax_rates": [],+ "type": "invoiceitem",+ "unit_amount_excluding_tax": "7322"+ },+ {+ "amount": 112000,+ "amount_excluding_tax": 112000,+ "currency": "usd",+ "description": "Additional license (Jan 2, 2012 - Jan 2, 2013)",+ "discount_amounts": [],+ "discountable": false,+ "discounts": [],+ "id": "il_NORMALIZED00000000000004",+ "invoice_item": "ii_NORMALIZED00000000000004",+ "livemode": false,+ "metadata": {},+ "object": "line_item",+ "period": {+ "end": 1357095845,+ "start": 1325473445+ },+ "plan": null,+ "price": {+ "active": false,+ "billing_scheme": "per_unit",+ "created": 1000000000,+ "currency": "usd",+ "custom_unit_amount": null,+ "id": "price_NORMALIZED00000000000004",+ "livemode": false,+ "lookup_key": null,+ "metadata": {},+ "nickname": null,+ "object": "price",+ "product": "prod_NORMALIZED0004",+ "recurring": null,+ "tax_behavior": "unspecified",+ "tiers_mode": null,+ "transform_quantity": null,+ "type": "one_time",+ "unit_amount": 8000,+ "unit_amount_decimal": "8000"+ },+ "proration": false,+ "proration_details": {+ "credited_items": null+ },+ "quantity": 14,+ "subscription": null,+ "tax_amounts": [],+ "tax_rates": [],+ "type": "invoiceitem",+ "unit_amount_excluding_tax": "8000"+ }+ ],+ "has_more": false,+ "object": "list",+ "total_count": 2,+ "url": "/v1/invoices/in_NORMALIZED00000000000002/lines"+ },+ "livemode": false,+ "metadata": {},+ "next_payment_attempt": 1000000000,+ "number": null,+ "object": "invoice",+ "on_behalf_of": null,+ "paid": false,+ "paid_out_of_band": false,+ "payment_intent": null,+ "payment_settings": {+ "default_mandate": null,+ "payment_method_options": null,+ "payment_method_types": null+ },+ "period_end": 1000000000,+ "period_start": 1000000000,+ "post_payment_credit_notes_amount": 0,+ "pre_payment_credit_notes_amount": 0,+ "quote": null,+ "receipt_number": null,+ "rendering": {+ "amount_tax_display": null,+ "pdf": {+ "page_size": "auto"+ }+ },+ "rendering_options": null,+ "shipping_cost": null,+ "shipping_details": null,+ "starting_balance": 0,+ "statement_descriptor": "Zulip Cloud Standard",+ "status": "draft",+ "status_transitions": {+ "finalized_at": null,+ "marked_uncollectible_at": null,+ "paid_at": null,+ "voided_at": null+ },+ "subscription": null,+ "subscription_details": {+ "metadata": null+ },+ "subtotal": 148610,+ "subtotal_excluding_tax": 148610,+ "tax": null,+ "test_clock": null,+ "total": 148610,+ "total_discount_amounts": [],+ "total_excluding_tax": 148610,+ "total_tax_amounts": [],+ "transfer_data": null,+ "webhooks_delivered_at": null+}diff --git a/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Invoice.create.3.json b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Invoice.create.3.jsonnew file mode 100644index 00000000000..94e3f9651b9--- /dev/null+++ b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Invoice.create.3.json@@ -0,0 +1,158 @@+{+ "account_country": "US",+ "account_name": "Kandra Labs, Inc.",+ "account_tax_ids": null,+ "amount_due": 20000,+ "amount_paid": 0,+ "amount_remaining": 20000,+ "amount_shipping": 0,+ "application": null,+ "application_fee_amount": null,+ "attempt_count": 0,+ "attempted": false,+ "auto_advance": true,+ "automatic_tax": {+ "enabled": false,+ "status": null+ },+ "billing_reason": "manual",+ "charge": null,+ "collection_method": "charge_automatically",+ "created": 1000000000,+ "currency": "usd",+ "custom_fields": null,+ "customer": "cus_NORMALIZED0001",+ "customer_address": null,+ "customer_email": "[email protected]",+ "customer_name": null,+ "customer_phone": null,+ "customer_shipping": null,+ "customer_tax_exempt": "none",+ "customer_tax_ids": [],+ "default_payment_method": null,+ "default_source": null,+ "default_tax_rates": [],+ "description": null,+ "discount": null,+ "discounts": [],+ "due_date": null,+ "effective_at": null,+ "ending_balance": null,+ "footer": null,+ "from_invoice": null,+ "hosted_invoice_url": null,+ "id": "in_NORMALIZED00000000000003",+ "invoice_pdf": null,+ "last_finalization_error": null,+ "latest_revision": null,+ "lines": {+ "data": [+ {+ "amount": 20000,+ "amount_excluding_tax": 20000,+ "currency": "usd",+ "description": "Zulip Cloud Standard - renewal",+ "discount_amounts": [],+ "discountable": false,+ "discounts": [],+ "id": "il_NORMALIZED00000000000005",+ "invoice_item": "ii_NORMALIZED00000000000005",+ "livemode": false,+ "metadata": {},+ "object": "line_item",+ "period": {+ "end": 1359774245,+ "start": 1357095845+ },+ "plan": null,+ "price": {+ "active": false,+ "billing_scheme": "per_unit",+ "created": 1000000000,+ "currency": "usd",+ "custom_unit_amount": null,+ "id": "price_NORMALIZED00000000000005",+ "livemode": false,+ "lookup_key": null,+ "metadata": {},+ "nickname": null,+ "object": "price",+ "product": "prod_NORMALIZED0005",+ "recurring": null,+ "tax_behavior": "unspecified",+ "tiers_mode": null,+ "transform_quantity": null,+ "type": "one_time",+ "unit_amount": 800,+ "unit_amount_decimal": "800"+ },+ "proration": false,+ "proration_details": {+ "credited_items": null+ },+ "quantity": 25,+ "subscription": null,+ "tax_amounts": [],+ "tax_rates": [],+ "type": "invoiceitem",+ "unit_amount_excluding_tax": "800"+ }+ ],+ "has_more": false,+ "object": "list",+ "total_count": 1,+ "url": "/v1/invoices/in_NORMALIZED00000000000003/lines"+ },+ "livemode": false,+ "metadata": {},+ "next_payment_attempt": 1000000000,+ "number": null,+ "object": "invoice",+ "on_behalf_of": null,+ "paid": false,+ "paid_out_of_band": false,+ "payment_intent": null,+ "payment_settings": {+ "default_mandate": null,+ "payment_method_options": null,+ "payment_method_types": null+ },+ "period_end": 1000000000,+ "period_start": 1000000000,+ "post_payment_credit_notes_amount": 0,+ "pre_payment_credit_notes_amount": 0,+ "quote": null,+ "receipt_number": null,+ "rendering": {+ "amount_tax_display": null,+ "pdf": {+ "page_size": "auto"+ }+ },+ "rendering_options": null,+ "shipping_cost": null,+ "shipping_details": null,+ "starting_balance": 0,+ "statement_descriptor": "Zulip Cloud Standard",+ "status": "draft",+ "status_transitions": {+ "finalized_at": null,+ "marked_uncollectible_at": null,+ "paid_at": null,+ "voided_at": null+ },+ "subscription": null,+ "subscription_details": {+ "metadata": null+ },+ "subtotal": 20000,+ "subtotal_excluding_tax": 20000,+ "tax": null,+ "test_clock": null,+ "total": 20000,+ "total_discount_amounts": [],+ "total_excluding_tax": 20000,+ "total_tax_amounts": [],+ "transfer_data": null,+ "webhooks_delivered_at": null+}diff --git a/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Invoice.finalize_invoice.1.json b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Invoice.finalize_invoice.1.jsonnew file mode 100644index 00000000000..dc4a8a0795c--- /dev/null+++ b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Invoice.finalize_invoice.1.json@@ -0,0 +1,208 @@+{+ "account_country": "US",+ "account_name": "Kandra Labs, Inc.",+ "account_tax_ids": null,+ "amount_due": 0,+ "amount_paid": 0,+ "amount_remaining": 0,+ "amount_shipping": 0,+ "application": null,+ "application_fee_amount": null,+ "attempt_count": 0,+ "attempted": true,+ "auto_advance": false,+ "automatic_tax": {+ "enabled": false,+ "status": null+ },+ "billing_reason": "manual",+ "charge": null,+ "collection_method": "charge_automatically",+ "created": 1000000000,+ "currency": "usd",+ "custom_fields": null,+ "customer": "cus_NORMALIZED0001",+ "customer_address": null,+ "customer_email": "[email protected]",+ "customer_name": null,+ "customer_phone": null,+ "customer_shipping": null,+ "customer_tax_exempt": "none",+ "customer_tax_ids": [],+ "default_payment_method": null,+ "default_source": null,+ "default_tax_rates": [],+ "description": null,+ "discount": null,+ "discounts": [],+ "due_date": null,+ "effective_at": 1000000000,+ "ending_balance": 0,+ "footer": null,+ "from_invoice": null,+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/test_NORMALIZED01a3dERVFhcm9xRGpzLF9QMnZ4UWJoMFB1eExidGNGWUQyNEtmR2h3dGU0MUNwLDkxMDk5MDc102003eiBMKW1?s=ap",+ "id": "in_NORMALIZED00000000000001",+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/test_NORMALIZED01a3dERVFhcm9xRGpzLF9QMnZ4UWJoMFB1eExidGNGWUQyNEtmR2h3dGU0MUNwLDkxMDk5MDc102003eiBMKW1/pdf?s=ap",+ "last_finalization_error": null,+ "latest_revision": null,+ "lines": {+ "data": [+ {+ "amount": 48000,+ "amount_excluding_tax": 48000,+ "currency": "usd",+ "description": "Zulip Cloud Standard",+ "discount_amounts": [],+ "discountable": false,+ "discounts": [],+ "id": "il_NORMALIZED00000000000001",+ "invoice_item": "ii_NORMALIZED00000000000001",+ "livemode": false,+ "metadata": {},+ "object": "line_item",+ "period": {+ "end": 1357095845,+ "start": 1325473445+ },+ "plan": null,+ "price": {+ "active": false,+ "billing_scheme": "per_unit",+ "created": 1000000000,+ "currency": "usd",+ "custom_unit_amount": null,+ "id": "price_NORMALIZED00000000000001",+ "livemode": false,+ "lookup_key": null,+ "metadata": {},+ "nickname": null,+ "object": "price",+ "product": "prod_NORMALIZED0001",+ "recurring": null,+ "tax_behavior": "unspecified",+ "tiers_mode": null,+ "transform_quantity": null,+ "type": "one_time",+ "unit_amount": 8000,+ "unit_amount_decimal": "8000"+ },+ "proration": false,+ "proration_details": {+ "credited_items": null+ },+ "quantity": 6,+ "subscription": null,+ "tax_amounts": [],+ "tax_rates": [],+ "type": "invoiceitem",+ "unit_amount_excluding_tax": "8000"+ },+ {+ "amount": -48000,+ "amount_excluding_tax": -48000,+ "currency": "usd",+ "description": "Payment (Card ending in 4242)",+ "discount_amounts": [],+ "discountable": false,+ "discounts": [],+ "id": "il_NORMALIZED00000000000002",+ "invoice_item": "ii_NORMALIZED00000000000002",+ "livemode": false,+ "metadata": {},+ "object": "line_item",+ "period": {+ "end": 1000000000,+ "start": 1000000000+ },+ "plan": null,+ "price": {+ "active": false,+ "billing_scheme": "per_unit",+ "created": 1000000000,+ "currency": "usd",+ "custom_unit_amount": null,+ "id": "price_NORMALIZED00000000000002",+ "livemode": false,+ "lookup_key": null,+ "metadata": {},+ "nickname": null,+ "object": "price",+ "product": "prod_NORMALIZED0002",+ "recurring": null,+ "tax_behavior": "unspecified",+ "tiers_mode": null,+ "transform_quantity": null,+ "type": "one_time",+ "unit_amount": -48000,+ "unit_amount_decimal": "-48000"+ },+ "proration": false,+ "proration_details": {+ "credited_items": null+ },+ "quantity": 1,+ "subscription": null,+ "tax_amounts": [],+ "tax_rates": [],+ "type": "invoiceitem",+ "unit_amount_excluding_tax": "-48000"+ }+ ],+ "has_more": false,+ "object": "list",+ "total_count": 2,+ "url": "/v1/invoices/in_NORMALIZED00000000000001/lines"+ },+ "livemode": false,+ "metadata": {},+ "next_payment_attempt": null,+ "number": "NORMALI-0002",+ "object": "invoice",+ "on_behalf_of": null,+ "paid": true,+ "paid_out_of_band": false,+ "payment_intent": null,+ "payment_settings": {+ "default_mandate": null,+ "payment_method_options": null,+ "payment_method_types": null+ },+ "period_end": 1000000000,+ "period_start": 1000000000,+ "post_payment_credit_notes_amount": 0,+ "pre_payment_credit_notes_amount": 0,+ "quote": null,+ "receipt_number": null,+ "rendering": {+ "amount_tax_display": null,+ "pdf": {+ "page_size": "letter"+ }+ },+ "rendering_options": null,+ "shipping_cost": null,+ "shipping_details": null,+ "starting_balance": 0,+ "statement_descriptor": "Zulip Cloud Standard",+ "status": "paid",+ "status_transitions": {+ "finalized_at": 1000000000,+ "marked_uncollectible_at": null,+ "paid_at": 1000000000,+ "voided_at": null+ },+ "subscription": null,+ "subscription_details": {+ "metadata": null+ },+ "subtotal": 0,+ "subtotal_excluding_tax": 0,+ "tax": null,+ "test_clock": null,+ "total": 0,+ "total_discount_amounts": [],+ "total_excluding_tax": 0,+ "total_tax_amounts": [],+ "transfer_data": null,+ "webhooks_delivered_at": null+}diff --git a/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Invoice.finalize_invoice.2.json b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Invoice.finalize_invoice.2.jsonnew file mode 100644index 00000000000..549b7eadc5d--- /dev/null+++ b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Invoice.finalize_invoice.2.json@@ -0,0 +1,208 @@+{+ "account_country": "US",+ "account_name": "Kandra Labs, Inc.",+ "account_tax_ids": null,+ "amount_due": 148610,+ "amount_paid": 0,+ "amount_remaining": 148610,+ "amount_shipping": 0,+ "application": null,+ "application_fee_amount": null,+ "attempt_count": 0,+ "attempted": false,+ "auto_advance": true,+ "automatic_tax": {+ "enabled": false,+ "status": null+ },+ "billing_reason": "manual",+ "charge": null,+ "collection_method": "charge_automatically",+ "created": 1000000000,+ "currency": "usd",+ "custom_fields": null,+ "customer": "cus_NORMALIZED0001",+ "customer_address": null,+ "customer_email": "[email protected]",+ "customer_name": null,+ "customer_phone": null,+ "customer_shipping": null,+ "customer_tax_exempt": "none",+ "customer_tax_ids": [],+ "default_payment_method": null,+ "default_source": null,+ "default_tax_rates": [],+ "description": null,+ "discount": null,+ "discounts": [],+ "due_date": null,+ "effective_at": 1000000000,+ "ending_balance": 0,+ "footer": null,+ "from_invoice": null,+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/test_NORMALIZED01a3dERVFhcm9xRGpzLF9QMnZ4TVRnMVNhSVpXMkhQaHcxTmxQZHB5Y2J1cmppLDkxMDk5MDc50200XJ3z7NiD?s=ap",+ "id": "in_NORMALIZED00000000000002",+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/test_NORMALIZED01a3dERVFhcm9xRGpzLF9QMnZ4TVRnMVNhSVpXMkhQaHcxTmxQZHB5Y2J1cmppLDkxMDk5MDc50200XJ3z7NiD/pdf?s=ap",+ "last_finalization_error": null,+ "latest_revision": null,+ "lines": {+ "data": [+ {+ "amount": 36610,+ "amount_excluding_tax": 36610,+ "currency": "usd",+ "description": "Additional license (Feb 2, 2012 - Jan 2, 2013)",+ "discount_amounts": [],+ "discountable": false,+ "discounts": [],+ "id": "il_NORMALIZED00000000000003",+ "invoice_item": "ii_NORMALIZED00000000000003",+ "livemode": false,+ "metadata": {},+ "object": "line_item",+ "period": {+ "end": 1357095845,+ "start": 1328151845+ },+ "plan": null,+ "price": {+ "active": false,+ "billing_scheme": "per_unit",+ "created": 1000000000,+ "currency": "usd",+ "custom_unit_amount": null,+ "id": "price_NORMALIZED00000000000003",+ "livemode": false,+ "lookup_key": null,+ "metadata": {},+ "nickname": null,+ "object": "price",+ "product": "prod_NORMALIZED0003",+ "recurring": null,+ "tax_behavior": "unspecified",+ "tiers_mode": null,+ "transform_quantity": null,+ "type": "one_time",+ "unit_amount": 7322,+ "unit_amount_decimal": "7322"+ },+ "proration": false,+ "proration_details": {+ "credited_items": null+ },+ "quantity": 5,+ "subscription": null,+ "tax_amounts": [],+ "tax_rates": [],+ "type": "invoiceitem",+ "unit_amount_excluding_tax": "7322"+ },+ {+ "amount": 112000,+ "amount_excluding_tax": 112000,+ "currency": "usd",+ "description": "Additional license (Jan 2, 2012 - Jan 2, 2013)",+ "discount_amounts": [],+ "discountable": false,+ "discounts": [],+ "id": "il_NORMALIZED00000000000004",+ "invoice_item": "ii_NORMALIZED00000000000004",+ "livemode": false,+ "metadata": {},+ "object": "line_item",+ "period": {+ "end": 1357095845,+ "start": 1325473445+ },+ "plan": null,+ "price": {+ "active": false,+ "billing_scheme": "per_unit",+ "created": 1000000000,+ "currency": "usd",+ "custom_unit_amount": null,+ "id": "price_NORMALIZED00000000000004",+ "livemode": false,+ "lookup_key": null,+ "metadata": {},+ "nickname": null,+ "object": "price",+ "product": "prod_NORMALIZED0004",+ "recurring": null,+ "tax_behavior": "unspecified",+ "tiers_mode": null,+ "transform_quantity": null,+ "type": "one_time",+ "unit_amount": 8000,+ "unit_amount_decimal": "8000"+ },+ "proration": false,+ "proration_details": {+ "credited_items": null+ },+ "quantity": 14,+ "subscription": null,+ "tax_amounts": [],+ "tax_rates": [],+ "type": "invoiceitem",+ "unit_amount_excluding_tax": "8000"+ }+ ],+ "has_more": false,+ "object": "list",+ "total_count": 2,+ "url": "/v1/invoices/in_NORMALIZED00000000000002/lines"+ },+ "livemode": false,+ "metadata": {},+ "next_payment_attempt": 1000000000,+ "number": "NORMALI-0003",+ "object": "invoice",+ "on_behalf_of": null,+ "paid": false,+ "paid_out_of_band": false,+ "payment_intent": "pi_NORMALIZED00000000000002",+ "payment_settings": {+ "default_mandate": null,+ "payment_method_options": null,+ "payment_method_types": null+ },+ "period_end": 1000000000,+ "period_start": 1000000000,+ "post_payment_credit_notes_amount": 0,+ "pre_payment_credit_notes_amount": 0,+ "quote": null,+ "receipt_number": null,+ "rendering": {+ "amount_tax_display": null,+ "pdf": {+ "page_size": "letter"+ }+ },+ "rendering_options": null,+ "shipping_cost": null,+ "shipping_details": null,+ "starting_balance": 0,+ "statement_descriptor": "Zulip Cloud Standard",+ "status": "open",+ "status_transitions": {+ "finalized_at": 1000000000,+ "marked_uncollectible_at": null,+ "paid_at": null,+ "voided_at": null+ },+ "subscription": null,+ "subscription_details": {+ "metadata": null+ },+ "subtotal": 148610,+ "subtotal_excluding_tax": 148610,+ "tax": null,+ "test_clock": null,+ "total": 148610,+ "total_discount_amounts": [],+ "total_excluding_tax": 148610,+ "total_tax_amounts": [],+ "transfer_data": null,+ "webhooks_delivered_at": null+}diff --git a/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Invoice.finalize_invoice.3.json b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Invoice.finalize_invoice.3.jsonnew file mode 100644index 00000000000..64f45b12280--- /dev/null+++ b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Invoice.finalize_invoice.3.json@@ -0,0 +1,158 @@+{+ "account_country": "US",+ "account_name": "Kandra Labs, Inc.",+ "account_tax_ids": null,+ "amount_due": 20000,+ "amount_paid": 0,+ "amount_remaining": 20000,+ "amount_shipping": 0,+ "application": null,+ "application_fee_amount": null,+ "attempt_count": 0,+ "attempted": false,+ "auto_advance": true,+ "automatic_tax": {+ "enabled": false,+ "status": null+ },+ "billing_reason": "manual",+ "charge": null,+ "collection_method": "charge_automatically",+ "created": 1000000000,+ "currency": "usd",+ "custom_fields": null,+ "customer": "cus_NORMALIZED0001",+ "customer_address": null,+ "customer_email": "[email protected]",+ "customer_name": null,+ "customer_phone": null,+ "customer_shipping": null,+ "customer_tax_exempt": "none",+ "customer_tax_ids": [],+ "default_payment_method": null,+ "default_source": null,+ "default_tax_rates": [],+ "description": null,+ "discount": null,+ "discounts": [],+ "due_date": null,+ "effective_at": 1000000000,+ "ending_balance": 0,+ "footer": null,+ "from_invoice": null,+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/test_NORMALIZED01a3dERVFhcm9xRGpzLF9QMnZ4RzNVRW5JU0tjTzZlN3p3c01xamV2eUY1MEYwLDkxMDk5MDgx0200VEq1S4LP?s=ap",+ "id": "in_NORMALIZED00000000000003",+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/test_NORMALIZED01a3dERVFhcm9xRGpzLF9QMnZ4RzNVRW5JU0tjTzZlN3p3c01xamV2eUY1MEYwLDkxMDk5MDgx0200VEq1S4LP/pdf?s=ap",+ "last_finalization_error": null,+ "latest_revision": null,+ "lines": {+ "data": [+ {+ "amount": 20000,+ "amount_excluding_tax": 20000,+ "currency": "usd",+ "description": "Zulip Cloud Standard - renewal",+ "discount_amounts": [],+ "discountable": false,+ "discounts": [],+ "id": "il_NORMALIZED00000000000005",+ "invoice_item": "ii_NORMALIZED00000000000005",+ "livemode": false,+ "metadata": {},+ "object": "line_item",+ "period": {+ "end": 1359774245,+ "start": 1357095845+ },+ "plan": null,+ "price": {+ "active": false,+ "billing_scheme": "per_unit",+ "created": 1000000000,+ "currency": "usd",+ "custom_unit_amount": null,+ "id": "price_NORMALIZED00000000000005",+ "livemode": false,+ "lookup_key": null,+ "metadata": {},+ "nickname": null,+ "object": "price",+ "product": "prod_NORMALIZED0005",+ "recurring": null,+ "tax_behavior": "unspecified",+ "tiers_mode": null,+ "transform_quantity": null,+ "type": "one_time",+ "unit_amount": 800,+ "unit_amount_decimal": "800"+ },+ "proration": false,+ "proration_details": {+ "credited_items": null+ },+ "quantity": 25,+ "subscription": null,+ "tax_amounts": [],+ "tax_rates": [],+ "type": "invoiceitem",+ "unit_amount_excluding_tax": "800"+ }+ ],+ "has_more": false,+ "object": "list",+ "total_count": 1,+ "url": "/v1/invoices/in_NORMALIZED00000000000003/lines"+ },+ "livemode": false,+ "metadata": {},+ "next_payment_attempt": 1000000000,+ "number": "NORMALI-0004",+ "object": "invoice",+ "on_behalf_of": null,+ "paid": false,+ "paid_out_of_band": false,+ "payment_intent": "pi_NORMALIZED00000000000003",+ "payment_settings": {+ "default_mandate": null,+ "payment_method_options": null,+ "payment_method_types": null+ },+ "period_end": 1000000000,+ "period_start": 1000000000,+ "post_payment_credit_notes_amount": 0,+ "pre_payment_credit_notes_amount": 0,+ "quote": null,+ "receipt_number": null,+ "rendering": {+ "amount_tax_display": null,+ "pdf": {+ "page_size": "letter"+ }+ },+ "rendering_options": null,+ "shipping_cost": null,+ "shipping_details": null,+ "starting_balance": 0,+ "statement_descriptor": "Zulip Cloud Standard",+ "status": "open",+ "status_transitions": {+ "finalized_at": 1000000000,+ "marked_uncollectible_at": null,+ "paid_at": null,+ "voided_at": null+ },+ "subscription": null,+ "subscription_details": {+ "metadata": null+ },+ "subtotal": 20000,+ "subtotal_excluding_tax": 20000,+ "tax": null,+ "test_clock": null,+ "total": 20000,+ "total_discount_amounts": [],+ "total_excluding_tax": 20000,+ "total_tax_amounts": [],+ "transfer_data": null,+ "webhooks_delivered_at": null+}diff --git a/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Invoice.list.1.json b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Invoice.list.1.jsonnew file mode 100644index 00000000000..e39960ab725--- /dev/null+++ b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Invoice.list.1.json@@ -0,0 +1,6 @@+{+ "data": [],+ "has_more": false,+ "object": "list",+ "url": "/v1/invoices"+}diff --git a/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Invoice.list.2.json b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Invoice.list.2.jsonnew file mode 100644index 00000000000..3809582ab0b--- /dev/null+++ b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Invoice.list.2.json@@ -0,0 +1,423 @@+{+ "data": [+ {+ "account_country": "US",+ "account_name": "Kandra Labs, Inc.",+ "account_tax_ids": null,+ "amount_due": 148610,+ "amount_paid": 0,+ "amount_remaining": 148610,+ "amount_shipping": 0,+ "application": null,+ "application_fee_amount": null,+ "attempt_count": 0,+ "attempted": false,+ "auto_advance": true,+ "automatic_tax": {+ "enabled": false,+ "status": null+ },+ "billing_reason": "manual",+ "charge": null,+ "collection_method": "charge_automatically",+ "created": 1000000000,+ "currency": "usd",+ "custom_fields": null,+ "customer": "cus_NORMALIZED0001",+ "customer_address": null,+ "customer_email": "[email protected]",+ "customer_name": null,+ "customer_phone": null,+ "customer_shipping": null,+ "customer_tax_exempt": "none",+ "customer_tax_ids": [],+ "default_payment_method": null,+ "default_source": null,+ "default_tax_rates": [],+ "description": null,+ "discount": null,+ "discounts": [],+ "due_date": null,+ "effective_at": 1000000000,+ "ending_balance": 0,+ "footer": null,+ "from_invoice": null,+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/test_NORMALIZED01a3dERVFhcm9xRGpzLF9QMnZ4TVRnMVNhSVpXMkhQaHcxTmxQZHB5Y2J1cmppLDkxMDk5MDc50200XJ3z7NiD?s=ap",+ "id": "in_NORMALIZED00000000000002",+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/test_NORMALIZED01a3dERVFhcm9xRGpzLF9QMnZ4TVRnMVNhSVpXMkhQaHcxTmxQZHB5Y2J1cmppLDkxMDk5MDc50200XJ3z7NiD/pdf?s=ap",+ "last_finalization_error": null,+ "latest_revision": null,+ "lines": {+ "data": [+ {+ "amount": 36610,+ "amount_excluding_tax": 36610,+ "currency": "usd",+ "description": "Additional license (Feb 2, 2012 - Jan 2, 2013)",+ "discount_amounts": [],+ "discountable": false,+ "discounts": [],+ "id": "il_NORMALIZED00000000000003",+ "invoice_item": "ii_NORMALIZED00000000000003",+ "livemode": false,+ "metadata": {},+ "object": "line_item",+ "period": {+ "end": 1357095845,+ "start": 1328151845+ },+ "plan": null,+ "price": {+ "active": false,+ "billing_scheme": "per_unit",+ "created": 1000000000,+ "currency": "usd",+ "custom_unit_amount": null,+ "id": "price_NORMALIZED00000000000003",+ "livemode": false,+ "lookup_key": null,+ "metadata": {},+ "nickname": null,+ "object": "price",+ "product": "prod_NORMALIZED0003",+ "recurring": null,+ "tax_behavior": "unspecified",+ "tiers_mode": null,+ "transform_quantity": null,+ "type": "one_time",+ "unit_amount": 7322,+ "unit_amount_decimal": "7322"+ },+ "proration": false,+ "proration_details": {+ "credited_items": null+ },+ "quantity": 5,+ "subscription": null,+ "tax_amounts": [],+ "tax_rates": [],+ "type": "invoiceitem",+ "unit_amount_excluding_tax": "7322"+ },+ {+ "amount": 112000,+ "amount_excluding_tax": 112000,+ "currency": "usd",+ "description": "Additional license (Jan 2, 2012 - Jan 2, 2013)",+ "discount_amounts": [],+ "discountable": false,+ "discounts": [],+ "id": "il_NORMALIZED00000000000004",+ "invoice_item": "ii_NORMALIZED00000000000004",+ "livemode": false,+ "metadata": {},+ "object": "line_item",+ "period": {+ "end": 1357095845,+ "start": 1325473445+ },+ "plan": null,+ "price": {+ "active": false,+ "billing_scheme": "per_unit",+ "created": 1000000000,+ "currency": "usd",+ "custom_unit_amount": null,+ "id": "price_NORMALIZED00000000000004",+ "livemode": false,+ "lookup_key": null,+ "metadata": {},+ "nickname": null,+ "object": "price",+ "product": "prod_NORMALIZED0004",+ "recurring": null,+ "tax_behavior": "unspecified",+ "tiers_mode": null,+ "transform_quantity": null,+ "type": "one_time",+ "unit_amount": 8000,+ "unit_amount_decimal": "8000"+ },+ "proration": false,+ "proration_details": {+ "credited_items": null+ },+ "quantity": 14,+ "subscription": null,+ "tax_amounts": [],+ "tax_rates": [],+ "type": "invoiceitem",+ "unit_amount_excluding_tax": "8000"+ }+ ],+ "has_more": false,+ "object": "list",+ "total_count": 2,+ "url": "/v1/invoices/in_NORMALIZED00000000000002/lines"+ },+ "livemode": false,+ "metadata": {},+ "next_payment_attempt": 1000000000,+ "number": "NORMALI-0003",+ "object": "invoice",+ "on_behalf_of": null,+ "paid": false,+ "paid_out_of_band": false,+ "payment_intent": "pi_NORMALIZED00000000000002",+ "payment_settings": {+ "default_mandate": null,+ "payment_method_options": null,+ "payment_method_types": null+ },+ "period_end": 1000000000,+ "period_start": 1000000000,+ "post_payment_credit_notes_amount": 0,+ "pre_payment_credit_notes_amount": 0,+ "quote": null,+ "receipt_number": null,+ "rendering": {+ "amount_tax_display": null,+ "pdf": {+ "page_size": "letter"+ }+ },+ "rendering_options": null,+ "shipping_cost": null,+ "shipping_details": null,+ "starting_balance": 0,+ "statement_descriptor": "Zulip Cloud Standard",+ "status": "open",+ "status_transitions": {+ "finalized_at": 1000000000,+ "marked_uncollectible_at": null,+ "paid_at": null,+ "voided_at": null+ },+ "subscription": null,+ "subscription_details": {+ "metadata": null+ },+ "subtotal": 148610,+ "subtotal_excluding_tax": 148610,+ "tax": null,+ "test_clock": null,+ "total": 148610,+ "total_discount_amounts": [],+ "total_excluding_tax": 148610,+ "total_tax_amounts": [],+ "transfer_data": null,+ "webhooks_delivered_at": null+ },+ {+ "account_country": "US",+ "account_name": "Kandra Labs, Inc.",+ "account_tax_ids": null,+ "amount_due": 0,+ "amount_paid": 0,+ "amount_remaining": 0,+ "amount_shipping": 0,+ "application": null,+ "application_fee_amount": null,+ "attempt_count": 0,+ "attempted": true,+ "auto_advance": false,+ "automatic_tax": {+ "enabled": false,+ "status": null+ },+ "billing_reason": "manual",+ "charge": null,+ "collection_method": "charge_automatically",+ "created": 1000000000,+ "currency": "usd",+ "custom_fields": null,+ "customer": "cus_NORMALIZED0001",+ "customer_address": null,+ "customer_email": "[email protected]",+ "customer_name": null,+ "customer_phone": null,+ "customer_shipping": null,+ "customer_tax_exempt": "none",+ "customer_tax_ids": [],+ "default_payment_method": null,+ "default_source": null,+ "default_tax_rates": [],+ "description": null,+ "discount": null,+ "discounts": [],+ "due_date": null,+ "effective_at": 1000000000,+ "ending_balance": 0,+ "footer": null,+ "from_invoice": null,+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/test_NORMALIZED01a3dERVFhcm9xRGpzLF9QMnZ4UWJoMFB1eExidGNGWUQyNEtmR2h3dGU0MUNwLDkxMDk5MDc50200Qe49yv98?s=ap",+ "id": "in_NORMALIZED00000000000001",+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/test_NORMALIZED01a3dERVFhcm9xRGpzLF9QMnZ4UWJoMFB1eExidGNGWUQyNEtmR2h3dGU0MUNwLDkxMDk5MDc50200Qe49yv98/pdf?s=ap",+ "last_finalization_error": null,+ "latest_revision": null,+ "lines": {+ "data": [+ {+ "amount": 48000,+ "amount_excluding_tax": 48000,+ "currency": "usd",+ "description": "Zulip Cloud Standard",+ "discount_amounts": [],+ "discountable": false,+ "discounts": [],+ "id": "il_NORMALIZED00000000000001",+ "invoice_item": "ii_NORMALIZED00000000000001",+ "livemode": false,+ "metadata": {},+ "object": "line_item",+ "period": {+ "end": 1357095845,+ "start": 1325473445+ },+ "plan": null,+ "price": {+ "active": false,+ "billing_scheme": "per_unit",+ "created": 1000000000,+ "currency": "usd",+ "custom_unit_amount": null,+ "id": "price_NORMALIZED00000000000001",+ "livemode": false,+ "lookup_key": null,+ "metadata": {},+ "nickname": null,+ "object": "price",+ "product": "prod_NORMALIZED0001",+ "recurring": null,+ "tax_behavior": "unspecified",+ "tiers_mode": null,+ "transform_quantity": null,+ "type": "one_time",+ "unit_amount": 8000,+ "unit_amount_decimal": "8000"+ },+ "proration": false,+ "proration_details": {+ "credited_items": null+ },+ "quantity": 6,+ "subscription": null,+ "tax_amounts": [],+ "tax_rates": [],+ "type": "invoiceitem",+ "unit_amount_excluding_tax": "8000"+ },+ {+ "amount": -48000,+ "amount_excluding_tax": -48000,+ "currency": "usd",+ "description": "Payment (Card ending in 4242)",+ "discount_amounts": [],+ "discountable": false,+ "discounts": [],+ "id": "il_NORMALIZED00000000000002",+ "invoice_item": "ii_NORMALIZED00000000000002",+ "livemode": false,+ "metadata": {},+ "object": "line_item",+ "period": {+ "end": 1000000000,+ "start": 1000000000+ },+ "plan": null,+ "price": {+ "active": false,+ "billing_scheme": "per_unit",+ "created": 1000000000,+ "currency": "usd",+ "custom_unit_amount": null,+ "id": "price_NORMALIZED00000000000002",+ "livemode": false,+ "lookup_key": null,+ "metadata": {},+ "nickname": null,+ "object": "price",+ "product": "prod_NORMALIZED0002",+ "recurring": null,+ "tax_behavior": "unspecified",+ "tiers_mode": null,+ "transform_quantity": null,+ "type": "one_time",+ "unit_amount": -48000,+ "unit_amount_decimal": "-48000"+ },+ "proration": false,+ "proration_details": {+ "credited_items": null+ },+ "quantity": 1,+ "subscription": null,+ "tax_amounts": [],+ "tax_rates": [],+ "type": "invoiceitem",+ "unit_amount_excluding_tax": "-48000"+ }+ ],+ "has_more": false,+ "object": "list",+ "total_count": 2,+ "url": "/v1/invoices/in_NORMALIZED00000000000001/lines"+ },+ "livemode": false,+ "metadata": {},+ "next_payment_attempt": null,+ "number": "NORMALI-0002",+ "object": "invoice",+ "on_behalf_of": null,+ "paid": true,+ "paid_out_of_band": false,+ "payment_intent": null,+ "payment_settings": {+ "default_mandate": null,+ "payment_method_options": null,+ "payment_method_types": null+ },+ "period_end": 1000000000,+ "period_start": 1000000000,+ "post_payment_credit_notes_amount": 0,+ "pre_payment_credit_notes_amount": 0,+ "quote": null,+ "receipt_number": null,+ "rendering": {+ "amount_tax_display": null,+ "pdf": {+ "page_size": "letter"+ }+ },+ "rendering_options": null,+ "shipping_cost": null,+ "shipping_details": null,+ "starting_balance": 0,+ "statement_descriptor": "Zulip Cloud Standard",+ "status": "paid",+ "status_transitions": {+ "finalized_at": 1000000000,+ "marked_uncollectible_at": null,+ "paid_at": 1000000000,+ "voided_at": null+ },+ "subscription": null,+ "subscription_details": {+ "metadata": null+ },+ "subtotal": 0,+ "subtotal_excluding_tax": 0,+ "tax": null,+ "test_clock": null,+ "total": 0,+ "total_discount_amounts": [],+ "total_excluding_tax": 0,+ "total_tax_amounts": [],+ "transfer_data": null,+ "webhooks_delivered_at": 1000000000+ }+ ],+ "has_more": false,+ "object": "list",+ "url": "/v1/invoices"+}diff --git a/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Invoice.list.3.json b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Invoice.list.3.jsonnew file mode 100644index 00000000000..5bfe08a9e08--- /dev/null+++ b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--Invoice.list.3.json@@ -0,0 +1,581 @@+{+ "data": [+ {+ "account_country": "US",+ "account_name": "Kandra Labs, Inc.",+ "account_tax_ids": null,+ "amount_due": 20000,+ "amount_paid": 0,+ "amount_remaining": 20000,+ "amount_shipping": 0,+ "application": null,+ "application_fee_amount": null,+ "attempt_count": 0,+ "attempted": false,+ "auto_advance": true,+ "automatic_tax": {+ "enabled": false,+ "status": null+ },+ "billing_reason": "manual",+ "charge": null,+ "collection_method": "charge_automatically",+ "created": 1000000000,+ "currency": "usd",+ "custom_fields": null,+ "customer": "cus_NORMALIZED0001",+ "customer_address": null,+ "customer_email": "[email protected]",+ "customer_name": null,+ "customer_phone": null,+ "customer_shipping": null,+ "customer_tax_exempt": "none",+ "customer_tax_ids": [],+ "default_payment_method": null,+ "default_source": null,+ "default_tax_rates": [],+ "description": null,+ "discount": null,+ "discounts": [],+ "due_date": null,+ "effective_at": 1000000000,+ "ending_balance": 0,+ "footer": null,+ "from_invoice": null,+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/test_NORMALIZED01a3dERVFhcm9xRGpzLF9QMnZ4RzNVRW5JU0tjTzZlN3p3c01xamV2eUY1MEYwLDkxMDk5MDgx0200VEq1S4LP?s=ap",+ "id": "in_NORMALIZED00000000000003",+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/test_NORMALIZED01a3dERVFhcm9xRGpzLF9QMnZ4RzNVRW5JU0tjTzZlN3p3c01xamV2eUY1MEYwLDkxMDk5MDgx0200VEq1S4LP/pdf?s=ap",+ "last_finalization_error": null,+ "latest_revision": null,+ "lines": {+ "data": [+ {+ "amount": 20000,+ "amount_excluding_tax": 20000,+ "currency": "usd",+ "description": "Zulip Cloud Standard - renewal",+ "discount_amounts": [],+ "discountable": false,+ "discounts": [],+ "id": "il_NORMALIZED00000000000005",+ "invoice_item": "ii_NORMALIZED00000000000005",+ "livemode": false,+ "metadata": {},+ "object": "line_item",+ "period": {+ "end": 1359774245,+ "start": 1357095845+ },+ "plan": null,+ "price": {+ "active": false,+ "billing_scheme": "per_unit",+ "created": 1000000000,+ "currency": "usd",+ "custom_unit_amount": null,+ "id": "price_NORMALIZED00000000000005",+ "livemode": false,+ "lookup_key": null,+ "metadata": {},+ "nickname": null,+ "object": "price",+ "product": "prod_NORMALIZED0005",+ "recurring": null,+ "tax_behavior": "unspecified",+ "tiers_mode": null,+ "transform_quantity": null,+ "type": "one_time",+ "unit_amount": 800,+ "unit_amount_decimal": "800"+ },+ "proration": false,+ "proration_details": {+ "credited_items": null+ },+ "quantity": 25,+ "subscription": null,+ "tax_amounts": [],+ "tax_rates": [],+ "type": "invoiceitem",+ "unit_amount_excluding_tax": "800"+ }+ ],+ "has_more": false,+ "object": "list",+ "total_count": 1,+ "url": "/v1/invoices/in_NORMALIZED00000000000003/lines"+ },+ "livemode": false,+ "metadata": {},+ "next_payment_attempt": 1000000000,+ "number": "NORMALI-0004",+ "object": "invoice",+ "on_behalf_of": null,+ "paid": false,+ "paid_out_of_band": false,+ "payment_intent": "pi_NORMALIZED00000000000003",+ "payment_settings": {+ "default_mandate": null,+ "payment_method_options": null,+ "payment_method_types": null+ },+ "period_end": 1000000000,+ "period_start": 1000000000,+ "post_payment_credit_notes_amount": 0,+ "pre_payment_credit_notes_amount": 0,+ "quote": null,+ "receipt_number": null,+ "rendering": {+ "amount_tax_display": null,+ "pdf": {+ "page_size": "letter"+ }+ },+ "rendering_options": null,+ "shipping_cost": null,+ "shipping_details": null,+ "starting_balance": 0,+ "statement_descriptor": "Zulip Cloud Standard",+ "status": "open",+ "status_transitions": {+ "finalized_at": 1000000000,+ "marked_uncollectible_at": null,+ "paid_at": null,+ "voided_at": null+ },+ "subscription": null,+ "subscription_details": {+ "metadata": null+ },+ "subtotal": 20000,+ "subtotal_excluding_tax": 20000,+ "tax": null,+ "test_clock": null,+ "total": 20000,+ "total_discount_amounts": [],+ "total_excluding_tax": 20000,+ "total_tax_amounts": [],+ "transfer_data": null,+ "webhooks_delivered_at": null+ },+ {+ "account_country": "US",+ "account_name": "Kandra Labs, Inc.",+ "account_tax_ids": null,+ "amount_due": 148610,+ "amount_paid": 0,+ "amount_remaining": 148610,+ "amount_shipping": 0,+ "application": null,+ "application_fee_amount": null,+ "attempt_count": 0,+ "attempted": false,+ "auto_advance": true,+ "automatic_tax": {+ "enabled": false,+ "status": null+ },+ "billing_reason": "manual",+ "charge": null,+ "collection_method": "charge_automatically",+ "created": 1000000000,+ "currency": "usd",+ "custom_fields": null,+ "customer": "cus_NORMALIZED0001",+ "customer_address": null,+ "customer_email": "[email protected]",+ "customer_name": null,+ "customer_phone": null,+ "customer_shipping": null,+ "customer_tax_exempt": "none",+ "customer_tax_ids": [],+ "default_payment_method": null,+ "default_source": null,+ "default_tax_rates": [],+ "description": null,+ "discount": null,+ "discounts": [],+ "due_date": null,+ "effective_at": 1000000000,+ "ending_balance": 0,+ "footer": null,+ "from_invoice": null,+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/test_NORMALIZED01a3dERVFhcm9xRGpzLF9QMnZ4TVRnMVNhSVpXMkhQaHcxTmxQZHB5Y2J1cmppLDkxMDk5MDgx02006df2r3u7?s=ap",+ "id": "in_NORMALIZED00000000000002",+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/test_NORMALIZED01a3dERVFhcm9xRGpzLF9QMnZ4TVRnMVNhSVpXMkhQaHcxTmxQZHB5Y2J1cmppLDkxMDk5MDgx02006df2r3u7/pdf?s=ap",+ "last_finalization_error": null,+ "latest_revision": null,+ "lines": {+ "data": [+ {+ "amount": 36610,+ "amount_excluding_tax": 36610,+ "currency": "usd",+ "description": "Additional license (Feb 2, 2012 - Jan 2, 2013)",+ "discount_amounts": [],+ "discountable": false,+ "discounts": [],+ "id": "il_NORMALIZED00000000000003",+ "invoice_item": "ii_NORMALIZED00000000000003",+ "livemode": false,+ "metadata": {},+ "object": "line_item",+ "period": {+ "end": 1357095845,+ "start": 1328151845+ },+ "plan": null,+ "price": {+ "active": false,+ "billing_scheme": "per_unit",+ "created": 1000000000,+ "currency": "usd",+ "custom_unit_amount": null,+ "id": "price_NORMALIZED00000000000003",+ "livemode": false,+ "lookup_key": null,+ "metadata": {},+ "nickname": null,+ "object": "price",+ "product": "prod_NORMALIZED0003",+ "recurring": null,+ "tax_behavior": "unspecified",+ "tiers_mode": null,+ "transform_quantity": null,+ "type": "one_time",+ "unit_amount": 7322,+ "unit_amount_decimal": "7322"+ },+ "proration": false,+ "proration_details": {+ "credited_items": null+ },+ "quantity": 5,+ "subscription": null,+ "tax_amounts": [],+ "tax_rates": [],+ "type": "invoiceitem",+ "unit_amount_excluding_tax": "7322"+ },+ {+ "amount": 112000,+ "amount_excluding_tax": 112000,+ "currency": "usd",+ "description": "Additional license (Jan 2, 2012 - Jan 2, 2013)",+ "discount_amounts": [],+ "discountable": false,+ "discounts": [],+ "id": "il_NORMALIZED00000000000004",+ "invoice_item": "ii_NORMALIZED00000000000004",+ "livemode": false,+ "metadata": {},+ "object": "line_item",+ "period": {+ "end": 1357095845,+ "start": 1325473445+ },+ "plan": null,+ "price": {+ "active": false,+ "billing_scheme": "per_unit",+ "created": 1000000000,+ "currency": "usd",+ "custom_unit_amount": null,+ "id": "price_NORMALIZED00000000000004",+ "livemode": false,+ "lookup_key": null,+ "metadata": {},+ "nickname": null,+ "object": "price",+ "product": "prod_NORMALIZED0004",+ "recurring": null,+ "tax_behavior": "unspecified",+ "tiers_mode": null,+ "transform_quantity": null,+ "type": "one_time",+ "unit_amount": 8000,+ "unit_amount_decimal": "8000"+ },+ "proration": false,+ "proration_details": {+ "credited_items": null+ },+ "quantity": 14,+ "subscription": null,+ "tax_amounts": [],+ "tax_rates": [],+ "type": "invoiceitem",+ "unit_amount_excluding_tax": "8000"+ }+ ],+ "has_more": false,+ "object": "list",+ "total_count": 2,+ "url": "/v1/invoices/in_NORMALIZED00000000000002/lines"+ },+ "livemode": false,+ "metadata": {},+ "next_payment_attempt": 1000000000,+ "number": "NORMALI-0003",+ "object": "invoice",+ "on_behalf_of": null,+ "paid": false,+ "paid_out_of_band": false,+ "payment_intent": "pi_NORMALIZED00000000000002",+ "payment_settings": {+ "default_mandate": null,+ "payment_method_options": null,+ "payment_method_types": null+ },+ "period_end": 1000000000,+ "period_start": 1000000000,+ "post_payment_credit_notes_amount": 0,+ "pre_payment_credit_notes_amount": 0,+ "quote": null,+ "receipt_number": null,+ "rendering": {+ "amount_tax_display": null,+ "pdf": {+ "page_size": "letter"+ }+ },+ "rendering_options": null,+ "shipping_cost": null,+ "shipping_details": null,+ "starting_balance": 0,+ "statement_descriptor": "Zulip Cloud Standard",+ "status": "open",+ "status_transitions": {+ "finalized_at": 1000000000,+ "marked_uncollectible_at": null,+ "paid_at": null,+ "voided_at": null+ },+ "subscription": null,+ "subscription_details": {+ "metadata": null+ },+ "subtotal": 148610,+ "subtotal_excluding_tax": 148610,+ "tax": null,+ "test_clock": null,+ "total": 148610,+ "total_discount_amounts": [],+ "total_excluding_tax": 148610,+ "total_tax_amounts": [],+ "transfer_data": null,+ "webhooks_delivered_at": 1000000000+ },+ {+ "account_country": "US",+ "account_name": "Kandra Labs, Inc.",+ "account_tax_ids": null,+ "amount_due": 0,+ "amount_paid": 0,+ "amount_remaining": 0,+ "amount_shipping": 0,+ "application": null,+ "application_fee_amount": null,+ "attempt_count": 0,+ "attempted": true,+ "auto_advance": false,+ "automatic_tax": {+ "enabled": false,+ "status": null+ },+ "billing_reason": "manual",+ "charge": null,+ "collection_method": "charge_automatically",+ "created": 1000000000,+ "currency": "usd",+ "custom_fields": null,+ "customer": "cus_NORMALIZED0001",+ "customer_address": null,+ "customer_email": "[email protected]",+ "customer_name": null,+ "customer_phone": null,+ "customer_shipping": null,+ "customer_tax_exempt": "none",+ "customer_tax_ids": [],+ "default_payment_method": null,+ "default_source": null,+ "default_tax_rates": [],+ "description": null,+ "discount": null,+ "discounts": [],+ "due_date": null,+ "effective_at": 1000000000,+ "ending_balance": 0,+ "footer": null,+ "from_invoice": null,+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/test_NORMALIZED01a3dERVFhcm9xRGpzLF9QMnZ4UWJoMFB1eExidGNGWUQyNEtmR2h3dGU0MUNwLDkxMDk5MDgx0200pWIilkBy?s=ap",+ "id": "in_NORMALIZED00000000000001",+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/test_NORMALIZED01a3dERVFhcm9xRGpzLF9QMnZ4UWJoMFB1eExidGNGWUQyNEtmR2h3dGU0MUNwLDkxMDk5MDgx0200pWIilkBy/pdf?s=ap",+ "last_finalization_error": null,+ "latest_revision": null,+ "lines": {+ "data": [+ {+ "amount": 48000,+ "amount_excluding_tax": 48000,+ "currency": "usd",+ "description": "Zulip Cloud Standard",+ "discount_amounts": [],+ "discountable": false,+ "discounts": [],+ "id": "il_NORMALIZED00000000000001",+ "invoice_item": "ii_NORMALIZED00000000000001",+ "livemode": false,+ "metadata": {},+ "object": "line_item",+ "period": {+ "end": 1357095845,+ "start": 1325473445+ },+ "plan": null,+ "price": {+ "active": false,+ "billing_scheme": "per_unit",+ "created": 1000000000,+ "currency": "usd",+ "custom_unit_amount": null,+ "id": "price_NORMALIZED00000000000001",+ "livemode": false,+ "lookup_key": null,+ "metadata": {},+ "nickname": null,+ "object": "price",+ "product": "prod_NORMALIZED0001",+ "recurring": null,+ "tax_behavior": "unspecified",+ "tiers_mode": null,+ "transform_quantity": null,+ "type": "one_time",+ "unit_amount": 8000,+ "unit_amount_decimal": "8000"+ },+ "proration": false,+ "proration_details": {+ "credited_items": null+ },+ "quantity": 6,+ "subscription": null,+ "tax_amounts": [],+ "tax_rates": [],+ "type": "invoiceitem",+ "unit_amount_excluding_tax": "8000"+ },+ {+ "amount": -48000,+ "amount_excluding_tax": -48000,+ "currency": "usd",+ "description": "Payment (Card ending in 4242)",+ "discount_amounts": [],+ "discountable": false,+ "discounts": [],+ "id": "il_NORMALIZED00000000000002",+ "invoice_item": "ii_NORMALIZED00000000000002",+ "livemode": false,+ "metadata": {},+ "object": "line_item",+ "period": {+ "end": 1000000000,+ "start": 1000000000+ },+ "plan": null,+ "price": {+ "active": false,+ "billing_scheme": "per_unit",+ "created": 1000000000,+ "currency": "usd",+ "custom_unit_amount": null,+ "id": "price_NORMALIZED00000000000002",+ "livemode": false,+ "lookup_key": null,+ "metadata": {},+ "nickname": null,+ "object": "price",+ "product": "prod_NORMALIZED0002",+ "recurring": null,+ "tax_behavior": "unspecified",+ "tiers_mode": null,+ "transform_quantity": null,+ "type": "one_time",+ "unit_amount": -48000,+ "unit_amount_decimal": "-48000"+ },+ "proration": false,+ "proration_details": {+ "credited_items": null+ },+ "quantity": 1,+ "subscription": null,+ "tax_amounts": [],+ "tax_rates": [],+ "type": "invoiceitem",+ "unit_amount_excluding_tax": "-48000"+ }+ ],+ "has_more": false,+ "object": "list",+ "total_count": 2,+ "url": "/v1/invoices/in_NORMALIZED00000000000001/lines"+ },+ "livemode": false,+ "metadata": {},+ "next_payment_attempt": null,+ "number": "NORMALI-0002",+ "object": "invoice",+ "on_behalf_of": null,+ "paid": true,+ "paid_out_of_band": false,+ "payment_intent": null,+ "payment_settings": {+ "default_mandate": null,+ "payment_method_options": null,+ "payment_method_types": null+ },+ "period_end": 1000000000,+ "period_start": 1000000000,+ "post_payment_credit_notes_amount": 0,+ "pre_payment_credit_notes_amount": 0,+ "quote": null,+ "receipt_number": null,+ "rendering": {+ "amount_tax_display": null,+ "pdf": {+ "page_size": "letter"+ }+ },+ "rendering_options": null,+ "shipping_cost": null,+ "shipping_details": null,+ "starting_balance": 0,+ "statement_descriptor": "Zulip Cloud Standard",+ "status": "paid",+ "status_transitions": {+ "finalized_at": 1000000000,+ "marked_uncollectible_at": null,+ "paid_at": 1000000000,+ "voided_at": null+ },+ "subscription": null,+ "subscription_details": {+ "metadata": null+ },+ "subtotal": 0,+ "subtotal_excluding_tax": 0,+ "tax": null,+ "test_clock": null,+ "total": 0,+ "total_discount_amounts": [],+ "total_excluding_tax": 0,+ "total_tax_amounts": [],+ "transfer_data": null,+ "webhooks_delivered_at": 1000000000+ }+ ],+ "has_more": false,+ "object": "list",+ "url": "/v1/invoices"+}diff --git a/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--InvoiceItem.create.1.json b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--InvoiceItem.create.1.jsonnew file mode 100644index 00000000000..fcb1c3c2e9d--- /dev/null+++ b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--InvoiceItem.create.1.json@@ -0,0 +1,47 @@+{+ "amount": -48000,+ "currency": "usd",+ "customer": "cus_NORMALIZED0001",+ "date": 1000000000,+ "description": "Payment (Card ending in 4242)",+ "discountable": false,+ "discounts": [],+ "id": "ii_NORMALIZED00000000000002",+ "invoice": null,+ "livemode": false,+ "metadata": {},+ "object": "invoiceitem",+ "period": {+ "end": 1000000000,+ "start": 1000000000+ },+ "plan": null,+ "price": {+ "active": false,+ "billing_scheme": "per_unit",+ "created": 1000000000,+ "currency": "usd",+ "custom_unit_amount": null,+ "id": "price_NORMALIZED00000000000002",+ "livemode": false,+ "lookup_key": null,+ "metadata": {},+ "nickname": null,+ "object": "price",+ "product": "prod_NORMALIZED0002",+ "recurring": null,+ "tax_behavior": "unspecified",+ "tiers_mode": null,+ "transform_quantity": null,+ "type": "one_time",+ "unit_amount": -48000,+ "unit_amount_decimal": "-48000"+ },+ "proration": false,+ "quantity": 1,+ "subscription": null,+ "tax_rates": [],+ "test_clock": null,+ "unit_amount": -48000,+ "unit_amount_decimal": "-48000"+}diff --git a/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--InvoiceItem.create.2.json b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--InvoiceItem.create.2.jsonnew file mode 100644index 00000000000..11622f30a73--- /dev/null+++ b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--InvoiceItem.create.2.json@@ -0,0 +1,47 @@+{+ "amount": 48000,+ "currency": "usd",+ "customer": "cus_NORMALIZED0001",+ "date": 1000000000,+ "description": "Zulip Cloud Standard",+ "discountable": false,+ "discounts": [],+ "id": "ii_NORMALIZED00000000000001",+ "invoice": null,+ "livemode": false,+ "metadata": {},+ "object": "invoiceitem",+ "period": {+ "end": 1357095845,+ "start": 1325473445+ },+ "plan": null,+ "price": {+ "active": false,+ "billing_scheme": "per_unit",+ "created": 1000000000,+ "currency": "usd",+ "custom_unit_amount": null,+ "id": "price_NORMALIZED00000000000001",+ "livemode": false,+ "lookup_key": null,+ "metadata": {},+ "nickname": null,+ "object": "price",+ "product": "prod_NORMALIZED0001",+ "recurring": null,+ "tax_behavior": "unspecified",+ "tiers_mode": null,+ "transform_quantity": null,+ "type": "one_time",+ "unit_amount": 8000,+ "unit_amount_decimal": "8000"+ },+ "proration": false,+ "quantity": 6,+ "subscription": null,+ "tax_rates": [],+ "test_clock": null,+ "unit_amount": 8000,+ "unit_amount_decimal": "8000"+}diff --git a/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--InvoiceItem.create.3.json b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--InvoiceItem.create.3.jsonnew file mode 100644index 00000000000..088916fb64e--- /dev/null+++ b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--InvoiceItem.create.3.json@@ -0,0 +1,47 @@+{+ "amount": 112000,+ "currency": "usd",+ "customer": "cus_NORMALIZED0001",+ "date": 1000000000,+ "description": "Additional license (Jan 2, 2012 - Jan 2, 2013)",+ "discountable": false,+ "discounts": [],+ "id": "ii_NORMALIZED00000000000004",+ "invoice": null,+ "livemode": false,+ "metadata": {},+ "object": "invoiceitem",+ "period": {+ "end": 1357095845,+ "start": 1325473445+ },+ "plan": null,+ "price": {+ "active": false,+ "billing_scheme": "per_unit",+ "created": 1000000000,+ "currency": "usd",+ "custom_unit_amount": null,+ "id": "price_NORMALIZED00000000000004",+ "livemode": false,+ "lookup_key": null,+ "metadata": {},+ "nickname": null,+ "object": "price",+ "product": "prod_NORMALIZED0004",+ "recurring": null,+ "tax_behavior": "unspecified",+ "tiers_mode": null,+ "transform_quantity": null,+ "type": "one_time",+ "unit_amount": 8000,+ "unit_amount_decimal": "8000"+ },+ "proration": false,+ "quantity": 14,+ "subscription": null,+ "tax_rates": [],+ "test_clock": null,+ "unit_amount": 8000,+ "unit_amount_decimal": "8000"+}diff --git a/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--InvoiceItem.create.4.json b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--InvoiceItem.create.4.jsonnew file mode 100644index 00000000000..6f22f400450--- /dev/null+++ b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--InvoiceItem.create.4.json@@ -0,0 +1,47 @@+{+ "amount": 36610,+ "currency": "usd",+ "customer": "cus_NORMALIZED0001",+ "date": 1000000000,+ "description": "Additional license (Feb 2, 2012 - Jan 2, 2013)",+ "discountable": false,+ "discounts": [],+ "id": "ii_NORMALIZED00000000000003",+ "invoice": null,+ "livemode": false,+ "metadata": {},+ "object": "invoiceitem",+ "period": {+ "end": 1357095845,+ "start": 1328151845+ },+ "plan": null,+ "price": {+ "active": false,+ "billing_scheme": "per_unit",+ "created": 1000000000,+ "currency": "usd",+ "custom_unit_amount": null,+ "id": "price_NORMALIZED00000000000003",+ "livemode": false,+ "lookup_key": null,+ "metadata": {},+ "nickname": null,+ "object": "price",+ "product": "prod_NORMALIZED0003",+ "recurring": null,+ "tax_behavior": "unspecified",+ "tiers_mode": null,+ "transform_quantity": null,+ "type": "one_time",+ "unit_amount": 7322,+ "unit_amount_decimal": "7322"+ },+ "proration": false,+ "quantity": 5,+ "subscription": null,+ "tax_rates": [],+ "test_clock": null,+ "unit_amount": 7322,+ "unit_amount_decimal": "7322"+}diff --git a/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--InvoiceItem.create.5.json b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--InvoiceItem.create.5.jsonnew file mode 100644index 00000000000..05b0e1fc5f5--- /dev/null+++ b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--InvoiceItem.create.5.json@@ -0,0 +1,47 @@+{+ "amount": 20000,+ "currency": "usd",+ "customer": "cus_NORMALIZED0001",+ "date": 1000000000,+ "description": "Zulip Cloud Standard - renewal",+ "discountable": false,+ "discounts": [],+ "id": "ii_NORMALIZED00000000000005",+ "invoice": null,+ "livemode": false,+ "metadata": {},+ "object": "invoiceitem",+ "period": {+ "end": 1359774245,+ "start": 1357095845+ },+ "plan": null,+ "price": {+ "active": false,+ "billing_scheme": "per_unit",+ "created": 1000000000,+ "currency": "usd",+ "custom_unit_amount": null,+ "id": "price_NORMALIZED00000000000005",+ "livemode": false,+ "lookup_key": null,+ "metadata": {},+ "nickname": null,+ "object": "price",+ "product": "prod_NORMALIZED0005",+ "recurring": null,+ "tax_behavior": "unspecified",+ "tiers_mode": null,+ "transform_quantity": null,+ "type": "one_time",+ "unit_amount": 800,+ "unit_amount_decimal": "800"+ },+ "proration": false,+ "quantity": 25,+ "subscription": null,+ "tax_rates": [],+ "test_clock": null,+ "unit_amount": 800,+ "unit_amount_decimal": "800"+}diff --git a/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--PaymentIntent.create.1.json b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--PaymentIntent.create.1.jsonnew file mode 100644index 00000000000..aadf902f017--- /dev/null+++ b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--PaymentIntent.create.1.json@@ -0,0 +1,197 @@+{+ "amount": 48000,+ "amount_capturable": 0,+ "amount_details": {+ "tip": {}+ },+ "amount_received": 48000,+ "application": null,+ "application_fee_amount": null,+ "automatic_payment_methods": null,+ "canceled_at": null,+ "cancellation_reason": null,+ "capture_method": "automatic",+ "charges": {+ "data": [+ {+ "amount": 48000,+ "amount_captured": 48000,+ "amount_refunded": 0,+ "application": null,+ "application_fee": null,+ "application_fee_amount": null,+ "balance_transaction": "txn_NORMALIZED00000000000001",+ "billing_details": {+ "address": {+ "city": null,+ "country": null,+ "line1": null,+ "line2": null,+ "postal_code": null,+ "state": null+ },+ "email": null,+ "name": null,+ "phone": null+ },+ "calculated_statement_descriptor": "ZULIP CLOUD STANDARD",+ "captured": true,+ "created": 1000000000,+ "currency": "usd",+ "customer": "cus_NORMALIZED0001",+ "description": "Upgrade to Zulip Cloud Standard, $80.0 x 6",+ "destination": null,+ "dispute": null,+ "disputed": false,+ "failure_balance_transaction": null,+ "failure_code": null,+ "failure_message": null,+ "fraud_details": {},+ "id": "ch_NORMALIZED00000000000001",+ "invoice": null,+ "livemode": false,+ "metadata": {+ "billing_modality": "charge_automatically",+ "billing_schedule": "1",+ "license_management": "automatic",+ "licenses": "6",+ "price_per_license": "8000",+ "realm_id": "1",+ "realm_str": "zulip",+ "seat_count": "6",+ "type": "upgrade",+ "user_email": "[email protected]",+ "user_id": "10"+ },+ "object": "charge",+ "on_behalf_of": null,+ "order": null,+ "outcome": {+ "network_status": "approved_by_network",+ "reason": null,+ "risk_level": "normal",+ "risk_score": 0,+ "seller_message": "Payment complete.",+ "type": "authorized"+ },+ "paid": true,+ "payment_intent": "pi_NORMALIZED00000000000001",+ "payment_method": "pm_1OEq5XDEQaroqDjsE08QDOEc",+ "payment_method_details": {+ "card": {+ "amount_authorized": 48000,+ "brand": "visa",+ "checks": {+ "address_line1_check": null,+ "address_postal_code_check": null,+ "cvc_check": "pass"+ },+ "country": "US",+ "exp_month": 11,+ "exp_year": 2024,+ "extended_authorization": {+ "status": "disabled"+ },+ "fingerprint": "NORMALIZED000001",+ "funding": "credit",+ "incremental_authorization": {+ "status": "unavailable"+ },+ "installments": null,+ "last4": "4242",+ "mandate": null,+ "multicapture": {+ "status": "unavailable"+ },+ "network": "visa",+ "network_token": {+ "used": false+ },+ "overcapture": {+ "maximum_amount_capturable": 48000,+ "status": "unavailable"+ },+ "three_d_secure": null,+ "wallet": null+ },+ "type": "card"+ },+ "receipt_email": "[email protected]",+ "receipt_number": null,+ "receipt_url": "https://pay.stripe.com/receipts/payment/CAcaFwoVYWNjdF8xN3ZUa3dERVFhcm9xRGpzKMDr8aoGMgZX-VtV8qk6LBbqZ2JFr-lHqLsmMn3R_0CVwuzI1a_3jAEMtfuRBPK0TnOp4pzU76tE-Ve9",+ "refunded": false,+ "refunds": {+ "data": [],+ "has_more": false,+ "object": "list",+ "total_count": 0,+ "url": "/v1/charges/ch_NORMALIZED00000000000001/refunds"+ },+ "review": null,+ "shipping": null,+ "source": null,+ "source_transfer": null,+ "statement_descriptor": "Zulip Cloud Standard",+ "statement_descriptor_suffix": null,+ "status": "succeeded",+ "transfer_data": null,+ "transfer_group": null+ }+ ],+ "has_more": false,+ "object": "list",+ "total_count": 1,+ "url": "/v1/charges?payment_intent=pi_NORMALIZED00000000000001"+ },+ "client_secret": "pi_NORMALIZED00000000000001_secret_eYLA3D7ohAqPQ59UJVTA8WDnu",+ "confirmation_method": "automatic",+ "created": 1000000000,+ "currency": "usd",+ "customer": "cus_NORMALIZED0001",+ "description": "Upgrade to Zulip Cloud Standard, $80.0 x 6",+ "id": "pi_NORMALIZED00000000000001",+ "invoice": null,+ "last_payment_error": null,+ "latest_charge": "ch_NORMALIZED00000000000001",+ "livemode": false,+ "metadata": {+ "billing_modality": "charge_automatically",+ "billing_schedule": "1",+ "license_management": "automatic",+ "licenses": "6",+ "price_per_license": "8000",+ "realm_id": "1",+ "realm_str": "zulip",+ "seat_count": "6",+ "type": "upgrade",+ "user_email": "[email protected]",+ "user_id": "10"+ },+ "next_action": null,+ "object": "payment_intent",+ "on_behalf_of": null,+ "payment_method": "pm_1OEq5XDEQaroqDjsE08QDOEc",+ "payment_method_configuration_details": null,+ "payment_method_options": {+ "card": {+ "installments": null,+ "mandate_options": null,+ "network": null,+ "request_three_d_secure": "automatic"+ }+ },+ "payment_method_types": [+ "card"+ ],+ "processing": null,+ "receipt_email": "[email protected]",+ "review": null,+ "setup_future_usage": null,+ "shipping": null,+ "source": null,+ "statement_descriptor": "Zulip Cloud Standard",+ "statement_descriptor_suffix": null,+ "status": "succeeded",+ "transfer_data": null,+ "transfer_group": null+}diff --git a/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--SetupIntent.create.1.json b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--SetupIntent.create.1.jsonnew file mode 100644index 00000000000..04376403a93--- /dev/null+++ b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--SetupIntent.create.1.json@@ -0,0 +1,34 @@+{+ "application": null,+ "automatic_payment_methods": null,+ "cancellation_reason": null,+ "client_secret": "seti_1OEq5XDEQaroqDjsUeY9FWcB_secret_P2vxdMaLDhloDAZ6R9CQYmf9Wn4rta9",+ "created": 1000000000,+ "customer": "cus_NORMALIZED0001",+ "description": null,+ "flow_directions": null,+ "id": "seti_1OEq5XDEQaroqDjsUeY9FWcB",+ "last_setup_error": null,+ "latest_attempt": "setatt_1OEq5XDEQaroqDjsMkLMpQq4",+ "livemode": false,+ "mandate": null,+ "metadata": {},+ "next_action": null,+ "object": "setup_intent",+ "on_behalf_of": null,+ "payment_method": "pm_1OEq5XDEQaroqDjsE08QDOEc",+ "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/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--SetupIntent.list.1.json b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--SetupIntent.list.1.jsonnew file mode 100644index 00000000000..9bb3dfa0ce1--- /dev/null+++ b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--SetupIntent.list.1.json@@ -0,0 +1,41 @@+{+ "data": [+ {+ "application": null,+ "automatic_payment_methods": null,+ "cancellation_reason": null,+ "client_secret": "seti_1OEq5VDEQaroqDjsoY8XRUGD_secret_P2vx6Ki0b4ZE2nqaPXVMyCIR0mjnbdD",+ "created": 1000000000,+ "customer": "cus_NORMALIZED0001",+ "description": null,+ "flow_directions": null,+ "id": "seti_1OEq5VDEQaroqDjsoY8XRUGD",+ "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/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--SetupIntent.retrieve.1.json b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--SetupIntent.retrieve.1.jsonnew file mode 100644index 00000000000..04376403a93--- /dev/null+++ b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--SetupIntent.retrieve.1.json@@ -0,0 +1,34 @@+{+ "application": null,+ "automatic_payment_methods": null,+ "cancellation_reason": null,+ "client_secret": "seti_1OEq5XDEQaroqDjsUeY9FWcB_secret_P2vxdMaLDhloDAZ6R9CQYmf9Wn4rta9",+ "created": 1000000000,+ "customer": "cus_NORMALIZED0001",+ "description": null,+ "flow_directions": null,+ "id": "seti_1OEq5XDEQaroqDjsUeY9FWcB",+ "last_setup_error": null,+ "latest_attempt": "setatt_1OEq5XDEQaroqDjsMkLMpQq4",+ "livemode": false,+ "mandate": null,+ "metadata": {},+ "next_action": null,+ "object": "setup_intent",+ "on_behalf_of": null,+ "payment_method": "pm_1OEq5XDEQaroqDjsE08QDOEc",+ "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/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--checkout.Session.create.1.json b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--checkout.Session.create.1.jsonnew file mode 100644index 00000000000..f9ff0972f7e--- /dev/null+++ b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--checkout.Session.create.1.json@@ -0,0 +1,73 @@+{+ "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://zulip.testserver/upgrade/",+ "client_reference_id": null,+ "client_secret": null,+ "consent": null,+ "consent_collection": null,+ "created": 1000000000,+ "currency": null,+ "currency_conversion": null,+ "custom_fields": [],+ "custom_text": {+ "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_NORMALIZED02uKgiSfXC8Ib0lLgV128tC4fA64VwFYaazOIyyZYKBtFwlI",+ "invoice": null,+ "invoice_creation": null,+ "livemode": false,+ "locale": null,+ "metadata": {+ "type": "card_update",+ "user_id": "10"+ },+ "mode": "setup",+ "object": "checkout.session",+ "payment_intent": null,+ "payment_link": null,+ "payment_method_collection": "always",+ "payment_method_configuration_details": null,+ "payment_method_options": {},+ "payment_method_types": [+ "card"+ ],+ "payment_status": "no_payment_required",+ "phone_number_collection": {+ "enabled": false+ },+ "recovered_from": null,+ "setup_intent": "seti_1OEq5VDEQaroqDjsoY8XRUGD",+ "shipping": null,+ "shipping_address_collection": null,+ "shipping_options": [],+ "shipping_rate": null,+ "status": "open",+ "submit_type": null,+ "subscription": null,+ "success_url": "http://zulip.testserver/billing/event_status?stripe_session_id={CHECKOUT_SESSION_ID}",+ "total_details": null,+ "ui_mode": "hosted",+ "url": "https://checkout.stripe.com/c/pay/cs_test_NORMALIZED02uKgiSfXC8Ib0lLgV128tC4fA64VwFYaazOIyyZYKBtFwlI#fidkdWxOYHwnPyd1blpxYHZxWl1UZjFOczZJXUE2PUpzUWNPV2ZpdlFzUCcpJ2N3amhWYHdzYHcnP3F3cGApJ2lkfGpwcVF8dWAnPyd2bGtiaWBaZmppcGhrJyknYGtkZ2lgVWlkZmBtamlhYHd2Jz9xd3BgeCUl"+}diff --git a/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--checkout.Session.list.1.json b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--checkout.Session.list.1.jsonnew file mode 100644index 00000000000..49eef5d590d--- /dev/null+++ b/corporate/tests/stripe_fixtures/switch_from_annual_plan_to_monthly_plan_for_automatic_license_management--checkout.Session.list.1.json@@ -0,0 +1,80 @@+{+ "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://zulip.testserver/upgrade/",+ "client_reference_id": null,+ "client_secret": null,+ "consent": null,+ "consent_collection": null,+ "created": 1000000000,+ "currency": null,+ "currency_conversion": null,+ "custom_fields": [],+ "custom_text": {+ "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_NORMALIZED02uKgiSfXC8Ib0lLgV128tC4fA64VwFYaazOIyyZYKBtFwlI",+ "invoice": null,+ "invoice_creation": null,+ "livemode": false,+ "locale": null,+ "metadata": {+ "type": "card_update",+ "user_id": "10"+ },+ "mode": "setup",+ "object": "checkout.session",+ "payment_intent": null,+ "payment_link": null,+ "payment_method_collection": "always",+ "payment_method_configuration_details": null,+ "payment_method_options": {},+ "payment_method_types": [+ "card"+ ],+ "payment_status": "no_payment_required",+ "phone_number_collection": {+ "enabled": false+ },+ "recovered_from": null,+ "setup_intent": "seti_1OEq5VDEQaroqDjsoY8XRUGD",+ "shipping": null,+ "shipping_address_collection": null,+ "shipping_options": [],+ "shipping_rate": null,+ "status": "open",+ "submit_type": null,+ "subscription": null,+ "success_url": "http://zulip.testserver/billing/event_status?stripe_session_id={CHECKOUT_SESSION_ID}",+ "total_details": null,+ "ui_mode": "hosted",+ "url": "https://checkout.stripe.com/c/pay/cs_test_NORMALIZED02uKgiSfXC8Ib0lLgV128tC4fA64VwFYaazOIyyZYKBtFwlI#fidkdWxOYHwnPyd1blpxYHZxWl1UZjFOczZJXUE2PUpzUWNPV2ZpdlFzUCcpJ2N3amhWYHdzYHcnP3F3cGApJ2lkfGpwcVF8dWAnPyd2bGtiaWBaZmppcGhrJyknYGtkZ2lgVWlkZmBtamlhYHd2Jz9xd3BgeCUl"+ }+ ],+ "has_more": true,+ "object": "list",+ "url": "/v1/checkout/sessions"+}diff --git a/corporate/tests/test_stripe.py b/corporate/tests/test_stripe.pyindex 7fbc9d992b3..5fb3dbf1625 100644--- a/corporate/tests/test_stripe.py+++ b/corporate/tests/test_stripe.py@@ -2628,6 +2628,182 @@ class StripeTest(StripeTestCase):for key, value in annual_plan_invoice_item_params.items():self.assertEqual(invoice_item[key], value)+ @mock_stripe()+ def test_switch_from_annual_plan_to_monthly_plan_for_automatic_license_management(+ self, *mocks: Mock+ ) -> None:+ user = self.example_user("hamlet")+ self.login_user(user)+ self.add_card_and_upgrade(user, schedule="annual")+ annual_plan = get_current_plan_by_realm(user.realm)+ assert annual_plan is not None+ self.assertEqual(annual_plan.automanage_licenses, True)+ self.assertEqual(annual_plan.billing_schedule, CustomerPlan.ANNUAL)++ stripe_customer_id = Customer.objects.get(realm=user.realm).id+ new_plan = get_current_plan_by_realm(user.realm)+ assert new_plan is not None++ with self.assertLogs("corporate.stripe", "INFO") as m:+ with patch("corporate.views.billing_page.timezone_now", return_value=self.now):+ response = self.client_patch(+ "/json/billing/plan",+ {"status": CustomerPlan.SWITCH_TO_MONTHLY_AT_END_OF_CYCLE},+ )+ expected_log = f"INFO:corporate.stripe:Change plan status: Customer.id: {stripe_customer_id}, CustomerPlan.id: {new_plan.id}, status: {CustomerPlan.SWITCH_TO_MONTHLY_AT_END_OF_CYCLE}"+ self.assertEqual(m.output[0], expected_log)+ self.assert_json_success(response)+ annual_plan.refresh_from_db()+ self.assertEqual(annual_plan.status, CustomerPlan.SWITCH_TO_MONTHLY_AT_END_OF_CYCLE)+ with patch("corporate.lib.stripe.timezone_now", return_value=self.now):+ response = self.client_get("/billing/")+ self.assert_in_success_response(+ ["Your plan will switch to monthly billing on January 2, 2013"], response+ )++ with patch("corporate.lib.stripe.get_latest_seat_count", return_value=20):+ update_license_ledger_if_needed(user.realm, self.now)+ self.assertEqual(LicenseLedger.objects.filter(plan=annual_plan).count(), 2)+ self.assertEqual(+ LicenseLedger.objects.order_by("-id")+ .values_list("licenses", "licenses_at_next_renewal")+ .first(),+ (20, 20),+ )++ # Check that we don't switch to monthly plan at next invoice date (which is used to charge user for+ # additional licenses) but at the end of current billing cycle.+ self.assertEqual(annual_plan.next_invoice_date, self.next_month)+ with patch("corporate.lib.stripe.timezone_now", return_value=annual_plan.next_invoice_date):+ with patch("corporate.lib.stripe.get_latest_seat_count", return_value=25):+ assert annual_plan.next_invoice_date is not None+ update_license_ledger_if_needed(user.realm, annual_plan.next_invoice_date)++ annual_plan.refresh_from_db()+ self.assertEqual(annual_plan.status, CustomerPlan.SWITCH_TO_MONTHLY_AT_END_OF_CYCLE)+ self.assertEqual(annual_plan.next_invoice_date, self.next_month)+ self.assertEqual(annual_plan.billing_schedule, CustomerPlan.ANNUAL)+ self.assertEqual(LicenseLedger.objects.filter(plan=annual_plan).count(), 3)++ invoice_plans_as_needed(self.next_month + timedelta(days=1))++ annual_plan.refresh_from_db()+ self.assertEqual(annual_plan.next_invoice_date, add_months(self.next_month, 1))+ self.assertEqual(annual_plan.invoicing_status, CustomerPlan.DONE)+ self.assertEqual(LicenseLedger.objects.filter(plan=annual_plan).count(), 3)++ customer = get_customer_by_realm(user.realm)+ assert customer is not None+ assert customer.stripe_customer_id+ [invoice0, invoice1] = iter(stripe.Invoice.list(customer=customer.stripe_customer_id))+ [invoice_item1, invoice_item2] = iter(invoice0.lines)+ annual_plan_invoice_item_params = {+ "amount": 7322 * 5,+ "description": "Additional license (Feb 2, 2012 - Jan 2, 2013)",+ "plan": None,+ "quantity": 5,+ "subscription": None,+ "discountable": False,+ "period": {+ "start": datetime_to_timestamp(self.next_month),+ "end": datetime_to_timestamp(self.next_year),+ },+ }++ for key, value in annual_plan_invoice_item_params.items():+ self.assertEqual(invoice_item1[key], value)++ annual_plan_invoice_item_params = {+ "amount": 14 * 80 * 1 * 100,+ "description": "Additional license (Jan 2, 2012 - Jan 2, 2013)",+ "plan": None,+ "quantity": 14,+ "subscription": None,+ "discountable": False,+ "period": {+ "start": datetime_to_timestamp(self.now),+ "end": datetime_to_timestamp(self.next_year),+ },+ }++ for key, value in annual_plan_invoice_item_params.items():+ self.assertEqual(invoice_item2[key], value)++ # Check that we switch to monthly plan at the end of current billing cycle.+ with patch("corporate.lib.stripe.timezone_now", return_value=self.next_year):+ with patch("corporate.lib.stripe.get_latest_seat_count", return_value=25):+ update_license_ledger_if_needed(user.realm, self.next_year)+ self.assertEqual(LicenseLedger.objects.filter(plan=annual_plan).count(), 3)+ customer = get_customer_by_realm(user.realm)+ assert customer is not None+ annual_plan.refresh_from_db()+ self.assertEqual(annual_plan.status, CustomerPlan.ENDED)+ self.assertEqual(annual_plan.next_invoice_date, add_months(self.next_month, 1))+ monthly_plan = get_current_plan_by_realm(user.realm)+ assert monthly_plan is not None+ self.assertEqual(monthly_plan.status, CustomerPlan.ACTIVE)+ self.assertEqual(monthly_plan.billing_schedule, CustomerPlan.MONTHLY)+ self.assertEqual(monthly_plan.invoicing_status, CustomerPlan.INITIAL_INVOICE_TO_BE_SENT)+ self.assertEqual(monthly_plan.billing_cycle_anchor, self.next_year)+ self.assertEqual(monthly_plan.next_invoice_date, self.next_year)+ self.assertEqual(monthly_plan.invoiced_through, None)+ monthly_ledger_entries = LicenseLedger.objects.filter(plan=monthly_plan).order_by("id")+ self.assert_length(monthly_ledger_entries, 2)+ self.assertEqual(monthly_ledger_entries[0].is_renewal, True)+ self.assertEqual(+ monthly_ledger_entries.values_list("licenses", "licenses_at_next_renewal")[0], (25, 25)+ )+ self.assertEqual(monthly_ledger_entries[1].is_renewal, False)+ self.assertEqual(+ monthly_ledger_entries.values_list("licenses", "licenses_at_next_renewal")[1], (25, 25)+ )+ audit_log = RealmAuditLog.objects.get(+ event_type=RealmAuditLog.CUSTOMER_SWITCHED_FROM_ANNUAL_TO_MONTHLY_PLAN+ )+ self.assertEqual(audit_log.realm, user.realm)+ self.assertEqual(audit_log.extra_data["annual_plan_id"], annual_plan.id)+ self.assertEqual(audit_log.extra_data["monthly_plan_id"], monthly_plan.id)++ invoice_plans_as_needed(self.next_year)++ monthly_ledger_entries = LicenseLedger.objects.filter(plan=monthly_plan).order_by("id")+ self.assert_length(monthly_ledger_entries, 2)+ monthly_plan.refresh_from_db()+ self.assertEqual(monthly_plan.invoicing_status, CustomerPlan.DONE)+ self.assertEqual(monthly_plan.invoiced_through, monthly_ledger_entries[1])+ self.assertEqual(monthly_plan.billing_cycle_anchor, self.next_year)+ self.assertEqual(monthly_plan.next_invoice_date, add_months(self.next_year, 1))+ annual_plan.refresh_from_db()+ self.assertEqual(annual_plan.next_invoice_date, None)++ assert customer.stripe_customer_id+ [invoice0, invoice1, invoice2] = iter(+ stripe.Invoice.list(customer=customer.stripe_customer_id)+ )++ [invoice_item0] = iter(invoice0.lines)++ monthly_plan_invoice_item_params = {+ "amount": 25 * 8 * 100,+ "description": "Zulip Cloud Standard - renewal",+ "plan": None,+ "quantity": 25,+ "subscription": None,+ "discountable": False,+ "period": {+ "start": datetime_to_timestamp(self.next_year),+ "end": datetime_to_timestamp(add_months(self.next_year, 1)),+ },+ }+ for key, value in monthly_plan_invoice_item_params.items():+ self.assertEqual(invoice_item0[key], value)++ with patch("corporate.lib.stripe.timezone_now", return_value=self.now):+ response = self.client_get("/billing/")+ self.assert_not_in_success_response(+ ["Your plan will switch to annual billing on February 2, 2012"], response+ )+def test_reupgrade_after_plan_status_changed_to_downgrade_at_end_of_cycle(self) -> None:user = self.example_user("hamlet")self.login_user(user)diff --git a/corporate/views/billing_page.py b/corporate/views/billing_page.pyindex 29b968808ef..4af5c24938f 100644--- a/corporate/views/billing_page.py+++ b/corporate/views/billing_page.py@@ -132,6 +132,7 @@ def update_plan(CustomerPlan.ACTIVE,CustomerPlan.DOWNGRADE_AT_END_OF_CYCLE,CustomerPlan.SWITCH_TO_ANNUAL_AT_END_OF_CYCLE,+ CustomerPlan.SWITCH_TO_MONTHLY_AT_END_OF_CYCLE,CustomerPlan.ENDED,]),@@ -160,14 +161,23 @@ def update_plan(if status is not None:if status == CustomerPlan.ACTIVE:- assert plan.status == CustomerPlan.DOWNGRADE_AT_END_OF_CYCLE+ assert plan.status < CustomerPlan.LIVE_STATUS_THRESHOLDdo_change_plan_status(plan, status)elif status == CustomerPlan.DOWNGRADE_AT_END_OF_CYCLE:- assert plan.status == CustomerPlan.ACTIVE+ assert plan.status < CustomerPlan.LIVE_STATUS_THRESHOLDdowngrade_at_the_end_of_billing_cycle(user.realm)elif status == CustomerPlan.SWITCH_TO_ANNUAL_AT_END_OF_CYCLE:assert plan.billing_schedule == CustomerPlan.MONTHLY- assert plan.status == CustomerPlan.ACTIVE+ assert plan.status < CustomerPlan.LIVE_STATUS_THRESHOLD+ # Customer needs to switch to an active plan first to avoid unexpected behavior.+ assert plan.status != CustomerPlan.DOWNGRADE_AT_END_OF_CYCLE+ assert plan.fixed_price is None+ do_change_plan_status(plan, status)+ elif status == CustomerPlan.SWITCH_TO_MONTHLY_AT_END_OF_CYCLE:+ assert plan.billing_schedule == CustomerPlan.ANNUAL+ assert plan.status < CustomerPlan.LIVE_STATUS_THRESHOLD+ # Customer needs to switch to an active plan first to avoid unexpected behavior.+ assert plan.status != CustomerPlan.DOWNGRADE_AT_END_OF_CYCLEassert plan.fixed_price is Nonedo_change_plan_status(plan, status)elif status == CustomerPlan.ENDED:diff --git a/templates/corporate/billing.html b/templates/corporate/billing.htmlindex 637ba46e458..7f18c114cf9 100644--- a/templates/corporate/billing.html+++ b/templates/corporate/billing.html@@ -29,15 +29,44 @@{% endif %}</div></div>- <div class="input-box billing-page-field no-validation">- <label for="org-billing-frequency" class="inline-block label-title">Billing frequency</label>- <div id="org-billing-frequency" class="not-editable-realm-field">+ <div class="input-box billing-page-field no-validation org-billing-frequency-wrapper"+ data-current-billing-frequency="{{ billing_frequency }}"+ {%if free_trial %}data-free-trial="true"{% endif %}+ {%if downgrade_at_end_of_cycle %}data-downgrade-eoc="true"{% endif %}+ {%if switch_to_monthly_at_end_of_cycle %}data-switch-to-monthly-eoc="true"{% endif %}+ {%if switch_to_annual_at_end_of_cycle %}data-switch-to-annual-eoc="true"{% endif %}>+ <label for="org-billing-frequency">Billing frequency</label>+ {% if free_trial or downgrade_at_end_of_cycle %}+ <div class="not-editable-realm-field">{{ billing_frequency }}- {% if switch_to_annual_at_end_of_cycle %}- <br />+ </div>+ {% elif switch_to_annual_at_end_of_cycle %}+ <select name="schedule" id="org-billing-frequency-annual" class="billing-frequency-select">+ <option value="Monthly">Monthly</option>+ <option value="Annual" selected>Annual</option>+ </select>+ <div class="billing-frequency-message not-editable-realm-field">Your plan will switch to annual billing on {{ renewal_date }}.- {% endif %}</div>+ {%elif switch_to_monthly_at_end_of_cycle %}+ <select name="schedule" id="org-billing-frequency-monthly" class="billing-frequency-select">+ <option value="Monthly" selected>Monthly</option>+ <option value="Annual">Annual</option>+ </select>+ <div class="billing-frequency-message not-editable-realm-field">+ Your plan will switch to monthly billing on {{ renewal_date }}.+ </div>+ {% else %}+ <select name="schedule" id="org-billing-frequency-default" class="billing-frequency-select">+ <option value="Monthly" {% if billing_frequency == "Monthly" %}selected{% endif %}>Monthly</option>+ <option value="Annual" {% if billing_frequency == "Annual" %}selected{% endif %}>Annual</option>+ </select>+ {% endif %}+ <button id="org-billing-frequency-confirm-button" class="hide">+ <span class="billing-button-text">Update</span>+ <object class="loader billing-button-loader" type="image/svg+xml" data="{{ static('images/loading/loader-white.svg') }}"></object>+ </button>+ <div id="org-billing-frequency-change-error" class="alert alert-danger billing-page-error"></div></div>{% if automanage_licenses %}<div class="input-box billing-page-field no-validation">@@ -130,7 +159,14 @@<br />Expected charge: <strong>${{ renewal_amount }}</strong>{% if not fixed_price %}- (${{ price_per_license }} x {{ licenses_at_next_renewal }} {{ 'user' if licenses_at_next_renewal == 1 else 'users' }} x {{ "1 month" if billing_frequency == "Monthly" else "12 months" }})+ (${{ price_per_license }} x {{ licenses_at_next_renewal }} {{ 'user' if licenses_at_next_renewal == 1 else 'users' }} x+ {% if switch_to_annual_at_end_of_cycle %}+ 12 months+ {% elif switch_to_monthly_at_end_of_cycle %}+ 1 month+ {% else %}+ {{ "1 month" if billing_frequency == "Monthly" else "12 months" }}+ {% endif %}){% endif %}{% endif %}{% else %}diff --git a/web/src/billing/billing.ts b/web/src/billing/billing.tsindex ec8dbb1e41c..4aebbdfb614 100644--- a/web/src/billing/billing.ts+++ b/web/src/billing/billing.ts@@ -1,9 +1,20 @@import $ from "jquery";+import {z} from "zod";import * as portico_modals from "../portico/portico_modals";import * as helpers from "./helpers";+const billing_frequency_schema = z.enum(["Monthly", "Annual"]);++enum CustomerPlanStatus {+ ACTIVE = 1,+ DOWNGRADE_AT_END_OF_CYCLE = 2,+ FREE_TRIAL = 3,+ SWITCH_TO_ANNUAL_AT_END_OF_CYCLE = 4,+ SWITCH_TO_MONTHLY_AT_END_OF_CYCLE = 6,+}+export function create_update_current_cycle_license_request(): void {$("#current-manual-license-count-update-button .billing-button-text").text("");$("#current-manual-license-count-update-button .loader").show();@@ -255,6 +266,61 @@ export function initialize(): void {}}, 300); // Wait for 300ms after the user stops typing});++ $<HTMLInputElement>(".billing-frequency-select").on("change", function () {+ const $wrapper = $(".org-billing-frequency-wrapper");+ const switch_to_annual_eoc = $wrapper.attr("data-switch-to-annual-eoc") === "true";+ const switch_to_monthly_eoc = $wrapper.attr("data-switch-to-monthly-eoc") === "true";+ const free_trial = $wrapper.attr("data-free-trial") === "true";+ const downgrade_at_end_of_cycle = $wrapper.attr("data-downgrade-eoc") === "true";+ const current_billing_frequency = $wrapper.attr("data-current-billing-frequency");+ const billing_frequency_selected = billing_frequency_schema.parse(this.value);++ if (+ (switch_to_annual_eoc && billing_frequency_selected === "Monthly") ||+ (switch_to_monthly_eoc && billing_frequency_selected === "Annual")+ ) {+ $("#org-billing-frequency-confirm-button").toggleClass("hide", false);+ let new_status = CustomerPlanStatus.ACTIVE;+ if (downgrade_at_end_of_cycle) {+ new_status = CustomerPlanStatus.DOWNGRADE_AT_END_OF_CYCLE;+ } else if (free_trial) {+ new_status = CustomerPlanStatus.FREE_TRIAL;+ }+ $("#org-billing-frequency-confirm-button").attr("data-status", new_status);+ } else if (current_billing_frequency !== billing_frequency_selected) {+ $("#org-billing-frequency-confirm-button").toggleClass("hide", false);+ let new_status = CustomerPlanStatus.SWITCH_TO_ANNUAL_AT_END_OF_CYCLE;+ if (billing_frequency_selected === "Monthly") {+ new_status = CustomerPlanStatus.SWITCH_TO_MONTHLY_AT_END_OF_CYCLE;+ }+ $("#org-billing-frequency-confirm-button").attr("data-status", new_status);+ } else {+ $("#org-billing-frequency-confirm-button").toggleClass("hide", true);+ }+ });++ $("#org-billing-frequency-confirm-button").on("click", (e) => {+ e.preventDefault();+ void $.ajax({+ type: "patch",+ url: "/json/billing/plan",+ data: {+ status: $("#org-billing-frequency-confirm-button").attr("data-status"),+ },+ success() {+ window.location.replace(+ "/billing/?success_message=" ++ encodeURIComponent("Billing frequency has been updated."),+ );+ },+ error(xhr) {+ if (xhr.responseJSON?.msg) {+ $("#org-billing-frequency-change-error").text(xhr.responseJSON.msg);+ }+ },+ });+ });}$(() => {diff --git a/web/styles/portico/billing.css b/web/styles/portico/billing.cssindex ef52e1d61d5..0f9fd4bd7d9 100644--- a/web/styles/portico/billing.css+++ b/web/styles/portico/billing.css@@ -458,6 +458,7 @@ input[name="licenses"] {bottom: 15px;}+#billing-page #org-billing-frequency-confirm-button,#billing-page .license-count-update-button {margin: 0 auto;font-size: 1.1rem;@@ -465,10 +466,19 @@ input[name="licenses"] {width: 100px;}+#billing-page #org-billing-frequency-confirm-button.hide,#billing-page .license-count-update-button.hide {display: none;}+#billing-page #org-billing-frequency-confirm-button {+ margin: 0;+ display: block;+ position: absolute;+ top: 25px;+ right: 0;+}+#billing-page #current-license-change-form,#billing-page #next-license-change-form {margin-bottom: 0;@@ -535,6 +545,7 @@ input[name="licenses"] {}}+#billing-page-details .billing-frequency-message.not-editable-realm-field,#upgrade-page-details #onboarding-free-trial-not-ready,#onboarding-go-to-org .not-editable-realm-field,#free-trial-top-banner .not-editable-realm-field,@@ -592,6 +603,13 @@ input[name="licenses"] {margin-right: 0;}+#billing-page-details+ .org-billing-frequency-wrapper.input-box+ .billing-frequency-select {+ width: 150px;+}++#billing-page-details .org-billing-frequency-wrapper.billing-page-field,#upgrade-page-details .upgrade-add-card-container {text-align: left;}diff --git a/zerver/models.py b/zerver/models.pyindex 454fd820f39..3ab6b9fb507 100644--- a/zerver/models.py+++ b/zerver/models.py@@ -4782,6 +4782,7 @@ class AbstractRealmAuditLog(models.Model):CUSTOMER_CREATED = 501CUSTOMER_PLAN_CREATED = 502CUSTOMER_SWITCHED_FROM_MONTHLY_TO_ANNUAL_PLAN = 503+ CUSTOMER_SWITCHED_FROM_ANNUAL_TO_MONTHLY_PLAN = 504STREAM_CREATED = 601STREAM_DEACTIVATED = 602