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: Void open invoices of small realms without an active plan.

Vishnu KS50950de24c03
diff --git a/corporate/lib/stripe.py b/corporate/lib/stripe.py
index ee10297a9f7..501eea0b1ff 100644
--- a/corporate/lib/stripe.py
+++ b/corporate/lib/stripe.py
@@ -1009,33 +1009,34 @@ def downgrade_small_realms_behind_on_payments_as_needed() -> None:
realm = customer.realm
# For larger realms, we generally want to talk to the customer
- # before downgrading; so this logic only applies with 5.
+ # before downgrading or cancelling invoices; so this logic only applies with 5.
if get_latest_seat_count(realm) >= 5:
continue
- if get_current_plan_by_customer(customer) is None:
- continue
-
- # Only customers with last 2 invoices open should be downgraded.
- if not customer_has_last_n_invoices_open(customer, 2):
- continue
+ if get_current_plan_by_customer(customer) is not None:
+ # Only customers with last 2 invoices open should be downgraded.
+ if not customer_has_last_n_invoices_open(customer, 2):
+ continue
- # We've now decided to downgrade this customer and void all invoices, and the below will execute this.
+ # We've now decided to downgrade this customer and void all invoices, and the below will execute this.
- downgrade_now_without_creating_additional_invoices(realm)
- void_all_open_invoices(realm)
- context: Dict[str, str] = {
- "upgrade_url": f"{realm.uri}{reverse('initial_upgrade')}",
- "realm": realm,
- }
- send_email_to_billing_admins_and_realm_owners(
- "zerver/emails/realm_auto_downgraded",
- realm,
- from_name=FromAddress.security_email_from_name(language=realm.default_language),
- from_address=FromAddress.tokenized_no_reply_address(),
- language=realm.default_language,
- context=context,
- )
+ downgrade_now_without_creating_additional_invoices(realm)
+ void_all_open_invoices(realm)
+ context: Dict[str, str] = {
+ "upgrade_url": f"{realm.uri}{reverse('initial_upgrade')}",
+ "realm": realm,
+ }
+ send_email_to_billing_admins_and_realm_owners(
+ "zerver/emails/realm_auto_downgraded",
+ realm,
+ from_name=FromAddress.security_email_from_name(language=realm.default_language),
+ from_address=FromAddress.tokenized_no_reply_address(),
+ language=realm.default_language,
+ context=context,
+ )
+ else:
+ if customer_has_last_n_invoices_open(customer, 1):
+ void_all_open_invoices(realm)
def update_billing_method_of_current_plan(
diff --git a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Customer.create.1.json b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Customer.create.1.json
index 3776562c5a0..e4bc8ad667c 100644
--- a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Customer.create.1.json
+++ b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Customer.create.1.json
@@ -6,9 +6,9 @@
"currency": null,
"default_source": null,
"delinquent": false,
- "description": "realm_425511 (None)",
+ "description": "realm_773649 (None)",
"discount": null,
- "email": "[email protected]",
+ "email": "[email protected]",
"id": "cus_NORMALIZED0001",
"invoice_prefix": "NORMA01",
"invoice_settings": {
@@ -19,7 +19,7 @@
"livemode": false,
"metadata": {
"realm_id": "1",
- "realm_str": "realm_425511"
+ "realm_str": "realm_773649"
},
"name": null,
"next_invoice_sequence": 1,
diff --git a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Customer.create.2.json b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Customer.create.2.json
index 770b0eb0a3e..853870a5d70 100644
--- a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Customer.create.2.json
+++ b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Customer.create.2.json
@@ -6,9 +6,9 @@
"currency": null,
"default_source": null,
"delinquent": false,
- "description": "realm_701713 (None)",
+ "description": "realm_311774 (None)",
"discount": null,
- "email": "[email protected]",
+ "email": "[email protected]",
"id": "cus_NORMALIZED0002",
"invoice_prefix": "NORMA02",
"invoice_settings": {
@@ -19,7 +19,7 @@
"livemode": false,
"metadata": {
"realm_id": "2",
- "realm_str": "realm_701713"
+ "realm_str": "realm_311774"
},
"name": null,
"next_invoice_sequence": 1,
diff --git a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Customer.create.3.json b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Customer.create.3.json
index 9b906b42f9d..367108a35b5 100644
--- a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Customer.create.3.json
+++ b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Customer.create.3.json
@@ -6,9 +6,9 @@
"currency": null,
"default_source": null,
"delinquent": false,
- "description": "realm_612438 (None)",
+ "description": "realm_796925 (None)",
"discount": null,
- "email": "[email protected]",
+ "email": "[email protected]",
"id": "cus_NORMALIZED0003",
"invoice_prefix": "NORMA03",
"invoice_settings": {
@@ -19,7 +19,7 @@
"livemode": false,
"metadata": {
"realm_id": "3",
- "realm_str": "realm_612438"
+ "realm_str": "realm_796925"
},
"name": null,
"next_invoice_sequence": 1,
diff --git a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Customer.create.4.json b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Customer.create.4.json
index 2947e819fea..c9bdaaaf5d4 100644
--- a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Customer.create.4.json
+++ b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Customer.create.4.json
@@ -6,9 +6,9 @@
"currency": null,
"default_source": null,
"delinquent": false,
- "description": "realm_158636 (None)",
+ "description": "realm_466353 (None)",
"discount": null,
- "email": "[email protected]",
+ "email": "[email protected]",
"id": "cus_NORMALIZED0004",
"invoice_prefix": "NORMA04",
"invoice_settings": {
@@ -19,7 +19,7 @@
"livemode": false,
"metadata": {
"realm_id": "4",
- "realm_str": "realm_158636"
+ "realm_str": "realm_466353"
},
"name": null,
"next_invoice_sequence": 1,
diff --git a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Customer.create.5.json b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Customer.create.5.json
index 3987d8d629c..9aaff7edb49 100644
--- a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Customer.create.5.json
+++ b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Customer.create.5.json
@@ -6,9 +6,9 @@
"currency": null,
"default_source": null,
"delinquent": false,
- "description": "realm_345953 (None)",
+ "description": "realm_871146 (None)",
"discount": null,
- "email": "[email protected]",
+ "email": "[email protected]",
"id": "cus_NORMALIZED0005",
"invoice_prefix": "NORMA05",
"invoice_settings": {
@@ -19,7 +19,7 @@
"livemode": false,
"metadata": {
"realm_id": "5",
- "realm_str": "realm_345953"
+ "realm_str": "realm_871146"
},
"name": null,
"next_invoice_sequence": 1,
diff --git a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Customer.create.6.json b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Customer.create.6.json
index ccdd4d1df0e..29b89b6b384 100644
--- a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Customer.create.6.json
+++ b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Customer.create.6.json
@@ -6,9 +6,9 @@
"currency": null,
"default_source": null,
"delinquent": false,
- "description": "realm_186548 (None)",
+ "description": "realm_275607 (None)",
"discount": null,
- "email": "[email protected]",
+ "email": "[email protected]",
"id": "cus_NORMALIZED0006",
"invoice_prefix": "NORMA06",
"invoice_settings": {
@@ -19,7 +19,7 @@
"livemode": false,
"metadata": {
"realm_id": "6",
- "realm_str": "realm_186548"
+ "realm_str": "realm_275607"
},
"name": null,
"next_invoice_sequence": 1,
diff --git a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Customer.create.7.json b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Customer.create.7.json
new file mode 100644
index 00000000000..0c4bdb08804
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Customer.create.7.json
@@ -0,0 +1,54 @@
+{
+ "account_balance": 0,
+ "address": null,
+ "balance": 0,
+ "created": 1000000000,
+ "currency": null,
+ "default_source": null,
+ "delinquent": false,
+ "description": "realm_667253 (None)",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_NORMALIZED0007",
+ "invoice_prefix": "NORMA07",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": null,
+ "footer": null
+ },
+ "livemode": false,
+ "metadata": {
+ "realm_id": "7",
+ "realm_str": "realm_667253"
+ },
+ "name": null,
+ "next_invoice_sequence": 1,
+ "object": "customer",
+ "phone": null,
+ "preferred_locales": [],
+ "shipping": null,
+ "sources": {
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "total_count": 0,
+ "url": "/v1/customers/cus_NORMALIZED0007/sources"
+ },
+ "subscriptions": {
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "total_count": 0,
+ "url": "/v1/customers/cus_NORMALIZED0007/subscriptions"
+ },
+ "tax_exempt": "none",
+ "tax_ids": {
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "total_count": 0,
+ "url": "/v1/customers/cus_NORMALIZED0007/tax_ids"
+ },
+ "tax_info": null,
+ "tax_info_verification": null
+}
diff --git a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.create.1.json b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.create.1.json
index 90dd65f1686..6569af1bc09 100644
--- a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.create.1.json
+++ b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.create.1.json
@@ -20,9 +20,9 @@
"created": 1000000000,
"currency": "usd",
"custom_fields": null,
- "customer": "cus_NORMALIZED0003",
+ "customer": "cus_NORMALIZED0002",
"customer_address": null,
- "customer_email": "[email protected]",
+ "customer_email": "[email protected]",
"customer_name": null,
"customer_phone": null,
"customer_shipping": null,
@@ -67,13 +67,13 @@
"billing_scheme": "per_unit",
"created": 1000000000,
"currency": "usd",
- "id": "price_1J5YW6D2X8vgpBNGNRpvTb7X",
+ "id": "price_1JFeWTD2X8vgpBNGeBhxIJRV",
"livemode": false,
"lookup_key": null,
"metadata": {},
"nickname": null,
"object": "price",
- "product": "prod_Jj0XEKpg4Z7fzV",
+ "product": "prod_JtRPn38wkV84NL",
"recurring": null,
"tiers_mode": null,
"transform_quantity": null,
@@ -87,7 +87,7 @@
"tax_amounts": [],
"tax_rates": [],
"type": "invoiceitem",
- "unique_id": "il_1J5YW6D2X8vgpBNGJfmJCwyJ"
+ "unique_id": "il_1JFeWTD2X8vgpBNGsJaYnmWb"
}
],
"has_more": false,
@@ -111,6 +111,7 @@
"period_start": 1000000000,
"post_payment_credit_notes_amount": 0,
"pre_payment_credit_notes_amount": 0,
+ "quote": null,
"receipt_number": null,
"starting_balance": 0,
"statement_descriptor": "Zulip Standard",
diff --git a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.create.2.json b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.create.2.json
index 6005a53c14d..9ba45ea03ea 100644
--- a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.create.2.json
+++ b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.create.2.json
@@ -22,7 +22,7 @@
"custom_fields": null,
"customer": "cus_NORMALIZED0004",
"customer_address": null,
- "customer_email": "[email protected]",
+ "customer_email": "[email protected]",
"customer_name": null,
"customer_phone": null,
"customer_shipping": null,
@@ -67,13 +67,13 @@
"billing_scheme": "per_unit",
"created": 1000000000,
"currency": "usd",
- "id": "price_1J5YW8D2X8vgpBNGjQO5ySQC",
+ "id": "price_1JFeWXD2X8vgpBNGvUdNYypd",
"livemode": false,
"lookup_key": null,
"metadata": {},
"nickname": null,
"object": "price",
- "product": "prod_Jj0XcBc6MoFHgE",
+ "product": "prod_JtRP8I6UaXKjma",
"recurring": null,
"tiers_mode": null,
"transform_quantity": null,
@@ -87,7 +87,7 @@
"tax_amounts": [],
"tax_rates": [],
"type": "invoiceitem",
- "unique_id": "il_1J5YW8D2X8vgpBNGf92BtWOV"
+ "unique_id": "il_1JFeWXD2X8vgpBNGE9ssZbrU"
}
],
"has_more": false,
@@ -111,6 +111,7 @@
"period_start": 1000000000,
"post_payment_credit_notes_amount": 0,
"pre_payment_credit_notes_amount": 0,
+ "quote": null,
"receipt_number": null,
"starting_balance": 0,
"statement_descriptor": "Zulip Standard",
diff --git a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.create.3.json b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.create.3.json
index 6ce4cb688d9..ae312cf08cf 100644
--- a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.create.3.json
+++ b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.create.3.json
@@ -20,9 +20,9 @@
"created": 1000000000,
"currency": "usd",
"custom_fields": null,
- "customer": "cus_NORMALIZED0004",
+ "customer": "cus_NORMALIZED0005",
"customer_address": null,
- "customer_email": "[email protected]",
+ "customer_email": "[email protected]",
"customer_name": null,
"customer_phone": null,
"customer_shipping": null,
@@ -67,13 +67,13 @@
"billing_scheme": "per_unit",
"created": 1000000000,
"currency": "usd",
- "id": "price_1J5YWBD2X8vgpBNGk65s4Bby",
+ "id": "price_1JFeWaD2X8vgpBNG2Bwcq97U",
"livemode": false,
"lookup_key": null,
"metadata": {},
"nickname": null,
"object": "price",
- "product": "prod_Jj0XXEj43ttifM",
+ "product": "prod_JtRPXPerAm8d5s",
"recurring": null,
"tiers_mode": null,
"transform_quantity": null,
@@ -87,7 +87,7 @@
"tax_amounts": [],
"tax_rates": [],
"type": "invoiceitem",
- "unique_id": "il_1J5YWBD2X8vgpBNGdBrYTZWS"
+ "unique_id": "il_1JFeWaD2X8vgpBNGpursqy1k"
}
],
"has_more": false,
@@ -111,6 +111,7 @@
"period_start": 1000000000,
"post_payment_credit_notes_amount": 0,
"pre_payment_credit_notes_amount": 0,
+ "quote": null,
"receipt_number": null,
"starting_balance": 0,
"statement_descriptor": "Zulip Standard",
diff --git a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.create.4.json b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.create.4.json
index 8d293494322..18733c71fae 100644
--- a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.create.4.json
+++ b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.create.4.json
@@ -22,7 +22,7 @@
"custom_fields": null,
"customer": "cus_NORMALIZED0005",
"customer_address": null,
- "customer_email": "[email protected]",
+ "customer_email": "[email protected]",
"customer_name": null,
"customer_phone": null,
"customer_shipping": null,
@@ -67,13 +67,13 @@
"billing_scheme": "per_unit",
"created": 1000000000,
"currency": "usd",
- "id": "price_1J5YWED2X8vgpBNGJPqvl8ls",
+ "id": "price_1JFeWdD2X8vgpBNGWZ9YZH5I",
"livemode": false,
"lookup_key": null,
"metadata": {},
"nickname": null,
"object": "price",
- "product": "prod_Jj0XOrbeS8UGnX",
+ "product": "prod_JtRPDqSSyDKbv9",
"recurring": null,
"tiers_mode": null,
"transform_quantity": null,
@@ -87,7 +87,7 @@
"tax_amounts": [],
"tax_rates": [],
"type": "invoiceitem",
- "unique_id": "il_1J5YWED2X8vgpBNGcPMTOMfD"
+ "unique_id": "il_1JFeWdD2X8vgpBNG2XxhJotY"
}
],
"has_more": false,
@@ -111,6 +111,7 @@
"period_start": 1000000000,
"post_payment_credit_notes_amount": 0,
"pre_payment_credit_notes_amount": 0,
+ "quote": null,
"receipt_number": null,
"starting_balance": 0,
"statement_descriptor": "Zulip Standard",
diff --git a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.create.5.json b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.create.5.json
index 59e25e602fa..51c05c49c29 100644
--- a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.create.5.json
+++ b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.create.5.json
@@ -20,9 +20,9 @@
"created": 1000000000,
"currency": "usd",
"custom_fields": null,
- "customer": "cus_NORMALIZED0005",
+ "customer": "cus_NORMALIZED0006",
"customer_address": null,
- "customer_email": "[email protected]",
+ "customer_email": "[email protected]",
"customer_name": null,
"customer_phone": null,
"customer_shipping": null,
@@ -67,13 +67,13 @@
"billing_scheme": "per_unit",
"created": 1000000000,
"currency": "usd",
- "id": "price_1J5YWHD2X8vgpBNGwEA9hn4b",
+ "id": "price_1JFeWgD2X8vgpBNG8aZDuPfL",
"livemode": false,
"lookup_key": null,
"metadata": {},
"nickname": null,
"object": "price",
- "product": "prod_Jj0XvpvSalZcLc",
+ "product": "prod_JtRPmcvspB67ms",
"recurring": null,
"tiers_mode": null,
"transform_quantity": null,
@@ -87,7 +87,7 @@
"tax_amounts": [],
"tax_rates": [],
"type": "invoiceitem",
- "unique_id": "il_1J5YWHD2X8vgpBNGmcQgjQGx"
+ "unique_id": "il_1JFeWgD2X8vgpBNGOIjdBP2A"
}
],
"has_more": false,
@@ -111,6 +111,7 @@
"period_start": 1000000000,
"post_payment_credit_notes_amount": 0,
"pre_payment_credit_notes_amount": 0,
+ "quote": null,
"receipt_number": null,
"starting_balance": 0,
"statement_descriptor": "Zulip Standard",
diff --git a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.create.6.json b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.create.6.json
index ca1621a0c46..6f284ae74cd 100644
--- a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.create.6.json
+++ b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.create.6.json
@@ -22,7 +22,7 @@
"custom_fields": null,
"customer": "cus_NORMALIZED0006",
"customer_address": null,
- "customer_email": "[email protected]",
+ "customer_email": "[email protected]",
"customer_name": null,
"customer_phone": null,
"customer_shipping": null,
@@ -67,13 +67,13 @@
"billing_scheme": "per_unit",
"created": 1000000000,
"currency": "usd",
- "id": "price_1J5YWMD2X8vgpBNGGQAGsuaj",
+ "id": "price_1JFeWjD2X8vgpBNGCdWCb2b0",
"livemode": false,
"lookup_key": null,
"metadata": {},
"nickname": null,
"object": "price",
- "product": "prod_Jj0XRALl1QAQk5",
+ "product": "prod_JtRPhPDQW59jge",
"recurring": null,
"tiers_mode": null,
"transform_quantity": null,
@@ -87,7 +87,7 @@
"tax_amounts": [],
"tax_rates": [],
"type": "invoiceitem",
- "unique_id": "il_1J5YWMD2X8vgpBNGTMs8cYiR"
+ "unique_id": "il_1JFeWjD2X8vgpBNGoimP1ybx"
}
],
"has_more": false,
@@ -111,6 +111,7 @@
"period_start": 1000000000,
"post_payment_credit_notes_amount": 0,
"pre_payment_credit_notes_amount": 0,
+ "quote": null,
"receipt_number": null,
"starting_balance": 0,
"statement_descriptor": "Zulip Standard",
diff --git a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.create.7.json b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.create.7.json
index a3242d50dfd..71b6464c110 100644
--- a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.create.7.json
+++ b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.create.7.json
@@ -20,9 +20,9 @@
"created": 1000000000,
"currency": "usd",
"custom_fields": null,
- "customer": "cus_NORMALIZED0006",
+ "customer": "cus_NORMALIZED0007",
"customer_address": null,
- "customer_email": "[email protected]",
+ "customer_email": "[email protected]",
"customer_name": null,
"customer_phone": null,
"customer_shipping": null,
@@ -67,13 +67,13 @@
"billing_scheme": "per_unit",
"created": 1000000000,
"currency": "usd",
- "id": "price_1J5YWPD2X8vgpBNGdU5odKe9",
+ "id": "price_1JFeWnD2X8vgpBNGonaCy8Je",
"livemode": false,
"lookup_key": null,
"metadata": {},
"nickname": null,
"object": "price",
- "product": "prod_Jj0X7KLLErkxlq",
+ "product": "prod_JtRPPpAxytZfRb",
"recurring": null,
"tiers_mode": null,
"transform_quantity": null,
@@ -87,7 +87,7 @@
"tax_amounts": [],
"tax_rates": [],
"type": "invoiceitem",
- "unique_id": "il_1J5YWPD2X8vgpBNGayzkkXN2"
+ "unique_id": "il_1JFeWnD2X8vgpBNGb9q2ENil"
}
],
"has_more": false,
@@ -111,6 +111,7 @@
"period_start": 1000000000,
"post_payment_credit_notes_amount": 0,
"pre_payment_credit_notes_amount": 0,
+ "quote": null,
"receipt_number": null,
"starting_balance": 0,
"statement_descriptor": "Zulip Standard",
diff --git a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.create.8.json b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.create.8.json
new file mode 100644
index 00000000000..941ce43bacc
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.create.8.json
@@ -0,0 +1,134 @@
+{
+ "account_country": "US",
+ "account_name": "NORMALIZED-1",
+ "account_tax_ids": null,
+ "amount_due": 10000,
+ "amount_paid": 0,
+ "amount_remaining": 10000,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "automatic_tax": {
+ "enabled": false,
+ "status": null
+ },
+ "billing": "send_invoice",
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "send_invoice",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_NORMALIZED0007",
+ "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,
+ "discounts": [],
+ "due_date": 1000000000,
+ "ending_balance": null,
+ "finalized_at": null,
+ "footer": null,
+ "hosted_invoice_url": null,
+ "id": "in_NORMALIZED00000000000008",
+ "invoice_pdf": null,
+ "last_finalization_error": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 10000,
+ "currency": "usd",
+ "description": "Zulip standard",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_NORMALIZED00000000000008",
+ "invoice_item": "ii_NORMALIZED00000000000008",
+ "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_1JFeWrD2X8vgpBNGo9vkCPfG",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_JtRPdALh7J9pfm",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 10000,
+ "unit_amount_decimal": "10000"
+ },
+ "proration": false,
+ "quantity": 1,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1JFeWrD2X8vgpBNGwgPccK0V"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/in_NORMALIZED00000000000008/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": null,
+ "number": "NORMALI-0008",
+ "object": "invoice",
+ "on_behalf_of": null,
+ "paid": false,
+ "payment_intent": null,
+ "payment_settings": {
+ "payment_method_options": null,
+ "payment_method_types": null
+ },
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "quote": null,
+ "receipt_number": null,
+ "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": 10000,
+ "tax": null,
+ "tax_percent": null,
+ "total": 10000,
+ "total_discount_amounts": [],
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": null
+}
diff --git a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.finalize_invoice.1.json b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.finalize_invoice.1.json
index c202e76b61e..e6eea7a955f 100644
--- a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.finalize_invoice.1.json
+++ b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.finalize_invoice.1.json
@@ -20,9 +20,9 @@
"created": 1000000000,
"currency": "usd",
"custom_fields": null,
- "customer": "cus_NORMALIZED0003",
+ "customer": "cus_NORMALIZED0002",
"customer_address": null,
- "customer_email": "[email protected]",
+ "customer_email": "[email protected]",
"customer_name": null,
"customer_phone": null,
"customer_shipping": null,
@@ -39,9 +39,9 @@
"ending_balance": 0,
"finalized_at": 1000000000,
"footer": null,
- "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000001w2De8",
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED00000000000000017UyVH",
"id": "in_NORMALIZED00000000000001",
- "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000001w2De8/pdf",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED00000000000000017UyVH/pdf",
"last_finalization_error": null,
"lines": {
"data": [
@@ -67,13 +67,13 @@
"billing_scheme": "per_unit",
"created": 1000000000,
"currency": "usd",
- "id": "price_1J5YW6D2X8vgpBNGNRpvTb7X",
+ "id": "price_1JFeWTD2X8vgpBNGeBhxIJRV",
"livemode": false,
"lookup_key": null,
"metadata": {},
"nickname": null,
"object": "price",
- "product": "prod_Jj0XEKpg4Z7fzV",
+ "product": "prod_JtRPn38wkV84NL",
"recurring": null,
"tiers_mode": null,
"transform_quantity": null,
@@ -87,7 +87,7 @@
"tax_amounts": [],
"tax_rates": [],
"type": "invoiceitem",
- "unique_id": "il_1J5YW6D2X8vgpBNGJfmJCwyJ"
+ "unique_id": "il_1JFeWTD2X8vgpBNGsJaYnmWb"
}
],
"has_more": false,
@@ -102,7 +102,7 @@
"object": "invoice",
"on_behalf_of": null,
"paid": false,
- "payment_intent": "pi_1J5YW7D2X8vgpBNG5Yb5dYds",
+ "payment_intent": "pi_1JFeWVD2X8vgpBNGGLOnw5bd",
"payment_settings": {
"payment_method_options": null,
"payment_method_types": null
@@ -111,6 +111,7 @@
"period_start": 1000000000,
"post_payment_credit_notes_amount": 0,
"pre_payment_credit_notes_amount": 0,
+ "quote": null,
"receipt_number": null,
"starting_balance": 0,
"statement_descriptor": "Zulip Standard",
diff --git a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.finalize_invoice.2.json b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.finalize_invoice.2.json
index 4aad5a8ff1b..cce03c8422e 100644
--- a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.finalize_invoice.2.json
+++ b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.finalize_invoice.2.json
@@ -22,7 +22,7 @@
"custom_fields": null,
"customer": "cus_NORMALIZED0004",
"customer_address": null,
- "customer_email": "[email protected]",
+ "customer_email": "[email protected]",
"customer_name": null,
"customer_phone": null,
"customer_shipping": null,
@@ -39,9 +39,9 @@
"ending_balance": 0,
"finalized_at": 1000000000,
"footer": null,
- "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000002idVh7",
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000002K5ysO",
"id": "in_NORMALIZED00000000000002",
- "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000002idVh7/pdf",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000002K5ysO/pdf",
"last_finalization_error": null,
"lines": {
"data": [
@@ -67,13 +67,13 @@
"billing_scheme": "per_unit",
"created": 1000000000,
"currency": "usd",
- "id": "price_1J5YW8D2X8vgpBNGjQO5ySQC",
+ "id": "price_1JFeWXD2X8vgpBNGvUdNYypd",
"livemode": false,
"lookup_key": null,
"metadata": {},
"nickname": null,
"object": "price",
- "product": "prod_Jj0XcBc6MoFHgE",
+ "product": "prod_JtRP8I6UaXKjma",
"recurring": null,
"tiers_mode": null,
"transform_quantity": null,
@@ -87,7 +87,7 @@
"tax_amounts": [],
"tax_rates": [],
"type": "invoiceitem",
- "unique_id": "il_1J5YW8D2X8vgpBNGf92BtWOV"
+ "unique_id": "il_1JFeWXD2X8vgpBNGE9ssZbrU"
}
],
"has_more": false,
@@ -102,7 +102,7 @@
"object": "invoice",
"on_behalf_of": null,
"paid": false,
- "payment_intent": "pi_1J5YWAD2X8vgpBNGXw0Js5PH",
+ "payment_intent": "pi_1JFeWYD2X8vgpBNGjHEu0VCP",
"payment_settings": {
"payment_method_options": null,
"payment_method_types": null
@@ -111,6 +111,7 @@
"period_start": 1000000000,
"post_payment_credit_notes_amount": 0,
"pre_payment_credit_notes_amount": 0,
+ "quote": null,
"receipt_number": null,
"starting_balance": 0,
"statement_descriptor": "Zulip Standard",
@@ -129,5 +130,5 @@
"total_discount_amounts": [],
"total_tax_amounts": [],
"transfer_data": null,
- "webhooks_delivered_at": null
+ "webhooks_delivered_at": 1000000000
}
diff --git a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.finalize_invoice.3.json b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.finalize_invoice.3.json
index a18f9821c9f..3fdac241d5b 100644
--- a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.finalize_invoice.3.json
+++ b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.finalize_invoice.3.json
@@ -20,9 +20,9 @@
"created": 1000000000,
"currency": "usd",
"custom_fields": null,
- "customer": "cus_NORMALIZED0004",
+ "customer": "cus_NORMALIZED0005",
"customer_address": null,
- "customer_email": "[email protected]",
+ "customer_email": "[email protected]",
"customer_name": null,
"customer_phone": null,
"customer_shipping": null,
@@ -39,9 +39,9 @@
"ending_balance": 0,
"finalized_at": 1000000000,
"footer": null,
- "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000003nsJBj",
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED00000000000000033OCj1",
"id": "in_NORMALIZED00000000000003",
- "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000003nsJBj/pdf",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED00000000000000033OCj1/pdf",
"last_finalization_error": null,
"lines": {
"data": [
@@ -67,13 +67,13 @@
"billing_scheme": "per_unit",
"created": 1000000000,
"currency": "usd",
- "id": "price_1J5YWBD2X8vgpBNGk65s4Bby",
+ "id": "price_1JFeWaD2X8vgpBNG2Bwcq97U",
"livemode": false,
"lookup_key": null,
"metadata": {},
"nickname": null,
"object": "price",
- "product": "prod_Jj0XXEj43ttifM",
+ "product": "prod_JtRPXPerAm8d5s",
"recurring": null,
"tiers_mode": null,
"transform_quantity": null,
@@ -87,7 +87,7 @@
"tax_amounts": [],
"tax_rates": [],
"type": "invoiceitem",
- "unique_id": "il_1J5YWBD2X8vgpBNGdBrYTZWS"
+ "unique_id": "il_1JFeWaD2X8vgpBNGpursqy1k"
}
],
"has_more": false,
@@ -102,7 +102,7 @@
"object": "invoice",
"on_behalf_of": null,
"paid": false,
- "payment_intent": "pi_1J5YWDD2X8vgpBNGVKjx2VAT",
+ "payment_intent": "pi_1JFeWcD2X8vgpBNG3oiqJwm0",
"payment_settings": {
"payment_method_options": null,
"payment_method_types": null
@@ -111,6 +111,7 @@
"period_start": 1000000000,
"post_payment_credit_notes_amount": 0,
"pre_payment_credit_notes_amount": 0,
+ "quote": null,
"receipt_number": null,
"starting_balance": 0,
"statement_descriptor": "Zulip Standard",
diff --git a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.finalize_invoice.4.json b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.finalize_invoice.4.json
index 881f2cd7229..e693a35516b 100644
--- a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.finalize_invoice.4.json
+++ b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.finalize_invoice.4.json
@@ -22,7 +22,7 @@
"custom_fields": null,
"customer": "cus_NORMALIZED0005",
"customer_address": null,
- "customer_email": "[email protected]",
+ "customer_email": "[email protected]",
"customer_name": null,
"customer_phone": null,
"customer_shipping": null,
@@ -39,9 +39,9 @@
"ending_balance": 0,
"finalized_at": 1000000000,
"footer": null,
- "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000004w1nCX",
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000004MR4hK",
"id": "in_NORMALIZED00000000000004",
- "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000004w1nCX/pdf",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000004MR4hK/pdf",
"last_finalization_error": null,
"lines": {
"data": [
@@ -67,13 +67,13 @@
"billing_scheme": "per_unit",
"created": 1000000000,
"currency": "usd",
- "id": "price_1J5YWED2X8vgpBNGJPqvl8ls",
+ "id": "price_1JFeWdD2X8vgpBNGWZ9YZH5I",
"livemode": false,
"lookup_key": null,
"metadata": {},
"nickname": null,
"object": "price",
- "product": "prod_Jj0XOrbeS8UGnX",
+ "product": "prod_JtRPDqSSyDKbv9",
"recurring": null,
"tiers_mode": null,
"transform_quantity": null,
@@ -87,7 +87,7 @@
"tax_amounts": [],
"tax_rates": [],
"type": "invoiceitem",
- "unique_id": "il_1J5YWED2X8vgpBNGcPMTOMfD"
+ "unique_id": "il_1JFeWdD2X8vgpBNG2XxhJotY"
}
],
"has_more": false,
@@ -102,7 +102,7 @@
"object": "invoice",
"on_behalf_of": null,
"paid": false,
- "payment_intent": "pi_1J5YWGD2X8vgpBNGOTyIX1H3",
+ "payment_intent": "pi_1JFeWfD2X8vgpBNGrdVPwOSc",
"payment_settings": {
"payment_method_options": null,
"payment_method_types": null
@@ -111,6 +111,7 @@
"period_start": 1000000000,
"post_payment_credit_notes_amount": 0,
"pre_payment_credit_notes_amount": 0,
+ "quote": null,
"receipt_number": null,
"starting_balance": 0,
"statement_descriptor": "Zulip Standard",
diff --git a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.finalize_invoice.5.json b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.finalize_invoice.5.json
index b7683eba7be..88b571e4115 100644
--- a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.finalize_invoice.5.json
+++ b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.finalize_invoice.5.json
@@ -20,9 +20,9 @@
"created": 1000000000,
"currency": "usd",
"custom_fields": null,
- "customer": "cus_NORMALIZED0005",
+ "customer": "cus_NORMALIZED0006",
"customer_address": null,
- "customer_email": "[email protected]",
+ "customer_email": "[email protected]",
"customer_name": null,
"customer_phone": null,
"customer_shipping": null,
@@ -39,9 +39,9 @@
"ending_balance": 0,
"finalized_at": 1000000000,
"footer": null,
- "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000005e3XWY",
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED00000000000000059dDfj",
"id": "in_NORMALIZED00000000000005",
- "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000005e3XWY/pdf",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED00000000000000059dDfj/pdf",
"last_finalization_error": null,
"lines": {
"data": [
@@ -67,13 +67,13 @@
"billing_scheme": "per_unit",
"created": 1000000000,
"currency": "usd",
- "id": "price_1J5YWHD2X8vgpBNGwEA9hn4b",
+ "id": "price_1JFeWgD2X8vgpBNG8aZDuPfL",
"livemode": false,
"lookup_key": null,
"metadata": {},
"nickname": null,
"object": "price",
- "product": "prod_Jj0XvpvSalZcLc",
+ "product": "prod_JtRPmcvspB67ms",
"recurring": null,
"tiers_mode": null,
"transform_quantity": null,
@@ -87,7 +87,7 @@
"tax_amounts": [],
"tax_rates": [],
"type": "invoiceitem",
- "unique_id": "il_1J5YWHD2X8vgpBNGmcQgjQGx"
+ "unique_id": "il_1JFeWgD2X8vgpBNGOIjdBP2A"
}
],
"has_more": false,
@@ -102,7 +102,7 @@
"object": "invoice",
"on_behalf_of": null,
"paid": false,
- "payment_intent": "pi_1J5YWJD2X8vgpBNGkNf5igPN",
+ "payment_intent": "pi_1JFeWhD2X8vgpBNGZr4xgMC3",
"payment_settings": {
"payment_method_options": null,
"payment_method_types": null
@@ -111,6 +111,7 @@
"period_start": 1000000000,
"post_payment_credit_notes_amount": 0,
"pre_payment_credit_notes_amount": 0,
+ "quote": null,
"receipt_number": null,
"starting_balance": 0,
"statement_descriptor": "Zulip Standard",
@@ -129,5 +130,5 @@
"total_discount_amounts": [],
"total_tax_amounts": [],
"transfer_data": null,
- "webhooks_delivered_at": 1000000000
+ "webhooks_delivered_at": null
}
diff --git a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.finalize_invoice.6.json b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.finalize_invoice.6.json
index 8eb21abd54a..694c49d5674 100644
--- a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.finalize_invoice.6.json
+++ b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.finalize_invoice.6.json
@@ -22,7 +22,7 @@
"custom_fields": null,
"customer": "cus_NORMALIZED0006",
"customer_address": null,
- "customer_email": "[email protected]",
+ "customer_email": "[email protected]",
"customer_name": null,
"customer_phone": null,
"customer_shipping": null,
@@ -39,9 +39,9 @@
"ending_balance": 0,
"finalized_at": 1000000000,
"footer": null,
- "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000006s5YVx",
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000006sHPi7",
"id": "in_NORMALIZED00000000000006",
- "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000006s5YVx/pdf",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000006sHPi7/pdf",
"last_finalization_error": null,
"lines": {
"data": [
@@ -67,13 +67,13 @@
"billing_scheme": "per_unit",
"created": 1000000000,
"currency": "usd",
- "id": "price_1J5YWMD2X8vgpBNGGQAGsuaj",
+ "id": "price_1JFeWjD2X8vgpBNGCdWCb2b0",
"livemode": false,
"lookup_key": null,
"metadata": {},
"nickname": null,
"object": "price",
- "product": "prod_Jj0XRALl1QAQk5",
+ "product": "prod_JtRPhPDQW59jge",
"recurring": null,
"tiers_mode": null,
"transform_quantity": null,
@@ -87,7 +87,7 @@
"tax_amounts": [],
"tax_rates": [],
"type": "invoiceitem",
- "unique_id": "il_1J5YWMD2X8vgpBNGTMs8cYiR"
+ "unique_id": "il_1JFeWjD2X8vgpBNGoimP1ybx"
}
],
"has_more": false,
@@ -102,7 +102,7 @@
"object": "invoice",
"on_behalf_of": null,
"paid": false,
- "payment_intent": "pi_1J5YWOD2X8vgpBNGoAHwi7t6",
+ "payment_intent": "pi_1JFeWlD2X8vgpBNGZD62kg07",
"payment_settings": {
"payment_method_options": null,
"payment_method_types": null
@@ -111,6 +111,7 @@
"period_start": 1000000000,
"post_payment_credit_notes_amount": 0,
"pre_payment_credit_notes_amount": 0,
+ "quote": null,
"receipt_number": null,
"starting_balance": 0,
"statement_descriptor": "Zulip Standard",
diff --git a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.finalize_invoice.7.json b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.finalize_invoice.7.json
index 585210a4d9f..3ada3577c48 100644
--- a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.finalize_invoice.7.json
+++ b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.finalize_invoice.7.json
@@ -20,9 +20,9 @@
"created": 1000000000,
"currency": "usd",
"custom_fields": null,
- "customer": "cus_NORMALIZED0006",
+ "customer": "cus_NORMALIZED0007",
"customer_address": null,
- "customer_email": "[email protected]",
+ "customer_email": "[email protected]",
"customer_name": null,
"customer_phone": null,
"customer_shipping": null,
@@ -39,9 +39,9 @@
"ending_balance": 0,
"finalized_at": 1000000000,
"footer": null,
- "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000007m8tcn",
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED00000000000000074tznY",
"id": "in_NORMALIZED00000000000007",
- "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000007m8tcn/pdf",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED00000000000000074tznY/pdf",
"last_finalization_error": null,
"lines": {
"data": [
@@ -67,13 +67,13 @@
"billing_scheme": "per_unit",
"created": 1000000000,
"currency": "usd",
- "id": "price_1J5YWPD2X8vgpBNGdU5odKe9",
+ "id": "price_1JFeWnD2X8vgpBNGonaCy8Je",
"livemode": false,
"lookup_key": null,
"metadata": {},
"nickname": null,
"object": "price",
- "product": "prod_Jj0X7KLLErkxlq",
+ "product": "prod_JtRPPpAxytZfRb",
"recurring": null,
"tiers_mode": null,
"transform_quantity": null,
@@ -87,7 +87,7 @@
"tax_amounts": [],
"tax_rates": [],
"type": "invoiceitem",
- "unique_id": "il_1J5YWPD2X8vgpBNGayzkkXN2"
+ "unique_id": "il_1JFeWnD2X8vgpBNGb9q2ENil"
}
],
"has_more": false,
@@ -102,7 +102,7 @@
"object": "invoice",
"on_behalf_of": null,
"paid": false,
- "payment_intent": "pi_1J5YWQD2X8vgpBNGCa6w5Qan",
+ "payment_intent": "pi_1JFeWpD2X8vgpBNGT32sTUXY",
"payment_settings": {
"payment_method_options": null,
"payment_method_types": null
@@ -111,6 +111,7 @@
"period_start": 1000000000,
"post_payment_credit_notes_amount": 0,
"pre_payment_credit_notes_amount": 0,
+ "quote": null,
"receipt_number": null,
"starting_balance": 0,
"statement_descriptor": "Zulip Standard",
diff --git a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.finalize_invoice.8.json b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.finalize_invoice.8.json
new file mode 100644
index 00000000000..8403ebf9331
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.finalize_invoice.8.json
@@ -0,0 +1,134 @@
+{
+ "account_country": "US",
+ "account_name": "NORMALIZED-1",
+ "account_tax_ids": null,
+ "amount_due": 10000,
+ "amount_paid": 0,
+ "amount_remaining": 10000,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "automatic_tax": {
+ "enabled": false,
+ "status": null
+ },
+ "billing": "send_invoice",
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "send_invoice",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_NORMALIZED0007",
+ "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,
+ "discounts": [],
+ "due_date": 1000000000,
+ "ending_balance": 0,
+ "finalized_at": 1000000000,
+ "footer": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000008kYrKh",
+ "id": "in_NORMALIZED00000000000008",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000008kYrKh/pdf",
+ "last_finalization_error": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 10000,
+ "currency": "usd",
+ "description": "Zulip standard",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_NORMALIZED00000000000008",
+ "invoice_item": "ii_NORMALIZED00000000000008",
+ "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_1JFeWrD2X8vgpBNGo9vkCPfG",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_JtRPdALh7J9pfm",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 10000,
+ "unit_amount_decimal": "10000"
+ },
+ "proration": false,
+ "quantity": 1,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1JFeWrD2X8vgpBNGwgPccK0V"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/in_NORMALIZED00000000000008/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": null,
+ "number": "NORMALI-0008",
+ "object": "invoice",
+ "on_behalf_of": null,
+ "paid": false,
+ "payment_intent": "pi_1JFeWtD2X8vgpBNGOsqqXzqw",
+ "payment_settings": {
+ "payment_method_options": null,
+ "payment_method_types": null
+ },
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "quote": null,
+ "receipt_number": null,
+ "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": 10000,
+ "tax": null,
+ "tax_percent": null,
+ "total": 10000,
+ "total_discount_amounts": [],
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": null
+}
diff --git a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.list.2.json b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.list.2.json
index 72bbc0f46e3..03f4866f22f 100644
--- a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.list.2.json
+++ b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.list.2.json
@@ -22,9 +22,9 @@
"created": 1000000000,
"currency": "usd",
"custom_fields": null,
- "customer": "cus_NORMALIZED0003",
+ "customer": "cus_NORMALIZED0002",
"customer_address": null,
- "customer_email": "[email protected]",
+ "customer_email": "[email protected]",
"customer_name": null,
"customer_phone": null,
"customer_shipping": null,
@@ -41,9 +41,9 @@
"ending_balance": 0,
"finalized_at": 1000000000,
"footer": null,
- "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000001w2De8",
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED00000000000000017UyVH",
"id": "in_NORMALIZED00000000000001",
- "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000001w2De8/pdf",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED00000000000000017UyVH/pdf",
"last_finalization_error": null,
"lines": {
"data": [
@@ -69,13 +69,13 @@
"billing_scheme": "per_unit",
"created": 1000000000,
"currency": "usd",
- "id": "price_1J5YW6D2X8vgpBNGNRpvTb7X",
+ "id": "price_1JFeWTD2X8vgpBNGeBhxIJRV",
"livemode": false,
"lookup_key": null,
"metadata": {},
"nickname": null,
"object": "price",
- "product": "prod_Jj0XEKpg4Z7fzV",
+ "product": "prod_JtRPn38wkV84NL",
"recurring": null,
"tiers_mode": null,
"transform_quantity": null,
@@ -89,7 +89,7 @@
"tax_amounts": [],
"tax_rates": [],
"type": "invoiceitem",
- "unique_id": "il_1J5YW6D2X8vgpBNGJfmJCwyJ"
+ "unique_id": "il_1JFeWTD2X8vgpBNGsJaYnmWb"
}
],
"has_more": false,
@@ -104,7 +104,7 @@
"object": "invoice",
"on_behalf_of": null,
"paid": false,
- "payment_intent": "pi_1J5YW7D2X8vgpBNG5Yb5dYds",
+ "payment_intent": "pi_1JFeWVD2X8vgpBNGGLOnw5bd",
"payment_settings": {
"payment_method_options": null,
"payment_method_types": null
@@ -113,6 +113,7 @@
"period_start": 1000000000,
"post_payment_credit_notes_amount": 0,
"pre_payment_credit_notes_amount": 0,
+ "quote": null,
"receipt_number": null,
"starting_balance": 0,
"statement_descriptor": "Zulip Standard",
diff --git a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.list.3.json b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.list.3.json
index ffbf76d4b5c..e39960ab725 100644
--- a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.list.3.json
+++ b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.list.3.json
@@ -1,272 +1,5 @@
{
- "data": [
- {
- "account_country": "US",
- "account_name": "NORMALIZED-1",
- "account_tax_ids": null,
- "amount_due": 10000,
- "amount_paid": 0,
- "amount_remaining": 10000,
- "application_fee": null,
- "attempt_count": 0,
- "attempted": false,
- "auto_advance": true,
- "automatic_tax": {
- "enabled": false,
- "status": null
- },
- "billing": "send_invoice",
- "billing_reason": "manual",
- "charge": null,
- "collection_method": "send_invoice",
- "created": 1000000000,
- "currency": "usd",
- "custom_fields": null,
- "customer": "cus_NORMALIZED0004",
- "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,
- "discounts": [],
- "due_date": 1000000000,
- "ending_balance": 0,
- "finalized_at": 1000000000,
- "footer": null,
- "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000003nsJBj",
- "id": "in_NORMALIZED00000000000003",
- "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000003nsJBj/pdf",
- "last_finalization_error": null,
- "lines": {
- "data": [
- {
- "amount": 10000,
- "currency": "usd",
- "description": "Zulip standard",
- "discount_amounts": [],
- "discountable": false,
- "discounts": [],
- "id": "ii_NORMALIZED00000000000003",
- "invoice_item": "ii_NORMALIZED00000000000003",
- "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_1J5YWBD2X8vgpBNGk65s4Bby",
- "livemode": false,
- "lookup_key": null,
- "metadata": {},
- "nickname": null,
- "object": "price",
- "product": "prod_Jj0XXEj43ttifM",
- "recurring": null,
- "tiers_mode": null,
- "transform_quantity": null,
- "type": "one_time",
- "unit_amount": 10000,
- "unit_amount_decimal": "10000"
- },
- "proration": false,
- "quantity": 1,
- "subscription": null,
- "tax_amounts": [],
- "tax_rates": [],
- "type": "invoiceitem",
- "unique_id": "il_1J5YWBD2X8vgpBNGdBrYTZWS"
- }
- ],
- "has_more": false,
- "object": "list",
- "total_count": 1,
- "url": "/v1/invoices/in_NORMALIZED00000000000003/lines"
- },
- "livemode": false,
- "metadata": {},
- "next_payment_attempt": null,
- "number": "NORMALI-0003",
- "object": "invoice",
- "on_behalf_of": null,
- "paid": false,
- "payment_intent": "pi_1J5YWDD2X8vgpBNGVKjx2VAT",
- "payment_settings": {
- "payment_method_options": null,
- "payment_method_types": null
- },
- "period_end": 1000000000,
- "period_start": 1000000000,
- "post_payment_credit_notes_amount": 0,
- "pre_payment_credit_notes_amount": 0,
- "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": 10000,
- "tax": null,
- "tax_percent": null,
- "total": 10000,
- "total_discount_amounts": [],
- "total_tax_amounts": [],
- "transfer_data": null,
- "webhooks_delivered_at": 1000000000
- },
- {
- "account_country": "US",
- "account_name": "NORMALIZED-1",
- "account_tax_ids": null,
- "amount_due": 10000,
- "amount_paid": 0,
- "amount_remaining": 10000,
- "application_fee": null,
- "attempt_count": 0,
- "attempted": false,
- "auto_advance": true,
- "automatic_tax": {
- "enabled": false,
- "status": null
- },
- "billing": "send_invoice",
- "billing_reason": "manual",
- "charge": null,
- "collection_method": "send_invoice",
- "created": 1000000000,
- "currency": "usd",
- "custom_fields": null,
- "customer": "cus_NORMALIZED0004",
- "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,
- "discounts": [],
- "due_date": 1000000000,
- "ending_balance": 0,
- "finalized_at": 1000000000,
- "footer": null,
- "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000002idVh7",
- "id": "in_NORMALIZED00000000000002",
- "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000002idVh7/pdf",
- "last_finalization_error": null,
- "lines": {
- "data": [
- {
- "amount": 10000,
- "currency": "usd",
- "description": "Zulip standard",
- "discount_amounts": [],
- "discountable": false,
- "discounts": [],
- "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_1J5YW8D2X8vgpBNGjQO5ySQC",
- "livemode": false,
- "lookup_key": null,
- "metadata": {},
- "nickname": null,
- "object": "price",
- "product": "prod_Jj0XcBc6MoFHgE",
- "recurring": null,
- "tiers_mode": null,
- "transform_quantity": null,
- "type": "one_time",
- "unit_amount": 10000,
- "unit_amount_decimal": "10000"
- },
- "proration": false,
- "quantity": 1,
- "subscription": null,
- "tax_amounts": [],
- "tax_rates": [],
- "type": "invoiceitem",
- "unique_id": "il_1J5YW8D2X8vgpBNGf92BtWOV"
- }
- ],
- "has_more": false,
- "object": "list",
- "total_count": 1,
- "url": "/v1/invoices/in_NORMALIZED00000000000002/lines"
- },
- "livemode": false,
- "metadata": {},
- "next_payment_attempt": null,
- "number": "NORMALI-0002",
- "object": "invoice",
- "on_behalf_of": null,
- "paid": false,
- "payment_intent": "pi_1J5YWAD2X8vgpBNGXw0Js5PH",
- "payment_settings": {
- "payment_method_options": null,
- "payment_method_types": null
- },
- "period_end": 1000000000,
- "period_start": 1000000000,
- "post_payment_credit_notes_amount": 0,
- "pre_payment_credit_notes_amount": 0,
- "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": 10000,
- "tax": null,
- "tax_percent": null,
- "total": 10000,
- "total_discount_amounts": [],
- "total_tax_amounts": [],
- "transfer_data": null,
- "webhooks_delivered_at": 1000000000
- }
- ],
+ "data": [],
"has_more": false,
"object": "list",
"url": "/v1/invoices"
diff --git a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.list.4.json b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.list.4.json
index fca90201bff..3f407204653 100644
--- a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.list.4.json
+++ b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.list.4.json
@@ -10,7 +10,7 @@
"application_fee": null,
"attempt_count": 0,
"attempted": false,
- "auto_advance": false,
+ "auto_advance": true,
"automatic_tax": {
"enabled": false,
"status": null
@@ -22,9 +22,9 @@
"created": 1000000000,
"currency": "usd",
"custom_fields": null,
- "customer": "cus_NORMALIZED0005",
+ "customer": "cus_NORMALIZED0004",
"customer_address": null,
- "customer_email": "[email protected]",
+ "customer_email": "[email protected]",
"customer_name": null,
"customer_phone": null,
"customer_shipping": null,
@@ -41,9 +41,9 @@
"ending_balance": 0,
"finalized_at": 1000000000,
"footer": null,
- "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000005e3XWY",
- "id": "in_NORMALIZED00000000000005",
- "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000005e3XWY/pdf",
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000002K5ysO",
+ "id": "in_NORMALIZED00000000000002",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000002K5ysO/pdf",
"last_finalization_error": null,
"lines": {
"data": [
@@ -54,8 +54,8 @@
"discount_amounts": [],
"discountable": false,
"discounts": [],
- "id": "ii_NORMALIZED00000000000005",
- "invoice_item": "ii_NORMALIZED00000000000005",
+ "id": "ii_NORMALIZED00000000000002",
+ "invoice_item": "ii_NORMALIZED00000000000002",
"livemode": false,
"metadata": {},
"object": "line_item",
@@ -69,13 +69,13 @@
"billing_scheme": "per_unit",
"created": 1000000000,
"currency": "usd",
- "id": "price_1J5YWHD2X8vgpBNGwEA9hn4b",
+ "id": "price_1JFeWXD2X8vgpBNGvUdNYypd",
"livemode": false,
"lookup_key": null,
"metadata": {},
"nickname": null,
"object": "price",
- "product": "prod_Jj0XvpvSalZcLc",
+ "product": "prod_JtRP8I6UaXKjma",
"recurring": null,
"tiers_mode": null,
"transform_quantity": null,
@@ -89,22 +89,22 @@
"tax_amounts": [],
"tax_rates": [],
"type": "invoiceitem",
- "unique_id": "il_1J5YWHD2X8vgpBNGmcQgjQGx"
+ "unique_id": "il_1JFeWXD2X8vgpBNGE9ssZbrU"
}
],
"has_more": false,
"object": "list",
"total_count": 1,
- "url": "/v1/invoices/in_NORMALIZED00000000000005/lines"
+ "url": "/v1/invoices/in_NORMALIZED00000000000002/lines"
},
"livemode": false,
"metadata": {},
"next_payment_attempt": null,
- "number": "NORMALI-0005",
+ "number": "NORMALI-0002",
"object": "invoice",
"on_behalf_of": null,
- "paid": true,
- "payment_intent": null,
+ "paid": false,
+ "payment_intent": "pi_1JFeWYD2X8vgpBNGjHEu0VCP",
"payment_settings": {
"payment_method_options": null,
"payment_method_types": null
@@ -113,147 +113,15 @@
"period_start": 1000000000,
"post_payment_credit_notes_amount": 0,
"pre_payment_credit_notes_amount": 0,
+ "quote": null,
"receipt_number": null,
"starting_balance": 0,
"statement_descriptor": "Zulip Standard",
- "status": "paid",
+ "status": "open",
"status_transitions": {
"finalized_at": 1000000000,
"marked_uncollectible_at": null,
- "paid_at": 1000000000,
- "voided_at": null
- },
- "subscription": null,
- "subtotal": 10000,
- "tax": null,
- "tax_percent": null,
- "total": 10000,
- "total_discount_amounts": [],
- "total_tax_amounts": [],
- "transfer_data": null,
- "webhooks_delivered_at": 1000000000
- },
- {
- "account_country": "US",
- "account_name": "NORMALIZED-1",
- "account_tax_ids": null,
- "amount_due": 10000,
- "amount_paid": 0,
- "amount_remaining": 10000,
- "application_fee": null,
- "attempt_count": 0,
- "attempted": false,
- "auto_advance": false,
- "automatic_tax": {
- "enabled": false,
- "status": null
- },
- "billing": "send_invoice",
- "billing_reason": "manual",
- "charge": null,
- "collection_method": "send_invoice",
- "created": 1000000000,
- "currency": "usd",
- "custom_fields": null,
- "customer": "cus_NORMALIZED0005",
- "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,
- "discounts": [],
- "due_date": 1000000000,
- "ending_balance": 0,
- "finalized_at": 1000000000,
- "footer": null,
- "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000004w1nCX",
- "id": "in_NORMALIZED00000000000004",
- "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000004w1nCX/pdf",
- "last_finalization_error": null,
- "lines": {
- "data": [
- {
- "amount": 10000,
- "currency": "usd",
- "description": "Zulip standard",
- "discount_amounts": [],
- "discountable": false,
- "discounts": [],
- "id": "ii_NORMALIZED00000000000004",
- "invoice_item": "ii_NORMALIZED00000000000004",
- "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_1J5YWED2X8vgpBNGJPqvl8ls",
- "livemode": false,
- "lookup_key": null,
- "metadata": {},
- "nickname": null,
- "object": "price",
- "product": "prod_Jj0XOrbeS8UGnX",
- "recurring": null,
- "tiers_mode": null,
- "transform_quantity": null,
- "type": "one_time",
- "unit_amount": 10000,
- "unit_amount_decimal": "10000"
- },
- "proration": false,
- "quantity": 1,
- "subscription": null,
- "tax_amounts": [],
- "tax_rates": [],
- "type": "invoiceitem",
- "unique_id": "il_1J5YWED2X8vgpBNGcPMTOMfD"
- }
- ],
- "has_more": false,
- "object": "list",
- "total_count": 1,
- "url": "/v1/invoices/in_NORMALIZED00000000000004/lines"
- },
- "livemode": false,
- "metadata": {},
- "next_payment_attempt": null,
- "number": "NORMALI-0004",
- "object": "invoice",
- "on_behalf_of": null,
- "paid": true,
- "payment_intent": null,
- "payment_settings": {
- "payment_method_options": null,
- "payment_method_types": null
- },
- "period_end": 1000000000,
- "period_start": 1000000000,
- "post_payment_credit_notes_amount": 0,
- "pre_payment_credit_notes_amount": 0,
- "receipt_number": null,
- "starting_balance": 0,
- "statement_descriptor": "Zulip Standard",
- "status": "paid",
- "status_transitions": {
- "finalized_at": 1000000000,
- "marked_uncollectible_at": null,
- "paid_at": 1000000000,
+ "paid_at": null,
"voided_at": null
},
"subscription": null,
diff --git a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.list.5.json b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.list.5.json
new file mode 100644
index 00000000000..f68fea69251
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.list.5.json
@@ -0,0 +1,275 @@
+{
+ "data": [
+ {
+ "account_country": "US",
+ "account_name": "NORMALIZED-1",
+ "account_tax_ids": null,
+ "amount_due": 10000,
+ "amount_paid": 0,
+ "amount_remaining": 10000,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "automatic_tax": {
+ "enabled": false,
+ "status": null
+ },
+ "billing": "send_invoice",
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "send_invoice",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_NORMALIZED0005",
+ "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,
+ "discounts": [],
+ "due_date": 1000000000,
+ "ending_balance": 0,
+ "finalized_at": 1000000000,
+ "footer": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000004MR4hK",
+ "id": "in_NORMALIZED00000000000004",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000004MR4hK/pdf",
+ "last_finalization_error": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 10000,
+ "currency": "usd",
+ "description": "Zulip standard",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_NORMALIZED00000000000004",
+ "invoice_item": "ii_NORMALIZED00000000000004",
+ "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_1JFeWdD2X8vgpBNGWZ9YZH5I",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_JtRPDqSSyDKbv9",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 10000,
+ "unit_amount_decimal": "10000"
+ },
+ "proration": false,
+ "quantity": 1,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1JFeWdD2X8vgpBNG2XxhJotY"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/in_NORMALIZED00000000000004/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": null,
+ "number": "NORMALI-0004",
+ "object": "invoice",
+ "on_behalf_of": null,
+ "paid": false,
+ "payment_intent": "pi_1JFeWfD2X8vgpBNGrdVPwOSc",
+ "payment_settings": {
+ "payment_method_options": null,
+ "payment_method_types": null
+ },
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "quote": null,
+ "receipt_number": null,
+ "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": 10000,
+ "tax": null,
+ "tax_percent": null,
+ "total": 10000,
+ "total_discount_amounts": [],
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1000000000
+ },
+ {
+ "account_country": "US",
+ "account_name": "NORMALIZED-1",
+ "account_tax_ids": null,
+ "amount_due": 10000,
+ "amount_paid": 0,
+ "amount_remaining": 10000,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "automatic_tax": {
+ "enabled": false,
+ "status": null
+ },
+ "billing": "send_invoice",
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "send_invoice",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_NORMALIZED0005",
+ "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,
+ "discounts": [],
+ "due_date": 1000000000,
+ "ending_balance": 0,
+ "finalized_at": 1000000000,
+ "footer": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED00000000000000033OCj1",
+ "id": "in_NORMALIZED00000000000003",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED00000000000000033OCj1/pdf",
+ "last_finalization_error": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 10000,
+ "currency": "usd",
+ "description": "Zulip standard",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_NORMALIZED00000000000003",
+ "invoice_item": "ii_NORMALIZED00000000000003",
+ "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_1JFeWaD2X8vgpBNG2Bwcq97U",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_JtRPXPerAm8d5s",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 10000,
+ "unit_amount_decimal": "10000"
+ },
+ "proration": false,
+ "quantity": 1,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1JFeWaD2X8vgpBNGpursqy1k"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/in_NORMALIZED00000000000003/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": null,
+ "number": "NORMALI-0003",
+ "object": "invoice",
+ "on_behalf_of": null,
+ "paid": false,
+ "payment_intent": "pi_1JFeWcD2X8vgpBNG3oiqJwm0",
+ "payment_settings": {
+ "payment_method_options": null,
+ "payment_method_types": null
+ },
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "quote": null,
+ "receipt_number": null,
+ "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": 10000,
+ "tax": null,
+ "tax_percent": null,
+ "total": 10000,
+ "total_discount_amounts": [],
+ "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/downgrade_small_realms_behind_on_payments_as_needed--Invoice.list.6.json b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.list.6.json
new file mode 100644
index 00000000000..09a3caf6218
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.list.6.json
@@ -0,0 +1,275 @@
+{
+ "data": [
+ {
+ "account_country": "US",
+ "account_name": "NORMALIZED-1",
+ "account_tax_ids": null,
+ "amount_due": 10000,
+ "amount_paid": 0,
+ "amount_remaining": 10000,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": false,
+ "automatic_tax": {
+ "enabled": false,
+ "status": null
+ },
+ "billing": "send_invoice",
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "send_invoice",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_NORMALIZED0006",
+ "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,
+ "discounts": [],
+ "due_date": 1000000000,
+ "ending_balance": 0,
+ "finalized_at": 1000000000,
+ "footer": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000006sHPi7",
+ "id": "in_NORMALIZED00000000000006",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000006sHPi7/pdf",
+ "last_finalization_error": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 10000,
+ "currency": "usd",
+ "description": "Zulip standard",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_NORMALIZED00000000000006",
+ "invoice_item": "ii_NORMALIZED00000000000006",
+ "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_1JFeWjD2X8vgpBNGCdWCb2b0",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_JtRPhPDQW59jge",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 10000,
+ "unit_amount_decimal": "10000"
+ },
+ "proration": false,
+ "quantity": 1,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1JFeWjD2X8vgpBNGoimP1ybx"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/in_NORMALIZED00000000000006/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": null,
+ "number": "NORMALI-0006",
+ "object": "invoice",
+ "on_behalf_of": null,
+ "paid": true,
+ "payment_intent": null,
+ "payment_settings": {
+ "payment_method_options": null,
+ "payment_method_types": null
+ },
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "quote": null,
+ "receipt_number": null,
+ "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": 10000,
+ "tax": null,
+ "tax_percent": null,
+ "total": 10000,
+ "total_discount_amounts": [],
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1000000000
+ },
+ {
+ "account_country": "US",
+ "account_name": "NORMALIZED-1",
+ "account_tax_ids": null,
+ "amount_due": 10000,
+ "amount_paid": 0,
+ "amount_remaining": 10000,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": false,
+ "automatic_tax": {
+ "enabled": false,
+ "status": null
+ },
+ "billing": "send_invoice",
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "send_invoice",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_NORMALIZED0006",
+ "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,
+ "discounts": [],
+ "due_date": 1000000000,
+ "ending_balance": 0,
+ "finalized_at": 1000000000,
+ "footer": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED00000000000000059dDfj",
+ "id": "in_NORMALIZED00000000000005",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED00000000000000059dDfj/pdf",
+ "last_finalization_error": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 10000,
+ "currency": "usd",
+ "description": "Zulip standard",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_NORMALIZED00000000000005",
+ "invoice_item": "ii_NORMALIZED00000000000005",
+ "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_1JFeWgD2X8vgpBNG8aZDuPfL",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_JtRPmcvspB67ms",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 10000,
+ "unit_amount_decimal": "10000"
+ },
+ "proration": false,
+ "quantity": 1,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1JFeWgD2X8vgpBNGOIjdBP2A"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/in_NORMALIZED00000000000005/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": null,
+ "number": "NORMALI-0005",
+ "object": "invoice",
+ "on_behalf_of": null,
+ "paid": true,
+ "payment_intent": null,
+ "payment_settings": {
+ "payment_method_options": null,
+ "payment_method_types": null
+ },
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "quote": null,
+ "receipt_number": null,
+ "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": 10000,
+ "tax": null,
+ "tax_percent": null,
+ "total": 10000,
+ "total_discount_amounts": [],
+ "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/downgrade_small_realms_behind_on_payments_as_needed--Invoice.pay.1.json b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.pay.1.json
index 267220fde63..84470f6a715 100644
--- a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.pay.1.json
+++ b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.pay.1.json
@@ -20,9 +20,9 @@
"created": 1000000000,
"currency": "usd",
"custom_fields": null,
- "customer": "cus_NORMALIZED0005",
+ "customer": "cus_NORMALIZED0006",
"customer_address": null,
- "customer_email": "[email protected]",
+ "customer_email": "[email protected]",
"customer_name": null,
"customer_phone": null,
"customer_shipping": null,
@@ -39,9 +39,9 @@
"ending_balance": 0,
"finalized_at": 1000000000,
"footer": null,
- "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000004w1nCX",
- "id": "in_NORMALIZED00000000000004",
- "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000004w1nCX/pdf",
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED00000000000000059dDfj",
+ "id": "in_NORMALIZED00000000000005",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED00000000000000059dDfj/pdf",
"last_finalization_error": null,
"lines": {
"data": [
@@ -52,8 +52,8 @@
"discount_amounts": [],
"discountable": false,
"discounts": [],
- "id": "ii_NORMALIZED00000000000004",
- "invoice_item": "ii_NORMALIZED00000000000004",
+ "id": "ii_NORMALIZED00000000000005",
+ "invoice_item": "ii_NORMALIZED00000000000005",
"livemode": false,
"metadata": {},
"object": "line_item",
@@ -67,13 +67,13 @@
"billing_scheme": "per_unit",
"created": 1000000000,
"currency": "usd",
- "id": "price_1J5YWED2X8vgpBNGJPqvl8ls",
+ "id": "price_1JFeWgD2X8vgpBNG8aZDuPfL",
"livemode": false,
"lookup_key": null,
"metadata": {},
"nickname": null,
"object": "price",
- "product": "prod_Jj0XOrbeS8UGnX",
+ "product": "prod_JtRPmcvspB67ms",
"recurring": null,
"tiers_mode": null,
"transform_quantity": null,
@@ -87,18 +87,18 @@
"tax_amounts": [],
"tax_rates": [],
"type": "invoiceitem",
- "unique_id": "il_1J5YWED2X8vgpBNGcPMTOMfD"
+ "unique_id": "il_1JFeWgD2X8vgpBNGOIjdBP2A"
}
],
"has_more": false,
"object": "list",
"total_count": 1,
- "url": "/v1/invoices/in_NORMALIZED00000000000004/lines"
+ "url": "/v1/invoices/in_NORMALIZED00000000000005/lines"
},
"livemode": false,
"metadata": {},
"next_payment_attempt": null,
- "number": "NORMALI-0004",
+ "number": "NORMALI-0005",
"object": "invoice",
"on_behalf_of": null,
"paid": true,
@@ -111,6 +111,7 @@
"period_start": 1000000000,
"post_payment_credit_notes_amount": 0,
"pre_payment_credit_notes_amount": 0,
+ "quote": null,
"receipt_number": null,
"starting_balance": 0,
"statement_descriptor": "Zulip Standard",
diff --git a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.pay.2.json b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.pay.2.json
index b44f8aec577..cb8978ebdae 100644
--- a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.pay.2.json
+++ b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--Invoice.pay.2.json
@@ -20,9 +20,9 @@
"created": 1000000000,
"currency": "usd",
"custom_fields": null,
- "customer": "cus_NORMALIZED0005",
+ "customer": "cus_NORMALIZED0006",
"customer_address": null,
- "customer_email": "[email protected]",
+ "customer_email": "[email protected]",
"customer_name": null,
"customer_phone": null,
"customer_shipping": null,
@@ -39,9 +39,9 @@
"ending_balance": 0,
"finalized_at": 1000000000,
"footer": null,
- "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000005e3XWY",
- "id": "in_NORMALIZED00000000000005",
- "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000005e3XWY/pdf",
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000006sHPi7",
+ "id": "in_NORMALIZED00000000000006",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000006sHPi7/pdf",
"last_finalization_error": null,
"lines": {
"data": [
@@ -52,8 +52,8 @@
"discount_amounts": [],
"discountable": false,
"discounts": [],
- "id": "ii_NORMALIZED00000000000005",
- "invoice_item": "ii_NORMALIZED00000000000005",
+ "id": "ii_NORMALIZED00000000000006",
+ "invoice_item": "ii_NORMALIZED00000000000006",
"livemode": false,
"metadata": {},
"object": "line_item",
@@ -67,13 +67,13 @@
"billing_scheme": "per_unit",
"created": 1000000000,
"currency": "usd",
- "id": "price_1J5YWHD2X8vgpBNGwEA9hn4b",
+ "id": "price_1JFeWjD2X8vgpBNGCdWCb2b0",
"livemode": false,
"lookup_key": null,
"metadata": {},
"nickname": null,
"object": "price",
- "product": "prod_Jj0XvpvSalZcLc",
+ "product": "prod_JtRPhPDQW59jge",
"recurring": null,
"tiers_mode": null,
"transform_quantity": null,
@@ -87,18 +87,18 @@
"tax_amounts": [],
"tax_rates": [],
"type": "invoiceitem",
- "unique_id": "il_1J5YWHD2X8vgpBNGmcQgjQGx"
+ "unique_id": "il_1JFeWjD2X8vgpBNGoimP1ybx"
}
],
"has_more": false,
"object": "list",
"total_count": 1,
- "url": "/v1/invoices/in_NORMALIZED00000000000005/lines"
+ "url": "/v1/invoices/in_NORMALIZED00000000000006/lines"
},
"livemode": false,
"metadata": {},
"next_payment_attempt": null,
- "number": "NORMALI-0005",
+ "number": "NORMALI-0006",
"object": "invoice",
"on_behalf_of": null,
"paid": true,
@@ -111,6 +111,7 @@
"period_start": 1000000000,
"post_payment_credit_notes_amount": 0,
"pre_payment_credit_notes_amount": 0,
+ "quote": null,
"receipt_number": null,
"starting_balance": 0,
"statement_descriptor": "Zulip Standard",
@@ -129,5 +130,5 @@
"total_discount_amounts": [],
"total_tax_amounts": [],
"transfer_data": null,
- "webhooks_delivered_at": 1000000000
+ "webhooks_delivered_at": null
}
diff --git a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--InvoiceItem.create.1.json b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--InvoiceItem.create.1.json
index 1457f1a436f..ef4997f285c 100644
--- a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--InvoiceItem.create.1.json
+++ b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--InvoiceItem.create.1.json
@@ -1,7 +1,7 @@
{
"amount": 10000,
"currency": "usd",
- "customer": "cus_NORMALIZED0003",
+ "customer": "cus_NORMALIZED0002",
"date": 1000000000,
"description": "Zulip standard",
"discountable": false,
@@ -21,13 +21,13 @@
"billing_scheme": "per_unit",
"created": 1000000000,
"currency": "usd",
- "id": "price_1J5YW6D2X8vgpBNGNRpvTb7X",
+ "id": "price_1JFeWTD2X8vgpBNGeBhxIJRV",
"livemode": false,
"lookup_key": null,
"metadata": {},
"nickname": null,
"object": "price",
- "product": "prod_Jj0XEKpg4Z7fzV",
+ "product": "prod_JtRPn38wkV84NL",
"recurring": null,
"tiers_mode": null,
"transform_quantity": null,
diff --git a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--InvoiceItem.create.2.json b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--InvoiceItem.create.2.json
index e33c0caff00..257bd73f25b 100644
--- a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--InvoiceItem.create.2.json
+++ b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--InvoiceItem.create.2.json
@@ -21,13 +21,13 @@
"billing_scheme": "per_unit",
"created": 1000000000,
"currency": "usd",
- "id": "price_1J5YW8D2X8vgpBNGjQO5ySQC",
+ "id": "price_1JFeWXD2X8vgpBNGvUdNYypd",
"livemode": false,
"lookup_key": null,
"metadata": {},
"nickname": null,
"object": "price",
- "product": "prod_Jj0XcBc6MoFHgE",
+ "product": "prod_JtRP8I6UaXKjma",
"recurring": null,
"tiers_mode": null,
"transform_quantity": null,
diff --git a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--InvoiceItem.create.3.json b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--InvoiceItem.create.3.json
index a12ccf83b88..7b2e8f82872 100644
--- a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--InvoiceItem.create.3.json
+++ b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--InvoiceItem.create.3.json
@@ -1,7 +1,7 @@
{
"amount": 10000,
"currency": "usd",
- "customer": "cus_NORMALIZED0004",
+ "customer": "cus_NORMALIZED0005",
"date": 1000000000,
"description": "Zulip standard",
"discountable": false,
@@ -21,13 +21,13 @@
"billing_scheme": "per_unit",
"created": 1000000000,
"currency": "usd",
- "id": "price_1J5YWBD2X8vgpBNGk65s4Bby",
+ "id": "price_1JFeWaD2X8vgpBNG2Bwcq97U",
"livemode": false,
"lookup_key": null,
"metadata": {},
"nickname": null,
"object": "price",
- "product": "prod_Jj0XXEj43ttifM",
+ "product": "prod_JtRPXPerAm8d5s",
"recurring": null,
"tiers_mode": null,
"transform_quantity": null,
diff --git a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--InvoiceItem.create.4.json b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--InvoiceItem.create.4.json
index 9f7dba94437..dd99b2d4614 100644
--- a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--InvoiceItem.create.4.json
+++ b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--InvoiceItem.create.4.json
@@ -21,13 +21,13 @@
"billing_scheme": "per_unit",
"created": 1000000000,
"currency": "usd",
- "id": "price_1J5YWED2X8vgpBNGJPqvl8ls",
+ "id": "price_1JFeWdD2X8vgpBNGWZ9YZH5I",
"livemode": false,
"lookup_key": null,
"metadata": {},
"nickname": null,
"object": "price",
- "product": "prod_Jj0XOrbeS8UGnX",
+ "product": "prod_JtRPDqSSyDKbv9",
"recurring": null,
"tiers_mode": null,
"transform_quantity": null,
diff --git a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--InvoiceItem.create.5.json b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--InvoiceItem.create.5.json
index 4c6adef06c8..e374cfcf263 100644
--- a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--InvoiceItem.create.5.json
+++ b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--InvoiceItem.create.5.json
@@ -1,7 +1,7 @@
{
"amount": 10000,
"currency": "usd",
- "customer": "cus_NORMALIZED0005",
+ "customer": "cus_NORMALIZED0006",
"date": 1000000000,
"description": "Zulip standard",
"discountable": false,
@@ -21,13 +21,13 @@
"billing_scheme": "per_unit",
"created": 1000000000,
"currency": "usd",
- "id": "price_1J5YWHD2X8vgpBNGwEA9hn4b",
+ "id": "price_1JFeWgD2X8vgpBNG8aZDuPfL",
"livemode": false,
"lookup_key": null,
"metadata": {},
"nickname": null,
"object": "price",
- "product": "prod_Jj0XvpvSalZcLc",
+ "product": "prod_JtRPmcvspB67ms",
"recurring": null,
"tiers_mode": null,
"transform_quantity": null,
diff --git a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--InvoiceItem.create.6.json b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--InvoiceItem.create.6.json
index becb8f03230..ef92fc8fc69 100644
--- a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--InvoiceItem.create.6.json
+++ b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--InvoiceItem.create.6.json
@@ -21,13 +21,13 @@
"billing_scheme": "per_unit",
"created": 1000000000,
"currency": "usd",
- "id": "price_1J5YWMD2X8vgpBNGGQAGsuaj",
+ "id": "price_1JFeWjD2X8vgpBNGCdWCb2b0",
"livemode": false,
"lookup_key": null,
"metadata": {},
"nickname": null,
"object": "price",
- "product": "prod_Jj0XRALl1QAQk5",
+ "product": "prod_JtRPhPDQW59jge",
"recurring": null,
"tiers_mode": null,
"transform_quantity": null,
diff --git a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--InvoiceItem.create.7.json b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--InvoiceItem.create.7.json
index a666db3a9a4..22628d77d28 100644
--- a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--InvoiceItem.create.7.json
+++ b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--InvoiceItem.create.7.json
@@ -1,7 +1,7 @@
{
"amount": 10000,
"currency": "usd",
- "customer": "cus_NORMALIZED0006",
+ "customer": "cus_NORMALIZED0007",
"date": 1000000000,
"description": "Zulip standard",
"discountable": false,
@@ -21,13 +21,13 @@
"billing_scheme": "per_unit",
"created": 1000000000,
"currency": "usd",
- "id": "price_1J5YWPD2X8vgpBNGdU5odKe9",
+ "id": "price_1JFeWnD2X8vgpBNGonaCy8Je",
"livemode": false,
"lookup_key": null,
"metadata": {},
"nickname": null,
"object": "price",
- "product": "prod_Jj0X7KLLErkxlq",
+ "product": "prod_JtRPPpAxytZfRb",
"recurring": null,
"tiers_mode": null,
"transform_quantity": null,
diff --git a/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--InvoiceItem.create.8.json b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--InvoiceItem.create.8.json
new file mode 100644
index 00000000000..1a6ad6a3c08
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/downgrade_small_realms_behind_on_payments_as_needed--InvoiceItem.create.8.json
@@ -0,0 +1,44 @@
+{
+ "amount": 10000,
+ "currency": "usd",
+ "customer": "cus_NORMALIZED0007",
+ "date": 1000000000,
+ "description": "Zulip standard",
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_NORMALIZED00000000000008",
+ "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_1JFeWrD2X8vgpBNGo9vkCPfG",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_JtRPdALh7J9pfm",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 10000,
+ "unit_amount_decimal": "10000"
+ },
+ "proration": false,
+ "quantity": 1,
+ "subscription": null,
+ "tax_rates": [],
+ "unit_amount": 10000,
+ "unit_amount_decimal": "10000"
+}
diff --git a/corporate/tests/test_stripe.py b/corporate/tests/test_stripe.py
index 2f022322f29..1989fd797ea 100644
--- a/corporate/tests/test_stripe.py
+++ b/corporate/tests/test_stripe.py
@@ -2811,6 +2811,11 @@ class StripeTest(StripeTestCase):
)
rows.append(Row(realm, Realm.SELF_HOSTED, None, None, False, False))
+ realm, customer, _, _ = create_realm(
+ users_to_create=1, create_stripe_customer=True, create_plan=False, num_invoices=1
+ )
+ rows.append(Row(realm, Realm.SELF_HOSTED, None, None, True, False))
+
realm, _, plan, _ = create_realm(
users_to_create=1, create_stripe_customer=True, create_plan=True
)