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: Allow updating licenses of plans on manual license management.

Vishnu KS323ad83d98a4
diff --git a/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan--Customer.create.1.json b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan--Customer.create.1.json
new file mode 100644
index 00000000000..24c4bc8fe17
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan--Customer.create.1.json
@@ -0,0 +1,54 @@
+{
+ "account_balance": 0,
+ "address": null,
+ "balance": 0,
+ "created": 1000000000,
+ "currency": null,
+ "default_source": null,
+ "delinquent": false,
+ "description": "zulip (Zulip Dev)",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_NORMALIZED0001",
+ "invoice_prefix": "NORMA01",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": null,
+ "footer": null
+ },
+ "livemode": false,
+ "metadata": {
+ "realm_id": "1",
+ "realm_str": "zulip"
+ },
+ "name": null,
+ "next_invoice_sequence": 1,
+ "object": "customer",
+ "phone": null,
+ "preferred_locales": [],
+ "shipping": null,
+ "sources": {
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "total_count": 0,
+ "url": "/v1/customers/cus_NORMALIZED0001/sources"
+ },
+ "subscriptions": {
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "total_count": 0,
+ "url": "/v1/customers/cus_NORMALIZED0001/subscriptions"
+ },
+ "tax_exempt": "none",
+ "tax_ids": {
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "total_count": 0,
+ "url": "/v1/customers/cus_NORMALIZED0001/tax_ids"
+ },
+ "tax_info": null,
+ "tax_info_verification": null
+}
diff --git a/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan--Customer.retrieve.1.json b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan--Customer.retrieve.1.json
new file mode 100644
index 00000000000..d3b72bc2df2
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan--Customer.retrieve.1.json
@@ -0,0 +1,142 @@
+{
+ "account_balance": 0,
+ "address": null,
+ "balance": 0,
+ "created": 1000000000,
+ "currency": "usd",
+ "default_source": {
+ "ach_credit_transfer": {
+ "account_number": "test_NORMALIZED01",
+ "bank_name": "TEST BANK",
+ "fingerprint": "NORMALIZED000001",
+ "refund_account_holder_name": null,
+ "refund_account_holder_type": null,
+ "refund_routing_number": null,
+ "routing_number": "110000000",
+ "swift_code": "TSTEZ122"
+ },
+ "amount": null,
+ "client_secret": "src_client_secret_NORMALIZED00000000000001",
+ "created": 1000000000,
+ "currency": "usd",
+ "customer": "cus_NORMALIZED0001",
+ "flow": "receiver",
+ "id": "src_NORMALIZED00000000000001",
+ "livemode": false,
+ "metadata": {},
+ "object": "source",
+ "owner": {
+ "address": null,
+ "email": "[email protected]",
+ "name": null,
+ "phone": null,
+ "verified_address": null,
+ "verified_email": null,
+ "verified_name": null,
+ "verified_phone": null
+ },
+ "receiver": {
+ "address": "000000000-test_NORMALIZED01",
+ "amount_charged": 0,
+ "amount_received": 0,
+ "amount_returned": 0,
+ "refund_attributes_method": "email",
+ "refund_attributes_status": "missing"
+ },
+ "statement_descriptor": null,
+ "status": "pending",
+ "type": "ach_credit_transfer",
+ "usage": "reusable"
+ },
+ "delinquent": false,
+ "description": "zulip (Zulip Dev)",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_NORMALIZED0001",
+ "invoice_prefix": "NORMA01",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": null,
+ "footer": null
+ },
+ "livemode": false,
+ "metadata": {
+ "realm_id": "1",
+ "realm_str": "zulip"
+ },
+ "name": null,
+ "next_invoice_sequence": 3,
+ "object": "customer",
+ "phone": null,
+ "preferred_locales": [],
+ "shipping": null,
+ "sources": {
+ "data": [
+ {
+ "ach_credit_transfer": {
+ "account_number": "test_NORMALIZED01",
+ "bank_name": "TEST BANK",
+ "fingerprint": "NORMALIZED000001",
+ "refund_account_holder_name": null,
+ "refund_account_holder_type": null,
+ "refund_routing_number": null,
+ "routing_number": "110000000",
+ "swift_code": "TSTEZ122"
+ },
+ "amount": null,
+ "client_secret": "src_client_secret_NORMALIZED00000000000001",
+ "created": 1000000000,
+ "currency": "usd",
+ "customer": "cus_NORMALIZED0001",
+ "flow": "receiver",
+ "id": "src_NORMALIZED00000000000001",
+ "livemode": false,
+ "metadata": {},
+ "object": "source",
+ "owner": {
+ "address": null,
+ "email": "[email protected]",
+ "name": null,
+ "phone": null,
+ "verified_address": null,
+ "verified_email": null,
+ "verified_name": null,
+ "verified_phone": null
+ },
+ "receiver": {
+ "address": "000000000-test_NORMALIZED01",
+ "amount_charged": 0,
+ "amount_received": 0,
+ "amount_returned": 0,
+ "refund_attributes_method": "email",
+ "refund_attributes_status": "missing"
+ },
+ "statement_descriptor": null,
+ "status": "pending",
+ "type": "ach_credit_transfer",
+ "usage": "reusable"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/customers/cus_NORMALIZED0001/sources"
+ },
+ "subscriptions": {
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "total_count": 0,
+ "url": "/v1/customers/cus_NORMALIZED0001/subscriptions"
+ },
+ "tax_exempt": "none",
+ "tax_ids": {
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "total_count": 0,
+ "url": "/v1/customers/cus_NORMALIZED0001/tax_ids"
+ },
+ "tax_info": null,
+ "tax_info_verification": null
+}
diff --git a/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan--Customer.retrieve.2.json b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan--Customer.retrieve.2.json
new file mode 100644
index 00000000000..339c1869f6f
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan--Customer.retrieve.2.json
@@ -0,0 +1,142 @@
+{
+ "account_balance": 0,
+ "address": null,
+ "balance": 0,
+ "created": 1000000000,
+ "currency": "usd",
+ "default_source": {
+ "ach_credit_transfer": {
+ "account_number": "test_NORMALIZED01",
+ "bank_name": "TEST BANK",
+ "fingerprint": "NORMALIZED000001",
+ "refund_account_holder_name": null,
+ "refund_account_holder_type": null,
+ "refund_routing_number": null,
+ "routing_number": "110000000",
+ "swift_code": "TSTEZ122"
+ },
+ "amount": null,
+ "client_secret": "src_client_secret_NORMALIZED00000000000001",
+ "created": 1000000000,
+ "currency": "usd",
+ "customer": "cus_NORMALIZED0001",
+ "flow": "receiver",
+ "id": "src_NORMALIZED00000000000001",
+ "livemode": false,
+ "metadata": {},
+ "object": "source",
+ "owner": {
+ "address": null,
+ "email": "[email protected]",
+ "name": null,
+ "phone": null,
+ "verified_address": null,
+ "verified_email": null,
+ "verified_name": null,
+ "verified_phone": null
+ },
+ "receiver": {
+ "address": "000000000-test_NORMALIZED01",
+ "amount_charged": 0,
+ "amount_received": 0,
+ "amount_returned": 0,
+ "refund_attributes_method": "email",
+ "refund_attributes_status": "missing"
+ },
+ "statement_descriptor": null,
+ "status": "pending",
+ "type": "ach_credit_transfer",
+ "usage": "reusable"
+ },
+ "delinquent": false,
+ "description": "zulip (Zulip Dev)",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_NORMALIZED0001",
+ "invoice_prefix": "NORMA01",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": null,
+ "footer": null
+ },
+ "livemode": false,
+ "metadata": {
+ "realm_id": "1",
+ "realm_str": "zulip"
+ },
+ "name": null,
+ "next_invoice_sequence": 4,
+ "object": "customer",
+ "phone": null,
+ "preferred_locales": [],
+ "shipping": null,
+ "sources": {
+ "data": [
+ {
+ "ach_credit_transfer": {
+ "account_number": "test_NORMALIZED01",
+ "bank_name": "TEST BANK",
+ "fingerprint": "NORMALIZED000001",
+ "refund_account_holder_name": null,
+ "refund_account_holder_type": null,
+ "refund_routing_number": null,
+ "routing_number": "110000000",
+ "swift_code": "TSTEZ122"
+ },
+ "amount": null,
+ "client_secret": "src_client_secret_NORMALIZED00000000000001",
+ "created": 1000000000,
+ "currency": "usd",
+ "customer": "cus_NORMALIZED0001",
+ "flow": "receiver",
+ "id": "src_NORMALIZED00000000000001",
+ "livemode": false,
+ "metadata": {},
+ "object": "source",
+ "owner": {
+ "address": null,
+ "email": "[email protected]",
+ "name": null,
+ "phone": null,
+ "verified_address": null,
+ "verified_email": null,
+ "verified_name": null,
+ "verified_phone": null
+ },
+ "receiver": {
+ "address": "000000000-test_NORMALIZED01",
+ "amount_charged": 0,
+ "amount_received": 0,
+ "amount_returned": 0,
+ "refund_attributes_method": "email",
+ "refund_attributes_status": "missing"
+ },
+ "statement_descriptor": null,
+ "status": "pending",
+ "type": "ach_credit_transfer",
+ "usage": "reusable"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/customers/cus_NORMALIZED0001/sources"
+ },
+ "subscriptions": {
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "total_count": 0,
+ "url": "/v1/customers/cus_NORMALIZED0001/subscriptions"
+ },
+ "tax_exempt": "none",
+ "tax_ids": {
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "total_count": 0,
+ "url": "/v1/customers/cus_NORMALIZED0001/tax_ids"
+ },
+ "tax_info": null,
+ "tax_info_verification": null
+}
diff --git a/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan--Invoice.create.1.json b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan--Invoice.create.1.json
new file mode 100644
index 00000000000..9856b12c6b1
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan--Invoice.create.1.json
@@ -0,0 +1,124 @@
+{
+ "account_country": "US",
+ "account_name": "Vishnu Test",
+ "account_tax_ids": null,
+ "amount_due": 800000,
+ "amount_paid": 0,
+ "amount_remaining": 800000,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "send_invoice",
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "send_invoice",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_NORMALIZED0001",
+ "customer_address": null,
+ "customer_email": "[email protected]",
+ "customer_name": null,
+ "customer_phone": null,
+ "customer_shipping": null,
+ "customer_tax_exempt": "none",
+ "customer_tax_ids": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "discounts": [],
+ "due_date": 1000000000,
+ "ending_balance": null,
+ "finalized_at": null,
+ "footer": null,
+ "hosted_invoice_url": null,
+ "id": "in_NORMALIZED00000000000001",
+ "invoice_pdf": null,
+ "last_finalization_error": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 800000,
+ "currency": "usd",
+ "description": "Zulip Standard",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_NORMALIZED00000000000001",
+ "invoice_item": "ii_NORMALIZED00000000000001",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1I1Z7VD2X8vgpBNGEDWFERwd",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_Icola1rjDMk7Gn",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 100,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1I1Z7VD2X8vgpBNG4ABCXBHM"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/in_NORMALIZED00000000000001/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": null,
+ "number": "NORMALI-0001",
+ "object": "invoice",
+ "paid": false,
+ "payment_intent": null,
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "receipt_number": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Standard",
+ "status": "draft",
+ "status_transitions": {
+ "finalized_at": null,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subtotal": 800000,
+ "tax": null,
+ "tax_percent": null,
+ "total": 800000,
+ "total_discount_amounts": [],
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": null
+}
diff --git a/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan--Invoice.create.2.json b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan--Invoice.create.2.json
new file mode 100644
index 00000000000..426504ab48b
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan--Invoice.create.2.json
@@ -0,0 +1,168 @@
+{
+ "account_country": "US",
+ "account_name": "Vishnu Test",
+ "account_tax_ids": null,
+ "amount_due": 1600000,
+ "amount_paid": 0,
+ "amount_remaining": 1600000,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "send_invoice",
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "send_invoice",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_NORMALIZED0001",
+ "customer_address": null,
+ "customer_email": "[email protected]",
+ "customer_name": null,
+ "customer_phone": null,
+ "customer_shipping": null,
+ "customer_tax_exempt": "none",
+ "customer_tax_ids": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "discounts": [],
+ "due_date": 1000000000,
+ "ending_balance": null,
+ "finalized_at": null,
+ "footer": null,
+ "hosted_invoice_url": null,
+ "id": "in_NORMALIZED00000000000002",
+ "invoice_pdf": null,
+ "last_finalization_error": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 1200000,
+ "currency": "usd",
+ "description": "Zulip Standard - renewal",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_NORMALIZED00000000000002",
+ "invoice_item": "ii_NORMALIZED00000000000002",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1388631845,
+ "start": 1357095845
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1I1Z7ZD2X8vgpBNG7tOz2g1t",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_IcolNsCQAKuNp0",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 150,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1I1Z7ZD2X8vgpBNG9BQP6hmG"
+ },
+ {
+ "amount": 400000,
+ "currency": "usd",
+ "description": "Additional license (Jan 2, 2012 - Jan 2, 2013)",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_NORMALIZED00000000000003",
+ "invoice_item": "ii_NORMALIZED00000000000003",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1I1Z7YD2X8vgpBNGoXXJJrxC",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_IcolwKFOzzJdfY",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 50,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1I1Z7YD2X8vgpBNG7m9DarDi"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 2,
+ "url": "/v1/invoices/in_NORMALIZED00000000000002/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": null,
+ "number": "NORMALI-0002",
+ "object": "invoice",
+ "paid": false,
+ "payment_intent": null,
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "receipt_number": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Standard",
+ "status": "draft",
+ "status_transitions": {
+ "finalized_at": null,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subtotal": 1600000,
+ "tax": null,
+ "tax_percent": null,
+ "total": 1600000,
+ "total_discount_amounts": [],
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": null
+}
diff --git a/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan--Invoice.create.3.json b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan--Invoice.create.3.json
new file mode 100644
index 00000000000..ab4ec60cc58
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan--Invoice.create.3.json
@@ -0,0 +1,124 @@
+{
+ "account_country": "US",
+ "account_name": "Vishnu Test",
+ "account_tax_ids": null,
+ "amount_due": 960000,
+ "amount_paid": 0,
+ "amount_remaining": 960000,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "send_invoice",
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "send_invoice",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_NORMALIZED0001",
+ "customer_address": null,
+ "customer_email": "[email protected]",
+ "customer_name": null,
+ "customer_phone": null,
+ "customer_shipping": null,
+ "customer_tax_exempt": "none",
+ "customer_tax_ids": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "discounts": [],
+ "due_date": 1000000000,
+ "ending_balance": null,
+ "finalized_at": null,
+ "footer": null,
+ "hosted_invoice_url": null,
+ "id": "in_NORMALIZED00000000000003",
+ "invoice_pdf": null,
+ "last_finalization_error": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 960000,
+ "currency": "usd",
+ "description": "Zulip Standard - renewal",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_NORMALIZED00000000000004",
+ "invoice_item": "ii_NORMALIZED00000000000004",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1420167845,
+ "start": 1388631845
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1I1Z7cD2X8vgpBNGuVEbvcBx",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_IcolGnxXoZmJW6",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 120,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1I1Z7cD2X8vgpBNGLTCwAmPa"
+ }
+ ],
+ "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",
+ "paid": false,
+ "payment_intent": null,
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "receipt_number": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Standard",
+ "status": "draft",
+ "status_transitions": {
+ "finalized_at": null,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subtotal": 960000,
+ "tax": null,
+ "tax_percent": null,
+ "total": 960000,
+ "total_discount_amounts": [],
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": null
+}
diff --git a/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan--Invoice.finalize_invoice.1.json b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan--Invoice.finalize_invoice.1.json
new file mode 100644
index 00000000000..4f951e838d4
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan--Invoice.finalize_invoice.1.json
@@ -0,0 +1,124 @@
+{
+ "account_country": "US",
+ "account_name": "Vishnu Test",
+ "account_tax_ids": null,
+ "amount_due": 800000,
+ "amount_paid": 0,
+ "amount_remaining": 800000,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "send_invoice",
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "send_invoice",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_NORMALIZED0001",
+ "customer_address": null,
+ "customer_email": "[email protected]",
+ "customer_name": null,
+ "customer_phone": null,
+ "customer_shipping": null,
+ "customer_tax_exempt": "none",
+ "customer_tax_ids": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "discounts": [],
+ "due_date": 1000000000,
+ "ending_balance": 0,
+ "finalized_at": 1000000000,
+ "footer": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000001yO4oh",
+ "id": "in_NORMALIZED00000000000001",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000001yO4oh/pdf",
+ "last_finalization_error": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 800000,
+ "currency": "usd",
+ "description": "Zulip Standard",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_NORMALIZED00000000000001",
+ "invoice_item": "ii_NORMALIZED00000000000001",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1I1Z7VD2X8vgpBNGEDWFERwd",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_Icola1rjDMk7Gn",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 100,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1I1Z7VD2X8vgpBNG4ABCXBHM"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/in_NORMALIZED00000000000001/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": null,
+ "number": "NORMALI-0001",
+ "object": "invoice",
+ "paid": false,
+ "payment_intent": "pi_1I1Z7WD2X8vgpBNGlgnvL5Re",
+ "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": 800000,
+ "tax": null,
+ "tax_percent": null,
+ "total": 800000,
+ "total_discount_amounts": [],
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": null
+}
diff --git a/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan--Invoice.finalize_invoice.2.json b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan--Invoice.finalize_invoice.2.json
new file mode 100644
index 00000000000..52828a3015e
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan--Invoice.finalize_invoice.2.json
@@ -0,0 +1,168 @@
+{
+ "account_country": "US",
+ "account_name": "Vishnu Test",
+ "account_tax_ids": null,
+ "amount_due": 1600000,
+ "amount_paid": 0,
+ "amount_remaining": 1600000,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "send_invoice",
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "send_invoice",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_NORMALIZED0001",
+ "customer_address": null,
+ "customer_email": "[email protected]",
+ "customer_name": null,
+ "customer_phone": null,
+ "customer_shipping": null,
+ "customer_tax_exempt": "none",
+ "customer_tax_ids": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "discounts": [],
+ "due_date": 1000000000,
+ "ending_balance": 0,
+ "finalized_at": 1000000000,
+ "footer": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000002VzefV",
+ "id": "in_NORMALIZED00000000000002",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000002VzefV/pdf",
+ "last_finalization_error": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 1200000,
+ "currency": "usd",
+ "description": "Zulip Standard - renewal",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_NORMALIZED00000000000002",
+ "invoice_item": "ii_NORMALIZED00000000000002",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1388631845,
+ "start": 1357095845
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1I1Z7ZD2X8vgpBNG7tOz2g1t",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_IcolNsCQAKuNp0",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 150,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1I1Z7ZD2X8vgpBNG9BQP6hmG"
+ },
+ {
+ "amount": 400000,
+ "currency": "usd",
+ "description": "Additional license (Jan 2, 2012 - Jan 2, 2013)",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_NORMALIZED00000000000003",
+ "invoice_item": "ii_NORMALIZED00000000000003",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1I1Z7YD2X8vgpBNGoXXJJrxC",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_IcolwKFOzzJdfY",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 50,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1I1Z7YD2X8vgpBNG7m9DarDi"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 2,
+ "url": "/v1/invoices/in_NORMALIZED00000000000002/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": null,
+ "number": "NORMALI-0002",
+ "object": "invoice",
+ "paid": false,
+ "payment_intent": "pi_1I1Z7aD2X8vgpBNGZloSAnLC",
+ "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": 1600000,
+ "tax": null,
+ "tax_percent": null,
+ "total": 1600000,
+ "total_discount_amounts": [],
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": null
+}
diff --git a/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan--Invoice.finalize_invoice.3.json b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan--Invoice.finalize_invoice.3.json
new file mode 100644
index 00000000000..6fd73a2e882
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan--Invoice.finalize_invoice.3.json
@@ -0,0 +1,124 @@
+{
+ "account_country": "US",
+ "account_name": "Vishnu Test",
+ "account_tax_ids": null,
+ "amount_due": 960000,
+ "amount_paid": 0,
+ "amount_remaining": 960000,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "send_invoice",
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "send_invoice",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_NORMALIZED0001",
+ "customer_address": null,
+ "customer_email": "[email protected]",
+ "customer_name": null,
+ "customer_phone": null,
+ "customer_shipping": null,
+ "customer_tax_exempt": "none",
+ "customer_tax_ids": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "discounts": [],
+ "due_date": 1000000000,
+ "ending_balance": 0,
+ "finalized_at": 1000000000,
+ "footer": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000003ODsSp",
+ "id": "in_NORMALIZED00000000000003",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000003ODsSp/pdf",
+ "last_finalization_error": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 960000,
+ "currency": "usd",
+ "description": "Zulip Standard - renewal",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_NORMALIZED00000000000004",
+ "invoice_item": "ii_NORMALIZED00000000000004",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1420167845,
+ "start": 1388631845
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1I1Z7cD2X8vgpBNGuVEbvcBx",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_IcolGnxXoZmJW6",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 120,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1I1Z7cD2X8vgpBNGLTCwAmPa"
+ }
+ ],
+ "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",
+ "paid": false,
+ "payment_intent": "pi_1I1Z7dD2X8vgpBNGCrOtv0tO",
+ "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": 960000,
+ "tax": null,
+ "tax_percent": null,
+ "total": 960000,
+ "total_discount_amounts": [],
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": null
+}
diff --git a/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan--Invoice.list.1.json b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan--Invoice.list.1.json
new file mode 100644
index 00000000000..bcbc5b73449
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan--Invoice.list.1.json
@@ -0,0 +1,299 @@
+{
+ "data": [
+ {
+ "account_country": "US",
+ "account_name": "Vishnu Test",
+ "account_tax_ids": null,
+ "amount_due": 1600000,
+ "amount_paid": 0,
+ "amount_remaining": 1600000,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "send_invoice",
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "send_invoice",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_NORMALIZED0001",
+ "customer_address": null,
+ "customer_email": "[email protected]",
+ "customer_name": null,
+ "customer_phone": null,
+ "customer_shipping": null,
+ "customer_tax_exempt": "none",
+ "customer_tax_ids": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "discounts": [],
+ "due_date": 1000000000,
+ "ending_balance": 0,
+ "finalized_at": 1000000000,
+ "footer": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000002VzefV",
+ "id": "in_NORMALIZED00000000000002",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000002VzefV/pdf",
+ "last_finalization_error": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 1200000,
+ "currency": "usd",
+ "description": "Zulip Standard - renewal",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_NORMALIZED00000000000002",
+ "invoice_item": "ii_NORMALIZED00000000000002",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1388631845,
+ "start": 1357095845
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1I1Z7ZD2X8vgpBNG7tOz2g1t",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_IcolNsCQAKuNp0",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 150,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1I1Z7ZD2X8vgpBNG9BQP6hmG"
+ },
+ {
+ "amount": 400000,
+ "currency": "usd",
+ "description": "Additional license (Jan 2, 2012 - Jan 2, 2013)",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_NORMALIZED00000000000003",
+ "invoice_item": "ii_NORMALIZED00000000000003",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1I1Z7YD2X8vgpBNGoXXJJrxC",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_IcolwKFOzzJdfY",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 50,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1I1Z7YD2X8vgpBNG7m9DarDi"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 2,
+ "url": "/v1/invoices/in_NORMALIZED00000000000002/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": null,
+ "number": "NORMALI-0002",
+ "object": "invoice",
+ "paid": false,
+ "payment_intent": "pi_1I1Z7aD2X8vgpBNGZloSAnLC",
+ "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": 1600000,
+ "tax": null,
+ "tax_percent": null,
+ "total": 1600000,
+ "total_discount_amounts": [],
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1000000000
+ },
+ {
+ "account_country": "US",
+ "account_name": "Vishnu Test",
+ "account_tax_ids": null,
+ "amount_due": 800000,
+ "amount_paid": 0,
+ "amount_remaining": 800000,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "send_invoice",
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "send_invoice",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_NORMALIZED0001",
+ "customer_address": null,
+ "customer_email": "[email protected]",
+ "customer_name": null,
+ "customer_phone": null,
+ "customer_shipping": null,
+ "customer_tax_exempt": "none",
+ "customer_tax_ids": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "discounts": [],
+ "due_date": 1000000000,
+ "ending_balance": 0,
+ "finalized_at": 1000000000,
+ "footer": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000001yO4oh",
+ "id": "in_NORMALIZED00000000000001",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000001yO4oh/pdf",
+ "last_finalization_error": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 800000,
+ "currency": "usd",
+ "description": "Zulip Standard",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_NORMALIZED00000000000001",
+ "invoice_item": "ii_NORMALIZED00000000000001",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1I1Z7VD2X8vgpBNGEDWFERwd",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_Icola1rjDMk7Gn",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 100,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1I1Z7VD2X8vgpBNG4ABCXBHM"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/in_NORMALIZED00000000000001/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": null,
+ "number": "NORMALI-0001",
+ "object": "invoice",
+ "paid": false,
+ "payment_intent": "pi_1I1Z7WD2X8vgpBNGlgnvL5Re",
+ "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": 800000,
+ "tax": null,
+ "tax_percent": null,
+ "total": 800000,
+ "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/update_licenses_of_manual_plan--Invoice.list.2.json b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan--Invoice.list.2.json
new file mode 100644
index 00000000000..70dcf509612
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan--Invoice.list.2.json
@@ -0,0 +1,423 @@
+{
+ "data": [
+ {
+ "account_country": "US",
+ "account_name": "Vishnu Test",
+ "account_tax_ids": null,
+ "amount_due": 960000,
+ "amount_paid": 0,
+ "amount_remaining": 960000,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "send_invoice",
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "send_invoice",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_NORMALIZED0001",
+ "customer_address": null,
+ "customer_email": "[email protected]",
+ "customer_name": null,
+ "customer_phone": null,
+ "customer_shipping": null,
+ "customer_tax_exempt": "none",
+ "customer_tax_ids": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "discounts": [],
+ "due_date": 1000000000,
+ "ending_balance": 0,
+ "finalized_at": 1000000000,
+ "footer": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000003ODsSp",
+ "id": "in_NORMALIZED00000000000003",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000003ODsSp/pdf",
+ "last_finalization_error": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 960000,
+ "currency": "usd",
+ "description": "Zulip Standard - renewal",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_NORMALIZED00000000000004",
+ "invoice_item": "ii_NORMALIZED00000000000004",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1420167845,
+ "start": 1388631845
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1I1Z7cD2X8vgpBNGuVEbvcBx",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_IcolGnxXoZmJW6",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 120,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1I1Z7cD2X8vgpBNGLTCwAmPa"
+ }
+ ],
+ "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",
+ "paid": false,
+ "payment_intent": "pi_1I1Z7dD2X8vgpBNGCrOtv0tO",
+ "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": 960000,
+ "tax": null,
+ "tax_percent": null,
+ "total": 960000,
+ "total_discount_amounts": [],
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1000000000
+ },
+ {
+ "account_country": "US",
+ "account_name": "Vishnu Test",
+ "account_tax_ids": null,
+ "amount_due": 1600000,
+ "amount_paid": 0,
+ "amount_remaining": 1600000,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "send_invoice",
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "send_invoice",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_NORMALIZED0001",
+ "customer_address": null,
+ "customer_email": "[email protected]",
+ "customer_name": null,
+ "customer_phone": null,
+ "customer_shipping": null,
+ "customer_tax_exempt": "none",
+ "customer_tax_ids": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "discounts": [],
+ "due_date": 1000000000,
+ "ending_balance": 0,
+ "finalized_at": 1000000000,
+ "footer": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000002VzefV",
+ "id": "in_NORMALIZED00000000000002",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000002VzefV/pdf",
+ "last_finalization_error": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 1200000,
+ "currency": "usd",
+ "description": "Zulip Standard - renewal",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_NORMALIZED00000000000002",
+ "invoice_item": "ii_NORMALIZED00000000000002",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1388631845,
+ "start": 1357095845
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1I1Z7ZD2X8vgpBNG7tOz2g1t",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_IcolNsCQAKuNp0",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 150,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1I1Z7ZD2X8vgpBNG9BQP6hmG"
+ },
+ {
+ "amount": 400000,
+ "currency": "usd",
+ "description": "Additional license (Jan 2, 2012 - Jan 2, 2013)",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_NORMALIZED00000000000003",
+ "invoice_item": "ii_NORMALIZED00000000000003",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1I1Z7YD2X8vgpBNGoXXJJrxC",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_IcolwKFOzzJdfY",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 50,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1I1Z7YD2X8vgpBNG7m9DarDi"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 2,
+ "url": "/v1/invoices/in_NORMALIZED00000000000002/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": null,
+ "number": "NORMALI-0002",
+ "object": "invoice",
+ "paid": false,
+ "payment_intent": "pi_1I1Z7aD2X8vgpBNGZloSAnLC",
+ "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": 1600000,
+ "tax": null,
+ "tax_percent": null,
+ "total": 1600000,
+ "total_discount_amounts": [],
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1000000000
+ },
+ {
+ "account_country": "US",
+ "account_name": "Vishnu Test",
+ "account_tax_ids": null,
+ "amount_due": 800000,
+ "amount_paid": 0,
+ "amount_remaining": 800000,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "send_invoice",
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "send_invoice",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_NORMALIZED0001",
+ "customer_address": null,
+ "customer_email": "[email protected]",
+ "customer_name": null,
+ "customer_phone": null,
+ "customer_shipping": null,
+ "customer_tax_exempt": "none",
+ "customer_tax_ids": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "discounts": [],
+ "due_date": 1000000000,
+ "ending_balance": 0,
+ "finalized_at": 1000000000,
+ "footer": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000001yO4oh",
+ "id": "in_NORMALIZED00000000000001",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000001yO4oh/pdf",
+ "last_finalization_error": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 800000,
+ "currency": "usd",
+ "description": "Zulip Standard",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_NORMALIZED00000000000001",
+ "invoice_item": "ii_NORMALIZED00000000000001",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1I1Z7VD2X8vgpBNGEDWFERwd",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_Icola1rjDMk7Gn",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 100,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1I1Z7VD2X8vgpBNG4ABCXBHM"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/in_NORMALIZED00000000000001/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": null,
+ "number": "NORMALI-0001",
+ "object": "invoice",
+ "paid": false,
+ "payment_intent": "pi_1I1Z7WD2X8vgpBNGlgnvL5Re",
+ "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": 800000,
+ "tax": null,
+ "tax_percent": null,
+ "total": 800000,
+ "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/update_licenses_of_manual_plan--InvoiceItem.create.1.json b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan--InvoiceItem.create.1.json
new file mode 100644
index 00000000000..89ec7c8e92d
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan--InvoiceItem.create.1.json
@@ -0,0 +1,44 @@
+{
+ "amount": 800000,
+ "currency": "usd",
+ "customer": "cus_NORMALIZED0001",
+ "date": 1000000000,
+ "description": "Zulip Standard",
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_NORMALIZED00000000000001",
+ "invoice": null,
+ "livemode": false,
+ "metadata": {},
+ "object": "invoiceitem",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1I1Z7VD2X8vgpBNGEDWFERwd",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_Icola1rjDMk7Gn",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 100,
+ "subscription": null,
+ "tax_rates": [],
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+}
diff --git a/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan--InvoiceItem.create.2.json b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan--InvoiceItem.create.2.json
new file mode 100644
index 00000000000..5af8b3ee994
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan--InvoiceItem.create.2.json
@@ -0,0 +1,44 @@
+{
+ "amount": 400000,
+ "currency": "usd",
+ "customer": "cus_NORMALIZED0001",
+ "date": 1000000000,
+ "description": "Additional license (Jan 2, 2012 - Jan 2, 2013)",
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_NORMALIZED00000000000003",
+ "invoice": null,
+ "livemode": false,
+ "metadata": {},
+ "object": "invoiceitem",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1I1Z7YD2X8vgpBNGoXXJJrxC",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_IcolwKFOzzJdfY",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 50,
+ "subscription": null,
+ "tax_rates": [],
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+}
diff --git a/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan--InvoiceItem.create.3.json b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan--InvoiceItem.create.3.json
new file mode 100644
index 00000000000..06422cbce0d
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan--InvoiceItem.create.3.json
@@ -0,0 +1,44 @@
+{
+ "amount": 1200000,
+ "currency": "usd",
+ "customer": "cus_NORMALIZED0001",
+ "date": 1000000000,
+ "description": "Zulip Standard - renewal",
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_NORMALIZED00000000000002",
+ "invoice": null,
+ "livemode": false,
+ "metadata": {},
+ "object": "invoiceitem",
+ "period": {
+ "end": 1388631845,
+ "start": 1357095845
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1I1Z7ZD2X8vgpBNG7tOz2g1t",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_IcolNsCQAKuNp0",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 150,
+ "subscription": null,
+ "tax_rates": [],
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+}
diff --git a/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan--InvoiceItem.create.4.json b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan--InvoiceItem.create.4.json
new file mode 100644
index 00000000000..f101493a7c7
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan--InvoiceItem.create.4.json
@@ -0,0 +1,44 @@
+{
+ "amount": 960000,
+ "currency": "usd",
+ "customer": "cus_NORMALIZED0001",
+ "date": 1000000000,
+ "description": "Zulip Standard - renewal",
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_NORMALIZED00000000000004",
+ "invoice": null,
+ "livemode": false,
+ "metadata": {},
+ "object": "invoiceitem",
+ "period": {
+ "end": 1420167845,
+ "start": 1388631845
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1I1Z7cD2X8vgpBNGuVEbvcBx",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_IcolGnxXoZmJW6",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 120,
+ "subscription": null,
+ "tax_rates": [],
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+}
diff --git a/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan_from_billing_page--Customer.create.1.json b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan_from_billing_page--Customer.create.1.json
new file mode 100644
index 00000000000..24c4bc8fe17
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan_from_billing_page--Customer.create.1.json
@@ -0,0 +1,54 @@
+{
+ "account_balance": 0,
+ "address": null,
+ "balance": 0,
+ "created": 1000000000,
+ "currency": null,
+ "default_source": null,
+ "delinquent": false,
+ "description": "zulip (Zulip Dev)",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_NORMALIZED0001",
+ "invoice_prefix": "NORMA01",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": null,
+ "footer": null
+ },
+ "livemode": false,
+ "metadata": {
+ "realm_id": "1",
+ "realm_str": "zulip"
+ },
+ "name": null,
+ "next_invoice_sequence": 1,
+ "object": "customer",
+ "phone": null,
+ "preferred_locales": [],
+ "shipping": null,
+ "sources": {
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "total_count": 0,
+ "url": "/v1/customers/cus_NORMALIZED0001/sources"
+ },
+ "subscriptions": {
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "total_count": 0,
+ "url": "/v1/customers/cus_NORMALIZED0001/subscriptions"
+ },
+ "tax_exempt": "none",
+ "tax_ids": {
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "total_count": 0,
+ "url": "/v1/customers/cus_NORMALIZED0001/tax_ids"
+ },
+ "tax_info": null,
+ "tax_info_verification": null
+}
diff --git a/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan_from_billing_page--Customer.retrieve.1.json b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan_from_billing_page--Customer.retrieve.1.json
new file mode 100644
index 00000000000..d3b72bc2df2
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan_from_billing_page--Customer.retrieve.1.json
@@ -0,0 +1,142 @@
+{
+ "account_balance": 0,
+ "address": null,
+ "balance": 0,
+ "created": 1000000000,
+ "currency": "usd",
+ "default_source": {
+ "ach_credit_transfer": {
+ "account_number": "test_NORMALIZED01",
+ "bank_name": "TEST BANK",
+ "fingerprint": "NORMALIZED000001",
+ "refund_account_holder_name": null,
+ "refund_account_holder_type": null,
+ "refund_routing_number": null,
+ "routing_number": "110000000",
+ "swift_code": "TSTEZ122"
+ },
+ "amount": null,
+ "client_secret": "src_client_secret_NORMALIZED00000000000001",
+ "created": 1000000000,
+ "currency": "usd",
+ "customer": "cus_NORMALIZED0001",
+ "flow": "receiver",
+ "id": "src_NORMALIZED00000000000001",
+ "livemode": false,
+ "metadata": {},
+ "object": "source",
+ "owner": {
+ "address": null,
+ "email": "[email protected]",
+ "name": null,
+ "phone": null,
+ "verified_address": null,
+ "verified_email": null,
+ "verified_name": null,
+ "verified_phone": null
+ },
+ "receiver": {
+ "address": "000000000-test_NORMALIZED01",
+ "amount_charged": 0,
+ "amount_received": 0,
+ "amount_returned": 0,
+ "refund_attributes_method": "email",
+ "refund_attributes_status": "missing"
+ },
+ "statement_descriptor": null,
+ "status": "pending",
+ "type": "ach_credit_transfer",
+ "usage": "reusable"
+ },
+ "delinquent": false,
+ "description": "zulip (Zulip Dev)",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_NORMALIZED0001",
+ "invoice_prefix": "NORMA01",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": null,
+ "footer": null
+ },
+ "livemode": false,
+ "metadata": {
+ "realm_id": "1",
+ "realm_str": "zulip"
+ },
+ "name": null,
+ "next_invoice_sequence": 3,
+ "object": "customer",
+ "phone": null,
+ "preferred_locales": [],
+ "shipping": null,
+ "sources": {
+ "data": [
+ {
+ "ach_credit_transfer": {
+ "account_number": "test_NORMALIZED01",
+ "bank_name": "TEST BANK",
+ "fingerprint": "NORMALIZED000001",
+ "refund_account_holder_name": null,
+ "refund_account_holder_type": null,
+ "refund_routing_number": null,
+ "routing_number": "110000000",
+ "swift_code": "TSTEZ122"
+ },
+ "amount": null,
+ "client_secret": "src_client_secret_NORMALIZED00000000000001",
+ "created": 1000000000,
+ "currency": "usd",
+ "customer": "cus_NORMALIZED0001",
+ "flow": "receiver",
+ "id": "src_NORMALIZED00000000000001",
+ "livemode": false,
+ "metadata": {},
+ "object": "source",
+ "owner": {
+ "address": null,
+ "email": "[email protected]",
+ "name": null,
+ "phone": null,
+ "verified_address": null,
+ "verified_email": null,
+ "verified_name": null,
+ "verified_phone": null
+ },
+ "receiver": {
+ "address": "000000000-test_NORMALIZED01",
+ "amount_charged": 0,
+ "amount_received": 0,
+ "amount_returned": 0,
+ "refund_attributes_method": "email",
+ "refund_attributes_status": "missing"
+ },
+ "statement_descriptor": null,
+ "status": "pending",
+ "type": "ach_credit_transfer",
+ "usage": "reusable"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/customers/cus_NORMALIZED0001/sources"
+ },
+ "subscriptions": {
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "total_count": 0,
+ "url": "/v1/customers/cus_NORMALIZED0001/subscriptions"
+ },
+ "tax_exempt": "none",
+ "tax_ids": {
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "total_count": 0,
+ "url": "/v1/customers/cus_NORMALIZED0001/tax_ids"
+ },
+ "tax_info": null,
+ "tax_info_verification": null
+}
diff --git a/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan_from_billing_page--Customer.retrieve.2.json b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan_from_billing_page--Customer.retrieve.2.json
new file mode 100644
index 00000000000..339c1869f6f
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan_from_billing_page--Customer.retrieve.2.json
@@ -0,0 +1,142 @@
+{
+ "account_balance": 0,
+ "address": null,
+ "balance": 0,
+ "created": 1000000000,
+ "currency": "usd",
+ "default_source": {
+ "ach_credit_transfer": {
+ "account_number": "test_NORMALIZED01",
+ "bank_name": "TEST BANK",
+ "fingerprint": "NORMALIZED000001",
+ "refund_account_holder_name": null,
+ "refund_account_holder_type": null,
+ "refund_routing_number": null,
+ "routing_number": "110000000",
+ "swift_code": "TSTEZ122"
+ },
+ "amount": null,
+ "client_secret": "src_client_secret_NORMALIZED00000000000001",
+ "created": 1000000000,
+ "currency": "usd",
+ "customer": "cus_NORMALIZED0001",
+ "flow": "receiver",
+ "id": "src_NORMALIZED00000000000001",
+ "livemode": false,
+ "metadata": {},
+ "object": "source",
+ "owner": {
+ "address": null,
+ "email": "[email protected]",
+ "name": null,
+ "phone": null,
+ "verified_address": null,
+ "verified_email": null,
+ "verified_name": null,
+ "verified_phone": null
+ },
+ "receiver": {
+ "address": "000000000-test_NORMALIZED01",
+ "amount_charged": 0,
+ "amount_received": 0,
+ "amount_returned": 0,
+ "refund_attributes_method": "email",
+ "refund_attributes_status": "missing"
+ },
+ "statement_descriptor": null,
+ "status": "pending",
+ "type": "ach_credit_transfer",
+ "usage": "reusable"
+ },
+ "delinquent": false,
+ "description": "zulip (Zulip Dev)",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_NORMALIZED0001",
+ "invoice_prefix": "NORMA01",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": null,
+ "footer": null
+ },
+ "livemode": false,
+ "metadata": {
+ "realm_id": "1",
+ "realm_str": "zulip"
+ },
+ "name": null,
+ "next_invoice_sequence": 4,
+ "object": "customer",
+ "phone": null,
+ "preferred_locales": [],
+ "shipping": null,
+ "sources": {
+ "data": [
+ {
+ "ach_credit_transfer": {
+ "account_number": "test_NORMALIZED01",
+ "bank_name": "TEST BANK",
+ "fingerprint": "NORMALIZED000001",
+ "refund_account_holder_name": null,
+ "refund_account_holder_type": null,
+ "refund_routing_number": null,
+ "routing_number": "110000000",
+ "swift_code": "TSTEZ122"
+ },
+ "amount": null,
+ "client_secret": "src_client_secret_NORMALIZED00000000000001",
+ "created": 1000000000,
+ "currency": "usd",
+ "customer": "cus_NORMALIZED0001",
+ "flow": "receiver",
+ "id": "src_NORMALIZED00000000000001",
+ "livemode": false,
+ "metadata": {},
+ "object": "source",
+ "owner": {
+ "address": null,
+ "email": "[email protected]",
+ "name": null,
+ "phone": null,
+ "verified_address": null,
+ "verified_email": null,
+ "verified_name": null,
+ "verified_phone": null
+ },
+ "receiver": {
+ "address": "000000000-test_NORMALIZED01",
+ "amount_charged": 0,
+ "amount_received": 0,
+ "amount_returned": 0,
+ "refund_attributes_method": "email",
+ "refund_attributes_status": "missing"
+ },
+ "statement_descriptor": null,
+ "status": "pending",
+ "type": "ach_credit_transfer",
+ "usage": "reusable"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/customers/cus_NORMALIZED0001/sources"
+ },
+ "subscriptions": {
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "total_count": 0,
+ "url": "/v1/customers/cus_NORMALIZED0001/subscriptions"
+ },
+ "tax_exempt": "none",
+ "tax_ids": {
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "total_count": 0,
+ "url": "/v1/customers/cus_NORMALIZED0001/tax_ids"
+ },
+ "tax_info": null,
+ "tax_info_verification": null
+}
diff --git a/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan_from_billing_page--Invoice.create.1.json b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan_from_billing_page--Invoice.create.1.json
new file mode 100644
index 00000000000..23cf5ddbb88
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan_from_billing_page--Invoice.create.1.json
@@ -0,0 +1,124 @@
+{
+ "account_country": "US",
+ "account_name": "Vishnu Test",
+ "account_tax_ids": null,
+ "amount_due": 800000,
+ "amount_paid": 0,
+ "amount_remaining": 800000,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "send_invoice",
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "send_invoice",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_NORMALIZED0001",
+ "customer_address": null,
+ "customer_email": "[email protected]",
+ "customer_name": null,
+ "customer_phone": null,
+ "customer_shipping": null,
+ "customer_tax_exempt": "none",
+ "customer_tax_ids": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "discounts": [],
+ "due_date": 1000000000,
+ "ending_balance": null,
+ "finalized_at": null,
+ "footer": null,
+ "hosted_invoice_url": null,
+ "id": "in_NORMALIZED00000000000001",
+ "invoice_pdf": null,
+ "last_finalization_error": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 800000,
+ "currency": "usd",
+ "description": "Zulip Standard",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_NORMALIZED00000000000001",
+ "invoice_item": "ii_NORMALIZED00000000000001",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1I2KRVD2X8vgpBNG9esQtj8L",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_IdbekBbBgKxfBl",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 100,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1I2KRVD2X8vgpBNGvl4i8eac"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/in_NORMALIZED00000000000001/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": null,
+ "number": "NORMALI-0001",
+ "object": "invoice",
+ "paid": false,
+ "payment_intent": null,
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "receipt_number": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Standard",
+ "status": "draft",
+ "status_transitions": {
+ "finalized_at": null,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subtotal": 800000,
+ "tax": null,
+ "tax_percent": null,
+ "total": 800000,
+ "total_discount_amounts": [],
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": null
+}
diff --git a/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan_from_billing_page--Invoice.create.2.json b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan_from_billing_page--Invoice.create.2.json
new file mode 100644
index 00000000000..d942e8a039f
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan_from_billing_page--Invoice.create.2.json
@@ -0,0 +1,168 @@
+{
+ "account_country": "US",
+ "account_name": "Vishnu Test",
+ "account_tax_ids": null,
+ "amount_due": 1600000,
+ "amount_paid": 0,
+ "amount_remaining": 1600000,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "send_invoice",
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "send_invoice",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_NORMALIZED0001",
+ "customer_address": null,
+ "customer_email": "[email protected]",
+ "customer_name": null,
+ "customer_phone": null,
+ "customer_shipping": null,
+ "customer_tax_exempt": "none",
+ "customer_tax_ids": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "discounts": [],
+ "due_date": 1000000000,
+ "ending_balance": null,
+ "finalized_at": null,
+ "footer": null,
+ "hosted_invoice_url": null,
+ "id": "in_NORMALIZED00000000000002",
+ "invoice_pdf": null,
+ "last_finalization_error": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 1200000,
+ "currency": "usd",
+ "description": "Zulip Standard - renewal",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_NORMALIZED00000000000002",
+ "invoice_item": "ii_NORMALIZED00000000000002",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1388631845,
+ "start": 1357095845
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1I2KRYD2X8vgpBNGCflF8VYB",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_Idbeh61pACCNHE",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 150,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1I2KRYD2X8vgpBNGIYfu4anF"
+ },
+ {
+ "amount": 400000,
+ "currency": "usd",
+ "description": "Additional license (Jan 2, 2012 - Jan 2, 2013)",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_NORMALIZED00000000000003",
+ "invoice_item": "ii_NORMALIZED00000000000003",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1I2KRYD2X8vgpBNGaGRmF77j",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_Idbe1Gr2iiwoWB",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 50,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1I2KRYD2X8vgpBNGdmBXG8v1"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 2,
+ "url": "/v1/invoices/in_NORMALIZED00000000000002/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": null,
+ "number": "NORMALI-0002",
+ "object": "invoice",
+ "paid": false,
+ "payment_intent": null,
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "receipt_number": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Standard",
+ "status": "draft",
+ "status_transitions": {
+ "finalized_at": null,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subtotal": 1600000,
+ "tax": null,
+ "tax_percent": null,
+ "total": 1600000,
+ "total_discount_amounts": [],
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": null
+}
diff --git a/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan_from_billing_page--Invoice.create.3.json b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan_from_billing_page--Invoice.create.3.json
new file mode 100644
index 00000000000..b933e664789
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan_from_billing_page--Invoice.create.3.json
@@ -0,0 +1,124 @@
+{
+ "account_country": "US",
+ "account_name": "Vishnu Test",
+ "account_tax_ids": null,
+ "amount_due": 960000,
+ "amount_paid": 0,
+ "amount_remaining": 960000,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "send_invoice",
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "send_invoice",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_NORMALIZED0001",
+ "customer_address": null,
+ "customer_email": "[email protected]",
+ "customer_name": null,
+ "customer_phone": null,
+ "customer_shipping": null,
+ "customer_tax_exempt": "none",
+ "customer_tax_ids": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "discounts": [],
+ "due_date": 1000000000,
+ "ending_balance": null,
+ "finalized_at": null,
+ "footer": null,
+ "hosted_invoice_url": null,
+ "id": "in_NORMALIZED00000000000003",
+ "invoice_pdf": null,
+ "last_finalization_error": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 960000,
+ "currency": "usd",
+ "description": "Zulip Standard - renewal",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_NORMALIZED00000000000004",
+ "invoice_item": "ii_NORMALIZED00000000000004",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1420167845,
+ "start": 1388631845
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1I2KRbD2X8vgpBNGYPSjBZYZ",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_IdbeRrNHvhUjov",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 120,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1I2KRbD2X8vgpBNG6KqjtrC3"
+ }
+ ],
+ "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",
+ "paid": false,
+ "payment_intent": null,
+ "period_end": 1000000000,
+ "period_start": 1000000000,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "receipt_number": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Standard",
+ "status": "draft",
+ "status_transitions": {
+ "finalized_at": null,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subtotal": 960000,
+ "tax": null,
+ "tax_percent": null,
+ "total": 960000,
+ "total_discount_amounts": [],
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": null
+}
diff --git a/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan_from_billing_page--Invoice.finalize_invoice.1.json b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan_from_billing_page--Invoice.finalize_invoice.1.json
new file mode 100644
index 00000000000..13dd03b7f0e
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan_from_billing_page--Invoice.finalize_invoice.1.json
@@ -0,0 +1,124 @@
+{
+ "account_country": "US",
+ "account_name": "Vishnu Test",
+ "account_tax_ids": null,
+ "amount_due": 800000,
+ "amount_paid": 0,
+ "amount_remaining": 800000,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "send_invoice",
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "send_invoice",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_NORMALIZED0001",
+ "customer_address": null,
+ "customer_email": "[email protected]",
+ "customer_name": null,
+ "customer_phone": null,
+ "customer_shipping": null,
+ "customer_tax_exempt": "none",
+ "customer_tax_ids": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "discounts": [],
+ "due_date": 1000000000,
+ "ending_balance": 0,
+ "finalized_at": 1000000000,
+ "footer": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000001cSL6o",
+ "id": "in_NORMALIZED00000000000001",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000001cSL6o/pdf",
+ "last_finalization_error": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 800000,
+ "currency": "usd",
+ "description": "Zulip Standard",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_NORMALIZED00000000000001",
+ "invoice_item": "ii_NORMALIZED00000000000001",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1I2KRVD2X8vgpBNG9esQtj8L",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_IdbekBbBgKxfBl",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 100,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1I2KRVD2X8vgpBNGvl4i8eac"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/in_NORMALIZED00000000000001/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": null,
+ "number": "NORMALI-0001",
+ "object": "invoice",
+ "paid": false,
+ "payment_intent": "pi_1I2KRWD2X8vgpBNGn1bBebXw",
+ "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": 800000,
+ "tax": null,
+ "tax_percent": null,
+ "total": 800000,
+ "total_discount_amounts": [],
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1000000000
+}
diff --git a/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan_from_billing_page--Invoice.finalize_invoice.2.json b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan_from_billing_page--Invoice.finalize_invoice.2.json
new file mode 100644
index 00000000000..fc6cf87f23a
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan_from_billing_page--Invoice.finalize_invoice.2.json
@@ -0,0 +1,168 @@
+{
+ "account_country": "US",
+ "account_name": "Vishnu Test",
+ "account_tax_ids": null,
+ "amount_due": 1600000,
+ "amount_paid": 0,
+ "amount_remaining": 1600000,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "send_invoice",
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "send_invoice",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_NORMALIZED0001",
+ "customer_address": null,
+ "customer_email": "[email protected]",
+ "customer_name": null,
+ "customer_phone": null,
+ "customer_shipping": null,
+ "customer_tax_exempt": "none",
+ "customer_tax_ids": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "discounts": [],
+ "due_date": 1000000000,
+ "ending_balance": 0,
+ "finalized_at": 1000000000,
+ "footer": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000002GLqJZ",
+ "id": "in_NORMALIZED00000000000002",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000002GLqJZ/pdf",
+ "last_finalization_error": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 1200000,
+ "currency": "usd",
+ "description": "Zulip Standard - renewal",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_NORMALIZED00000000000002",
+ "invoice_item": "ii_NORMALIZED00000000000002",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1388631845,
+ "start": 1357095845
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1I2KRYD2X8vgpBNGCflF8VYB",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_Idbeh61pACCNHE",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 150,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1I2KRYD2X8vgpBNGIYfu4anF"
+ },
+ {
+ "amount": 400000,
+ "currency": "usd",
+ "description": "Additional license (Jan 2, 2012 - Jan 2, 2013)",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_NORMALIZED00000000000003",
+ "invoice_item": "ii_NORMALIZED00000000000003",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1I2KRYD2X8vgpBNGaGRmF77j",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_Idbe1Gr2iiwoWB",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 50,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1I2KRYD2X8vgpBNGdmBXG8v1"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 2,
+ "url": "/v1/invoices/in_NORMALIZED00000000000002/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": null,
+ "number": "NORMALI-0002",
+ "object": "invoice",
+ "paid": false,
+ "payment_intent": "pi_1I2KRaD2X8vgpBNGr7FXPbXU",
+ "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": 1600000,
+ "tax": null,
+ "tax_percent": null,
+ "total": 1600000,
+ "total_discount_amounts": [],
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": null
+}
diff --git a/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan_from_billing_page--Invoice.finalize_invoice.3.json b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan_from_billing_page--Invoice.finalize_invoice.3.json
new file mode 100644
index 00000000000..ff8ec5a64e0
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan_from_billing_page--Invoice.finalize_invoice.3.json
@@ -0,0 +1,124 @@
+{
+ "account_country": "US",
+ "account_name": "Vishnu Test",
+ "account_tax_ids": null,
+ "amount_due": 960000,
+ "amount_paid": 0,
+ "amount_remaining": 960000,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "send_invoice",
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "send_invoice",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_NORMALIZED0001",
+ "customer_address": null,
+ "customer_email": "[email protected]",
+ "customer_name": null,
+ "customer_phone": null,
+ "customer_shipping": null,
+ "customer_tax_exempt": "none",
+ "customer_tax_ids": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "discounts": [],
+ "due_date": 1000000000,
+ "ending_balance": 0,
+ "finalized_at": 1000000000,
+ "footer": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000003vYywT",
+ "id": "in_NORMALIZED00000000000003",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000003vYywT/pdf",
+ "last_finalization_error": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 960000,
+ "currency": "usd",
+ "description": "Zulip Standard - renewal",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_NORMALIZED00000000000004",
+ "invoice_item": "ii_NORMALIZED00000000000004",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1420167845,
+ "start": 1388631845
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1I2KRbD2X8vgpBNGYPSjBZYZ",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_IdbeRrNHvhUjov",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 120,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1I2KRbD2X8vgpBNG6KqjtrC3"
+ }
+ ],
+ "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",
+ "paid": false,
+ "payment_intent": "pi_1I2KRdD2X8vgpBNGJzS4K4wk",
+ "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": 960000,
+ "tax": null,
+ "tax_percent": null,
+ "total": 960000,
+ "total_discount_amounts": [],
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": null
+}
diff --git a/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan_from_billing_page--Invoice.list.1.json b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan_from_billing_page--Invoice.list.1.json
new file mode 100644
index 00000000000..aca4b1dc899
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan_from_billing_page--Invoice.list.1.json
@@ -0,0 +1,299 @@
+{
+ "data": [
+ {
+ "account_country": "US",
+ "account_name": "Vishnu Test",
+ "account_tax_ids": null,
+ "amount_due": 1600000,
+ "amount_paid": 0,
+ "amount_remaining": 1600000,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "send_invoice",
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "send_invoice",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_NORMALIZED0001",
+ "customer_address": null,
+ "customer_email": "[email protected]",
+ "customer_name": null,
+ "customer_phone": null,
+ "customer_shipping": null,
+ "customer_tax_exempt": "none",
+ "customer_tax_ids": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "discounts": [],
+ "due_date": 1000000000,
+ "ending_balance": 0,
+ "finalized_at": 1000000000,
+ "footer": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000002GLqJZ",
+ "id": "in_NORMALIZED00000000000002",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000002GLqJZ/pdf",
+ "last_finalization_error": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 1200000,
+ "currency": "usd",
+ "description": "Zulip Standard - renewal",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_NORMALIZED00000000000002",
+ "invoice_item": "ii_NORMALIZED00000000000002",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1388631845,
+ "start": 1357095845
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1I2KRYD2X8vgpBNGCflF8VYB",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_Idbeh61pACCNHE",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 150,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1I2KRYD2X8vgpBNGIYfu4anF"
+ },
+ {
+ "amount": 400000,
+ "currency": "usd",
+ "description": "Additional license (Jan 2, 2012 - Jan 2, 2013)",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_NORMALIZED00000000000003",
+ "invoice_item": "ii_NORMALIZED00000000000003",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1I2KRYD2X8vgpBNGaGRmF77j",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_Idbe1Gr2iiwoWB",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 50,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1I2KRYD2X8vgpBNGdmBXG8v1"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 2,
+ "url": "/v1/invoices/in_NORMALIZED00000000000002/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": null,
+ "number": "NORMALI-0002",
+ "object": "invoice",
+ "paid": false,
+ "payment_intent": "pi_1I2KRaD2X8vgpBNGr7FXPbXU",
+ "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": 1600000,
+ "tax": null,
+ "tax_percent": null,
+ "total": 1600000,
+ "total_discount_amounts": [],
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1000000000
+ },
+ {
+ "account_country": "US",
+ "account_name": "Vishnu Test",
+ "account_tax_ids": null,
+ "amount_due": 800000,
+ "amount_paid": 0,
+ "amount_remaining": 800000,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "send_invoice",
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "send_invoice",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_NORMALIZED0001",
+ "customer_address": null,
+ "customer_email": "[email protected]",
+ "customer_name": null,
+ "customer_phone": null,
+ "customer_shipping": null,
+ "customer_tax_exempt": "none",
+ "customer_tax_ids": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "discounts": [],
+ "due_date": 1000000000,
+ "ending_balance": 0,
+ "finalized_at": 1000000000,
+ "footer": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000001cSL6o",
+ "id": "in_NORMALIZED00000000000001",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000001cSL6o/pdf",
+ "last_finalization_error": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 800000,
+ "currency": "usd",
+ "description": "Zulip Standard",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_NORMALIZED00000000000001",
+ "invoice_item": "ii_NORMALIZED00000000000001",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1I2KRVD2X8vgpBNG9esQtj8L",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_IdbekBbBgKxfBl",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 100,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1I2KRVD2X8vgpBNGvl4i8eac"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/in_NORMALIZED00000000000001/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": null,
+ "number": "NORMALI-0001",
+ "object": "invoice",
+ "paid": false,
+ "payment_intent": "pi_1I2KRWD2X8vgpBNGn1bBebXw",
+ "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": 800000,
+ "tax": null,
+ "tax_percent": null,
+ "total": 800000,
+ "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/update_licenses_of_manual_plan_from_billing_page--Invoice.list.2.json b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan_from_billing_page--Invoice.list.2.json
new file mode 100644
index 00000000000..8cc6f816320
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan_from_billing_page--Invoice.list.2.json
@@ -0,0 +1,423 @@
+{
+ "data": [
+ {
+ "account_country": "US",
+ "account_name": "Vishnu Test",
+ "account_tax_ids": null,
+ "amount_due": 960000,
+ "amount_paid": 0,
+ "amount_remaining": 960000,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "send_invoice",
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "send_invoice",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_NORMALIZED0001",
+ "customer_address": null,
+ "customer_email": "[email protected]",
+ "customer_name": null,
+ "customer_phone": null,
+ "customer_shipping": null,
+ "customer_tax_exempt": "none",
+ "customer_tax_ids": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "discounts": [],
+ "due_date": 1000000000,
+ "ending_balance": 0,
+ "finalized_at": 1000000000,
+ "footer": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000003vYywT",
+ "id": "in_NORMALIZED00000000000003",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000003vYywT/pdf",
+ "last_finalization_error": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 960000,
+ "currency": "usd",
+ "description": "Zulip Standard - renewal",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_NORMALIZED00000000000004",
+ "invoice_item": "ii_NORMALIZED00000000000004",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1420167845,
+ "start": 1388631845
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1I2KRbD2X8vgpBNGYPSjBZYZ",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_IdbeRrNHvhUjov",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 120,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1I2KRbD2X8vgpBNG6KqjtrC3"
+ }
+ ],
+ "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",
+ "paid": false,
+ "payment_intent": "pi_1I2KRdD2X8vgpBNGJzS4K4wk",
+ "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": 960000,
+ "tax": null,
+ "tax_percent": null,
+ "total": 960000,
+ "total_discount_amounts": [],
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1000000000
+ },
+ {
+ "account_country": "US",
+ "account_name": "Vishnu Test",
+ "account_tax_ids": null,
+ "amount_due": 1600000,
+ "amount_paid": 0,
+ "amount_remaining": 1600000,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "send_invoice",
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "send_invoice",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_NORMALIZED0001",
+ "customer_address": null,
+ "customer_email": "[email protected]",
+ "customer_name": null,
+ "customer_phone": null,
+ "customer_shipping": null,
+ "customer_tax_exempt": "none",
+ "customer_tax_ids": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "discounts": [],
+ "due_date": 1000000000,
+ "ending_balance": 0,
+ "finalized_at": 1000000000,
+ "footer": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000002GLqJZ",
+ "id": "in_NORMALIZED00000000000002",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000002GLqJZ/pdf",
+ "last_finalization_error": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 1200000,
+ "currency": "usd",
+ "description": "Zulip Standard - renewal",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_NORMALIZED00000000000002",
+ "invoice_item": "ii_NORMALIZED00000000000002",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1388631845,
+ "start": 1357095845
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1I2KRYD2X8vgpBNGCflF8VYB",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_Idbeh61pACCNHE",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 150,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1I2KRYD2X8vgpBNGIYfu4anF"
+ },
+ {
+ "amount": 400000,
+ "currency": "usd",
+ "description": "Additional license (Jan 2, 2012 - Jan 2, 2013)",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_NORMALIZED00000000000003",
+ "invoice_item": "ii_NORMALIZED00000000000003",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1I2KRYD2X8vgpBNGaGRmF77j",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_Idbe1Gr2iiwoWB",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 50,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1I2KRYD2X8vgpBNGdmBXG8v1"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 2,
+ "url": "/v1/invoices/in_NORMALIZED00000000000002/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": null,
+ "number": "NORMALI-0002",
+ "object": "invoice",
+ "paid": false,
+ "payment_intent": "pi_1I2KRaD2X8vgpBNGr7FXPbXU",
+ "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": 1600000,
+ "tax": null,
+ "tax_percent": null,
+ "total": 1600000,
+ "total_discount_amounts": [],
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": 1000000000
+ },
+ {
+ "account_country": "US",
+ "account_name": "Vishnu Test",
+ "account_tax_ids": null,
+ "amount_due": 800000,
+ "amount_paid": 0,
+ "amount_remaining": 800000,
+ "application_fee": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "billing": "send_invoice",
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "send_invoice",
+ "created": 1000000000,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_NORMALIZED0001",
+ "customer_address": null,
+ "customer_email": "[email protected]",
+ "customer_name": null,
+ "customer_phone": null,
+ "customer_shipping": null,
+ "customer_tax_exempt": "none",
+ "customer_tax_ids": [],
+ "date": 1000000000,
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "discounts": [],
+ "due_date": 1000000000,
+ "ending_balance": 0,
+ "finalized_at": 1000000000,
+ "footer": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000001cSL6o",
+ "id": "in_NORMALIZED00000000000001",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000001cSL6o/pdf",
+ "last_finalization_error": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 800000,
+ "currency": "usd",
+ "description": "Zulip Standard",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_NORMALIZED00000000000001",
+ "invoice_item": "ii_NORMALIZED00000000000001",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1I2KRVD2X8vgpBNG9esQtj8L",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_IdbekBbBgKxfBl",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 100,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unique_id": "il_1I2KRVD2X8vgpBNGvl4i8eac"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/invoices/in_NORMALIZED00000000000001/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": null,
+ "number": "NORMALI-0001",
+ "object": "invoice",
+ "paid": false,
+ "payment_intent": "pi_1I2KRWD2X8vgpBNGn1bBebXw",
+ "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": 800000,
+ "tax": null,
+ "tax_percent": null,
+ "total": 800000,
+ "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/update_licenses_of_manual_plan_from_billing_page--InvoiceItem.create.1.json b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan_from_billing_page--InvoiceItem.create.1.json
new file mode 100644
index 00000000000..5be38cb892d
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan_from_billing_page--InvoiceItem.create.1.json
@@ -0,0 +1,44 @@
+{
+ "amount": 800000,
+ "currency": "usd",
+ "customer": "cus_NORMALIZED0001",
+ "date": 1000000000,
+ "description": "Zulip Standard",
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_NORMALIZED00000000000001",
+ "invoice": null,
+ "livemode": false,
+ "metadata": {},
+ "object": "invoiceitem",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1I2KRVD2X8vgpBNG9esQtj8L",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_IdbekBbBgKxfBl",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 100,
+ "subscription": null,
+ "tax_rates": [],
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+}
diff --git a/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan_from_billing_page--InvoiceItem.create.2.json b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan_from_billing_page--InvoiceItem.create.2.json
new file mode 100644
index 00000000000..a944f0f9573
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan_from_billing_page--InvoiceItem.create.2.json
@@ -0,0 +1,44 @@
+{
+ "amount": 400000,
+ "currency": "usd",
+ "customer": "cus_NORMALIZED0001",
+ "date": 1000000000,
+ "description": "Additional license (Jan 2, 2012 - Jan 2, 2013)",
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_NORMALIZED00000000000003",
+ "invoice": null,
+ "livemode": false,
+ "metadata": {},
+ "object": "invoiceitem",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1I2KRYD2X8vgpBNGaGRmF77j",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_Idbe1Gr2iiwoWB",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 50,
+ "subscription": null,
+ "tax_rates": [],
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+}
diff --git a/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan_from_billing_page--InvoiceItem.create.3.json b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan_from_billing_page--InvoiceItem.create.3.json
new file mode 100644
index 00000000000..e28e66e42c8
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan_from_billing_page--InvoiceItem.create.3.json
@@ -0,0 +1,44 @@
+{
+ "amount": 1200000,
+ "currency": "usd",
+ "customer": "cus_NORMALIZED0001",
+ "date": 1000000000,
+ "description": "Zulip Standard - renewal",
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_NORMALIZED00000000000002",
+ "invoice": null,
+ "livemode": false,
+ "metadata": {},
+ "object": "invoiceitem",
+ "period": {
+ "end": 1388631845,
+ "start": 1357095845
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1I2KRYD2X8vgpBNGCflF8VYB",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_Idbeh61pACCNHE",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 150,
+ "subscription": null,
+ "tax_rates": [],
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+}
diff --git a/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan_from_billing_page--InvoiceItem.create.4.json b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan_from_billing_page--InvoiceItem.create.4.json
new file mode 100644
index 00000000000..0e06eeb114a
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/update_licenses_of_manual_plan_from_billing_page--InvoiceItem.create.4.json
@@ -0,0 +1,44 @@
+{
+ "amount": 960000,
+ "currency": "usd",
+ "customer": "cus_NORMALIZED0001",
+ "date": 1000000000,
+ "description": "Zulip Standard - renewal",
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_NORMALIZED00000000000004",
+ "invoice": null,
+ "livemode": false,
+ "metadata": {},
+ "object": "invoiceitem",
+ "period": {
+ "end": 1420167845,
+ "start": 1388631845
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1000000000,
+ "currency": "usd",
+ "id": "price_1I2KRbD2X8vgpBNGYPSjBZYZ",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_IdbeRrNHvhUjov",
+ "recurring": null,
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+ },
+ "proration": false,
+ "quantity": 120,
+ "subscription": null,
+ "tax_rates": [],
+ "unit_amount": 8000,
+ "unit_amount_decimal": "8000"
+}
diff --git a/corporate/tests/test_stripe.py b/corporate/tests/test_stripe.py
index 5798f481b6c..a537427511f 100644
--- a/corporate/tests/test_stripe.py
+++ b/corporate/tests/test_stripe.py
@@ -404,7 +404,7 @@ class StripeTestCase(ZulipTestCase):
if invoice: # send_invoice
params.update(
billing_modality="send_invoice",
- licenses=123,
+ licenses=kwargs.get("licenses", 123),
)
else: # charge_automatically
stripe_token = None
@@ -639,6 +639,15 @@ class StripeTest(StripeTestCase):
]:
self.assert_in_response(substring, response)
+ self.assert_not_in_success_response(
+ [
+ "You can only increase the number of licenses.",
+ "Number of licenses",
+ "Licenses in next renewal",
+ ],
+ response,
+ )
+
@mock_stripe(tested_timestamp_fields=["created"])
def test_upgrade_by_invoice(self, *mocks: Mock) -> None:
user = self.example_user("hamlet")
@@ -763,6 +772,9 @@ class StripeTest(StripeTestCase):
"January 2, 2013",
"$9,840.00", # 9840 = 80 * 123
"Billed by invoice",
+ "You can only increase the number of licenses.",
+ "Number of licenses",
+ "Licenses in next renewal",
]:
self.assert_in_response(substring, response)
@@ -2314,7 +2326,144 @@ class StripeTest(StripeTestCase):
self.assertEqual(old_plan.next_invoice_date, None)
self.assertEqual(old_plan.status, CustomerPlan.ENDED)
- def test_update_plan_with_invalid_status(self, *mocks: Mock) -> None:
+ @mock_stripe()
+ def test_update_licenses_of_manual_plan_from_billing_page(self, *mocks: Mock) -> None:
+ user = self.example_user("hamlet")
+ self.login_user(user)
+
+ with patch("corporate.lib.stripe.timezone_now", return_value=self.now):
+ self.upgrade(invoice=True, licenses=100)
+
+ with patch("corporate.views.timezone_now", return_value=self.now):
+ result = self.client_patch("/json/billing/plan", {"licenses": 100})
+ self.assert_json_error_contains(
+ result, "Your plan is already on 100 licenses in the current billing period."
+ )
+
+ with patch("corporate.views.timezone_now", return_value=self.now):
+ result = self.client_patch("/json/billing/plan", {"licenses_at_next_renewal": 100})
+ self.assert_json_error_contains(
+ result, "Your plan is already scheduled to renew with 100 licenses."
+ )
+
+ with patch("corporate.views.timezone_now", return_value=self.now):
+ result = self.client_patch("/json/billing/plan", {"licenses": 50})
+ self.assert_json_error_contains(
+ result, "You cannot decrease the licenses in the current billing period."
+ )
+
+ with patch("corporate.views.timezone_now", return_value=self.now):
+ result = self.client_patch("/json/billing/plan", {"licenses_at_next_renewal": 25})
+ self.assert_json_error_contains(result, "You must invoice for at least 30 users.")
+
+ with patch("corporate.views.timezone_now", return_value=self.now):
+ result = self.client_patch("/json/billing/plan", {"licenses": 2000})
+ self.assert_json_error_contains(
+ result, "Invoices with more than 1000 licenses can't be processed from this page."
+ )
+
+ with patch("corporate.views.timezone_now", return_value=self.now):
+ result = self.client_patch("/json/billing/plan", {"licenses": 150})
+ self.assert_json_success(result)
+ invoice_plans_as_needed(self.next_year)
+ stripe_customer = stripe_get_customer(
+ Customer.objects.get(realm=user.realm).stripe_customer_id
+ )
+ [invoice, _] = stripe.Invoice.list(customer=stripe_customer.id)
+ invoice_params = {
+ "amount_due": (8000 * 150 + 8000 * 50),
+ "amount_paid": 0,
+ "attempt_count": 0,
+ "auto_advance": True,
+ "billing": "send_invoice",
+ "statement_descriptor": "Zulip Standard",
+ "status": "open",
+ "total": (8000 * 150 + 8000 * 50),
+ }
+ for key, value in invoice_params.items():
+ self.assertEqual(invoice.get(key), value)
+ [renewal_item, extra_license_item] = invoice.lines
+ line_item_params = {
+ "amount": 8000 * 150,
+ "description": "Zulip Standard - renewal",
+ "discountable": False,
+ "period": {
+ "end": datetime_to_timestamp(self.next_year + timedelta(days=365)),
+ "start": datetime_to_timestamp(self.next_year),
+ },
+ "plan": None,
+ "proration": False,
+ "quantity": 150,
+ }
+ for key, value in line_item_params.items():
+ self.assertEqual(renewal_item.get(key), value)
+ line_item_params = {
+ "amount": 8000 * 50,
+ "description": "Additional license (Jan 2, 2012 - Jan 2, 2013)",
+ "discountable": False,
+ "period": {
+ "end": datetime_to_timestamp(self.next_year),
+ "start": datetime_to_timestamp(self.now),
+ },
+ "plan": None,
+ "proration": False,
+ "quantity": 50,
+ }
+ for key, value in line_item_params.items():
+ self.assertEqual(extra_license_item.get(key), value)
+
+ with patch("corporate.views.timezone_now", return_value=self.next_year):
+ result = self.client_patch("/json/billing/plan", {"licenses_at_next_renewal": 120})
+ self.assert_json_success(result)
+ invoice_plans_as_needed(self.next_year + timedelta(days=365))
+ stripe_customer = stripe_get_customer(
+ Customer.objects.get(realm=user.realm).stripe_customer_id
+ )
+ [invoice, _, _] = stripe.Invoice.list(customer=stripe_customer.id)
+ invoice_params = {
+ "amount_due": 8000 * 120,
+ "amount_paid": 0,
+ "attempt_count": 0,
+ "auto_advance": True,
+ "billing": "send_invoice",
+ "statement_descriptor": "Zulip Standard",
+ "status": "open",
+ "total": 8000 * 120,
+ }
+ for key, value in invoice_params.items():
+ self.assertEqual(invoice.get(key), value)
+ [renewal_item] = invoice.lines
+ line_item_params = {
+ "amount": 8000 * 120,
+ "description": "Zulip Standard - renewal",
+ "discountable": False,
+ "period": {
+ "end": datetime_to_timestamp(self.next_year + timedelta(days=2 * 365)),
+ "start": datetime_to_timestamp(self.next_year + timedelta(days=365)),
+ },
+ "plan": None,
+ "proration": False,
+ "quantity": 120,
+ }
+ for key, value in line_item_params.items():
+ self.assertEqual(renewal_item.get(key), value)
+
+ def test_update_licenses_of_automatic_plan_from_billing_page(self, *mocks: Mock) -> None:
+ user = self.example_user("hamlet")
+ self.login_user(user)
+
+ with patch("corporate.lib.stripe.timezone_now", return_value=self.now):
+ self.local_upgrade(self.seat_count, True, CustomerPlan.ANNUAL, "token")
+
+ with patch("corporate.views.timezone_now", return_value=self.now):
+ result = self.client_patch("/json/billing/plan", {"licenses": 100})
+ self.assert_json_error_contains(result, "Your plan is on automatic license management.")
+
+ with patch("corporate.views.timezone_now", return_value=self.now):
+ result = self.client_patch("/json/billing/plan", {"licenses_at_next_renewal": 100})
+ self.assert_json_error_contains(result, "Your plan is on automatic license management.")
+
+ def test_update_plan_with_invalid_status(self) -> None:
with patch("corporate.lib.stripe.timezone_now", return_value=self.now):
self.local_upgrade(self.seat_count, True, CustomerPlan.ANNUAL, "token")
self.login_user(self.example_user("hamlet"))
diff --git a/corporate/views.py b/corporate/views.py
index 2f3c540095f..ffc0de57e23 100644
--- a/corporate/views.py
+++ b/corporate/views.py
@@ -29,6 +29,7 @@ from corporate.lib.stripe import (
start_of_next_billing_cycle,
stripe_get_customer,
unsign_string,
+ update_license_ledger_for_manual_plan,
update_sponsorship_status,
validate_licenses,
)
@@ -305,6 +306,7 @@ def billing_home(request: HttpRequest) -> HttpResponse:
plan.status == CustomerPlan.SWITCH_TO_ANNUAL_AT_END_OF_CYCLE
)
licenses = last_ledger_entry.licenses
+ licenses_at_next_renewal = last_ledger_entry.licenses_at_next_renewal
seat_count = get_latest_seat_count(user.realm)
# Should do this in javascript, using the user's timezone
@@ -327,6 +329,7 @@ def billing_home(request: HttpRequest) -> HttpResponse:
automanage_licenses=plan.automanage_licenses,
switch_to_annual_at_end_of_cycle=switch_to_annual_at_end_of_cycle,
licenses=licenses,
+ licenses_at_next_renewal=licenses_at_next_renewal,
seat_count=seat_count,
renewal_date=renewal_date,
renewal_amount=f"{renewal_cents / 100.:,.2f}",
@@ -358,6 +361,10 @@ def update_plan(
),
default=None,
),
+ licenses: Optional[int] = REQ("licenses", json_validator=check_int, default=None),
+ licenses_at_next_renewal: Optional[int] = REQ(
+ "licenses_at_next_renewal", json_validator=check_int, default=None
+ ),
) -> HttpResponse:
plan = get_current_plan_by_realm(user.realm)
assert plan is not None # for mypy
@@ -388,6 +395,60 @@ def update_plan(
downgrade_now_without_creating_additional_invoices(user.realm)
return json_success()
+ if licenses is not None:
+ if plan.automanage_licenses:
+ return json_error(
+ _(
+ "Unable to update licenses manually. Your plan is on automatic license management."
+ )
+ )
+ if last_ledger_entry.licenses == licenses:
+ return json_error(
+ _(
+ "Your plan is already on {licenses} licenses in the current billing period."
+ ).format(licenses=licenses)
+ )
+ if last_ledger_entry.licenses > licenses:
+ return json_error(
+ _("You cannot decrease the licenses in the current billing period.").format(
+ licenses=licenses
+ )
+ )
+ try:
+ validate_licenses(
+ plan.charge_automatically, licenses, get_latest_seat_count(user.realm)
+ )
+ except BillingError as e:
+ return json_error(e.message, data={"error_description": e.description})
+ update_license_ledger_for_manual_plan(plan, timezone_now(), licenses=licenses)
+ return json_success()
+
+ if licenses_at_next_renewal is not None:
+ if plan.automanage_licenses:
+ return json_error(
+ _(
+ "Unable to update licenses manually. Your plan is on automatic license management."
+ )
+ )
+ if last_ledger_entry.licenses_at_next_renewal == licenses_at_next_renewal:
+ return json_error(
+ _(
+ "Your plan is already scheduled to renew with {licenses_at_next_renewal} licenses."
+ ).format(licenses_at_next_renewal=licenses_at_next_renewal)
+ )
+ try:
+ validate_licenses(
+ plan.charge_automatically,
+ licenses_at_next_renewal,
+ get_latest_seat_count(user.realm),
+ )
+ except BillingError as e:
+ return json_error(e.message, data={"error_description": e.description})
+ update_license_ledger_for_manual_plan(
+ plan, timezone_now(), licenses_at_next_renewal=licenses_at_next_renewal
+ )
+ return json_success()
+
return json_error(_("Nothing to change."))
diff --git a/frontend_tests/node_tests/billing.js b/frontend_tests/node_tests/billing.js
index d253998b545..66b7b987572 100644
--- a/frontend_tests/node_tests/billing.js
+++ b/frontend_tests/node_tests/billing.js
@@ -22,7 +22,7 @@ const helpers = mock_esm("../../static/js/billing/helpers", {
set_tab: () => {},
});
-zrequire("billing/billing");
+const billing = zrequire("billing/billing");
run_test("initialize", (override) => {
let token_func;
@@ -103,8 +103,100 @@ run_test("initialize", (override) => {
with_field(helpers, "create_ajax_request", plan_change_ajax, () => {
change_plan_status_click_handler(e);
+ assert(create_ajax_request_called);
+ });
+
+ create_ajax_request_called = false;
+ function license_change_ajax(
+ url,
+ form_name,
+ stripe_token,
+ ignored_inputs,
+ redirect_to,
+ method,
+ ) {
+ assert.equal(url, "/json/billing/plan");
+ assert.equal(form_name, "licensechange");
+ assert.equal(stripe_token, undefined);
+ assert.deepEqual(ignored_inputs, ["licenses_at_next_renewal"]);
+ assert.equal(redirect_to, undefined);
+ assert.equal(method, "PATCH");
+ create_ajax_request_called = true;
+ }
+ with_field(helpers, "create_ajax_request", license_change_ajax, () => {
+ billing.create_update_license_request();
+ assert(create_ajax_request_called);
+ });
+
+ let create_update_license_request_called = false;
+ override(billing, "create_update_license_request", () => {
+ create_update_license_request_called = true;
+ });
+
+ const confirm_license_update_click_handler = $("#confirm-license-update-button").get_on_handler(
+ "click",
+ );
+ confirm_license_update_click_handler(e);
+ assert(create_update_license_request_called);
+
+ let confirm_license_modal_shown = false;
+ override(helpers, "is_valid_input", () => true);
+ $("#confirm-licenses-modal").modal = (action) => {
+ assert(action, "show");
+ confirm_license_modal_shown = true;
+ };
+ $("#licensechange-input-section").data = (key) => {
+ assert(key, "licenses");
+ return 20;
+ };
+ $("#new_licenses_input").val = () => 15;
+ create_update_license_request_called = false;
+ const update_licenses_button_click_handler =
+ $("#update-licenses-button").get_on_handler("click");
+ update_licenses_button_click_handler(e);
+ assert(create_update_license_request_called);
+ assert(!confirm_license_modal_shown);
+
+ $("#new_licenses_input").val = () => 25;
+ create_update_license_request_called = false;
+ update_licenses_button_click_handler(e);
+ assert(!create_update_license_request_called);
+ assert(confirm_license_modal_shown);
+
+ override(helpers, "is_valid_input", () => false);
+ let prevent_default_called = false;
+ const event = {
+ prevent_default: () => {
+ prevent_default_called = true;
+ },
+ };
+ update_licenses_button_click_handler(event);
+ assert(!prevent_default_called);
+
+ const update_next_renewal_licenses_button_click_handler = $(
+ "#update-licenses-at-next-renewal-button",
+ ).get_on_handler("click");
+ create_ajax_request_called = false;
+ function licenses_at_next_renewal_change_ajax(
+ url,
+ form_name,
+ stripe_token,
+ ignored_inputs,
+ redirect_to,
+ method,
+ ) {
+ assert.equal(url, "/json/billing/plan");
+ assert.equal(form_name, "licensechange");
+ assert.equal(stripe_token, undefined);
+ assert.deepEqual(ignored_inputs, ["licenses"]);
+ assert.equal(redirect_to, undefined);
+ assert.equal(method, "PATCH");
+ create_ajax_request_called = true;
+ }
+ with_field(helpers, "create_ajax_request", licenses_at_next_renewal_change_ajax, () => {
+ update_next_renewal_licenses_button_click_handler(e);
+ assert(create_ajax_request_called);
});
- assert(create_ajax_request_called);
});
run_test("billing_template", () => {
@@ -114,5 +206,10 @@ run_test("billing_template", () => {
assert(document.querySelector("#cardchange_loading_indicator"));
assert(document.querySelector("#cardchange-success"));
+ assert(document.querySelector("#licensechange-error"));
+ assert(document.querySelector("#licensechange-loading"));
+ assert(document.querySelector("#licensechange_loading_indicator"));
+ assert(document.querySelector("#licensechange-success"));
+
assert(document.querySelector("input[name=csrfmiddlewaretoken]"));
});
diff --git a/static/js/billing/billing.js b/static/js/billing/billing.js
index 72c00a9d4d2..d10bdc27c79 100644
--- a/static/js/billing/billing.js
+++ b/static/js/billing/billing.js
@@ -2,6 +2,17 @@ import $ from "jquery";
import * as helpers from "./helpers";
+export function create_update_license_request() {
+ helpers.create_ajax_request(
+ "/json/billing/plan",
+ "licensechange",
+ undefined,
+ ["licenses_at_next_renewal"],
+ undefined,
+ "PATCH",
+ );
+}
+
export function initialize() {
helpers.set_tab("billing");
@@ -29,6 +40,38 @@ export function initialize() {
e.preventDefault();
});
+ $("#update-licenses-button").on("click", (e) => {
+ if (helpers.is_valid_input($("#new_licenses_input")) === false) {
+ return;
+ }
+ e.preventDefault();
+ const current_licenses = $("#licensechange-input-section").data("licenses");
+ const new_licenses = $("#new_licenses_input").val();
+ if (new_licenses > current_licenses) {
+ $("#new_license_count_holder").text(new_licenses);
+ $("#current_license_count_holder").text(current_licenses);
+ $("#confirm-licenses-modal").modal("show");
+ } else {
+ create_update_license_request();
+ }
+ });
+
+ $("#confirm-license-update-button").on("click", () => {
+ create_update_license_request();
+ });
+
+ $("#update-licenses-at-next-renewal-button").on("click", (e) => {
+ e.preventDefault();
+ helpers.create_ajax_request(
+ "/json/billing/plan",
+ "licensechange",
+ undefined,
+ ["licenses"],
+ undefined,
+ "PATCH",
+ );
+ });
+
$("#change-plan-status").on("click", (e) => {
helpers.create_ajax_request(
"/json/billing/plan",
diff --git a/static/styles/portico/billing.css b/static/styles/portico/billing.css
index 58ca244888a..ba1949a4af4 100644
--- a/static/styles/portico/billing.css
+++ b/static/styles/portico/billing.css
@@ -182,6 +182,7 @@
#sponsorship-loading,
#planchange-loading,
+ #licensechange-loading,
#cardchange-loading,
#invoice-loading,
#autopay-loading {
@@ -192,6 +193,7 @@
#sponsorship-success,
#planchange-success,
+ #licensechange-success,
#cardchange-success,
#invoice-success,
#autopay-success {
@@ -201,6 +203,7 @@
#sponsorship-error,
#planchange-error,
+ #licensechange-error,
#cardchange-error,
#invoice-error,
#autopay-error {
@@ -231,6 +234,7 @@
#sponsorship_loading_indicator,
#planchange_loading_indicator,
+ #licensechange_loading_indicator,
#cardchange_loading_indicator,
#invoice_loading_indicator,
#autopay_loading_indicator {
@@ -239,6 +243,7 @@
#sponsorship_loading_indicator_box_container,
#planchange_loading_indicator_box_container,
+ #licensechange_loading_indicator_box_container,
#cardchange_loading_indicator_box_container,
#invoice_loading_indicator_box_container,
#autopay_loading_indicator_box_container {
@@ -248,18 +253,20 @@
#sponsorship_loading_indicator_box,
#planchange_loading_indicator_box,
+ #licensechange_loading_indicator_box,
#cardchange_loading_indicator_box,
#invoice_loading_indicator_box,
#autopay_loading_indicator_box {
position: relative;
left: -50%;
top: -41px;
- z-index: 1;
+ z-index: 10;
border-radius: 6px;
}
#sponsorship_loading_indicator .loading_indicator_text,
#planchange_loading_indicator .loading_indicator_text,
+ #licensechange_loading_indicator .loading_indicator_text,
#cardchange_loading_indicator .loading_indicator_text,
#invoice_loading_indicator .loading_indicator_text,
#autopay_loading_indicator .loading_indicator_text {
diff --git a/templates/corporate/billing.html b/templates/corporate/billing.html
index 5ffb3d63ce9..92b8e940215 100644
--- a/templates/corporate/billing.html
+++ b/templates/corporate/billing.html
@@ -87,7 +87,45 @@
Card updated. The page will now reload.
</div>
</div>
+
<div class="tab-pane" id="settings">
+ {% if not automanage_licenses and not downgrade_at_end_of_cycle %}
+ <div id="licensechange-error" class="alert alert-danger"></div>
+ <div id="licensechange-input-section" data-licenses="{{ licenses }}">
+ <form id="licensechange-form">
+ <h3>Licenses</h3>
+ <h4>Number of licenses in the current billing period</h4>
+ <p>
+ You can only increase the number of licenses.
+ </p>
+ <input min="{{ licenses }}" type="number" name="licenses" value="{{ licenses }}" autocomplete="off" id="new_licenses_input" required/>
+ <br />
+ <button class="btn-info" id="update-licenses-button">Update</button>
+ <br />
+ <br />
+ <h4>Licenses in next renewal</h4>
+ <p>
+ You can increase or decrease the number of licenses.
+ </p>
+ <input type="number" name="licenses_at_next_renewal" value="{{ licenses_at_next_renewal }}" autocomplete="off" id="licenses_at_next_renewal_input"/>
+ <br />
+ <button class="btn-info" id="update-licenses-at-next-renewal-button">Update</button>
+ </form>
+ </div>
+ <div id="licensechange-loading">
+ <div class="zulip-loading-logo">
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 773.12 773.12">
+ <circle cx="386.56" cy="386.56" r="386.56"/>
+ <path d="M566.66 527.25c0 33.03-24.23 60.05-53.84 60.05H260.29c-29.61 0-53.84-27.02-53.84-60.05 0-20.22 9.09-38.2 22.93-49.09l134.37-120c2.5-2.14 5.74 1.31 3.94 4.19l-49.29 98.69c-1.38 2.76.41 6.16 3.25 6.16h191.18c29.61 0 53.83 27.03 53.83 60.05zm0-281.39c0 20.22-9.09 38.2-22.93 49.09l-134.37 120c-2.5 2.14-5.74-1.31-3.94-4.19l49.29-98.69c1.38-2.76-.41-6.16-3.25-6.16H260.29c-29.61 0-53.84-27.02-53.84-60.05s24.23-60.05 53.84-60.05h252.54c29.61 0 53.83 27.02 53.83 60.05z"/>
+ </svg>
+ </div>
+ <div id="licensechange_loading_indicator"></div>
+ </div>
+ <div id="licensechange-success" class="alert alert-success">
+ Plan updated. The page will now reload.
+ </div>
+ {% endif %}
+
<div id="planchange-error" class="alert alert-danger"></div>
<div id="planchange-input-section">
<form id="planchange-form">
@@ -127,10 +165,11 @@
<div id="planchange-success" class="alert alert-success">
Plan updated. The page will now reload.
</div>
- </div>
- <div class="tab-pane" id="loading">
+ <div class="tab-pane" id="loading">
+ </div>
</div>
</div>
+
<div id="goto-zulip-organization-link">
{% if onboarding %}
<br />
@@ -184,4 +223,28 @@
</div>
</div>
</div>
+
+
+<div id="confirm-licenses-modal" class="modal modal-bg hide fade" tabindex="-1" role="dialog" aria-labelledby="deactivation_self_modal_label" aria-hidden="true">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal" aria-label="{{ _('Close') }}"><span aria-hidden="true">&times;</span></button>
+ <h3 id="deactivation_self_modal_label">Confirm license increase</h3>
+ </div>
+ <div class="modal-body">
+ <p>
+ Are you sure you want to increase the licenses from
+ <b><span id="current_license_count_holder"></span></b> to
+ <b><span id="new_license_count_holder"></span></b>?
+ </p>
+ <p>
+ You would be charged for the additional licenses.
+ </p>
+ </div>
+ <div class="modal-footer">
+ <button class="button" data-dismiss="modal">Cancel</button>
+ <button class="button btn-success rounded" id="confirm-license-update-button" data-dismiss="modal" aria-hidden="true">
+ <span id="confirm-license-update">Confirm</span>
+ </button>
+ </div>
+</div>
{% endblock %}