Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

billing: Support switching from monthly to annual plan.

Vishnu KScde4486f8c80
diff --git a/corporate/lib/stripe.py b/corporate/lib/stripe.py
index c94051a8c34..e59eef8a090 100644
--- a/corporate/lib/stripe.py
+++ b/corporate/lib/stripe.py
@@ -125,14 +125,21 @@ def next_invoice_date(plan: CustomerPlan) -> Optional[datetime]:
def renewal_amount(plan: CustomerPlan, event_time: datetime) -> int: # nocoverage: TODO
if plan.fixed_price is not None:
return plan.fixed_price
- last_ledger_entry = make_end_of_cycle_updates_if_needed(plan, event_time)
+ new_plan, last_ledger_entry = make_end_of_cycle_updates_if_needed(plan, event_time)
if last_ledger_entry is None:
return 0
if last_ledger_entry.licenses_at_next_renewal is None:
return 0
+ if new_plan is not None:
+ plan = new_plan
assert(plan.price_per_license is not None) # for mypy
return plan.price_per_license * last_ledger_entry.licenses_at_next_renewal
+def get_idempotency_key(ledger_entry: LicenseLedger) -> Optional[str]:
+ if settings.TEST_SUITE:
+ return None
+ return f'ledger_entry:{ledger_entry.id}' # nocoverage
+
class BillingError(Exception):
# error messages
CONTACT_SUPPORT = _("Something went wrong. Please contact {email}.").format(
@@ -237,14 +244,14 @@ def do_replace_payment_source(user: UserProfile, stripe_token: str,
# event_time should roughly be timezone_now(). Not designed to handle
# event_times in the past or future
def make_end_of_cycle_updates_if_needed(plan: CustomerPlan,
- event_time: datetime) -> Optional[LicenseLedger]:
+ event_time: datetime) -> Tuple[Optional[CustomerPlan], Optional[LicenseLedger]]:
last_ledger_entry = LicenseLedger.objects.filter(plan=plan).order_by('-id').first()
last_renewal = LicenseLedger.objects.filter(plan=plan, is_renewal=True) \
.order_by('-id').first().event_time
next_billing_cycle = start_of_next_billing_cycle(plan, last_renewal)
if next_billing_cycle <= event_time:
if plan.status == CustomerPlan.ACTIVE:
- return LicenseLedger.objects.create(
+ return None, LicenseLedger.objects.create(
plan=plan, is_renewal=True, event_time=next_billing_cycle,
licenses=last_ledger_entry.licenses_at_next_renewal,
licenses_at_next_renewal=last_ledger_entry.licenses_at_next_renewal)
@@ -254,14 +261,52 @@ def make_end_of_cycle_updates_if_needed(plan: CustomerPlan,
plan.billing_cycle_anchor = plan.next_invoice_date.replace(microsecond=0)
plan.status = CustomerPlan.ACTIVE
plan.save(update_fields=["invoiced_through", "billing_cycle_anchor", "status"])
- return LicenseLedger.objects.create(
+ return None, LicenseLedger.objects.create(
plan=plan, is_renewal=True, event_time=next_billing_cycle,
licenses=last_ledger_entry.licenses_at_next_renewal,
licenses_at_next_renewal=last_ledger_entry.licenses_at_next_renewal)
+
+ if plan.status == CustomerPlan.SWITCH_TO_ANNUAL_AT_END_OF_CYCLE:
+ if plan.fixed_price is not None: # nocoverage
+ raise NotImplementedError("Can't switch fixed priced monthly plan to annual.")
+
+ plan.status = CustomerPlan.ENDED
+ plan.save(update_fields=["status"])
+
+ discount = plan.customer.default_discount or plan.discount
+ _, _, _, price_per_license = compute_plan_parameters(
+ automanage_licenses=plan.automanage_licenses, billing_schedule=CustomerPlan.ANNUAL,
+ discount=plan.discount
+ )
+
+ new_plan = CustomerPlan.objects.create(
+ customer=plan.customer, billing_schedule=CustomerPlan.ANNUAL, 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=last_ledger_entry.licenses_at_next_renewal,
+ licenses_at_next_renewal=last_ledger_entry.licenses_at_next_renewal
+ )
+
+ RealmAuditLog.objects.create(
+ realm=new_plan.customer.realm, event_time=event_time,
+ event_type=RealmAuditLog.CUSTOMER_SWITCHED_FROM_MONTHLY_TO_ANNUAL_PLAN,
+ extra_data=ujson.dumps({
+ "monthly_plan_id": plan.id,
+ "annual_plan_id": new_plan.id,
+ })
+ )
+ return new_plan, new_plan_ledger_entry
+
if plan.status == CustomerPlan.DOWNGRADE_AT_END_OF_CYCLE:
process_downgrade(plan)
- return None
- return last_ledger_entry
+ return None, None
+ return None, last_ledger_entry
# Returns Customer instead of stripe_customer so that we don't make a Stripe
# API call if there's nothing to update
@@ -410,11 +455,14 @@ def process_initial_upgrade(user: UserProfile, licenses: int, automanage_license
def update_license_ledger_for_automanaged_plan(realm: Realm, plan: CustomerPlan,
event_time: datetime) -> None:
- last_ledger_entry = make_end_of_cycle_updates_if_needed(plan, event_time)
+ new_plan, last_ledger_entry = make_end_of_cycle_updates_if_needed(plan, event_time)
if last_ledger_entry is None:
return
+ if new_plan is not None:
+ plan = new_plan
licenses_at_next_renewal = get_latest_seat_count(realm)
licenses = max(licenses_at_next_renewal, last_ledger_entry.licenses)
+
LicenseLedger.objects.create(
plan=plan, event_time=event_time, licenses=licenses,
licenses_at_next_renewal=licenses_at_next_renewal)
@@ -431,10 +479,17 @@ def invoice_plan(plan: CustomerPlan, event_time: datetime) -> None:
if plan.invoicing_status == CustomerPlan.STARTED:
raise NotImplementedError('Plan with invoicing_status==STARTED needs manual resolution.')
make_end_of_cycle_updates_if_needed(plan, event_time)
- assert(plan.invoiced_through is not None)
- licenses_base = plan.invoiced_through.licenses
+
+ if plan.invoicing_status == CustomerPlan.INITIAL_INVOICE_TO_BE_SENT:
+ invoiced_through_id = -1
+ licenses_base = None
+ else:
+ assert(plan.invoiced_through is not None)
+ licenses_base = plan.invoiced_through.licenses
+ invoiced_through_id = plan.invoiced_through.id
+
invoice_item_created = False
- for ledger_entry in LicenseLedger.objects.filter(plan=plan, id__gt=plan.invoiced_through.id,
+ for ledger_entry in LicenseLedger.objects.filter(plan=plan, id__gt=invoiced_through_id,
event_time__lte=event_time).order_by('id'):
price_args: Dict[str, int] = {}
if ledger_entry.is_renewal:
@@ -445,7 +500,7 @@ def invoice_plan(plan: CustomerPlan, event_time: datetime) -> None:
price_args = {'unit_amount': plan.price_per_license,
'quantity': ledger_entry.licenses}
description = "Zulip Standard - renewal"
- elif ledger_entry.licenses != licenses_base:
+ elif licenses_base is not None and ledger_entry.licenses != licenses_base:
assert(plan.price_per_license)
last_renewal = LicenseLedger.objects.filter(
plan=plan, is_renewal=True, event_time__lte=ledger_entry.event_time) \
@@ -461,9 +516,6 @@ def invoice_plan(plan: CustomerPlan, event_time: datetime) -> None:
plan.invoiced_through = ledger_entry
plan.invoicing_status = CustomerPlan.STARTED
plan.save(update_fields=['invoicing_status', 'invoiced_through'])
- idempotency_key: Optional[str] = f'ledger_entry:{ledger_entry.id}'
- if settings.TEST_SUITE:
- idempotency_key = None
stripe.InvoiceItem.create(
currency='usd',
customer=plan.customer.stripe_customer_id,
@@ -472,7 +524,7 @@ def invoice_plan(plan: CustomerPlan, event_time: datetime) -> None:
period = {'start': datetime_to_timestamp(ledger_entry.event_time),
'end': datetime_to_timestamp(
start_of_next_billing_cycle(plan, ledger_entry.event_time))},
- idempotency_key=idempotency_key,
+ idempotency_key=get_idempotency_key(ledger_entry),
**price_args)
invoice_item_created = True
plan.invoiced_through = ledger_entry
diff --git a/corporate/models.py b/corporate/models.py
index 715f10d7e3c..f2b06ebfb2f 100644
--- a/corporate/models.py
+++ b/corporate/models.py
@@ -44,6 +44,7 @@ class CustomerPlan(models.Model):
'LicenseLedger', null=True, on_delete=CASCADE, related_name='+')
DONE = 1
STARTED = 2
+ INITIAL_INVOICE_TO_BE_SENT = 3
invoicing_status: int = models.SmallIntegerField(default=DONE)
STANDARD = 1
@@ -54,6 +55,7 @@ class CustomerPlan(models.Model):
ACTIVE = 1
DOWNGRADE_AT_END_OF_CYCLE = 2
FREE_TRIAL = 3
+ SWITCH_TO_ANNUAL_AT_END_OF_CYCLE = 4
# "Live" plans should have a value < LIVE_STATUS_THRESHOLD.
# There should be at most one live plan per customer.
LIVE_STATUS_THRESHOLD = 10
diff --git a/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Charge.create.1.json b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Charge.create.1.json
new file mode 100644
index 00000000000..1d47b5d3578
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Charge.create.1.json
@@ -0,0 +1,116 @@
+{
+ "amount": 4800,
+ "amount_refunded": 0,
+ "application": null,
+ "application_fee": null,
+ "application_fee_amount": null,
+ "balance_transaction": "txn_NORMALIZED00000000000001",
+ "billing_details": {
+ "address": {
+ "city": "Pacific",
+ "country": "United States",
+ "line1": "Under the sea,",
+ "line2": null,
+ "postal_code": "33333",
+ "state": null
+ },
+ "email": null,
+ "name": "Ada Starr",
+ "phone": null
+ },
+ "calculated_statement_descriptor": "ZULIP STANDARD",
+ "captured": true,
+ "created": 1000000000,
+ "currency": "usd",
+ "customer": "cus_NORMALIZED0001",
+ "description": "Upgrade to Zulip Standard, $8.0 x 6",
+ "destination": null,
+ "dispute": null,
+ "disputed": false,
+ "failure_code": null,
+ "failure_message": null,
+ "fraud_details": {},
+ "id": "ch_NORMALIZED00000000000001",
+ "invoice": null,
+ "livemode": false,
+ "metadata": {},
+ "object": "charge",
+ "on_behalf_of": null,
+ "order": null,
+ "outcome": {
+ "network_status": "approved_by_network",
+ "reason": null,
+ "risk_level": "normal",
+ "risk_score": 00,
+ "seller_message": "Payment complete.",
+ "type": "authorized"
+ },
+ "paid": true,
+ "payment_intent": null,
+ "payment_method": "card_NORMALIZED00000000000001",
+ "payment_method_details": {
+ "card": {
+ "brand": "visa",
+ "checks": {
+ "address_line1_check": "pass",
+ "address_postal_code_check": "pass",
+ "cvc_check": "pass"
+ },
+ "country": "US",
+ "exp_month": 3,
+ "exp_year": 2033,
+ "fingerprint": "NORMALIZED000001",
+ "funding": "credit",
+ "installments": null,
+ "last4": "4242",
+ "network": "visa",
+ "three_d_secure": null,
+ "wallet": null
+ },
+ "type": "card"
+ },
+ "receipt_email": "[email protected]",
+ "receipt_number": null,
+ "receipt_url": "https://pay.stripe.com/receipts/acct_NORMALIZED000001/ch_NORMALIZED00000000000001/rcpt_NORMALIZED000000000000000000001",
+ "refunded": false,
+ "refunds": {
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "total_count": 0,
+ "url": "/v1/charges/ch_NORMALIZED00000000000001/refunds"
+ },
+ "review": null,
+ "shipping": null,
+ "source": {
+ "address_city": "Pacific",
+ "address_country": "United States",
+ "address_line1": "Under the sea,",
+ "address_line1_check": "pass",
+ "address_line2": null,
+ "address_state": null,
+ "address_zip": "33333",
+ "address_zip_check": "pass",
+ "brand": "Visa",
+ "country": "US",
+ "customer": "cus_NORMALIZED0001",
+ "cvc_check": "pass",
+ "dynamic_last4": null,
+ "exp_month": 3,
+ "exp_year": 2033,
+ "fingerprint": "NORMALIZED000001",
+ "funding": "credit",
+ "id": "card_NORMALIZED00000000000001",
+ "last4": "4242",
+ "metadata": {},
+ "name": "Ada Starr",
+ "object": "card",
+ "tokenization_method": null
+ },
+ "source_transfer": null,
+ "statement_descriptor": "Zulip Standard",
+ "statement_descriptor_suffix": null,
+ "status": "succeeded",
+ "transfer_data": null,
+ "transfer_group": null
+}
diff --git a/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Customer.create.1.json b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Customer.create.1.json
new file mode 100644
index 00000000000..1e87c2923cd
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Customer.create.1.json
@@ -0,0 +1,80 @@
+{
+ "account_balance": 0,
+ "address": null,
+ "balance": 0,
+ "created": 1000000000,
+ "currency": null,
+ "default_source": "card_NORMALIZED00000000000001",
+ "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
+ },
+ "livemode": false,
+ "metadata": {
+ "realm_id": "1",
+ "realm_str": "zulip"
+ },
+ "name": null,
+ "next_invoice_sequence": 1,
+ "object": "customer",
+ "phone": null,
+ "preferred_locales": [],
+ "shipping": null,
+ "sources": {
+ "data": [
+ {
+ "address_city": "Pacific",
+ "address_country": "United States",
+ "address_line1": "Under the sea,",
+ "address_line1_check": "pass",
+ "address_line2": null,
+ "address_state": null,
+ "address_zip": "33333",
+ "address_zip_check": "pass",
+ "brand": "Visa",
+ "country": "US",
+ "customer": "cus_NORMALIZED0001",
+ "cvc_check": "pass",
+ "dynamic_last4": null,
+ "exp_month": 3,
+ "exp_year": 2033,
+ "fingerprint": "NORMALIZED000001",
+ "funding": "credit",
+ "id": "card_NORMALIZED00000000000001",
+ "last4": "4242",
+ "metadata": {},
+ "name": "Ada Starr",
+ "object": "card",
+ "tokenization_method": null
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/customers/cus_NORMALIZED0001/sources"
+ },
+ "subscriptions": {
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "total_count": 0,
+ "url": "/v1/customers/cus_NORMALIZED0001/subscriptions"
+ },
+ "tax_exempt": "none",
+ "tax_ids": {
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "total_count": 0,
+ "url": "/v1/customers/cus_NORMALIZED0001/tax_ids"
+ },
+ "tax_info": null,
+ "tax_info_verification": null
+}
diff --git a/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Customer.retrieve.1.json b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Customer.retrieve.1.json
new file mode 100644
index 00000000000..17d00481138
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Customer.retrieve.1.json
@@ -0,0 +1,104 @@
+{
+ "account_balance": 0,
+ "address": null,
+ "balance": 0,
+ "created": 1000000000,
+ "currency": "usd",
+ "default_source": {
+ "address_city": "Pacific",
+ "address_country": "United States",
+ "address_line1": "Under the sea,",
+ "address_line1_check": "pass",
+ "address_line2": null,
+ "address_state": null,
+ "address_zip": "33333",
+ "address_zip_check": "pass",
+ "brand": "Visa",
+ "country": "US",
+ "customer": "cus_NORMALIZED0001",
+ "cvc_check": "pass",
+ "dynamic_last4": null,
+ "exp_month": 3,
+ "exp_year": 2033,
+ "fingerprint": "NORMALIZED000001",
+ "funding": "credit",
+ "id": "card_NORMALIZED00000000000001",
+ "last4": "4242",
+ "metadata": {},
+ "name": "Ada Starr",
+ "object": "card",
+ "tokenization_method": 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
+ },
+ "livemode": false,
+ "metadata": {
+ "realm_id": "1",
+ "realm_str": "zulip"
+ },
+ "name": null,
+ "next_invoice_sequence": 2,
+ "object": "customer",
+ "phone": null,
+ "preferred_locales": [],
+ "shipping": null,
+ "sources": {
+ "data": [
+ {
+ "address_city": "Pacific",
+ "address_country": "United States",
+ "address_line1": "Under the sea,",
+ "address_line1_check": "pass",
+ "address_line2": null,
+ "address_state": null,
+ "address_zip": "33333",
+ "address_zip_check": "pass",
+ "brand": "Visa",
+ "country": "US",
+ "customer": "cus_NORMALIZED0001",
+ "cvc_check": "pass",
+ "dynamic_last4": null,
+ "exp_month": 3,
+ "exp_year": 2033,
+ "fingerprint": "NORMALIZED000001",
+ "funding": "credit",
+ "id": "card_NORMALIZED00000000000001",
+ "last4": "4242",
+ "metadata": {},
+ "name": "Ada Starr",
+ "object": "card",
+ "tokenization_method": null
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/customers/cus_NORMALIZED0001/sources"
+ },
+ "subscriptions": {
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "total_count": 0,
+ "url": "/v1/customers/cus_NORMALIZED0001/subscriptions"
+ },
+ "tax_exempt": "none",
+ "tax_ids": {
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "total_count": 0,
+ "url": "/v1/customers/cus_NORMALIZED0001/tax_ids"
+ },
+ "tax_info": null,
+ "tax_info_verification": null
+}
diff --git a/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Invoice.create.1.json b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Invoice.create.1.json
new file mode 100644
index 00000000000..e9e1cfb02cd
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Invoice.create.1.json
@@ -0,0 +1,160 @@
+{
+ "account_country": "US",
+ "account_name": null,
+ "amount_due": 0,
+ "amount_paid": 0,
+ "amount_remaining": 0,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "charge_automatically",
+ "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": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "due_date": null,
+ "ending_balance": null,
+ "finalized_at": null,
+ "footer": null,
+ "hosted_invoice_url": null,
+ "id": "in_NORMALIZED00000000000001",
+ "invoice_pdf": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 4800,
+ "currency": "usd",
+ "description": "Zulip Standard",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000001",
+ "invoice_item": "ii_NORMALIZED00000000000001",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1328151845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ2MD2X8vgpBNGmnU3Nexq",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqrQVq8e30wd",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 800,
+ "unit_amount_decimal": "800"
+ },
+ "proration": false,
+ "quantity": 6,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ2MD2X8vgpBNGxjcmXQWz"
+ },
+ {
+ "amount": -4800,
+ "currency": "usd",
+ "description": "Payment (Card ending in 4242)",
+ "discountable": false,
+ "id": "ii_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",
+ "id": "price_1GvQ2MD2X8vgpBNGPP6MRxVi",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqIz3JTQJXqm",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": -4800,
+ "unit_amount_decimal": "-4800"
+ },
+ "proration": false,
+ "quantity": 1,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ2MD2X8vgpBNGxqc69b7U"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 2,
+ "url": "/v1/invoices/in_NORMALIZED00000000000001/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": 1000000000,
+ "number": "NORMALI-0001",
+ "object": "invoice",
+ "paid": false,
+ "payment_intent": null,
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "receipt_number": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Standard",
+ "status": "draft",
+ "status_transitions": {
+ "finalized_at": null,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subtotal": 0,
+ "tax": null,
+ "tax_percent": null,
+ "total": 0,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1000000000
+}
diff --git a/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Invoice.create.2.json b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Invoice.create.2.json
new file mode 100644
index 00000000000..b8feafbb7c5
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Invoice.create.2.json
@@ -0,0 +1,118 @@
+{
+ "account_country": "US",
+ "account_name": null,
+ "amount_due": 11200,
+ "amount_paid": 0,
+ "amount_remaining": 11200,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "charge_automatically",
+ "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": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "due_date": null,
+ "ending_balance": null,
+ "finalized_at": null,
+ "footer": null,
+ "hosted_invoice_url": null,
+ "id": "in_NORMALIZED00000000000002",
+ "invoice_pdf": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 11200,
+ "currency": "usd",
+ "description": "Additional license (Jan 2, 2012 - Feb 2, 2012)",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000003",
+ "invoice_item": "ii_NORMALIZED00000000000003",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1328151845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ2PD2X8vgpBNGi2WCVoxN",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqbn9E3BYkUq",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 800,
+ "unit_amount_decimal": "800"
+ },
+ "proration": false,
+ "quantity": 14,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ2PD2X8vgpBNGWj7t13XB"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/in_NORMALIZED00000000000002/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": 1000000000,
+ "number": "NORMALI-0002",
+ "object": "invoice",
+ "paid": false,
+ "payment_intent": null,
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "receipt_number": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Standard",
+ "status": "draft",
+ "status_transitions": {
+ "finalized_at": null,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subtotal": 11200,
+ "tax": null,
+ "tax_percent": null,
+ "total": 11200,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1000000000
+}
diff --git a/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Invoice.create.3.json b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Invoice.create.3.json
new file mode 100644
index 00000000000..c6b5486c58c
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Invoice.create.3.json
@@ -0,0 +1,160 @@
+{
+ "account_country": "US",
+ "account_name": null,
+ "amount_due": 200000,
+ "amount_paid": 0,
+ "amount_remaining": 200000,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "charge_automatically",
+ "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": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "due_date": null,
+ "ending_balance": null,
+ "finalized_at": null,
+ "footer": null,
+ "hosted_invoice_url": null,
+ "id": "in_NORMALIZED00000000000003",
+ "invoice_pdf": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 40000,
+ "currency": "usd",
+ "description": "Additional license (Feb 2, 2012 - Feb 2, 2013)",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000004",
+ "invoice_item": "ii_NORMALIZED00000000000004",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1359774245,
+ "start": 1328151845
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ2SD2X8vgpBNGDJwXOc3b",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqxNSx9MHbPC",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 5,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ2SD2X8vgpBNGlalvG9cv"
+ },
+ {
+ "amount": 160000,
+ "currency": "usd",
+ "description": "Zulip Standard - renewal",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000005",
+ "invoice_item": "ii_NORMALIZED00000000000005",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1359774245,
+ "start": 1328151845
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ2RD2X8vgpBNGanjAQMpk",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOquKicbsnEfk",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 20,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ2RD2X8vgpBNGgza03wZ5"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 2,
+ "url": "/v1/invoices/in_NORMALIZED00000000000003/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": 1000000000,
+ "number": "NORMALI-0003",
+ "object": "invoice",
+ "paid": false,
+ "payment_intent": null,
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "receipt_number": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Standard",
+ "status": "draft",
+ "status_transitions": {
+ "finalized_at": null,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subtotal": 200000,
+ "tax": null,
+ "tax_percent": null,
+ "total": 200000,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1000000000
+}
diff --git a/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Invoice.create.4.json b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Invoice.create.4.json
new file mode 100644
index 00000000000..50ee2d31457
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Invoice.create.4.json
@@ -0,0 +1,118 @@
+{
+ "account_country": "US",
+ "account_name": null,
+ "amount_due": 36830,
+ "amount_paid": 0,
+ "amount_remaining": 36830,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "charge_automatically",
+ "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": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "due_date": null,
+ "ending_balance": null,
+ "finalized_at": null,
+ "footer": null,
+ "hosted_invoice_url": null,
+ "id": "in_NORMALIZED00000000000004",
+ "invoice_pdf": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 36830,
+ "currency": "usd",
+ "description": "Additional license (Mar 2, 2012 - Feb 2, 2013)",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000006",
+ "invoice_item": "ii_NORMALIZED00000000000006",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1359774245,
+ "start": 1330657445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ2VD2X8vgpBNGa0BY3luD",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqPUFMHEL03U",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 7366,
+ "unit_amount_decimal": "7366"
+ },
+ "proration": false,
+ "quantity": 5,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ2VD2X8vgpBNGbpLwsVBN"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/in_NORMALIZED00000000000004/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": 1000000000,
+ "number": "NORMALI-0004",
+ "object": "invoice",
+ "paid": false,
+ "payment_intent": null,
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "receipt_number": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Standard",
+ "status": "draft",
+ "status_transitions": {
+ "finalized_at": null,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subtotal": 36830,
+ "tax": null,
+ "tax_percent": null,
+ "total": 36830,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1000000000
+}
diff --git a/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Invoice.create.5.json b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Invoice.create.5.json
new file mode 100644
index 00000000000..c0bfcaec063
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Invoice.create.5.json
@@ -0,0 +1,118 @@
+{
+ "account_country": "US",
+ "account_name": null,
+ "amount_due": 240000,
+ "amount_paid": 0,
+ "amount_remaining": 240000,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "charge_automatically",
+ "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": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "due_date": null,
+ "ending_balance": null,
+ "finalized_at": null,
+ "footer": null,
+ "hosted_invoice_url": null,
+ "id": "in_NORMALIZED00000000000005",
+ "invoice_pdf": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 240000,
+ "currency": "usd",
+ "description": "Zulip Standard - renewal",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000007",
+ "invoice_item": "ii_NORMALIZED00000000000007",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1391310245,
+ "start": 1359774245
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ2XD2X8vgpBNGamMRrAgW",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqc8FlpLiZkO",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 30,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ2XD2X8vgpBNGlycTk5fw"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/in_NORMALIZED00000000000005/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": 1000000000,
+ "number": "NORMALI-0005",
+ "object": "invoice",
+ "paid": false,
+ "payment_intent": null,
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "receipt_number": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Standard",
+ "status": "draft",
+ "status_transitions": {
+ "finalized_at": null,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subtotal": 240000,
+ "tax": null,
+ "tax_percent": null,
+ "total": 240000,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1000000000
+}
diff --git a/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Invoice.finalize_invoice.1.json b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Invoice.finalize_invoice.1.json
new file mode 100644
index 00000000000..453181d7266
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Invoice.finalize_invoice.1.json
@@ -0,0 +1,160 @@
+{
+ "account_country": "US",
+ "account_name": null,
+ "amount_due": 0,
+ "amount_paid": 0,
+ "amount_remaining": 0,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": true,
+ "auto_advance": false,
+ "billing": "charge_automatically",
+ "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": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "due_date": null,
+ "ending_balance": 0,
+ "finalized_at": 1000000000,
+ "footer": null,
+ "hosted_invoice_url": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000001sXXeo",
+ "id": "in_NORMALIZED00000000000001",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000001sXXeo/pdf",
+ "lines": {
+ "data": [
+ {
+ "amount": 4800,
+ "currency": "usd",
+ "description": "Zulip Standard",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000001",
+ "invoice_item": "ii_NORMALIZED00000000000001",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1328151845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ2MD2X8vgpBNGmnU3Nexq",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqrQVq8e30wd",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 800,
+ "unit_amount_decimal": "800"
+ },
+ "proration": false,
+ "quantity": 6,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ2MD2X8vgpBNGxjcmXQWz"
+ },
+ {
+ "amount": -4800,
+ "currency": "usd",
+ "description": "Payment (Card ending in 4242)",
+ "discountable": false,
+ "id": "ii_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",
+ "id": "price_1GvQ2MD2X8vgpBNGPP6MRxVi",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqIz3JTQJXqm",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": -4800,
+ "unit_amount_decimal": "-4800"
+ },
+ "proration": false,
+ "quantity": 1,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ2MD2X8vgpBNGxqc69b7U"
+ }
+ ],
+ "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",
+ "paid": true,
+ "payment_intent": null,
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "receipt_number": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Standard",
+ "status": "paid",
+ "status_transitions": {
+ "finalized_at": 1000000000,
+ "marked_uncollectible_at": null,
+ "paid_at": 1000000000,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subtotal": 0,
+ "tax": null,
+ "tax_percent": null,
+ "total": 0,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1000000000
+}
diff --git a/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Invoice.finalize_invoice.2.json b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Invoice.finalize_invoice.2.json
new file mode 100644
index 00000000000..9180702c2eb
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Invoice.finalize_invoice.2.json
@@ -0,0 +1,118 @@
+{
+ "account_country": "US",
+ "account_name": null,
+ "amount_due": 11200,
+ "amount_paid": 0,
+ "amount_remaining": 11200,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "charge_automatically",
+ "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": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "due_date": null,
+ "ending_balance": 0,
+ "finalized_at": 1000000000,
+ "footer": null,
+ "hosted_invoice_url": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000002BzaWK",
+ "id": "in_NORMALIZED00000000000002",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000002BzaWK/pdf",
+ "lines": {
+ "data": [
+ {
+ "amount": 11200,
+ "currency": "usd",
+ "description": "Additional license (Jan 2, 2012 - Feb 2, 2012)",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000003",
+ "invoice_item": "ii_NORMALIZED00000000000003",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1328151845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ2PD2X8vgpBNGi2WCVoxN",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqbn9E3BYkUq",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 800,
+ "unit_amount_decimal": "800"
+ },
+ "proration": false,
+ "quantity": 14,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ2PD2X8vgpBNGWj7t13XB"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/in_NORMALIZED00000000000002/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": 1000000000,
+ "number": "NORMALI-0002",
+ "object": "invoice",
+ "paid": false,
+ "payment_intent": "pi_1GvQ2RD2X8vgpBNGtEBCkF9Z",
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "receipt_number": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Standard",
+ "status": "open",
+ "status_transitions": {
+ "finalized_at": 1000000000,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subtotal": 11200,
+ "tax": null,
+ "tax_percent": null,
+ "total": 11200,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1000000000
+}
diff --git a/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Invoice.finalize_invoice.3.json b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Invoice.finalize_invoice.3.json
new file mode 100644
index 00000000000..b7a42a7662b
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Invoice.finalize_invoice.3.json
@@ -0,0 +1,160 @@
+{
+ "account_country": "US",
+ "account_name": null,
+ "amount_due": 200000,
+ "amount_paid": 0,
+ "amount_remaining": 200000,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "charge_automatically",
+ "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": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "due_date": null,
+ "ending_balance": 0,
+ "finalized_at": 1000000000,
+ "footer": null,
+ "hosted_invoice_url": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000003NiCvS",
+ "id": "in_NORMALIZED00000000000003",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000003NiCvS/pdf",
+ "lines": {
+ "data": [
+ {
+ "amount": 40000,
+ "currency": "usd",
+ "description": "Additional license (Feb 2, 2012 - Feb 2, 2013)",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000004",
+ "invoice_item": "ii_NORMALIZED00000000000004",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1359774245,
+ "start": 1328151845
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ2SD2X8vgpBNGDJwXOc3b",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqxNSx9MHbPC",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 5,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ2SD2X8vgpBNGlalvG9cv"
+ },
+ {
+ "amount": 160000,
+ "currency": "usd",
+ "description": "Zulip Standard - renewal",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000005",
+ "invoice_item": "ii_NORMALIZED00000000000005",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1359774245,
+ "start": 1328151845
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ2RD2X8vgpBNGanjAQMpk",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOquKicbsnEfk",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 20,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ2RD2X8vgpBNGgza03wZ5"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 2,
+ "url": "/v1/invoices/in_NORMALIZED00000000000003/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": 1000000000,
+ "number": "NORMALI-0003",
+ "object": "invoice",
+ "paid": false,
+ "payment_intent": "pi_1GvQ2TD2X8vgpBNGI7xPlRLT",
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "receipt_number": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Standard",
+ "status": "open",
+ "status_transitions": {
+ "finalized_at": 1000000000,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subtotal": 200000,
+ "tax": null,
+ "tax_percent": null,
+ "total": 200000,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1000000000
+}
diff --git a/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Invoice.finalize_invoice.4.json b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Invoice.finalize_invoice.4.json
new file mode 100644
index 00000000000..432094cc1ed
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Invoice.finalize_invoice.4.json
@@ -0,0 +1,118 @@
+{
+ "account_country": "US",
+ "account_name": null,
+ "amount_due": 36830,
+ "amount_paid": 0,
+ "amount_remaining": 36830,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "charge_automatically",
+ "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": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "due_date": null,
+ "ending_balance": 0,
+ "finalized_at": 1000000000,
+ "footer": null,
+ "hosted_invoice_url": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000004izTRV",
+ "id": "in_NORMALIZED00000000000004",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000004izTRV/pdf",
+ "lines": {
+ "data": [
+ {
+ "amount": 36830,
+ "currency": "usd",
+ "description": "Additional license (Mar 2, 2012 - Feb 2, 2013)",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000006",
+ "invoice_item": "ii_NORMALIZED00000000000006",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1359774245,
+ "start": 1330657445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ2VD2X8vgpBNGa0BY3luD",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqPUFMHEL03U",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 7366,
+ "unit_amount_decimal": "7366"
+ },
+ "proration": false,
+ "quantity": 5,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ2VD2X8vgpBNGbpLwsVBN"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/in_NORMALIZED00000000000004/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": 1000000000,
+ "number": "NORMALI-0004",
+ "object": "invoice",
+ "paid": false,
+ "payment_intent": "pi_1GvQ2WD2X8vgpBNGdKVWsvEL",
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "receipt_number": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Standard",
+ "status": "open",
+ "status_transitions": {
+ "finalized_at": 1000000000,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subtotal": 36830,
+ "tax": null,
+ "tax_percent": null,
+ "total": 36830,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1000000000
+}
diff --git a/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Invoice.finalize_invoice.5.json b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Invoice.finalize_invoice.5.json
new file mode 100644
index 00000000000..a5d35eb4892
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Invoice.finalize_invoice.5.json
@@ -0,0 +1,118 @@
+{
+ "account_country": "US",
+ "account_name": null,
+ "amount_due": 240000,
+ "amount_paid": 0,
+ "amount_remaining": 240000,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "charge_automatically",
+ "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": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "due_date": null,
+ "ending_balance": 0,
+ "finalized_at": 1000000000,
+ "footer": null,
+ "hosted_invoice_url": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000005DACfs",
+ "id": "in_NORMALIZED00000000000005",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000005DACfs/pdf",
+ "lines": {
+ "data": [
+ {
+ "amount": 240000,
+ "currency": "usd",
+ "description": "Zulip Standard - renewal",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000007",
+ "invoice_item": "ii_NORMALIZED00000000000007",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1391310245,
+ "start": 1359774245
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ2XD2X8vgpBNGamMRrAgW",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqc8FlpLiZkO",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 30,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ2XD2X8vgpBNGlycTk5fw"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/in_NORMALIZED00000000000005/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": 1000000000,
+ "number": "NORMALI-0005",
+ "object": "invoice",
+ "paid": false,
+ "payment_intent": "pi_1GvQ2ZD2X8vgpBNGWgT2rokR",
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "receipt_number": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Standard",
+ "status": "open",
+ "status_transitions": {
+ "finalized_at": 1000000000,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subtotal": 240000,
+ "tax": null,
+ "tax_percent": null,
+ "total": 240000,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1000000000
+}
diff --git a/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Invoice.list.1.json b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Invoice.list.1.json
new file mode 100644
index 00000000000..0d1b946bd9c
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Invoice.list.1.json
@@ -0,0 +1,445 @@
+{
+ "data": [
+ {
+ "account_country": "US",
+ "account_name": null,
+ "amount_due": 200000,
+ "amount_paid": 0,
+ "amount_remaining": 200000,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "charge_automatically",
+ "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": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "due_date": null,
+ "ending_balance": 0,
+ "finalized_at": 1000000000,
+ "footer": null,
+ "hosted_invoice_url": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000003NiCvS",
+ "id": "in_NORMALIZED00000000000003",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000003NiCvS/pdf",
+ "lines": {
+ "data": [
+ {
+ "amount": 40000,
+ "currency": "usd",
+ "description": "Additional license (Feb 2, 2012 - Feb 2, 2013)",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000004",
+ "invoice_item": "ii_NORMALIZED00000000000004",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1359774245,
+ "start": 1328151845
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ2SD2X8vgpBNGDJwXOc3b",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqxNSx9MHbPC",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 5,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ2SD2X8vgpBNGlalvG9cv"
+ },
+ {
+ "amount": 160000,
+ "currency": "usd",
+ "description": "Zulip Standard - renewal",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000005",
+ "invoice_item": "ii_NORMALIZED00000000000005",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1359774245,
+ "start": 1328151845
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ2RD2X8vgpBNGanjAQMpk",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOquKicbsnEfk",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 20,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ2RD2X8vgpBNGgza03wZ5"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 2,
+ "url": "/v1/invoices/in_NORMALIZED00000000000003/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": 1000000000,
+ "number": "NORMALI-0003",
+ "object": "invoice",
+ "paid": false,
+ "payment_intent": "pi_1GvQ2TD2X8vgpBNGI7xPlRLT",
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "receipt_number": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Standard",
+ "status": "open",
+ "status_transitions": {
+ "finalized_at": 1000000000,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subtotal": 200000,
+ "tax": null,
+ "tax_percent": null,
+ "total": 200000,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1000000000
+ },
+ {
+ "account_country": "US",
+ "account_name": null,
+ "amount_due": 11200,
+ "amount_paid": 0,
+ "amount_remaining": 11200,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "charge_automatically",
+ "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": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "due_date": null,
+ "ending_balance": 0,
+ "finalized_at": 1000000000,
+ "footer": null,
+ "hosted_invoice_url": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000002BzaWK",
+ "id": "in_NORMALIZED00000000000002",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000002BzaWK/pdf",
+ "lines": {
+ "data": [
+ {
+ "amount": 11200,
+ "currency": "usd",
+ "description": "Additional license (Jan 2, 2012 - Feb 2, 2012)",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000003",
+ "invoice_item": "ii_NORMALIZED00000000000003",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1328151845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ2PD2X8vgpBNGi2WCVoxN",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqbn9E3BYkUq",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 800,
+ "unit_amount_decimal": "800"
+ },
+ "proration": false,
+ "quantity": 14,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ2PD2X8vgpBNGWj7t13XB"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/in_NORMALIZED00000000000002/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": 1000000000,
+ "number": "NORMALI-0002",
+ "object": "invoice",
+ "paid": false,
+ "payment_intent": "pi_1GvQ2RD2X8vgpBNGtEBCkF9Z",
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "receipt_number": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Standard",
+ "status": "open",
+ "status_transitions": {
+ "finalized_at": 1000000000,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subtotal": 11200,
+ "tax": null,
+ "tax_percent": null,
+ "total": 11200,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1000000000
+ },
+ {
+ "account_country": "US",
+ "account_name": null,
+ "amount_due": 0,
+ "amount_paid": 0,
+ "amount_remaining": 0,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": true,
+ "auto_advance": false,
+ "billing": "charge_automatically",
+ "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": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "due_date": null,
+ "ending_balance": 0,
+ "finalized_at": 1000000000,
+ "footer": null,
+ "hosted_invoice_url": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000001sXXeo",
+ "id": "in_NORMALIZED00000000000001",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000001sXXeo/pdf",
+ "lines": {
+ "data": [
+ {
+ "amount": 4800,
+ "currency": "usd",
+ "description": "Zulip Standard",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000001",
+ "invoice_item": "ii_NORMALIZED00000000000001",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1328151845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ2MD2X8vgpBNGmnU3Nexq",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqrQVq8e30wd",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 800,
+ "unit_amount_decimal": "800"
+ },
+ "proration": false,
+ "quantity": 6,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ2MD2X8vgpBNGxjcmXQWz"
+ },
+ {
+ "amount": -4800,
+ "currency": "usd",
+ "description": "Payment (Card ending in 4242)",
+ "discountable": false,
+ "id": "ii_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",
+ "id": "price_1GvQ2MD2X8vgpBNGPP6MRxVi",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqIz3JTQJXqm",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": -4800,
+ "unit_amount_decimal": "-4800"
+ },
+ "proration": false,
+ "quantity": 1,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ2MD2X8vgpBNGxqc69b7U"
+ }
+ ],
+ "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",
+ "paid": true,
+ "payment_intent": null,
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "receipt_number": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Standard",
+ "status": "paid",
+ "status_transitions": {
+ "finalized_at": 1000000000,
+ "marked_uncollectible_at": null,
+ "paid_at": 1000000000,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subtotal": 0,
+ "tax": null,
+ "tax_percent": null,
+ "total": 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_monthly_plan_to_annual_plan_for_automatic_license_management--Invoice.list.2.json b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Invoice.list.2.json
new file mode 100644
index 00000000000..52e883d852c
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Invoice.list.2.json
@@ -0,0 +1,563 @@
+{
+ "data": [
+ {
+ "account_country": "US",
+ "account_name": null,
+ "amount_due": 36830,
+ "amount_paid": 0,
+ "amount_remaining": 36830,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "charge_automatically",
+ "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": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "due_date": null,
+ "ending_balance": 0,
+ "finalized_at": 1000000000,
+ "footer": null,
+ "hosted_invoice_url": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000004izTRV",
+ "id": "in_NORMALIZED00000000000004",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000004izTRV/pdf",
+ "lines": {
+ "data": [
+ {
+ "amount": 36830,
+ "currency": "usd",
+ "description": "Additional license (Mar 2, 2012 - Feb 2, 2013)",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000006",
+ "invoice_item": "ii_NORMALIZED00000000000006",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1359774245,
+ "start": 1330657445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ2VD2X8vgpBNGa0BY3luD",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqPUFMHEL03U",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 7366,
+ "unit_amount_decimal": "7366"
+ },
+ "proration": false,
+ "quantity": 5,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ2VD2X8vgpBNGbpLwsVBN"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/in_NORMALIZED00000000000004/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": 1000000000,
+ "number": "NORMALI-0004",
+ "object": "invoice",
+ "paid": false,
+ "payment_intent": "pi_1GvQ2WD2X8vgpBNGdKVWsvEL",
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "receipt_number": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Standard",
+ "status": "open",
+ "status_transitions": {
+ "finalized_at": 1000000000,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subtotal": 36830,
+ "tax": null,
+ "tax_percent": null,
+ "total": 36830,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1000000000
+ },
+ {
+ "account_country": "US",
+ "account_name": null,
+ "amount_due": 200000,
+ "amount_paid": 0,
+ "amount_remaining": 200000,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "charge_automatically",
+ "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": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "due_date": null,
+ "ending_balance": 0,
+ "finalized_at": 1000000000,
+ "footer": null,
+ "hosted_invoice_url": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000003NiCvS",
+ "id": "in_NORMALIZED00000000000003",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000003NiCvS/pdf",
+ "lines": {
+ "data": [
+ {
+ "amount": 40000,
+ "currency": "usd",
+ "description": "Additional license (Feb 2, 2012 - Feb 2, 2013)",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000004",
+ "invoice_item": "ii_NORMALIZED00000000000004",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1359774245,
+ "start": 1328151845
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ2SD2X8vgpBNGDJwXOc3b",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqxNSx9MHbPC",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 5,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ2SD2X8vgpBNGlalvG9cv"
+ },
+ {
+ "amount": 160000,
+ "currency": "usd",
+ "description": "Zulip Standard - renewal",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000005",
+ "invoice_item": "ii_NORMALIZED00000000000005",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1359774245,
+ "start": 1328151845
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ2RD2X8vgpBNGanjAQMpk",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOquKicbsnEfk",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 20,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ2RD2X8vgpBNGgza03wZ5"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 2,
+ "url": "/v1/invoices/in_NORMALIZED00000000000003/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": 1000000000,
+ "number": "NORMALI-0003",
+ "object": "invoice",
+ "paid": false,
+ "payment_intent": "pi_1GvQ2TD2X8vgpBNGI7xPlRLT",
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "receipt_number": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Standard",
+ "status": "open",
+ "status_transitions": {
+ "finalized_at": 1000000000,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subtotal": 200000,
+ "tax": null,
+ "tax_percent": null,
+ "total": 200000,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1000000000
+ },
+ {
+ "account_country": "US",
+ "account_name": null,
+ "amount_due": 11200,
+ "amount_paid": 0,
+ "amount_remaining": 11200,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "charge_automatically",
+ "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": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "due_date": null,
+ "ending_balance": 0,
+ "finalized_at": 1000000000,
+ "footer": null,
+ "hosted_invoice_url": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000002BzaWK",
+ "id": "in_NORMALIZED00000000000002",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000002BzaWK/pdf",
+ "lines": {
+ "data": [
+ {
+ "amount": 11200,
+ "currency": "usd",
+ "description": "Additional license (Jan 2, 2012 - Feb 2, 2012)",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000003",
+ "invoice_item": "ii_NORMALIZED00000000000003",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1328151845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ2PD2X8vgpBNGi2WCVoxN",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqbn9E3BYkUq",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 800,
+ "unit_amount_decimal": "800"
+ },
+ "proration": false,
+ "quantity": 14,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ2PD2X8vgpBNGWj7t13XB"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/in_NORMALIZED00000000000002/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": 1000000000,
+ "number": "NORMALI-0002",
+ "object": "invoice",
+ "paid": false,
+ "payment_intent": "pi_1GvQ2RD2X8vgpBNGtEBCkF9Z",
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "receipt_number": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Standard",
+ "status": "open",
+ "status_transitions": {
+ "finalized_at": 1000000000,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subtotal": 11200,
+ "tax": null,
+ "tax_percent": null,
+ "total": 11200,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1000000000
+ },
+ {
+ "account_country": "US",
+ "account_name": null,
+ "amount_due": 0,
+ "amount_paid": 0,
+ "amount_remaining": 0,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": true,
+ "auto_advance": false,
+ "billing": "charge_automatically",
+ "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": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "due_date": null,
+ "ending_balance": 0,
+ "finalized_at": 1000000000,
+ "footer": null,
+ "hosted_invoice_url": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000001sXXeo",
+ "id": "in_NORMALIZED00000000000001",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000001sXXeo/pdf",
+ "lines": {
+ "data": [
+ {
+ "amount": 4800,
+ "currency": "usd",
+ "description": "Zulip Standard",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000001",
+ "invoice_item": "ii_NORMALIZED00000000000001",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1328151845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ2MD2X8vgpBNGmnU3Nexq",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqrQVq8e30wd",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 800,
+ "unit_amount_decimal": "800"
+ },
+ "proration": false,
+ "quantity": 6,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ2MD2X8vgpBNGxjcmXQWz"
+ },
+ {
+ "amount": -4800,
+ "currency": "usd",
+ "description": "Payment (Card ending in 4242)",
+ "discountable": false,
+ "id": "ii_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",
+ "id": "price_1GvQ2MD2X8vgpBNGPP6MRxVi",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqIz3JTQJXqm",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": -4800,
+ "unit_amount_decimal": "-4800"
+ },
+ "proration": false,
+ "quantity": 1,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ2MD2X8vgpBNGxqc69b7U"
+ }
+ ],
+ "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",
+ "paid": true,
+ "payment_intent": null,
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "receipt_number": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Standard",
+ "status": "paid",
+ "status_transitions": {
+ "finalized_at": 1000000000,
+ "marked_uncollectible_at": null,
+ "paid_at": 1000000000,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subtotal": 0,
+ "tax": null,
+ "tax_percent": null,
+ "total": 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_monthly_plan_to_annual_plan_for_automatic_license_management--Invoice.list.3.json b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Invoice.list.3.json
new file mode 100644
index 00000000000..9f949ec1c92
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Invoice.list.3.json
@@ -0,0 +1,681 @@
+{
+ "data": [
+ {
+ "account_country": "US",
+ "account_name": null,
+ "amount_due": 240000,
+ "amount_paid": 0,
+ "amount_remaining": 240000,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "charge_automatically",
+ "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": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "due_date": null,
+ "ending_balance": 0,
+ "finalized_at": 1000000000,
+ "footer": null,
+ "hosted_invoice_url": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000005DACfs",
+ "id": "in_NORMALIZED00000000000005",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000005DACfs/pdf",
+ "lines": {
+ "data": [
+ {
+ "amount": 240000,
+ "currency": "usd",
+ "description": "Zulip Standard - renewal",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000007",
+ "invoice_item": "ii_NORMALIZED00000000000007",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1391310245,
+ "start": 1359774245
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ2XD2X8vgpBNGamMRrAgW",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqc8FlpLiZkO",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 30,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ2XD2X8vgpBNGlycTk5fw"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/in_NORMALIZED00000000000005/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": 1000000000,
+ "number": "NORMALI-0005",
+ "object": "invoice",
+ "paid": false,
+ "payment_intent": "pi_1GvQ2ZD2X8vgpBNGWgT2rokR",
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "receipt_number": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Standard",
+ "status": "open",
+ "status_transitions": {
+ "finalized_at": 1000000000,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subtotal": 240000,
+ "tax": null,
+ "tax_percent": null,
+ "total": 240000,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1000000000
+ },
+ {
+ "account_country": "US",
+ "account_name": null,
+ "amount_due": 36830,
+ "amount_paid": 0,
+ "amount_remaining": 36830,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "charge_automatically",
+ "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": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "due_date": null,
+ "ending_balance": 0,
+ "finalized_at": 1000000000,
+ "footer": null,
+ "hosted_invoice_url": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000004izTRV",
+ "id": "in_NORMALIZED00000000000004",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000004izTRV/pdf",
+ "lines": {
+ "data": [
+ {
+ "amount": 36830,
+ "currency": "usd",
+ "description": "Additional license (Mar 2, 2012 - Feb 2, 2013)",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000006",
+ "invoice_item": "ii_NORMALIZED00000000000006",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1359774245,
+ "start": 1330657445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ2VD2X8vgpBNGa0BY3luD",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqPUFMHEL03U",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 7366,
+ "unit_amount_decimal": "7366"
+ },
+ "proration": false,
+ "quantity": 5,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ2VD2X8vgpBNGbpLwsVBN"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/in_NORMALIZED00000000000004/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": 1000000000,
+ "number": "NORMALI-0004",
+ "object": "invoice",
+ "paid": false,
+ "payment_intent": "pi_1GvQ2WD2X8vgpBNGdKVWsvEL",
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "receipt_number": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Standard",
+ "status": "open",
+ "status_transitions": {
+ "finalized_at": 1000000000,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subtotal": 36830,
+ "tax": null,
+ "tax_percent": null,
+ "total": 36830,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1000000000
+ },
+ {
+ "account_country": "US",
+ "account_name": null,
+ "amount_due": 200000,
+ "amount_paid": 0,
+ "amount_remaining": 200000,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "charge_automatically",
+ "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": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "due_date": null,
+ "ending_balance": 0,
+ "finalized_at": 1000000000,
+ "footer": null,
+ "hosted_invoice_url": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000003NiCvS",
+ "id": "in_NORMALIZED00000000000003",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000003NiCvS/pdf",
+ "lines": {
+ "data": [
+ {
+ "amount": 40000,
+ "currency": "usd",
+ "description": "Additional license (Feb 2, 2012 - Feb 2, 2013)",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000004",
+ "invoice_item": "ii_NORMALIZED00000000000004",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1359774245,
+ "start": 1328151845
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ2SD2X8vgpBNGDJwXOc3b",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqxNSx9MHbPC",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 5,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ2SD2X8vgpBNGlalvG9cv"
+ },
+ {
+ "amount": 160000,
+ "currency": "usd",
+ "description": "Zulip Standard - renewal",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000005",
+ "invoice_item": "ii_NORMALIZED00000000000005",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1359774245,
+ "start": 1328151845
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ2RD2X8vgpBNGanjAQMpk",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOquKicbsnEfk",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 20,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ2RD2X8vgpBNGgza03wZ5"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 2,
+ "url": "/v1/invoices/in_NORMALIZED00000000000003/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": 1000000000,
+ "number": "NORMALI-0003",
+ "object": "invoice",
+ "paid": false,
+ "payment_intent": "pi_1GvQ2TD2X8vgpBNGI7xPlRLT",
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "receipt_number": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Standard",
+ "status": "open",
+ "status_transitions": {
+ "finalized_at": 1000000000,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subtotal": 200000,
+ "tax": null,
+ "tax_percent": null,
+ "total": 200000,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1000000000
+ },
+ {
+ "account_country": "US",
+ "account_name": null,
+ "amount_due": 11200,
+ "amount_paid": 0,
+ "amount_remaining": 11200,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "charge_automatically",
+ "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": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "due_date": null,
+ "ending_balance": 0,
+ "finalized_at": 1000000000,
+ "footer": null,
+ "hosted_invoice_url": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000002BzaWK",
+ "id": "in_NORMALIZED00000000000002",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000002BzaWK/pdf",
+ "lines": {
+ "data": [
+ {
+ "amount": 11200,
+ "currency": "usd",
+ "description": "Additional license (Jan 2, 2012 - Feb 2, 2012)",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000003",
+ "invoice_item": "ii_NORMALIZED00000000000003",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1328151845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ2PD2X8vgpBNGi2WCVoxN",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqbn9E3BYkUq",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 800,
+ "unit_amount_decimal": "800"
+ },
+ "proration": false,
+ "quantity": 14,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ2PD2X8vgpBNGWj7t13XB"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/in_NORMALIZED00000000000002/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": 1000000000,
+ "number": "NORMALI-0002",
+ "object": "invoice",
+ "paid": false,
+ "payment_intent": "pi_1GvQ2RD2X8vgpBNGtEBCkF9Z",
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "receipt_number": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Standard",
+ "status": "open",
+ "status_transitions": {
+ "finalized_at": 1000000000,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subtotal": 11200,
+ "tax": null,
+ "tax_percent": null,
+ "total": 11200,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1000000000
+ },
+ {
+ "account_country": "US",
+ "account_name": null,
+ "amount_due": 0,
+ "amount_paid": 0,
+ "amount_remaining": 0,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": true,
+ "auto_advance": false,
+ "billing": "charge_automatically",
+ "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": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "due_date": null,
+ "ending_balance": 0,
+ "finalized_at": 1000000000,
+ "footer": null,
+ "hosted_invoice_url": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000001sXXeo",
+ "id": "in_NORMALIZED00000000000001",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000001sXXeo/pdf",
+ "lines": {
+ "data": [
+ {
+ "amount": 4800,
+ "currency": "usd",
+ "description": "Zulip Standard",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000001",
+ "invoice_item": "ii_NORMALIZED00000000000001",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1328151845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ2MD2X8vgpBNGmnU3Nexq",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqrQVq8e30wd",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 800,
+ "unit_amount_decimal": "800"
+ },
+ "proration": false,
+ "quantity": 6,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ2MD2X8vgpBNGxjcmXQWz"
+ },
+ {
+ "amount": -4800,
+ "currency": "usd",
+ "description": "Payment (Card ending in 4242)",
+ "discountable": false,
+ "id": "ii_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",
+ "id": "price_1GvQ2MD2X8vgpBNGPP6MRxVi",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqIz3JTQJXqm",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": -4800,
+ "unit_amount_decimal": "-4800"
+ },
+ "proration": false,
+ "quantity": 1,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ2MD2X8vgpBNGxqc69b7U"
+ }
+ ],
+ "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",
+ "paid": true,
+ "payment_intent": null,
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "receipt_number": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Standard",
+ "status": "paid",
+ "status_transitions": {
+ "finalized_at": 1000000000,
+ "marked_uncollectible_at": null,
+ "paid_at": 1000000000,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subtotal": 0,
+ "tax": null,
+ "tax_percent": null,
+ "total": 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_monthly_plan_to_annual_plan_for_automatic_license_management--InvoiceItem.create.1.json b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--InvoiceItem.create.1.json
new file mode 100644
index 00000000000..1704e35403d
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--InvoiceItem.create.1.json
@@ -0,0 +1,43 @@
+{
+ "amount": -4800,
+ "currency": "usd",
+ "customer": "cus_NORMALIZED0001",
+ "date": 1000000000,
+ "description": "Payment (Card ending in 4242)",
+ "discountable": false,
+ "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",
+ "id": "price_1GvQ2MD2X8vgpBNGPP6MRxVi",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqIz3JTQJXqm",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": -4800,
+ "unit_amount_decimal": "-4800"
+ },
+ "proration": false,
+ "quantity": 1,
+ "subscription": null,
+ "tax_rates": [],
+ "unit_amount": -4800,
+ "unit_amount_decimal": "-4800"
+}
diff --git a/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--InvoiceItem.create.2.json b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--InvoiceItem.create.2.json
new file mode 100644
index 00000000000..7e972e9ed81
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--InvoiceItem.create.2.json
@@ -0,0 +1,43 @@
+{
+ "amount": 4800,
+ "currency": "usd",
+ "customer": "cus_NORMALIZED0001",
+ "date": 1000000000,
+ "description": "Zulip Standard",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000001",
+ "invoice": null,
+ "livemode": false,
+ "metadata": {},
+ "object": "invoiceitem",
+ "period": {
+ "end": 1328151845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ2MD2X8vgpBNGmnU3Nexq",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqrQVq8e30wd",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 800,
+ "unit_amount_decimal": "800"
+ },
+ "proration": false,
+ "quantity": 6,
+ "subscription": null,
+ "tax_rates": [],
+ "unit_amount": 800,
+ "unit_amount_decimal": "800"
+}
diff --git a/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--InvoiceItem.create.3.json b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--InvoiceItem.create.3.json
new file mode 100644
index 00000000000..85dfd73948f
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--InvoiceItem.create.3.json
@@ -0,0 +1,43 @@
+{
+ "amount": 11200,
+ "currency": "usd",
+ "customer": "cus_NORMALIZED0001",
+ "date": 1000000000,
+ "description": "Additional license (Jan 2, 2012 - Feb 2, 2012)",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000003",
+ "invoice": null,
+ "livemode": false,
+ "metadata": {},
+ "object": "invoiceitem",
+ "period": {
+ "end": 1328151845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ2PD2X8vgpBNGi2WCVoxN",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqbn9E3BYkUq",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 800,
+ "unit_amount_decimal": "800"
+ },
+ "proration": false,
+ "quantity": 14,
+ "subscription": null,
+ "tax_rates": [],
+ "unit_amount": 800,
+ "unit_amount_decimal": "800"
+}
diff --git a/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--InvoiceItem.create.4.json b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--InvoiceItem.create.4.json
new file mode 100644
index 00000000000..4df7018f01f
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--InvoiceItem.create.4.json
@@ -0,0 +1,43 @@
+{
+ "amount": 160000,
+ "currency": "usd",
+ "customer": "cus_NORMALIZED0001",
+ "date": 1000000000,
+ "description": "Zulip Standard - renewal",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000005",
+ "invoice": null,
+ "livemode": false,
+ "metadata": {},
+ "object": "invoiceitem",
+ "period": {
+ "end": 1359774245,
+ "start": 1328151845
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ2RD2X8vgpBNGanjAQMpk",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOquKicbsnEfk",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 20,
+ "subscription": null,
+ "tax_rates": [],
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+}
diff --git a/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--InvoiceItem.create.5.json b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--InvoiceItem.create.5.json
new file mode 100644
index 00000000000..b339b156709
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--InvoiceItem.create.5.json
@@ -0,0 +1,43 @@
+{
+ "amount": 40000,
+ "currency": "usd",
+ "customer": "cus_NORMALIZED0001",
+ "date": 1000000000,
+ "description": "Additional license (Feb 2, 2012 - Feb 2, 2013)",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000004",
+ "invoice": null,
+ "livemode": false,
+ "metadata": {},
+ "object": "invoiceitem",
+ "period": {
+ "end": 1359774245,
+ "start": 1328151845
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ2SD2X8vgpBNGDJwXOc3b",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqxNSx9MHbPC",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 5,
+ "subscription": null,
+ "tax_rates": [],
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+}
diff --git a/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--InvoiceItem.create.6.json b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--InvoiceItem.create.6.json
new file mode 100644
index 00000000000..be232f9485d
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--InvoiceItem.create.6.json
@@ -0,0 +1,43 @@
+{
+ "amount": 36830,
+ "currency": "usd",
+ "customer": "cus_NORMALIZED0001",
+ "date": 1000000000,
+ "description": "Additional license (Mar 2, 2012 - Feb 2, 2013)",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000006",
+ "invoice": null,
+ "livemode": false,
+ "metadata": {},
+ "object": "invoiceitem",
+ "period": {
+ "end": 1359774245,
+ "start": 1330657445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ2VD2X8vgpBNGa0BY3luD",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqPUFMHEL03U",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 7366,
+ "unit_amount_decimal": "7366"
+ },
+ "proration": false,
+ "quantity": 5,
+ "subscription": null,
+ "tax_rates": [],
+ "unit_amount": 7366,
+ "unit_amount_decimal": "7366"
+}
diff --git a/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--InvoiceItem.create.7.json b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--InvoiceItem.create.7.json
new file mode 100644
index 00000000000..d9dc8e90605
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--InvoiceItem.create.7.json
@@ -0,0 +1,43 @@
+{
+ "amount": 240000,
+ "currency": "usd",
+ "customer": "cus_NORMALIZED0001",
+ "date": 1000000000,
+ "description": "Zulip Standard - renewal",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000007",
+ "invoice": null,
+ "livemode": false,
+ "metadata": {},
+ "object": "invoiceitem",
+ "period": {
+ "end": 1391310245,
+ "start": 1359774245
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ2XD2X8vgpBNGamMRrAgW",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqc8FlpLiZkO",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 30,
+ "subscription": null,
+ "tax_rates": [],
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+}
diff --git a/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Token.create.1.json b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Token.create.1.json
new file mode 100644
index 00000000000..60d47536e7c
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_automatic_license_management--Token.create.1.json
@@ -0,0 +1,33 @@
+{
+ "card": {
+ "address_city": "Pacific",
+ "address_country": "United States",
+ "address_line1": "Under the sea,",
+ "address_line1_check": "unchecked",
+ "address_line2": null,
+ "address_state": null,
+ "address_zip": "33333",
+ "address_zip_check": "unchecked",
+ "brand": "Visa",
+ "country": "US",
+ "cvc_check": "unchecked",
+ "dynamic_last4": null,
+ "exp_month": 3,
+ "exp_year": 2033,
+ "fingerprint": "NORMALIZED000001",
+ "funding": "credit",
+ "id": "card_NORMALIZED00000000000001",
+ "last4": "4242",
+ "metadata": {},
+ "name": "Ada Starr",
+ "object": "card",
+ "tokenization_method": null
+ },
+ "client_ip": "0.0.0.0",
+ "created": 1000000000,
+ "id": "tok_NORMALIZED00000000000001",
+ "livemode": false,
+ "object": "token",
+ "type": "card",
+ "used": false
+}
diff --git a/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_manual_license_management--Charge.create.1.json b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_manual_license_management--Charge.create.1.json
new file mode 100644
index 00000000000..bea8e4b1fb5
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_manual_license_management--Charge.create.1.json
@@ -0,0 +1,116 @@
+{
+ "amount": 28000,
+ "amount_refunded": 0,
+ "application": null,
+ "application_fee": null,
+ "application_fee_amount": null,
+ "balance_transaction": "txn_NORMALIZED00000000000001",
+ "billing_details": {
+ "address": {
+ "city": "Pacific",
+ "country": "United States",
+ "line1": "Under the sea,",
+ "line2": null,
+ "postal_code": "33333",
+ "state": null
+ },
+ "email": null,
+ "name": "Ada Starr",
+ "phone": null
+ },
+ "calculated_statement_descriptor": "ZULIP STANDARD",
+ "captured": true,
+ "created": 1000000000,
+ "currency": "usd",
+ "customer": "cus_NORMALIZED0001",
+ "description": "Upgrade to Zulip Standard, $8.0 x 35",
+ "destination": null,
+ "dispute": null,
+ "disputed": false,
+ "failure_code": null,
+ "failure_message": null,
+ "fraud_details": {},
+ "id": "ch_NORMALIZED00000000000001",
+ "invoice": null,
+ "livemode": false,
+ "metadata": {},
+ "object": "charge",
+ "on_behalf_of": null,
+ "order": null,
+ "outcome": {
+ "network_status": "approved_by_network",
+ "reason": null,
+ "risk_level": "normal",
+ "risk_score": 00,
+ "seller_message": "Payment complete.",
+ "type": "authorized"
+ },
+ "paid": true,
+ "payment_intent": null,
+ "payment_method": "card_NORMALIZED00000000000001",
+ "payment_method_details": {
+ "card": {
+ "brand": "visa",
+ "checks": {
+ "address_line1_check": "pass",
+ "address_postal_code_check": "pass",
+ "cvc_check": "pass"
+ },
+ "country": "US",
+ "exp_month": 3,
+ "exp_year": 2033,
+ "fingerprint": "NORMALIZED000001",
+ "funding": "credit",
+ "installments": null,
+ "last4": "4242",
+ "network": "visa",
+ "three_d_secure": null,
+ "wallet": null
+ },
+ "type": "card"
+ },
+ "receipt_email": "[email protected]",
+ "receipt_number": null,
+ "receipt_url": "https://pay.stripe.com/receipts/acct_NORMALIZED000001/ch_NORMALIZED00000000000001/rcpt_NORMALIZED000000000000000000001",
+ "refunded": false,
+ "refunds": {
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "total_count": 0,
+ "url": "/v1/charges/ch_NORMALIZED00000000000001/refunds"
+ },
+ "review": null,
+ "shipping": null,
+ "source": {
+ "address_city": "Pacific",
+ "address_country": "United States",
+ "address_line1": "Under the sea,",
+ "address_line1_check": "pass",
+ "address_line2": null,
+ "address_state": null,
+ "address_zip": "33333",
+ "address_zip_check": "pass",
+ "brand": "Visa",
+ "country": "US",
+ "customer": "cus_NORMALIZED0001",
+ "cvc_check": "pass",
+ "dynamic_last4": null,
+ "exp_month": 3,
+ "exp_year": 2033,
+ "fingerprint": "NORMALIZED000001",
+ "funding": "credit",
+ "id": "card_NORMALIZED00000000000001",
+ "last4": "4242",
+ "metadata": {},
+ "name": "Ada Starr",
+ "object": "card",
+ "tokenization_method": null
+ },
+ "source_transfer": null,
+ "statement_descriptor": "Zulip Standard",
+ "statement_descriptor_suffix": null,
+ "status": "succeeded",
+ "transfer_data": null,
+ "transfer_group": null
+}
diff --git a/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_manual_license_management--Customer.create.1.json b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_manual_license_management--Customer.create.1.json
new file mode 100644
index 00000000000..1e87c2923cd
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_manual_license_management--Customer.create.1.json
@@ -0,0 +1,80 @@
+{
+ "account_balance": 0,
+ "address": null,
+ "balance": 0,
+ "created": 1000000000,
+ "currency": null,
+ "default_source": "card_NORMALIZED00000000000001",
+ "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
+ },
+ "livemode": false,
+ "metadata": {
+ "realm_id": "1",
+ "realm_str": "zulip"
+ },
+ "name": null,
+ "next_invoice_sequence": 1,
+ "object": "customer",
+ "phone": null,
+ "preferred_locales": [],
+ "shipping": null,
+ "sources": {
+ "data": [
+ {
+ "address_city": "Pacific",
+ "address_country": "United States",
+ "address_line1": "Under the sea,",
+ "address_line1_check": "pass",
+ "address_line2": null,
+ "address_state": null,
+ "address_zip": "33333",
+ "address_zip_check": "pass",
+ "brand": "Visa",
+ "country": "US",
+ "customer": "cus_NORMALIZED0001",
+ "cvc_check": "pass",
+ "dynamic_last4": null,
+ "exp_month": 3,
+ "exp_year": 2033,
+ "fingerprint": "NORMALIZED000001",
+ "funding": "credit",
+ "id": "card_NORMALIZED00000000000001",
+ "last4": "4242",
+ "metadata": {},
+ "name": "Ada Starr",
+ "object": "card",
+ "tokenization_method": null
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/customers/cus_NORMALIZED0001/sources"
+ },
+ "subscriptions": {
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "total_count": 0,
+ "url": "/v1/customers/cus_NORMALIZED0001/subscriptions"
+ },
+ "tax_exempt": "none",
+ "tax_ids": {
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "total_count": 0,
+ "url": "/v1/customers/cus_NORMALIZED0001/tax_ids"
+ },
+ "tax_info": null,
+ "tax_info_verification": null
+}
diff --git a/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_manual_license_management--Customer.retrieve.1.json b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_manual_license_management--Customer.retrieve.1.json
new file mode 100644
index 00000000000..17d00481138
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_manual_license_management--Customer.retrieve.1.json
@@ -0,0 +1,104 @@
+{
+ "account_balance": 0,
+ "address": null,
+ "balance": 0,
+ "created": 1000000000,
+ "currency": "usd",
+ "default_source": {
+ "address_city": "Pacific",
+ "address_country": "United States",
+ "address_line1": "Under the sea,",
+ "address_line1_check": "pass",
+ "address_line2": null,
+ "address_state": null,
+ "address_zip": "33333",
+ "address_zip_check": "pass",
+ "brand": "Visa",
+ "country": "US",
+ "customer": "cus_NORMALIZED0001",
+ "cvc_check": "pass",
+ "dynamic_last4": null,
+ "exp_month": 3,
+ "exp_year": 2033,
+ "fingerprint": "NORMALIZED000001",
+ "funding": "credit",
+ "id": "card_NORMALIZED00000000000001",
+ "last4": "4242",
+ "metadata": {},
+ "name": "Ada Starr",
+ "object": "card",
+ "tokenization_method": 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
+ },
+ "livemode": false,
+ "metadata": {
+ "realm_id": "1",
+ "realm_str": "zulip"
+ },
+ "name": null,
+ "next_invoice_sequence": 2,
+ "object": "customer",
+ "phone": null,
+ "preferred_locales": [],
+ "shipping": null,
+ "sources": {
+ "data": [
+ {
+ "address_city": "Pacific",
+ "address_country": "United States",
+ "address_line1": "Under the sea,",
+ "address_line1_check": "pass",
+ "address_line2": null,
+ "address_state": null,
+ "address_zip": "33333",
+ "address_zip_check": "pass",
+ "brand": "Visa",
+ "country": "US",
+ "customer": "cus_NORMALIZED0001",
+ "cvc_check": "pass",
+ "dynamic_last4": null,
+ "exp_month": 3,
+ "exp_year": 2033,
+ "fingerprint": "NORMALIZED000001",
+ "funding": "credit",
+ "id": "card_NORMALIZED00000000000001",
+ "last4": "4242",
+ "metadata": {},
+ "name": "Ada Starr",
+ "object": "card",
+ "tokenization_method": null
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/customers/cus_NORMALIZED0001/sources"
+ },
+ "subscriptions": {
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "total_count": 0,
+ "url": "/v1/customers/cus_NORMALIZED0001/subscriptions"
+ },
+ "tax_exempt": "none",
+ "tax_ids": {
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "total_count": 0,
+ "url": "/v1/customers/cus_NORMALIZED0001/tax_ids"
+ },
+ "tax_info": null,
+ "tax_info_verification": null
+}
diff --git a/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_manual_license_management--Invoice.create.1.json b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_manual_license_management--Invoice.create.1.json
new file mode 100644
index 00000000000..1340fa41dbf
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_manual_license_management--Invoice.create.1.json
@@ -0,0 +1,160 @@
+{
+ "account_country": "US",
+ "account_name": null,
+ "amount_due": 0,
+ "amount_paid": 0,
+ "amount_remaining": 0,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "charge_automatically",
+ "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": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "due_date": null,
+ "ending_balance": null,
+ "finalized_at": null,
+ "footer": null,
+ "hosted_invoice_url": null,
+ "id": "in_NORMALIZED00000000000001",
+ "invoice_pdf": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 28000,
+ "currency": "usd",
+ "description": "Zulip Standard",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000001",
+ "invoice_item": "ii_NORMALIZED00000000000001",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1328151845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ2zD2X8vgpBNGDaM7ljiA",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqmw9b9tkVwI",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 800,
+ "unit_amount_decimal": "800"
+ },
+ "proration": false,
+ "quantity": 35,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ2zD2X8vgpBNGBFITf66k"
+ },
+ {
+ "amount": -28000,
+ "currency": "usd",
+ "description": "Payment (Card ending in 4242)",
+ "discountable": false,
+ "id": "ii_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",
+ "id": "price_1GvQ2zD2X8vgpBNGqrPfeYwv",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqnKCoreROal",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": -28000,
+ "unit_amount_decimal": "-28000"
+ },
+ "proration": false,
+ "quantity": 1,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ2zD2X8vgpBNG6lkEsKdb"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 2,
+ "url": "/v1/invoices/in_NORMALIZED00000000000001/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": 1000000000,
+ "number": "NORMALI-0001",
+ "object": "invoice",
+ "paid": false,
+ "payment_intent": null,
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "receipt_number": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Standard",
+ "status": "draft",
+ "status_transitions": {
+ "finalized_at": null,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subtotal": 0,
+ "tax": null,
+ "tax_percent": null,
+ "total": 0,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1000000000
+}
diff --git a/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_manual_license_management--Invoice.create.2.json b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_manual_license_management--Invoice.create.2.json
new file mode 100644
index 00000000000..4ebf520a9ac
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_manual_license_management--Invoice.create.2.json
@@ -0,0 +1,118 @@
+{
+ "account_country": "US",
+ "account_name": null,
+ "amount_due": 280000,
+ "amount_paid": 0,
+ "amount_remaining": 280000,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "charge_automatically",
+ "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": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "due_date": null,
+ "ending_balance": null,
+ "finalized_at": null,
+ "footer": null,
+ "hosted_invoice_url": null,
+ "id": "in_NORMALIZED00000000000002",
+ "invoice_pdf": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 280000,
+ "currency": "usd",
+ "description": "Zulip Standard - renewal",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000003",
+ "invoice_item": "ii_NORMALIZED00000000000003",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1359774245,
+ "start": 1328151845
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ33D2X8vgpBNG2TI3HOsm",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqHbrO8DnCsf",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 35,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ33D2X8vgpBNGO728kgr0"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/in_NORMALIZED00000000000002/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": 1000000000,
+ "number": "NORMALI-0002",
+ "object": "invoice",
+ "paid": false,
+ "payment_intent": null,
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "receipt_number": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Standard",
+ "status": "draft",
+ "status_transitions": {
+ "finalized_at": null,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subtotal": 280000,
+ "tax": null,
+ "tax_percent": null,
+ "total": 280000,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1000000000
+}
diff --git a/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_manual_license_management--Invoice.create.3.json b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_manual_license_management--Invoice.create.3.json
new file mode 100644
index 00000000000..81e2f6dda8a
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_manual_license_management--Invoice.create.3.json
@@ -0,0 +1,118 @@
+{
+ "account_country": "US",
+ "account_name": null,
+ "amount_due": 280000,
+ "amount_paid": 0,
+ "amount_remaining": 280000,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "charge_automatically",
+ "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": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "due_date": null,
+ "ending_balance": null,
+ "finalized_at": null,
+ "footer": null,
+ "hosted_invoice_url": null,
+ "id": "in_NORMALIZED00000000000003",
+ "invoice_pdf": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 280000,
+ "currency": "usd",
+ "description": "Zulip Standard - renewal",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000004",
+ "invoice_item": "ii_NORMALIZED00000000000004",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1391310245,
+ "start": 1359774245
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ35D2X8vgpBNGxxsMtJzq",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqnsmnQwOxKS",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 35,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ35D2X8vgpBNGRUNA2sh6"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/in_NORMALIZED00000000000003/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": 1000000000,
+ "number": "NORMALI-0003",
+ "object": "invoice",
+ "paid": false,
+ "payment_intent": null,
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "receipt_number": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Standard",
+ "status": "draft",
+ "status_transitions": {
+ "finalized_at": null,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subtotal": 280000,
+ "tax": null,
+ "tax_percent": null,
+ "total": 280000,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1000000000
+}
diff --git a/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_manual_license_management--Invoice.finalize_invoice.1.json b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_manual_license_management--Invoice.finalize_invoice.1.json
new file mode 100644
index 00000000000..2c353ac873d
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_manual_license_management--Invoice.finalize_invoice.1.json
@@ -0,0 +1,160 @@
+{
+ "account_country": "US",
+ "account_name": null,
+ "amount_due": 0,
+ "amount_paid": 0,
+ "amount_remaining": 0,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": true,
+ "auto_advance": false,
+ "billing": "charge_automatically",
+ "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": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "due_date": null,
+ "ending_balance": 0,
+ "finalized_at": 1000000000,
+ "footer": null,
+ "hosted_invoice_url": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000001w996I",
+ "id": "in_NORMALIZED00000000000001",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000001w996I/pdf",
+ "lines": {
+ "data": [
+ {
+ "amount": 28000,
+ "currency": "usd",
+ "description": "Zulip Standard",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000001",
+ "invoice_item": "ii_NORMALIZED00000000000001",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1328151845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ2zD2X8vgpBNGDaM7ljiA",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqmw9b9tkVwI",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 800,
+ "unit_amount_decimal": "800"
+ },
+ "proration": false,
+ "quantity": 35,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ2zD2X8vgpBNGBFITf66k"
+ },
+ {
+ "amount": -28000,
+ "currency": "usd",
+ "description": "Payment (Card ending in 4242)",
+ "discountable": false,
+ "id": "ii_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",
+ "id": "price_1GvQ2zD2X8vgpBNGqrPfeYwv",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqnKCoreROal",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": -28000,
+ "unit_amount_decimal": "-28000"
+ },
+ "proration": false,
+ "quantity": 1,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ2zD2X8vgpBNG6lkEsKdb"
+ }
+ ],
+ "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",
+ "paid": true,
+ "payment_intent": null,
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "receipt_number": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Standard",
+ "status": "paid",
+ "status_transitions": {
+ "finalized_at": 1000000000,
+ "marked_uncollectible_at": null,
+ "paid_at": 1000000000,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subtotal": 0,
+ "tax": null,
+ "tax_percent": null,
+ "total": 0,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1000000000
+}
diff --git a/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_manual_license_management--Invoice.finalize_invoice.2.json b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_manual_license_management--Invoice.finalize_invoice.2.json
new file mode 100644
index 00000000000..02e6c388149
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_manual_license_management--Invoice.finalize_invoice.2.json
@@ -0,0 +1,118 @@
+{
+ "account_country": "US",
+ "account_name": null,
+ "amount_due": 280000,
+ "amount_paid": 0,
+ "amount_remaining": 280000,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "charge_automatically",
+ "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": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "due_date": null,
+ "ending_balance": 0,
+ "finalized_at": 1000000000,
+ "footer": null,
+ "hosted_invoice_url": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000002wWqyj",
+ "id": "in_NORMALIZED00000000000002",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000002wWqyj/pdf",
+ "lines": {
+ "data": [
+ {
+ "amount": 280000,
+ "currency": "usd",
+ "description": "Zulip Standard - renewal",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000003",
+ "invoice_item": "ii_NORMALIZED00000000000003",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1359774245,
+ "start": 1328151845
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ33D2X8vgpBNG2TI3HOsm",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqHbrO8DnCsf",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 35,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ33D2X8vgpBNGO728kgr0"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/in_NORMALIZED00000000000002/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": 1000000000,
+ "number": "NORMALI-0002",
+ "object": "invoice",
+ "paid": false,
+ "payment_intent": "pi_1GvQ34D2X8vgpBNGW2flNzcq",
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "receipt_number": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Standard",
+ "status": "open",
+ "status_transitions": {
+ "finalized_at": 1000000000,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subtotal": 280000,
+ "tax": null,
+ "tax_percent": null,
+ "total": 280000,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1000000000
+}
diff --git a/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_manual_license_management--Invoice.finalize_invoice.3.json b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_manual_license_management--Invoice.finalize_invoice.3.json
new file mode 100644
index 00000000000..ae889f9cd97
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_manual_license_management--Invoice.finalize_invoice.3.json
@@ -0,0 +1,118 @@
+{
+ "account_country": "US",
+ "account_name": null,
+ "amount_due": 280000,
+ "amount_paid": 0,
+ "amount_remaining": 280000,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "charge_automatically",
+ "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": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "due_date": null,
+ "ending_balance": 0,
+ "finalized_at": 1000000000,
+ "footer": null,
+ "hosted_invoice_url": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000003r9OM2",
+ "id": "in_NORMALIZED00000000000003",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000003r9OM2/pdf",
+ "lines": {
+ "data": [
+ {
+ "amount": 280000,
+ "currency": "usd",
+ "description": "Zulip Standard - renewal",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000004",
+ "invoice_item": "ii_NORMALIZED00000000000004",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1391310245,
+ "start": 1359774245
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ35D2X8vgpBNGxxsMtJzq",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqnsmnQwOxKS",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 35,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ35D2X8vgpBNGRUNA2sh6"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/in_NORMALIZED00000000000003/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": 1000000000,
+ "number": "NORMALI-0003",
+ "object": "invoice",
+ "paid": false,
+ "payment_intent": "pi_1GvQ37D2X8vgpBNGPnEnueSu",
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "receipt_number": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Standard",
+ "status": "open",
+ "status_transitions": {
+ "finalized_at": 1000000000,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subtotal": 280000,
+ "tax": null,
+ "tax_percent": null,
+ "total": 280000,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1000000000
+}
diff --git a/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_manual_license_management--Invoice.list.1.json b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_manual_license_management--Invoice.list.1.json
new file mode 100644
index 00000000000..f5030262039
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_manual_license_management--Invoice.list.1.json
@@ -0,0 +1,285 @@
+{
+ "data": [
+ {
+ "account_country": "US",
+ "account_name": null,
+ "amount_due": 280000,
+ "amount_paid": 0,
+ "amount_remaining": 280000,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "charge_automatically",
+ "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": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "due_date": null,
+ "ending_balance": 0,
+ "finalized_at": 1000000000,
+ "footer": null,
+ "hosted_invoice_url": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000002wWqyj",
+ "id": "in_NORMALIZED00000000000002",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000002wWqyj/pdf",
+ "lines": {
+ "data": [
+ {
+ "amount": 280000,
+ "currency": "usd",
+ "description": "Zulip Standard - renewal",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000003",
+ "invoice_item": "ii_NORMALIZED00000000000003",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1359774245,
+ "start": 1328151845
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ33D2X8vgpBNG2TI3HOsm",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqHbrO8DnCsf",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 35,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ33D2X8vgpBNGO728kgr0"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/in_NORMALIZED00000000000002/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": 1000000000,
+ "number": "NORMALI-0002",
+ "object": "invoice",
+ "paid": false,
+ "payment_intent": "pi_1GvQ34D2X8vgpBNGW2flNzcq",
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "receipt_number": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Standard",
+ "status": "open",
+ "status_transitions": {
+ "finalized_at": 1000000000,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subtotal": 280000,
+ "tax": null,
+ "tax_percent": null,
+ "total": 280000,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1000000000
+ },
+ {
+ "account_country": "US",
+ "account_name": null,
+ "amount_due": 0,
+ "amount_paid": 0,
+ "amount_remaining": 0,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": true,
+ "auto_advance": false,
+ "billing": "charge_automatically",
+ "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": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "due_date": null,
+ "ending_balance": 0,
+ "finalized_at": 1000000000,
+ "footer": null,
+ "hosted_invoice_url": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000001w996I",
+ "id": "in_NORMALIZED00000000000001",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000001w996I/pdf",
+ "lines": {
+ "data": [
+ {
+ "amount": 28000,
+ "currency": "usd",
+ "description": "Zulip Standard",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000001",
+ "invoice_item": "ii_NORMALIZED00000000000001",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1328151845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ2zD2X8vgpBNGDaM7ljiA",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqmw9b9tkVwI",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 800,
+ "unit_amount_decimal": "800"
+ },
+ "proration": false,
+ "quantity": 35,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ2zD2X8vgpBNGBFITf66k"
+ },
+ {
+ "amount": -28000,
+ "currency": "usd",
+ "description": "Payment (Card ending in 4242)",
+ "discountable": false,
+ "id": "ii_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",
+ "id": "price_1GvQ2zD2X8vgpBNGqrPfeYwv",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqnKCoreROal",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": -28000,
+ "unit_amount_decimal": "-28000"
+ },
+ "proration": false,
+ "quantity": 1,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ2zD2X8vgpBNG6lkEsKdb"
+ }
+ ],
+ "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",
+ "paid": true,
+ "payment_intent": null,
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "receipt_number": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Standard",
+ "status": "paid",
+ "status_transitions": {
+ "finalized_at": 1000000000,
+ "marked_uncollectible_at": null,
+ "paid_at": 1000000000,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subtotal": 0,
+ "tax": null,
+ "tax_percent": null,
+ "total": 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_monthly_plan_to_annual_plan_for_manual_license_management--Invoice.list.2.json b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_manual_license_management--Invoice.list.2.json
new file mode 100644
index 00000000000..ad6f6b03658
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_manual_license_management--Invoice.list.2.json
@@ -0,0 +1,403 @@
+{
+ "data": [
+ {
+ "account_country": "US",
+ "account_name": null,
+ "amount_due": 280000,
+ "amount_paid": 0,
+ "amount_remaining": 280000,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "charge_automatically",
+ "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": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "due_date": null,
+ "ending_balance": 0,
+ "finalized_at": 1000000000,
+ "footer": null,
+ "hosted_invoice_url": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000003r9OM2",
+ "id": "in_NORMALIZED00000000000003",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000003r9OM2/pdf",
+ "lines": {
+ "data": [
+ {
+ "amount": 280000,
+ "currency": "usd",
+ "description": "Zulip Standard - renewal",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000004",
+ "invoice_item": "ii_NORMALIZED00000000000004",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1391310245,
+ "start": 1359774245
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ35D2X8vgpBNGxxsMtJzq",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqnsmnQwOxKS",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 35,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ35D2X8vgpBNGRUNA2sh6"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/in_NORMALIZED00000000000003/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": 1000000000,
+ "number": "NORMALI-0003",
+ "object": "invoice",
+ "paid": false,
+ "payment_intent": "pi_1GvQ37D2X8vgpBNGPnEnueSu",
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "receipt_number": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Standard",
+ "status": "open",
+ "status_transitions": {
+ "finalized_at": 1000000000,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subtotal": 280000,
+ "tax": null,
+ "tax_percent": null,
+ "total": 280000,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1000000000
+ },
+ {
+ "account_country": "US",
+ "account_name": null,
+ "amount_due": 280000,
+ "amount_paid": 0,
+ "amount_remaining": 280000,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "charge_automatically",
+ "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": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "due_date": null,
+ "ending_balance": 0,
+ "finalized_at": 1000000000,
+ "footer": null,
+ "hosted_invoice_url": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000002wWqyj",
+ "id": "in_NORMALIZED00000000000002",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000002wWqyj/pdf",
+ "lines": {
+ "data": [
+ {
+ "amount": 280000,
+ "currency": "usd",
+ "description": "Zulip Standard - renewal",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000003",
+ "invoice_item": "ii_NORMALIZED00000000000003",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1359774245,
+ "start": 1328151845
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ33D2X8vgpBNG2TI3HOsm",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqHbrO8DnCsf",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 35,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ33D2X8vgpBNGO728kgr0"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/in_NORMALIZED00000000000002/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": 1000000000,
+ "number": "NORMALI-0002",
+ "object": "invoice",
+ "paid": false,
+ "payment_intent": "pi_1GvQ34D2X8vgpBNGW2flNzcq",
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "receipt_number": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Standard",
+ "status": "open",
+ "status_transitions": {
+ "finalized_at": 1000000000,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subtotal": 280000,
+ "tax": null,
+ "tax_percent": null,
+ "total": 280000,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1000000000
+ },
+ {
+ "account_country": "US",
+ "account_name": null,
+ "amount_due": 0,
+ "amount_paid": 0,
+ "amount_remaining": 0,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": true,
+ "auto_advance": false,
+ "billing": "charge_automatically",
+ "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": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "due_date": null,
+ "ending_balance": 0,
+ "finalized_at": 1000000000,
+ "footer": null,
+ "hosted_invoice_url": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000001w996I",
+ "id": "in_NORMALIZED00000000000001",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000001w996I/pdf",
+ "lines": {
+ "data": [
+ {
+ "amount": 28000,
+ "currency": "usd",
+ "description": "Zulip Standard",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000001",
+ "invoice_item": "ii_NORMALIZED00000000000001",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1328151845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ2zD2X8vgpBNGDaM7ljiA",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqmw9b9tkVwI",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 800,
+ "unit_amount_decimal": "800"
+ },
+ "proration": false,
+ "quantity": 35,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ2zD2X8vgpBNGBFITf66k"
+ },
+ {
+ "amount": -28000,
+ "currency": "usd",
+ "description": "Payment (Card ending in 4242)",
+ "discountable": false,
+ "id": "ii_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",
+ "id": "price_1GvQ2zD2X8vgpBNGqrPfeYwv",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqnKCoreROal",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": -28000,
+ "unit_amount_decimal": "-28000"
+ },
+ "proration": false,
+ "quantity": 1,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1GvQ2zD2X8vgpBNG6lkEsKdb"
+ }
+ ],
+ "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",
+ "paid": true,
+ "payment_intent": null,
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "receipt_number": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Standard",
+ "status": "paid",
+ "status_transitions": {
+ "finalized_at": 1000000000,
+ "marked_uncollectible_at": null,
+ "paid_at": 1000000000,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subtotal": 0,
+ "tax": null,
+ "tax_percent": null,
+ "total": 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_monthly_plan_to_annual_plan_for_manual_license_management--InvoiceItem.create.1.json b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_manual_license_management--InvoiceItem.create.1.json
new file mode 100644
index 00000000000..5c373505530
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_manual_license_management--InvoiceItem.create.1.json
@@ -0,0 +1,43 @@
+{
+ "amount": -28000,
+ "currency": "usd",
+ "customer": "cus_NORMALIZED0001",
+ "date": 1000000000,
+ "description": "Payment (Card ending in 4242)",
+ "discountable": false,
+ "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",
+ "id": "price_1GvQ2zD2X8vgpBNGqrPfeYwv",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqnKCoreROal",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": -28000,
+ "unit_amount_decimal": "-28000"
+ },
+ "proration": false,
+ "quantity": 1,
+ "subscription": null,
+ "tax_rates": [],
+ "unit_amount": -28000,
+ "unit_amount_decimal": "-28000"
+}
diff --git a/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_manual_license_management--InvoiceItem.create.2.json b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_manual_license_management--InvoiceItem.create.2.json
new file mode 100644
index 00000000000..131e4a36076
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_manual_license_management--InvoiceItem.create.2.json
@@ -0,0 +1,43 @@
+{
+ "amount": 28000,
+ "currency": "usd",
+ "customer": "cus_NORMALIZED0001",
+ "date": 1000000000,
+ "description": "Zulip Standard",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000001",
+ "invoice": null,
+ "livemode": false,
+ "metadata": {},
+ "object": "invoiceitem",
+ "period": {
+ "end": 1328151845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ2zD2X8vgpBNGDaM7ljiA",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqmw9b9tkVwI",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 800,
+ "unit_amount_decimal": "800"
+ },
+ "proration": false,
+ "quantity": 35,
+ "subscription": null,
+ "tax_rates": [],
+ "unit_amount": 800,
+ "unit_amount_decimal": "800"
+}
diff --git a/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_manual_license_management--InvoiceItem.create.3.json b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_manual_license_management--InvoiceItem.create.3.json
new file mode 100644
index 00000000000..1fc7a4ff419
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_manual_license_management--InvoiceItem.create.3.json
@@ -0,0 +1,43 @@
+{
+ "amount": 280000,
+ "currency": "usd",
+ "customer": "cus_NORMALIZED0001",
+ "date": 1000000000,
+ "description": "Zulip Standard - renewal",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000003",
+ "invoice": null,
+ "livemode": false,
+ "metadata": {},
+ "object": "invoiceitem",
+ "period": {
+ "end": 1359774245,
+ "start": 1328151845
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ33D2X8vgpBNG2TI3HOsm",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqHbrO8DnCsf",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 35,
+ "subscription": null,
+ "tax_rates": [],
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+}
diff --git a/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_manual_license_management--InvoiceItem.create.4.json b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_manual_license_management--InvoiceItem.create.4.json
new file mode 100644
index 00000000000..594d8b35eef
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_manual_license_management--InvoiceItem.create.4.json
@@ -0,0 +1,43 @@
+{
+ "amount": 280000,
+ "currency": "usd",
+ "customer": "cus_NORMALIZED0001",
+ "date": 1000000000,
+ "description": "Zulip Standard - renewal",
+ "discountable": false,
+ "id": "ii_NORMALIZED00000000000004",
+ "invoice": null,
+ "livemode": false,
+ "metadata": {},
+ "object": "invoiceitem",
+ "period": {
+ "end": 1391310245,
+ "start": 1359774245
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1GvQ35D2X8vgpBNGxxsMtJzq",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_HUOqnsmnQwOxKS",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 35,
+ "subscription": null,
+ "tax_rates": [],
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+}
diff --git a/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_manual_license_management--Token.create.1.json b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_manual_license_management--Token.create.1.json
new file mode 100644
index 00000000000..60d47536e7c
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/switch_from_monthly_plan_to_annual_plan_for_manual_license_management--Token.create.1.json
@@ -0,0 +1,33 @@
+{
+ "card": {
+ "address_city": "Pacific",
+ "address_country": "United States",
+ "address_line1": "Under the sea,",
+ "address_line1_check": "unchecked",
+ "address_line2": null,
+ "address_state": null,
+ "address_zip": "33333",
+ "address_zip_check": "unchecked",
+ "brand": "Visa",
+ "country": "US",
+ "cvc_check": "unchecked",
+ "dynamic_last4": null,
+ "exp_month": 3,
+ "exp_year": 2033,
+ "fingerprint": "NORMALIZED000001",
+ "funding": "credit",
+ "id": "card_NORMALIZED00000000000001",
+ "last4": "4242",
+ "metadata": {},
+ "name": "Ada Starr",
+ "object": "card",
+ "tokenization_method": null
+ },
+ "client_ip": "0.0.0.0",
+ "created": 1000000000,
+ "id": "tok_NORMALIZED00000000000001",
+ "livemode": false,
+ "object": "token",
+ "type": "card",
+ "used": false
+}
diff --git a/corporate/tests/test_stripe.py b/corporate/tests/test_stripe.py
index b1078415c4e..3bd16fb4074 100644
--- a/corporate/tests/test_stripe.py
+++ b/corporate/tests/test_stripe.py
@@ -1322,6 +1322,245 @@ class StripeTest(StripeTestCase):
invoice_plans_as_needed(self.next_year + timedelta(days=400))
mocked.assert_not_called()
+ @mock_stripe()
+ @patch("corporate.lib.stripe.billing_logger.info")
+ def test_switch_from_monthly_plan_to_annual_plan_for_automatic_license_management(self, *mocks: Mock) -> None:
+ user = self.example_user("hamlet")
+
+ self.login_user(user)
+ with patch('corporate.lib.stripe.timezone_now', return_value=self.now):
+ self.upgrade(schedule='monthly')
+ monthly_plan = get_current_plan_by_realm(user.realm)
+ assert(monthly_plan is not None)
+ self.assertEqual(monthly_plan.automanage_licenses, True)
+ self.assertEqual(monthly_plan.billing_schedule, CustomerPlan.MONTHLY)
+
+ response = self.client_post("/json/billing/plan/change",
+ {'status': CustomerPlan.SWITCH_TO_ANNUAL_AT_END_OF_CYCLE})
+ self.assert_json_success(response)
+ monthly_plan.refresh_from_db()
+ self.assertEqual(monthly_plan.status, CustomerPlan.SWITCH_TO_ANNUAL_AT_END_OF_CYCLE)
+ with patch('corporate.views.timezone_now', return_value=self.now):
+ response = self.client_get("/billing/")
+ self.assert_in_success_response(["be switched from monthly to annual billing on <strong>February 2, 2012"], 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=monthly_plan).count(), 2)
+ self.assertEqual(LicenseLedger.objects.order_by('-id').values_list(
+ 'licenses', 'licenses_at_next_renewal').first(), (20, 20))
+
+ with patch('corporate.lib.stripe.timezone_now', return_value=self.next_month):
+ with patch("corporate.lib.stripe.get_latest_seat_count", return_value=25):
+ update_license_ledger_if_needed(user.realm, self.next_month)
+ self.assertEqual(LicenseLedger.objects.filter(plan=monthly_plan).count(), 2)
+ customer = get_customer_by_realm(user.realm)
+ assert(customer is not None)
+ self.assertEqual(CustomerPlan.objects.filter(customer=customer).count(), 2)
+ monthly_plan.refresh_from_db()
+ self.assertEqual(monthly_plan.status, CustomerPlan.ENDED)
+ self.assertEqual(monthly_plan.next_invoice_date, self.next_month)
+ annual_plan = get_current_plan_by_realm(user.realm)
+ assert(annual_plan is not None)
+ self.assertEqual(annual_plan.status, CustomerPlan.ACTIVE)
+ self.assertEqual(annual_plan.billing_schedule, CustomerPlan.ANNUAL)
+ self.assertEqual(annual_plan.invoicing_status, CustomerPlan.INITIAL_INVOICE_TO_BE_SENT)
+ self.assertEqual(annual_plan.billing_cycle_anchor, self.next_month)
+ self.assertEqual(annual_plan.next_invoice_date, self.next_month)
+ self.assertEqual(annual_plan.invoiced_through, None)
+ annual_ledger_entries = LicenseLedger.objects.filter(plan=annual_plan).order_by('id')
+ self.assertEqual(len(annual_ledger_entries), 2)
+ self.assertEqual(annual_ledger_entries[0].is_renewal, True)
+ self.assertEqual(annual_ledger_entries.values_list('licenses', 'licenses_at_next_renewal')[0], (20, 20))
+ self.assertEqual(annual_ledger_entries[1].is_renewal, False)
+ self.assertEqual(annual_ledger_entries.values_list('licenses', 'licenses_at_next_renewal')[1], (25, 25))
+
+ invoice_plans_as_needed(self.next_month)
+
+ annual_ledger_entries = LicenseLedger.objects.filter(plan=annual_plan).order_by('id')
+ self.assertEqual(len(annual_ledger_entries), 2)
+ annual_plan.refresh_from_db()
+ self.assertEqual(annual_plan.invoicing_status, CustomerPlan.DONE)
+ self.assertEqual(annual_plan.invoiced_through, annual_ledger_entries[1])
+ self.assertEqual(annual_plan.billing_cycle_anchor, self.next_month)
+ self.assertEqual(annual_plan.next_invoice_date, add_months(self.next_month, 1))
+ monthly_plan.refresh_from_db()
+ self.assertEqual(monthly_plan.next_invoice_date, None)
+
+ invoices = [invoice for invoice in stripe.Invoice.list(customer=customer.stripe_customer_id)]
+ self.assertEqual(len(invoices), 3)
+
+ annual_plan_invoice_items = [invoice_item for invoice_item in invoices[0].get("lines")]
+ self.assertEqual(len(annual_plan_invoice_items), 2)
+ annual_plan_invoice_item_params = {
+ "amount": 5 * 80 * 100,
+ "description": "Additional license (Feb 2, 2012 - Feb 2, 2013)",
+ "plan": None, "quantity": 5, "subscription": None, "discountable": False,
+ "period": {
+ "start": datetime_to_timestamp(self.next_month),
+ "end": datetime_to_timestamp(add_months(self.next_month, 12))
+ },
+ }
+ for key, value in annual_plan_invoice_item_params.items():
+ self.assertEqual(annual_plan_invoice_items[0][key], value)
+
+ annual_plan_invoice_item_params = {
+ "amount": 20 * 80 * 100, "description": "Zulip Standard - renewal",
+ "plan": None, "quantity": 20, "subscription": None, "discountable": False,
+ "period": {
+ "start": datetime_to_timestamp(self.next_month),
+ "end": datetime_to_timestamp(add_months(self.next_month, 12))
+ },
+ }
+ for key, value in annual_plan_invoice_item_params.items():
+ self.assertEqual(annual_plan_invoice_items[1][key], value)
+
+ monthly_plan_invoice_items = [invoice_item for invoice_item in invoices[1].get("lines")]
+ self.assertEqual(len(monthly_plan_invoice_items), 1)
+ monthly_plan_invoice_item_params = {
+ "amount": 14 * 8 * 100,
+ "description": "Additional license (Jan 2, 2012 - Feb 2, 2012)",
+ "plan": None, "quantity": 14, "subscription": None, "discountable": False,
+ "period": {
+ "start": datetime_to_timestamp(self.now),
+ "end": datetime_to_timestamp(self.next_month)
+ },
+ }
+ for key, value in monthly_plan_invoice_item_params.items():
+ self.assertEqual(monthly_plan_invoice_items[0][key], value)
+
+ with patch("corporate.lib.stripe.get_latest_seat_count", return_value=30):
+ update_license_ledger_if_needed(user.realm, add_months(self.next_month, 1))
+ invoice_plans_as_needed(add_months(self.next_month, 1))
+
+ invoices = [invoice for invoice in stripe.Invoice.list(customer=customer.stripe_customer_id)]
+ self.assertEqual(len(invoices), 4)
+
+ monthly_plan_invoice_items = [invoice_item for invoice_item in invoices[0].get("lines")]
+ self.assertEqual(len(monthly_plan_invoice_items), 1)
+ monthly_plan_invoice_item_params = {
+ "amount": 5 * 7366,
+ "description": "Additional license (Mar 2, 2012 - Feb 2, 2013)",
+ "plan": None, "quantity": 5, "subscription": None, "discountable": False,
+ "period": {
+ "start": datetime_to_timestamp(add_months(self.next_month, 1)),
+ "end": datetime_to_timestamp(add_months(self.next_month, 12))
+ },
+ }
+ for key, value in monthly_plan_invoice_item_params.items():
+ self.assertEqual(monthly_plan_invoice_items[0][key], value)
+ invoice_plans_as_needed(add_months(self.now, 13))
+
+ invoices = [invoice for invoice in stripe.Invoice.list(customer=customer.stripe_customer_id)]
+ self.assertEqual(len(invoices), 5)
+
+ annual_plan_invoice_items = [invoice_item for invoice_item in invoices[0].get("lines")]
+ self.assertEqual(len(annual_plan_invoice_items), 1)
+ annual_plan_invoice_item_params = {
+ "amount": 30 * 80 * 100,
+ "description": "Zulip Standard - renewal",
+ "plan": None, "quantity": 30, "subscription": None, "discountable": False,
+ "period": {
+ "start": datetime_to_timestamp(add_months(self.next_month, 12)),
+ "end": datetime_to_timestamp(add_months(self.next_month, 24))
+ },
+ }
+ for key, value in annual_plan_invoice_item_params.items():
+ self.assertEqual(annual_plan_invoice_items[0][key], value)
+
+ @mock_stripe()
+ @patch("corporate.lib.stripe.billing_logger.info")
+ def test_switch_from_monthly_plan_to_annual_plan_for_manual_license_management(self, *mocks: Mock) -> None:
+ user = self.example_user("hamlet")
+ num_licenses = 35
+
+ self.login_user(user)
+ with patch('corporate.lib.stripe.timezone_now', return_value=self.now):
+ self.upgrade(schedule='monthly', license_management='manual', licenses=num_licenses)
+ monthly_plan = get_current_plan_by_realm(user.realm)
+ assert(monthly_plan is not None)
+ self.assertEqual(monthly_plan.automanage_licenses, False)
+ self.assertEqual(monthly_plan.billing_schedule, CustomerPlan.MONTHLY)
+
+ response = self.client_post("/json/billing/plan/change",
+ {'status': CustomerPlan.SWITCH_TO_ANNUAL_AT_END_OF_CYCLE})
+ self.assert_json_success(response)
+ monthly_plan.refresh_from_db()
+ self.assertEqual(monthly_plan.status, CustomerPlan.SWITCH_TO_ANNUAL_AT_END_OF_CYCLE)
+ with patch('corporate.views.timezone_now', return_value=self.now):
+ response = self.client_get("/billing/")
+ self.assert_in_success_response(["be switched from monthly to annual billing on <strong>February 2, 2012"], response)
+
+ with patch('corporate.lib.stripe.timezone_now', return_value=self.next_month):
+ invoice_plans_as_needed(self.next_month)
+
+ self.assertEqual(LicenseLedger.objects.filter(plan=monthly_plan).count(), 1)
+ customer = get_customer_by_realm(user.realm)
+ assert(customer is not None)
+ self.assertEqual(CustomerPlan.objects.filter(customer=customer).count(), 2)
+ monthly_plan.refresh_from_db()
+ self.assertEqual(monthly_plan.status, CustomerPlan.ENDED)
+ self.assertEqual(monthly_plan.next_invoice_date, None)
+ annual_plan = get_current_plan_by_realm(user.realm)
+ assert(annual_plan is not None)
+ self.assertEqual(annual_plan.status, CustomerPlan.ACTIVE)
+ self.assertEqual(annual_plan.billing_schedule, CustomerPlan.ANNUAL)
+ self.assertEqual(annual_plan.invoicing_status, CustomerPlan.INITIAL_INVOICE_TO_BE_SENT)
+ self.assertEqual(annual_plan.billing_cycle_anchor, self.next_month)
+ self.assertEqual(annual_plan.next_invoice_date, self.next_month)
+ annual_ledger_entries = LicenseLedger.objects.filter(plan=annual_plan).order_by('id')
+ self.assertEqual(len(annual_ledger_entries), 1)
+ self.assertEqual(annual_ledger_entries[0].is_renewal, True)
+ self.assertEqual(annual_ledger_entries.values_list('licenses', 'licenses_at_next_renewal')[0], (num_licenses, num_licenses))
+ self.assertEqual(annual_plan.invoiced_through, None)
+
+ with patch('corporate.lib.stripe.timezone_now', return_value=self.next_month):
+ invoice_plans_as_needed(self.next_month + timedelta(days=1))
+
+ annual_plan.refresh_from_db()
+ self.assertEqual(annual_plan.invoiced_through, annual_ledger_entries[0])
+ self.assertEqual(annual_plan.next_invoice_date, add_months(self.next_month, 12))
+ self.assertEqual(annual_plan.invoicing_status, CustomerPlan.DONE)
+
+ invoices = [invoice for invoice in stripe.Invoice.list(customer=customer.stripe_customer_id)]
+ self.assertEqual(len(invoices), 2)
+
+ annual_plan_invoice_items = [invoice_item for invoice_item in invoices[0].get("lines")]
+ self.assertEqual(len(annual_plan_invoice_items), 1)
+ annual_plan_invoice_item_params = {
+ "amount": num_licenses * 80 * 100, "description": "Zulip Standard - renewal",
+ "plan": None, "quantity": num_licenses, "subscription": None, "discountable": False,
+ "period": {
+ "start": datetime_to_timestamp(self.next_month),
+ "end": datetime_to_timestamp(add_months(self.next_month, 12))
+ },
+ }
+ for key, value in annual_plan_invoice_item_params.items():
+ self.assertEqual(annual_plan_invoice_items[0][key], value)
+
+ with patch('corporate.lib.stripe.invoice_plan') as m:
+ invoice_plans_as_needed(add_months(self.now, 2))
+ m.assert_not_called()
+
+ invoice_plans_as_needed(add_months(self.now, 13))
+
+ invoices = [invoice for invoice in stripe.Invoice.list(customer=customer.stripe_customer_id)]
+ self.assertEqual(len(invoices), 3)
+
+ annual_plan_invoice_items = [invoice_item for invoice_item in invoices[0].get("lines")]
+ self.assertEqual(len(annual_plan_invoice_items), 1)
+ annual_plan_invoice_item_params = {
+ "amount": num_licenses * 80 * 100,
+ "description": "Zulip Standard - renewal",
+ "plan": None, "quantity": num_licenses, "subscription": None, "discountable": False,
+ "period": {
+ "start": datetime_to_timestamp(add_months(self.next_month, 12)),
+ "end": datetime_to_timestamp(add_months(self.next_month, 24))
+ },
+ }
+ for key, value in annual_plan_invoice_item_params.items():
+ self.assertEqual(annual_plan_invoice_items[0][key], value)
+
@patch("corporate.lib.stripe.billing_logger.info")
def test_reupgrade_after_plan_status_changed_to_downgrade_at_end_of_cycle(self, mock_: Mock) -> None:
user = self.example_user("hamlet")
@@ -1719,7 +1958,8 @@ class LicenseLedgerTest(StripeTestCase):
self.assertEqual(LicenseLedger.objects.count(), 1)
# Plan needs to renew
# TODO: do_deactivate_user for a user, so that licenses_at_next_renewal != licenses
- ledger_entry = make_end_of_cycle_updates_if_needed(plan, self.next_year)
+ new_plan, ledger_entry = make_end_of_cycle_updates_if_needed(plan, self.next_year)
+ self.assertIsNone(new_plan)
self.assertEqual(LicenseLedger.objects.count(), 2)
ledger_params = {
'plan': plan, 'is_renewal': True, 'event_time': self.next_year,
diff --git a/corporate/views.py b/corporate/views.py
index 1ff800b4850..b49f19083d7 100644
--- a/corporate/views.py
+++ b/corporate/views.py
@@ -200,14 +200,17 @@ def billing_home(request: HttpRequest) -> HttpResponse:
plan = get_current_plan_by_customer(customer)
if plan is not None:
now = timezone_now()
- last_ledger_entry = make_end_of_cycle_updates_if_needed(plan, now)
+ new_plan, last_ledger_entry = make_end_of_cycle_updates_if_needed(plan, now)
if last_ledger_entry is not None:
+ if new_plan is not None: # nocoverage
+ plan = new_plan
plan_name = {
CustomerPlan.STANDARD: 'Zulip Standard',
CustomerPlan.PLUS: 'Zulip Plus',
}[plan.tier]
free_trial = plan.status == CustomerPlan.FREE_TRIAL
downgrade_at_end_of_cycle = plan.status == CustomerPlan.DOWNGRADE_AT_END_OF_CYCLE
+ switch_to_annual_at_end_of_cycle = plan.status == CustomerPlan.SWITCH_TO_ANNUAL_AT_END_OF_CYCLE
licenses = last_ledger_entry.licenses
licenses_used = get_latest_seat_count(user.realm)
# Should do this in javascript, using the user's timezone
@@ -226,6 +229,7 @@ def billing_home(request: HttpRequest) -> HttpResponse:
'free_trial': free_trial,
'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,
'licenses': licenses,
'licenses_used': licenses_used,
'renewal_date': renewal_date,
@@ -244,7 +248,8 @@ def billing_home(request: HttpRequest) -> HttpResponse:
@has_request_variables
def change_plan_status(request: HttpRequest, user: UserProfile,
status: int=REQ("status", validator=check_int)) -> HttpResponse:
- assert(status in [CustomerPlan.ACTIVE, CustomerPlan.DOWNGRADE_AT_END_OF_CYCLE, CustomerPlan.ENDED])
+ assert(status in [CustomerPlan.ACTIVE, CustomerPlan.DOWNGRADE_AT_END_OF_CYCLE,
+ CustomerPlan.SWITCH_TO_ANNUAL_AT_END_OF_CYCLE, CustomerPlan.ENDED])
plan = get_current_plan_by_realm(user.realm)
assert(plan is not None) # for mypy
@@ -255,6 +260,11 @@ def change_plan_status(request: HttpRequest, user: UserProfile,
elif status == CustomerPlan.DOWNGRADE_AT_END_OF_CYCLE:
assert(plan.status == CustomerPlan.ACTIVE)
do_change_plan_status(plan, status)
+ elif status == CustomerPlan.SWITCH_TO_ANNUAL_AT_END_OF_CYCLE:
+ assert(plan.billing_schedule == CustomerPlan.MONTHLY)
+ assert(plan.status == CustomerPlan.ACTIVE)
+ assert(plan.fixed_price is None)
+ do_change_plan_status(plan, status)
elif status == CustomerPlan.ENDED:
assert(plan.status == CustomerPlan.FREE_TRIAL)
downgrade_now(user.realm)
diff --git a/templates/corporate/billing.html b/templates/corporate/billing.html
index 5952d6fad4c..440b7436245 100644
--- a/templates/corporate/billing.html
+++ b/templates/corporate/billing.html
@@ -51,6 +51,8 @@
<strong>${{ renewal_amount }}</strong>.
{% elif downgrade_at_end_of_cycle %}
Your plan will be downgraded to <strong>Zulip Limited</strong> on <strong>{{ renewal_date }}</strong>.
+ {% elif switch_to_annual_at_end_of_cycle %}
+ Your plan will be switched from monthly to annual billing on <strong>{{ renewal_date }}</strong>.
{% else %}
Your plan will renew on <strong>{{ renewal_date }}</strong> for
<strong>${{ renewal_amount }}</strong>.
diff --git a/zerver/models.py b/zerver/models.py
index acc9c276b73..a944aa0d4cc 100644
--- a/zerver/models.py
+++ b/zerver/models.py
@@ -2674,6 +2674,7 @@ class AbstractRealmAuditLog(models.Model):
CUSTOMER_CREATED = 501
CUSTOMER_PLAN_CREATED = 502
+ CUSTOMER_SWITCHED_FROM_MONTHLY_TO_ANNUAL_PLAN = 503
event_type: int = models.PositiveSmallIntegerField()