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.

support: Add updating minimum licenses requirement after discount.

Lauryn Menardfb29a3526215
diff --git a/analytics/views/support.py b/analytics/views/support.py
index 315774bb8bb..4cf9fcb1015 100644
--- a/analytics/views/support.py
+++ b/analytics/views/support.py
@@ -409,6 +409,7 @@ def remote_servers_support(
remote_server_id: Optional[int] = REQ(default=None, converter=to_non_negative_int),
remote_realm_id: Optional[int] = REQ(default=None, converter=to_non_negative_int),
discount: Optional[Decimal] = REQ(default=None, converter=to_decimal),
+ minimum_licenses: Optional[int] = REQ(default=None, converter=to_non_negative_int),
sponsorship_pending: Optional[bool] = REQ(default=None, json_validator=check_bool),
approve_sponsorship: bool = REQ(default=False, json_validator=check_bool),
billing_modality: Optional[str] = REQ(
@@ -458,6 +459,11 @@ def remote_servers_support(
support_type=SupportType.attach_discount,
discount=discount,
)
+ elif minimum_licenses is not None:
+ support_view_request = SupportViewRequest(
+ support_type=SupportType.update_minimum_licenses,
+ minimum_licenses=minimum_licenses,
+ )
elif billing_modality is not None:
support_view_request = SupportViewRequest(
support_type=SupportType.update_billing_modality,
diff --git a/corporate/lib/stripe.py b/corporate/lib/stripe.py
index 35007a24cd3..fa2581a15f7 100644
--- a/corporate/lib/stripe.py
+++ b/corporate/lib/stripe.py
@@ -553,6 +553,7 @@ class SupportType(Enum):
attach_discount = 3
update_billing_modality = 4
modify_plan = 5
+ update_minimum_licenses = 6
class SupportViewRequest(TypedDict, total=False):
@@ -562,6 +563,7 @@ class SupportViewRequest(TypedDict, total=False):
billing_modality: Optional[str]
plan_modification: Optional[str]
new_plan_tier: Optional[int]
+ minimum_licenses: Optional[int]
class AuditLogEventType(Enum):
@@ -575,6 +577,7 @@ class AuditLogEventType(Enum):
CUSTOMER_SWITCHED_FROM_MONTHLY_TO_ANNUAL_PLAN = 8
CUSTOMER_SWITCHED_FROM_ANNUAL_TO_MONTHLY_PLAN = 9
BILLING_ENTITY_PLAN_TYPE_CHANGED = 10
+ MINIMUM_LICENSES_CHANGED = 11
class PlanTierChangeType(Enum):
@@ -1085,6 +1088,46 @@ class BillingSession(ABC):
)
return f"Discount for {self.billing_entity_display_name} changed to {new_discount_string}% from {old_discount_string}%."
+ def update_customer_minimum_licenses(self, new_minimum_license_count: int) -> str:
+ previous_minimum_license_count = None
+ customer = self.get_customer()
+
+ # Currently, the support admin view shows the form for adding
+ # a minimum license count after a default discount has been set.
+ assert customer is not None
+ if customer.default_discount is None or int(customer.default_discount) == 0:
+ raise SupportRequestError(
+ f"Discount for {self.billing_entity_display_name} must be updated before setting a minimum number of licenses."
+ )
+
+ plan = get_current_plan_by_customer(customer)
+ if plan is not None and plan.tier != CustomerPlan.TIER_SELF_HOSTED_LEGACY:
+ raise SupportRequestError(
+ f"Cannot set minimum licenses; active plan already exists for {self.billing_entity_display_name}."
+ )
+
+ next_plan = self.get_legacy_remote_server_next_plan(customer)
+ if next_plan is not None: # nocoverage
+ raise SupportRequestError(
+ f"Cannot set minimum licenses; upgrade to new plan already scheduled for {self.billing_entity_display_name}."
+ )
+
+ previous_minimum_license_count = customer.minimum_licenses
+ customer.minimum_licenses = new_minimum_license_count
+ customer.save(update_fields=["minimum_licenses"])
+
+ self.write_to_audit_log(
+ event_type=AuditLogEventType.MINIMUM_LICENSES_CHANGED,
+ event_time=timezone_now(),
+ extra_data={
+ "old_minimum_licenses": previous_minimum_license_count,
+ "new_minimum_licenses": new_minimum_license_count,
+ },
+ )
+ if previous_minimum_license_count is None:
+ previous_minimum_license_count = 0
+ return f"Minimum licenses for {self.billing_entity_display_name} changed to {new_minimum_license_count} from {previous_minimum_license_count}."
+
def update_customer_sponsorship_status(self, sponsorship_pending: bool) -> str:
customer = self.get_customer()
if customer is None:
@@ -2027,6 +2070,11 @@ class BillingSession(ABC):
return None, context
def min_licenses_for_plan(self, tier: int) -> int:
+ customer = self.get_customer()
+ if customer is not None and customer.minimum_licenses:
+ assert customer.default_discount is not None
+ return customer.minimum_licenses
+
if tier == CustomerPlan.TIER_SELF_HOSTED_BASIC:
return 10
if tier == CustomerPlan.TIER_SELF_HOSTED_BUSINESS:
@@ -2587,6 +2635,10 @@ class BillingSession(ABC):
assert support_request["discount"] is not None
new_discount = support_request["discount"]
success_message = self.attach_discount_to_customer(new_discount)
+ elif support_type == SupportType.update_minimum_licenses:
+ assert support_request["minimum_licenses"] is not None
+ new_minimum_license_count = support_request["minimum_licenses"]
+ success_message = self.update_customer_minimum_licenses(new_minimum_license_count)
elif support_type == SupportType.update_billing_modality:
assert support_request["billing_modality"] is not None
assert support_request["billing_modality"] in VALID_BILLING_MODALITY_VALUES
@@ -2909,6 +2961,8 @@ class RealmBillingSession(BillingSession):
return RealmAuditLog.CUSTOMER_PLAN_CREATED
elif event_type is AuditLogEventType.DISCOUNT_CHANGED:
return RealmAuditLog.REALM_DISCOUNT_CHANGED
+ elif event_type is AuditLogEventType.MINIMUM_LICENSES_CHANGED:
+ return RealmAuditLog.CUSTOMER_MINIMUM_LICENSES_CHANGED
elif event_type is AuditLogEventType.SPONSORSHIP_APPROVED:
return RealmAuditLog.REALM_SPONSORSHIP_APPROVED
elif event_type is AuditLogEventType.SPONSORSHIP_PENDING_STATUS_CHANGED:
@@ -3265,6 +3319,8 @@ class RemoteRealmBillingSession(BillingSession):
return RemoteRealmAuditLog.CUSTOMER_PLAN_CREATED
elif event_type is AuditLogEventType.DISCOUNT_CHANGED: # nocoverage
return RemoteRealmAuditLog.REMOTE_SERVER_DISCOUNT_CHANGED
+ elif event_type is AuditLogEventType.MINIMUM_LICENSES_CHANGED:
+ return RemoteRealmAuditLog.CUSTOMER_MINIMUM_LICENSES_CHANGED # nocoverage
elif event_type is AuditLogEventType.SPONSORSHIP_APPROVED:
return RemoteRealmAuditLog.REMOTE_SERVER_SPONSORSHIP_APPROVED
elif event_type is AuditLogEventType.SPONSORSHIP_PENDING_STATUS_CHANGED:
@@ -3675,6 +3731,8 @@ class RemoteServerBillingSession(BillingSession):
return RemoteZulipServerAuditLog.CUSTOMER_PLAN_CREATED
elif event_type is AuditLogEventType.DISCOUNT_CHANGED:
return RemoteZulipServerAuditLog.REMOTE_SERVER_DISCOUNT_CHANGED # nocoverage
+ elif event_type is AuditLogEventType.MINIMUM_LICENSES_CHANGED:
+ return RemoteZulipServerAuditLog.CUSTOMER_MINIMUM_LICENSES_CHANGED # nocoverage
elif event_type is AuditLogEventType.SPONSORSHIP_APPROVED:
return RemoteZulipServerAuditLog.REMOTE_SERVER_SPONSORSHIP_APPROVED
elif event_type is AuditLogEventType.SPONSORSHIP_PENDING_STATUS_CHANGED:
diff --git a/corporate/lib/support.py b/corporate/lib/support.py
index f70e7a8fecb..8565060e85e 100644
--- a/corporate/lib/support.py
+++ b/corporate/lib/support.py
@@ -44,6 +44,7 @@ class SponsorshipRequestDict(TypedDict):
class SponsorshipData:
sponsorship_pending: bool = False
default_discount: Optional[Decimal] = None
+ minimum_licenses: Optional[int] = None
latest_sponsorship_request: Optional[SponsorshipRequestDict] = None
@@ -89,6 +90,7 @@ def get_customer_discount_for_support_view(
def get_customer_sponsorship_data(customer: Customer) -> SponsorshipData:
pending = customer.sponsorship_pending
discount = customer.default_discount
+ licenses = customer.minimum_licenses
sponsorship_request = None
if pending:
last_sponsorship_request = (
@@ -116,6 +118,7 @@ def get_customer_sponsorship_data(customer: Customer) -> SponsorshipData:
return SponsorshipData(
sponsorship_pending=pending,
default_discount=discount,
+ minimum_licenses=licenses,
latest_sponsorship_request=sponsorship_request,
)
diff --git a/corporate/tests/stripe_fixtures/add_minimum_licenses--Charge.list.1.json b/corporate/tests/stripe_fixtures/add_minimum_licenses--Charge.list.1.json
new file mode 100644
index 00000000000..63cd55f6602
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/add_minimum_licenses--Charge.list.1.json
@@ -0,0 +1,133 @@
+{
+ "data": [
+ {
+ "amount": 100000,
+ "amount_captured": 100000,
+ "amount_refunded": 0,
+ "application": null,
+ "application_fee": null,
+ "application_fee_amount": null,
+ "balance_transaction": "txn_3OUBQpDEQaroqDjs1fV9FiTT",
+ "billing_details": {
+ "address": {
+ "city": null,
+ "country": null,
+ "line1": null,
+ "line2": null,
+ "postal_code": null,
+ "state": null
+ },
+ "email": null,
+ "name": null,
+ "phone": null
+ },
+ "calculated_statement_descriptor": "ZULIP CLOUD STANDARD",
+ "captured": true,
+ "created": 1704215231,
+ "currency": "usd",
+ "customer": "cus_PIn0tctXcJ76rV",
+ "description": "Upgrade to Zulip Cloud Standard, $40.0 x 25",
+ "destination": null,
+ "dispute": null,
+ "disputed": false,
+ "failure_balance_transaction": null,
+ "failure_code": null,
+ "failure_message": null,
+ "fraud_details": {},
+ "id": "ch_3OUBQpDEQaroqDjs1quOretD",
+ "invoice": null,
+ "livemode": false,
+ "metadata": {
+ "billing_modality": "charge_automatically",
+ "billing_schedule": "1",
+ "license_management": "automatic",
+ "licenses": "25",
+ "plan_tier": "1",
+ "price_per_license": "4000",
+ "realm_id": "2",
+ "realm_str": "zulip",
+ "seat_count": "25",
+ "type": "upgrade",
+ "user_email": "[email protected]",
+ "user_id": "10"
+ },
+ "object": "charge",
+ "on_behalf_of": null,
+ "order": null,
+ "outcome": {
+ "network_status": "approved_by_network",
+ "reason": null,
+ "risk_level": "normal",
+ "risk_score": 3,
+ "seller_message": "Payment complete.",
+ "type": "authorized"
+ },
+ "paid": true,
+ "payment_intent": "pi_3OUBQpDEQaroqDjs11DBy9EQ",
+ "payment_method": "pm_1OUBQlDEQaroqDjsLPwelbF3",
+ "payment_method_details": {
+ "card": {
+ "amount_authorized": 100000,
+ "brand": "visa",
+ "checks": {
+ "address_line1_check": null,
+ "address_postal_code_check": null,
+ "cvc_check": "pass"
+ },
+ "country": "US",
+ "exp_month": 1,
+ "exp_year": 2025,
+ "extended_authorization": {
+ "status": "disabled"
+ },
+ "fingerprint": "9XKsMixKBi6kIIzd",
+ "funding": "credit",
+ "incremental_authorization": {
+ "status": "unavailable"
+ },
+ "installments": null,
+ "last4": "4242",
+ "mandate": null,
+ "multicapture": {
+ "status": "unavailable"
+ },
+ "network": "visa",
+ "network_token": {
+ "used": false
+ },
+ "overcapture": {
+ "maximum_amount_capturable": 100000,
+ "status": "unavailable"
+ },
+ "three_d_secure": null,
+ "wallet": null
+ },
+ "type": "card"
+ },
+ "radar_options": {},
+ "receipt_email": "[email protected]",
+ "receipt_number": null,
+ "receipt_url": "https://pay.stripe.com/receipts/payment/CAcaFwoVYWNjdF8xN3ZUa3dERVFhcm9xRGpzKMSF0awGMgYpcxTVVK86LBaV6oa0oqG2PP0haQs1-XXNH4wtrEtcuqKOwvnQTmFFJWB35PU2v6EYpNf5",
+ "refunded": false,
+ "refunds": {
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "total_count": 0,
+ "url": "/v1/charges/ch_3OUBQpDEQaroqDjs1quOretD/refunds"
+ },
+ "review": null,
+ "shipping": null,
+ "source": null,
+ "source_transfer": null,
+ "statement_descriptor": "Zulip Cloud Standard",
+ "statement_descriptor_suffix": null,
+ "status": "succeeded",
+ "transfer_data": null,
+ "transfer_group": null
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "url": "/v1/charges"
+}
diff --git a/corporate/tests/stripe_fixtures/add_minimum_licenses--Customer.create.1.json b/corporate/tests/stripe_fixtures/add_minimum_licenses--Customer.create.1.json
new file mode 100644
index 00000000000..ccf28119092
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/add_minimum_licenses--Customer.create.1.json
@@ -0,0 +1,33 @@
+{
+ "address": null,
+ "balance": 0,
+ "created": 1704215224,
+ "currency": null,
+ "default_currency": null,
+ "default_source": null,
+ "delinquent": false,
+ "description": "zulip (Zulip Dev)",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_PIn0tctXcJ76rV",
+ "invoice_prefix": "9025AB67",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": null,
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "realm_id": "2",
+ "realm_str": "zulip"
+ },
+ "name": null,
+ "next_invoice_sequence": 1,
+ "object": "customer",
+ "phone": null,
+ "preferred_locales": [],
+ "shipping": null,
+ "tax_exempt": "none",
+ "test_clock": null
+}
diff --git a/corporate/tests/stripe_fixtures/add_minimum_licenses--Customer.modify.1.json b/corporate/tests/stripe_fixtures/add_minimum_licenses--Customer.modify.1.json
new file mode 100644
index 00000000000..b661a4447a7
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/add_minimum_licenses--Customer.modify.1.json
@@ -0,0 +1,33 @@
+{
+ "address": null,
+ "balance": 0,
+ "created": 1704215224,
+ "currency": null,
+ "default_currency": null,
+ "default_source": null,
+ "delinquent": false,
+ "description": "zulip (Zulip Dev)",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_PIn0tctXcJ76rV",
+ "invoice_prefix": "9025AB67",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": "pm_1OUBQlDEQaroqDjsLPwelbF3",
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "realm_id": "2",
+ "realm_str": "zulip"
+ },
+ "name": null,
+ "next_invoice_sequence": 1,
+ "object": "customer",
+ "phone": null,
+ "preferred_locales": [],
+ "shipping": null,
+ "tax_exempt": "none",
+ "test_clock": null
+}
diff --git a/corporate/tests/stripe_fixtures/add_minimum_licenses--Customer.retrieve.1.json b/corporate/tests/stripe_fixtures/add_minimum_licenses--Customer.retrieve.1.json
new file mode 100644
index 00000000000..7d983c32895
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/add_minimum_licenses--Customer.retrieve.1.json
@@ -0,0 +1,79 @@
+{
+ "address": null,
+ "balance": 0,
+ "created": 1704215224,
+ "currency": null,
+ "default_currency": null,
+ "default_source": null,
+ "delinquent": false,
+ "description": "zulip (Zulip Dev)",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_PIn0tctXcJ76rV",
+ "invoice_prefix": "9025AB67",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": {
+ "billing_details": {
+ "address": {
+ "city": null,
+ "country": null,
+ "line1": null,
+ "line2": null,
+ "postal_code": null,
+ "state": null
+ },
+ "email": null,
+ "name": null,
+ "phone": null
+ },
+ "card": {
+ "brand": "visa",
+ "checks": {
+ "address_line1_check": null,
+ "address_postal_code_check": null,
+ "cvc_check": "pass"
+ },
+ "country": "US",
+ "exp_month": 1,
+ "exp_year": 2025,
+ "fingerprint": "9XKsMixKBi6kIIzd",
+ "funding": "credit",
+ "generated_from": null,
+ "last4": "4242",
+ "networks": {
+ "available": [
+ "visa"
+ ],
+ "preferred": null
+ },
+ "three_d_secure_usage": {
+ "supported": true
+ },
+ "wallet": null
+ },
+ "created": 1704215227,
+ "customer": "cus_PIn0tctXcJ76rV",
+ "id": "pm_1OUBQlDEQaroqDjsLPwelbF3",
+ "livemode": false,
+ "metadata": {},
+ "object": "payment_method",
+ "type": "card"
+ },
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "realm_id": "2",
+ "realm_str": "zulip"
+ },
+ "name": null,
+ "next_invoice_sequence": 1,
+ "object": "customer",
+ "phone": null,
+ "preferred_locales": [],
+ "shipping": null,
+ "tax_exempt": "none",
+ "test_clock": null
+}
diff --git a/corporate/tests/stripe_fixtures/add_minimum_licenses--Customer.retrieve.2.json b/corporate/tests/stripe_fixtures/add_minimum_licenses--Customer.retrieve.2.json
new file mode 100644
index 00000000000..7d983c32895
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/add_minimum_licenses--Customer.retrieve.2.json
@@ -0,0 +1,79 @@
+{
+ "address": null,
+ "balance": 0,
+ "created": 1704215224,
+ "currency": null,
+ "default_currency": null,
+ "default_source": null,
+ "delinquent": false,
+ "description": "zulip (Zulip Dev)",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_PIn0tctXcJ76rV",
+ "invoice_prefix": "9025AB67",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": {
+ "billing_details": {
+ "address": {
+ "city": null,
+ "country": null,
+ "line1": null,
+ "line2": null,
+ "postal_code": null,
+ "state": null
+ },
+ "email": null,
+ "name": null,
+ "phone": null
+ },
+ "card": {
+ "brand": "visa",
+ "checks": {
+ "address_line1_check": null,
+ "address_postal_code_check": null,
+ "cvc_check": "pass"
+ },
+ "country": "US",
+ "exp_month": 1,
+ "exp_year": 2025,
+ "fingerprint": "9XKsMixKBi6kIIzd",
+ "funding": "credit",
+ "generated_from": null,
+ "last4": "4242",
+ "networks": {
+ "available": [
+ "visa"
+ ],
+ "preferred": null
+ },
+ "three_d_secure_usage": {
+ "supported": true
+ },
+ "wallet": null
+ },
+ "created": 1704215227,
+ "customer": "cus_PIn0tctXcJ76rV",
+ "id": "pm_1OUBQlDEQaroqDjsLPwelbF3",
+ "livemode": false,
+ "metadata": {},
+ "object": "payment_method",
+ "type": "card"
+ },
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "realm_id": "2",
+ "realm_str": "zulip"
+ },
+ "name": null,
+ "next_invoice_sequence": 1,
+ "object": "customer",
+ "phone": null,
+ "preferred_locales": [],
+ "shipping": null,
+ "tax_exempt": "none",
+ "test_clock": null
+}
diff --git a/corporate/tests/stripe_fixtures/add_minimum_licenses--Customer.retrieve.3.json b/corporate/tests/stripe_fixtures/add_minimum_licenses--Customer.retrieve.3.json
new file mode 100644
index 00000000000..7d983c32895
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/add_minimum_licenses--Customer.retrieve.3.json
@@ -0,0 +1,79 @@
+{
+ "address": null,
+ "balance": 0,
+ "created": 1704215224,
+ "currency": null,
+ "default_currency": null,
+ "default_source": null,
+ "delinquent": false,
+ "description": "zulip (Zulip Dev)",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_PIn0tctXcJ76rV",
+ "invoice_prefix": "9025AB67",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": {
+ "billing_details": {
+ "address": {
+ "city": null,
+ "country": null,
+ "line1": null,
+ "line2": null,
+ "postal_code": null,
+ "state": null
+ },
+ "email": null,
+ "name": null,
+ "phone": null
+ },
+ "card": {
+ "brand": "visa",
+ "checks": {
+ "address_line1_check": null,
+ "address_postal_code_check": null,
+ "cvc_check": "pass"
+ },
+ "country": "US",
+ "exp_month": 1,
+ "exp_year": 2025,
+ "fingerprint": "9XKsMixKBi6kIIzd",
+ "funding": "credit",
+ "generated_from": null,
+ "last4": "4242",
+ "networks": {
+ "available": [
+ "visa"
+ ],
+ "preferred": null
+ },
+ "three_d_secure_usage": {
+ "supported": true
+ },
+ "wallet": null
+ },
+ "created": 1704215227,
+ "customer": "cus_PIn0tctXcJ76rV",
+ "id": "pm_1OUBQlDEQaroqDjsLPwelbF3",
+ "livemode": false,
+ "metadata": {},
+ "object": "payment_method",
+ "type": "card"
+ },
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "realm_id": "2",
+ "realm_str": "zulip"
+ },
+ "name": null,
+ "next_invoice_sequence": 1,
+ "object": "customer",
+ "phone": null,
+ "preferred_locales": [],
+ "shipping": null,
+ "tax_exempt": "none",
+ "test_clock": null
+}
diff --git a/corporate/tests/stripe_fixtures/add_minimum_licenses--Customer.retrieve.4.json b/corporate/tests/stripe_fixtures/add_minimum_licenses--Customer.retrieve.4.json
new file mode 100644
index 00000000000..7d983c32895
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/add_minimum_licenses--Customer.retrieve.4.json
@@ -0,0 +1,79 @@
+{
+ "address": null,
+ "balance": 0,
+ "created": 1704215224,
+ "currency": null,
+ "default_currency": null,
+ "default_source": null,
+ "delinquent": false,
+ "description": "zulip (Zulip Dev)",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_PIn0tctXcJ76rV",
+ "invoice_prefix": "9025AB67",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": {
+ "billing_details": {
+ "address": {
+ "city": null,
+ "country": null,
+ "line1": null,
+ "line2": null,
+ "postal_code": null,
+ "state": null
+ },
+ "email": null,
+ "name": null,
+ "phone": null
+ },
+ "card": {
+ "brand": "visa",
+ "checks": {
+ "address_line1_check": null,
+ "address_postal_code_check": null,
+ "cvc_check": "pass"
+ },
+ "country": "US",
+ "exp_month": 1,
+ "exp_year": 2025,
+ "fingerprint": "9XKsMixKBi6kIIzd",
+ "funding": "credit",
+ "generated_from": null,
+ "last4": "4242",
+ "networks": {
+ "available": [
+ "visa"
+ ],
+ "preferred": null
+ },
+ "three_d_secure_usage": {
+ "supported": true
+ },
+ "wallet": null
+ },
+ "created": 1704215227,
+ "customer": "cus_PIn0tctXcJ76rV",
+ "id": "pm_1OUBQlDEQaroqDjsLPwelbF3",
+ "livemode": false,
+ "metadata": {},
+ "object": "payment_method",
+ "type": "card"
+ },
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "realm_id": "2",
+ "realm_str": "zulip"
+ },
+ "name": null,
+ "next_invoice_sequence": 1,
+ "object": "customer",
+ "phone": null,
+ "preferred_locales": [],
+ "shipping": null,
+ "tax_exempt": "none",
+ "test_clock": null
+}
diff --git a/corporate/tests/stripe_fixtures/add_minimum_licenses--Event.list.1.json b/corporate/tests/stripe_fixtures/add_minimum_licenses--Event.list.1.json
new file mode 100644
index 00000000000..f98e20b061a
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/add_minimum_licenses--Event.list.1.json
@@ -0,0 +1,60 @@
+{
+ "data": [
+ {
+ "api_version": "2020-08-27",
+ "created": 1704215228,
+ "data": {
+ "object": {
+ "address": null,
+ "balance": 0,
+ "created": 1704215224,
+ "currency": null,
+ "default_currency": null,
+ "default_source": null,
+ "delinquent": false,
+ "description": "zulip (Zulip Dev)",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_PIn0tctXcJ76rV",
+ "invoice_prefix": "9025AB67",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": "pm_1OUBQlDEQaroqDjsLPwelbF3",
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "realm_id": "2",
+ "realm_str": "zulip"
+ },
+ "name": null,
+ "next_invoice_sequence": 1,
+ "object": "customer",
+ "phone": null,
+ "preferred_locales": [],
+ "shipping": null,
+ "tax_exempt": "none",
+ "test_clock": null
+ },
+ "previous_attributes": {
+ "invoice_settings": {
+ "default_payment_method": null
+ }
+ }
+ },
+ "id": "evt_1OUBQmDEQaroqDjsbs9Oq5oL",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 0,
+ "request": {
+ "id": "req_kmJHRYZJHcCj0d",
+ "idempotency_key": "30f75b55-1178-4283-a8f1-21a847460765"
+ },
+ "type": "customer.updated"
+ }
+ ],
+ "has_more": true,
+ "object": "list",
+ "url": "/v1/events"
+}
diff --git a/corporate/tests/stripe_fixtures/add_minimum_licenses--Event.list.2.json b/corporate/tests/stripe_fixtures/add_minimum_licenses--Event.list.2.json
new file mode 100644
index 00000000000..77fc9864992
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/add_minimum_licenses--Event.list.2.json
@@ -0,0 +1,363 @@
+{
+ "data": [
+ {
+ "api_version": "2020-08-27",
+ "created": 1704215232,
+ "data": {
+ "object": {
+ "amount": 100000,
+ "amount_capturable": 0,
+ "amount_details": {
+ "tip": {}
+ },
+ "amount_received": 100000,
+ "application": null,
+ "application_fee_amount": null,
+ "automatic_payment_methods": null,
+ "canceled_at": null,
+ "cancellation_reason": null,
+ "capture_method": "automatic",
+ "charges": {
+ "data": [
+ {
+ "amount": 100000,
+ "amount_captured": 100000,
+ "amount_refunded": 0,
+ "application": null,
+ "application_fee": null,
+ "application_fee_amount": null,
+ "balance_transaction": "txn_3OUBQpDEQaroqDjs1fV9FiTT",
+ "billing_details": {
+ "address": {
+ "city": null,
+ "country": null,
+ "line1": null,
+ "line2": null,
+ "postal_code": null,
+ "state": null
+ },
+ "email": null,
+ "name": null,
+ "phone": null
+ },
+ "calculated_statement_descriptor": "ZULIP CLOUD STANDARD",
+ "captured": true,
+ "created": 1704215231,
+ "currency": "usd",
+ "customer": "cus_PIn0tctXcJ76rV",
+ "description": "Upgrade to Zulip Cloud Standard, $40.0 x 25",
+ "destination": null,
+ "dispute": null,
+ "disputed": false,
+ "failure_balance_transaction": null,
+ "failure_code": null,
+ "failure_message": null,
+ "fraud_details": {},
+ "id": "ch_3OUBQpDEQaroqDjs1quOretD",
+ "invoice": null,
+ "livemode": false,
+ "metadata": {
+ "billing_modality": "charge_automatically",
+ "billing_schedule": "1",
+ "license_management": "automatic",
+ "licenses": "25",
+ "plan_tier": "1",
+ "price_per_license": "4000",
+ "realm_id": "2",
+ "realm_str": "zulip",
+ "seat_count": "25",
+ "type": "upgrade",
+ "user_email": "[email protected]",
+ "user_id": "10"
+ },
+ "object": "charge",
+ "on_behalf_of": null,
+ "order": null,
+ "outcome": {
+ "network_status": "approved_by_network",
+ "reason": null,
+ "risk_level": "normal",
+ "risk_score": 3,
+ "seller_message": "Payment complete.",
+ "type": "authorized"
+ },
+ "paid": true,
+ "payment_intent": "pi_3OUBQpDEQaroqDjs11DBy9EQ",
+ "payment_method": "pm_1OUBQlDEQaroqDjsLPwelbF3",
+ "payment_method_details": {
+ "card": {
+ "amount_authorized": 100000,
+ "brand": "visa",
+ "checks": {
+ "address_line1_check": null,
+ "address_postal_code_check": null,
+ "cvc_check": "pass"
+ },
+ "country": "US",
+ "exp_month": 1,
+ "exp_year": 2025,
+ "extended_authorization": {
+ "status": "disabled"
+ },
+ "fingerprint": "9XKsMixKBi6kIIzd",
+ "funding": "credit",
+ "incremental_authorization": {
+ "status": "unavailable"
+ },
+ "installments": null,
+ "last4": "4242",
+ "mandate": null,
+ "multicapture": {
+ "status": "unavailable"
+ },
+ "network": "visa",
+ "network_token": {
+ "used": false
+ },
+ "overcapture": {
+ "maximum_amount_capturable": 100000,
+ "status": "unavailable"
+ },
+ "three_d_secure": null,
+ "wallet": null
+ },
+ "type": "card"
+ },
+ "radar_options": {},
+ "receipt_email": "[email protected]",
+ "receipt_number": null,
+ "receipt_url": "https://pay.stripe.com/receipts/payment/CAcaFwoVYWNjdF8xN3ZUa3dERVFhcm9xRGpzKMCF0awGMgbyULU2xvc6LBaaurTLlj-icoz0dAXvOjbkpDzSyD0DTkXyp59jCTny0gGQbrSoV96pwq9d",
+ "refunded": false,
+ "refunds": {
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "total_count": 0,
+ "url": "/v1/charges/ch_3OUBQpDEQaroqDjs1quOretD/refunds"
+ },
+ "review": null,
+ "shipping": null,
+ "source": null,
+ "source_transfer": null,
+ "statement_descriptor": "Zulip Cloud Standard",
+ "statement_descriptor_suffix": null,
+ "status": "succeeded",
+ "transfer_data": null,
+ "transfer_group": null
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/charges?payment_intent=pi_3OUBQpDEQaroqDjs11DBy9EQ"
+ },
+ "client_secret": "pi_3OUBQpDEQaroqDjs11DBy9EQ_secret_wT6ZX3cY2YshDpg73a3GHvIoF",
+ "confirmation_method": "automatic",
+ "created": 1704215231,
+ "currency": "usd",
+ "customer": "cus_PIn0tctXcJ76rV",
+ "description": "Upgrade to Zulip Cloud Standard, $40.0 x 25",
+ "id": "pi_3OUBQpDEQaroqDjs11DBy9EQ",
+ "invoice": null,
+ "last_payment_error": null,
+ "latest_charge": "ch_3OUBQpDEQaroqDjs1quOretD",
+ "livemode": false,
+ "metadata": {
+ "billing_modality": "charge_automatically",
+ "billing_schedule": "1",
+ "license_management": "automatic",
+ "licenses": "25",
+ "plan_tier": "1",
+ "price_per_license": "4000",
+ "realm_id": "2",
+ "realm_str": "zulip",
+ "seat_count": "25",
+ "type": "upgrade",
+ "user_email": "[email protected]",
+ "user_id": "10"
+ },
+ "next_action": null,
+ "object": "payment_intent",
+ "on_behalf_of": null,
+ "payment_method": "pm_1OUBQlDEQaroqDjsLPwelbF3",
+ "payment_method_configuration_details": null,
+ "payment_method_options": {
+ "card": {
+ "installments": null,
+ "mandate_options": null,
+ "network": null,
+ "request_three_d_secure": "automatic"
+ }
+ },
+ "payment_method_types": [
+ "card"
+ ],
+ "processing": null,
+ "receipt_email": "[email protected]",
+ "review": null,
+ "setup_future_usage": null,
+ "shipping": null,
+ "source": null,
+ "statement_descriptor": "Zulip Cloud Standard",
+ "statement_descriptor_suffix": null,
+ "status": "succeeded",
+ "transfer_data": null,
+ "transfer_group": null
+ }
+ },
+ "id": "evt_3OUBQpDEQaroqDjs1YNI09sB",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 2,
+ "request": {
+ "id": "req_aEjWKLveCDrPag",
+ "idempotency_key": "f6c86d42-6be6-4ec7-b252-3db27f51164f"
+ },
+ "type": "payment_intent.succeeded"
+ },
+ {
+ "api_version": "2020-08-27",
+ "created": 1704215232,
+ "data": {
+ "object": {
+ "amount": 100000,
+ "amount_captured": 100000,
+ "amount_refunded": 0,
+ "application": null,
+ "application_fee": null,
+ "application_fee_amount": null,
+ "balance_transaction": "txn_3OUBQpDEQaroqDjs1fV9FiTT",
+ "billing_details": {
+ "address": {
+ "city": null,
+ "country": null,
+ "line1": null,
+ "line2": null,
+ "postal_code": null,
+ "state": null
+ },
+ "email": null,
+ "name": null,
+ "phone": null
+ },
+ "calculated_statement_descriptor": "ZULIP CLOUD STANDARD",
+ "captured": true,
+ "created": 1704215231,
+ "currency": "usd",
+ "customer": "cus_PIn0tctXcJ76rV",
+ "description": "Upgrade to Zulip Cloud Standard, $40.0 x 25",
+ "destination": null,
+ "dispute": null,
+ "disputed": false,
+ "failure_balance_transaction": null,
+ "failure_code": null,
+ "failure_message": null,
+ "fraud_details": {},
+ "id": "ch_3OUBQpDEQaroqDjs1quOretD",
+ "invoice": null,
+ "livemode": false,
+ "metadata": {
+ "billing_modality": "charge_automatically",
+ "billing_schedule": "1",
+ "license_management": "automatic",
+ "licenses": "25",
+ "plan_tier": "1",
+ "price_per_license": "4000",
+ "realm_id": "2",
+ "realm_str": "zulip",
+ "seat_count": "25",
+ "type": "upgrade",
+ "user_email": "[email protected]",
+ "user_id": "10"
+ },
+ "object": "charge",
+ "on_behalf_of": null,
+ "order": null,
+ "outcome": {
+ "network_status": "approved_by_network",
+ "reason": null,
+ "risk_level": "normal",
+ "risk_score": 3,
+ "seller_message": "Payment complete.",
+ "type": "authorized"
+ },
+ "paid": true,
+ "payment_intent": "pi_3OUBQpDEQaroqDjs11DBy9EQ",
+ "payment_method": "pm_1OUBQlDEQaroqDjsLPwelbF3",
+ "payment_method_details": {
+ "card": {
+ "amount_authorized": 100000,
+ "brand": "visa",
+ "checks": {
+ "address_line1_check": null,
+ "address_postal_code_check": null,
+ "cvc_check": "pass"
+ },
+ "country": "US",
+ "exp_month": 1,
+ "exp_year": 2025,
+ "extended_authorization": {
+ "status": "disabled"
+ },
+ "fingerprint": "9XKsMixKBi6kIIzd",
+ "funding": "credit",
+ "incremental_authorization": {
+ "status": "unavailable"
+ },
+ "installments": null,
+ "last4": "4242",
+ "mandate": null,
+ "multicapture": {
+ "status": "unavailable"
+ },
+ "network": "visa",
+ "network_token": {
+ "used": false
+ },
+ "overcapture": {
+ "maximum_amount_capturable": 100000,
+ "status": "unavailable"
+ },
+ "three_d_secure": null,
+ "wallet": null
+ },
+ "type": "card"
+ },
+ "radar_options": {},
+ "receipt_email": "[email protected]",
+ "receipt_number": null,
+ "receipt_url": "https://pay.stripe.com/receipts/payment/CAcaFwoVYWNjdF8xN3ZUa3dERVFhcm9xRGpzKMCF0awGMgaJsPg25786LBYZCh3XvXRBnemo9ZPP_xvkdZGEA_YeUfTny9GXiSUlluudR4mMrGpmHGgf",
+ "refunded": false,
+ "refunds": {
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "total_count": 0,
+ "url": "/v1/charges/ch_3OUBQpDEQaroqDjs1quOretD/refunds"
+ },
+ "review": null,
+ "shipping": null,
+ "source": null,
+ "source_transfer": null,
+ "statement_descriptor": "Zulip Cloud Standard",
+ "statement_descriptor_suffix": null,
+ "status": "succeeded",
+ "transfer_data": null,
+ "transfer_group": null
+ }
+ },
+ "id": "evt_3OUBQpDEQaroqDjs1orskAhP",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 0,
+ "request": {
+ "id": "req_aEjWKLveCDrPag",
+ "idempotency_key": "f6c86d42-6be6-4ec7-b252-3db27f51164f"
+ },
+ "type": "charge.succeeded"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "url": "/v1/events"
+}
diff --git a/corporate/tests/stripe_fixtures/add_minimum_licenses--Event.list.3.json b/corporate/tests/stripe_fixtures/add_minimum_licenses--Event.list.3.json
new file mode 100644
index 00000000000..c9a40fb7a2f
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/add_minimum_licenses--Event.list.3.json
@@ -0,0 +1,650 @@
+{
+ "data": [
+ {
+ "api_version": "2020-08-27",
+ "created": 1704215234,
+ "data": {
+ "object": {
+ "account_country": "US",
+ "account_name": "Kandra Labs, Inc.",
+ "account_tax_ids": null,
+ "amount_due": 0,
+ "amount_paid": 0,
+ "amount_remaining": 0,
+ "amount_shipping": 0,
+ "application": null,
+ "application_fee_amount": null,
+ "attempt_count": 0,
+ "attempted": true,
+ "auto_advance": false,
+ "automatic_tax": {
+ "enabled": false,
+ "status": null
+ },
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "charge_automatically",
+ "created": 1704215233,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_PIn0tctXcJ76rV",
+ "customer_address": null,
+ "customer_email": "[email protected]",
+ "customer_name": null,
+ "customer_phone": null,
+ "customer_shipping": null,
+ "customer_tax_exempt": "none",
+ "customer_tax_ids": [],
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "discounts": [],
+ "due_date": null,
+ "effective_at": 1704215234,
+ "ending_balance": 0,
+ "footer": null,
+ "from_invoice": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_17vTkwDEQaroqDjs/test_YWNjdF8xN3ZUa3dERVFhcm9xRGpzLF9QSW4weHJJVU55WG9jZmNISVZpR3pQWTl1V3FUcW9CLDk0NzU2MDM00200ziCb5TUc?s=ap",
+ "id": "in_1OUBQrDEQaroqDjsbPLJDgMn",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_17vTkwDEQaroqDjs/test_YWNjdF8xN3ZUa3dERVFhcm9xRGpzLF9QSW4weHJJVU55WG9jZmNISVZpR3pQWTl1V3FUcW9CLDk0NzU2MDM00200ziCb5TUc/pdf?s=ap",
+ "last_finalization_error": null,
+ "latest_revision": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 100000,
+ "amount_excluding_tax": 100000,
+ "currency": "usd",
+ "description": "Zulip Cloud Standard",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "il_1OUBQrDEQaroqDjsu5IXdGR1",
+ "invoice_item": "ii_1OUBQrDEQaroqDjsGXVCSEDM",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1704215233,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1OUBQrDEQaroqDjsz0HiNGni",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_OvY3rmiwsD4vFL",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 4000,
+ "unit_amount_decimal": "4000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 25,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "4000"
+ },
+ {
+ "amount": -100000,
+ "amount_excluding_tax": -100000,
+ "currency": "usd",
+ "description": "Payment (Card ending in 4242)",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "il_1OUBQsDEQaroqDjsJJCbshpC",
+ "invoice_item": "ii_1OUBQrDEQaroqDjsBaYDFzhS",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1704215233,
+ "start": 1704215233
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1704215233,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1OUBQrDEQaroqDjszS8LaY14",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_OvY3hKgN66WIeP",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": -100000,
+ "unit_amount_decimal": "-100000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 1,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "-100000"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 2,
+ "url": "/v1/invoices/in_1OUBQrDEQaroqDjsbPLJDgMn/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": null,
+ "number": "9025AB67-0001",
+ "object": "invoice",
+ "on_behalf_of": null,
+ "paid": true,
+ "paid_out_of_band": false,
+ "payment_intent": null,
+ "payment_settings": {
+ "default_mandate": null,
+ "payment_method_options": null,
+ "payment_method_types": null
+ },
+ "period_end": 1704215233,
+ "period_start": 1704215233,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "quote": null,
+ "receipt_number": null,
+ "rendering": {
+ "amount_tax_display": null,
+ "pdf": {
+ "page_size": "letter"
+ }
+ },
+ "rendering_options": null,
+ "shipping_cost": null,
+ "shipping_details": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Cloud Standard",
+ "status": "paid",
+ "status_transitions": {
+ "finalized_at": 1704215234,
+ "marked_uncollectible_at": null,
+ "paid_at": 1704215234,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subscription_details": {
+ "metadata": null
+ },
+ "subtotal": 0,
+ "subtotal_excluding_tax": 0,
+ "tax": null,
+ "test_clock": null,
+ "total": 0,
+ "total_discount_amounts": [],
+ "total_excluding_tax": 0,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": null
+ },
+ "previous_attributes": {
+ "attempted": false,
+ "auto_advance": true,
+ "effective_at": null,
+ "ending_balance": null,
+ "hosted_invoice_url": null,
+ "invoice_pdf": null,
+ "next_payment_attempt": 1704218833,
+ "number": null,
+ "paid": false,
+ "rendering": {
+ "pdf": {
+ "page_size": "auto"
+ }
+ },
+ "status": "draft",
+ "status_transitions": {
+ "finalized_at": null,
+ "paid_at": null
+ }
+ }
+ },
+ "id": "evt_1OUBQtDEQaroqDjsEdO0Vy3p",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 2,
+ "request": {
+ "id": "req_MtxAFvQJ3mxW7e",
+ "idempotency_key": "73eb781c-3eaf-4db1-a3a0-35dd00794574"
+ },
+ "type": "invoice.updated"
+ },
+ {
+ "api_version": "2020-08-27",
+ "created": 1704215233,
+ "data": {
+ "object": {
+ "account_country": "US",
+ "account_name": "Kandra Labs, Inc.",
+ "account_tax_ids": null,
+ "amount_due": 0,
+ "amount_paid": 0,
+ "amount_remaining": 0,
+ "amount_shipping": 0,
+ "application": null,
+ "application_fee_amount": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "automatic_tax": {
+ "enabled": false,
+ "status": null
+ },
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "charge_automatically",
+ "created": 1704215233,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_PIn0tctXcJ76rV",
+ "customer_address": null,
+ "customer_email": "[email protected]",
+ "customer_name": null,
+ "customer_phone": null,
+ "customer_shipping": null,
+ "customer_tax_exempt": "none",
+ "customer_tax_ids": [],
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "discounts": [],
+ "due_date": null,
+ "effective_at": null,
+ "ending_balance": null,
+ "footer": null,
+ "from_invoice": null,
+ "hosted_invoice_url": null,
+ "id": "in_1OUBQrDEQaroqDjsbPLJDgMn",
+ "invoice_pdf": null,
+ "last_finalization_error": null,
+ "latest_revision": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 100000,
+ "amount_excluding_tax": 100000,
+ "currency": "usd",
+ "description": "Zulip Cloud Standard",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "il_1OUBQrDEQaroqDjsu5IXdGR1",
+ "invoice_item": "ii_1OUBQrDEQaroqDjsGXVCSEDM",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1704215233,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1OUBQrDEQaroqDjsz0HiNGni",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_OvY3rmiwsD4vFL",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 4000,
+ "unit_amount_decimal": "4000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 25,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "4000"
+ },
+ {
+ "amount": -100000,
+ "amount_excluding_tax": -100000,
+ "currency": "usd",
+ "description": "Payment (Card ending in 4242)",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "il_1OUBQsDEQaroqDjsJJCbshpC",
+ "invoice_item": "ii_1OUBQrDEQaroqDjsBaYDFzhS",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1704215233,
+ "start": 1704215233
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1704215233,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1OUBQrDEQaroqDjszS8LaY14",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_OvY3hKgN66WIeP",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": -100000,
+ "unit_amount_decimal": "-100000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 1,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "-100000"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 2,
+ "url": "/v1/invoices/in_1OUBQrDEQaroqDjsbPLJDgMn/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": 1704218833,
+ "number": null,
+ "object": "invoice",
+ "on_behalf_of": null,
+ "paid": false,
+ "paid_out_of_band": false,
+ "payment_intent": null,
+ "payment_settings": {
+ "default_mandate": null,
+ "payment_method_options": null,
+ "payment_method_types": null
+ },
+ "period_end": 1704215233,
+ "period_start": 1704215233,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "quote": null,
+ "receipt_number": null,
+ "rendering": {
+ "amount_tax_display": null,
+ "pdf": {
+ "page_size": "auto"
+ }
+ },
+ "rendering_options": null,
+ "shipping_cost": null,
+ "shipping_details": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Cloud Standard",
+ "status": "draft",
+ "status_transitions": {
+ "finalized_at": null,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subscription_details": {
+ "metadata": null
+ },
+ "subtotal": 0,
+ "subtotal_excluding_tax": 0,
+ "tax": null,
+ "test_clock": null,
+ "total": 0,
+ "total_discount_amounts": [],
+ "total_excluding_tax": 0,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": null
+ }
+ },
+ "id": "evt_1OUBQsDEQaroqDjs6LcwKF56",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 0,
+ "request": {
+ "id": "req_xGhPpKp2VBeKpc",
+ "idempotency_key": "c580e61d-b4fc-4a0c-9ed6-b43fd837a444"
+ },
+ "type": "invoice.created"
+ },
+ {
+ "api_version": "2020-08-27",
+ "created": 1704215233,
+ "data": {
+ "object": {
+ "amount": 100000,
+ "currency": "usd",
+ "customer": "cus_PIn0tctXcJ76rV",
+ "date": 1704215233,
+ "description": "Zulip Cloud Standard",
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_1OUBQrDEQaroqDjsGXVCSEDM",
+ "invoice": null,
+ "livemode": false,
+ "metadata": {},
+ "object": "invoiceitem",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1704215233,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1OUBQrDEQaroqDjsz0HiNGni",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_OvY3rmiwsD4vFL",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 4000,
+ "unit_amount_decimal": "4000"
+ },
+ "proration": false,
+ "quantity": 25,
+ "subscription": null,
+ "tax_rates": [],
+ "test_clock": null,
+ "unit_amount": 4000,
+ "unit_amount_decimal": "4000"
+ }
+ },
+ "id": "evt_1OUBQrDEQaroqDjsbeb8J6El",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 0,
+ "request": {
+ "id": "req_3I494hEx6aIjpx",
+ "idempotency_key": "2866fb07-2f6d-4823-b67f-3f083c63412b"
+ },
+ "type": "invoiceitem.created"
+ },
+ {
+ "api_version": "2020-08-27",
+ "created": 1704215233,
+ "data": {
+ "object": {
+ "amount": -100000,
+ "currency": "usd",
+ "customer": "cus_PIn0tctXcJ76rV",
+ "date": 1704215233,
+ "description": "Payment (Card ending in 4242)",
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_1OUBQrDEQaroqDjsBaYDFzhS",
+ "invoice": null,
+ "livemode": false,
+ "metadata": {},
+ "object": "invoiceitem",
+ "period": {
+ "end": 1704215233,
+ "start": 1704215233
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1704215233,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1OUBQrDEQaroqDjszS8LaY14",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_OvY3hKgN66WIeP",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": -100000,
+ "unit_amount_decimal": "-100000"
+ },
+ "proration": false,
+ "quantity": 1,
+ "subscription": null,
+ "tax_rates": [],
+ "test_clock": null,
+ "unit_amount": -100000,
+ "unit_amount_decimal": "-100000"
+ }
+ },
+ "id": "evt_1OUBQrDEQaroqDjsBJU2pV2N",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 0,
+ "request": {
+ "id": "req_B33MUzLDRume51",
+ "idempotency_key": "035ffed7-bfa0-4f66-9904-298a63dab90c"
+ },
+ "type": "invoiceitem.created"
+ },
+ {
+ "api_version": "2020-08-27",
+ "created": 1704215233,
+ "data": {
+ "object": {
+ "address": null,
+ "balance": 0,
+ "created": 1704215224,
+ "currency": "usd",
+ "default_currency": "usd",
+ "default_source": null,
+ "delinquent": false,
+ "description": "zulip (Zulip Dev)",
+ "discount": null,
+ "email": "[email protected]",
+ "id": "cus_PIn0tctXcJ76rV",
+ "invoice_prefix": "9025AB67",
+ "invoice_settings": {
+ "custom_fields": null,
+ "default_payment_method": "pm_1OUBQlDEQaroqDjsLPwelbF3",
+ "footer": null,
+ "rendering_options": null
+ },
+ "livemode": false,
+ "metadata": {
+ "realm_id": "2",
+ "realm_str": "zulip"
+ },
+ "name": null,
+ "next_invoice_sequence": 1,
+ "object": "customer",
+ "phone": null,
+ "preferred_locales": [],
+ "shipping": null,
+ "tax_exempt": "none",
+ "test_clock": null
+ },
+ "previous_attributes": {
+ "currency": null,
+ "default_currency": null
+ }
+ },
+ "id": "evt_1OUBQrDEQaroqDjsHyjGA2EP",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 0,
+ "request": {
+ "id": "req_B33MUzLDRume51",
+ "idempotency_key": "035ffed7-bfa0-4f66-9904-298a63dab90c"
+ },
+ "type": "customer.updated"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "url": "/v1/events"
+}
diff --git a/corporate/tests/stripe_fixtures/add_minimum_licenses--Event.list.4.json b/corporate/tests/stripe_fixtures/add_minimum_licenses--Event.list.4.json
new file mode 100644
index 00000000000..655245c5e78
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/add_minimum_licenses--Event.list.4.json
@@ -0,0 +1,453 @@
+{
+ "data": [
+ {
+ "api_version": "2020-08-27",
+ "created": 1704215234,
+ "data": {
+ "object": {
+ "account_country": "US",
+ "account_name": "Kandra Labs, Inc.",
+ "account_tax_ids": null,
+ "amount_due": 0,
+ "amount_paid": 0,
+ "amount_remaining": 0,
+ "amount_shipping": 0,
+ "application": null,
+ "application_fee_amount": null,
+ "attempt_count": 0,
+ "attempted": true,
+ "auto_advance": false,
+ "automatic_tax": {
+ "enabled": false,
+ "status": null
+ },
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "charge_automatically",
+ "created": 1704215233,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_PIn0tctXcJ76rV",
+ "customer_address": null,
+ "customer_email": "[email protected]",
+ "customer_name": null,
+ "customer_phone": null,
+ "customer_shipping": null,
+ "customer_tax_exempt": "none",
+ "customer_tax_ids": [],
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "discounts": [],
+ "due_date": null,
+ "effective_at": 1704215234,
+ "ending_balance": 0,
+ "footer": null,
+ "from_invoice": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_17vTkwDEQaroqDjs/test_YWNjdF8xN3ZUa3dERVFhcm9xRGpzLF9QSW4weHJJVU55WG9jZmNISVZpR3pQWTl1V3FUcW9CLDk0NzU2MDM10200LP6UGI4m?s=ap",
+ "id": "in_1OUBQrDEQaroqDjsbPLJDgMn",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_17vTkwDEQaroqDjs/test_YWNjdF8xN3ZUa3dERVFhcm9xRGpzLF9QSW4weHJJVU55WG9jZmNISVZpR3pQWTl1V3FUcW9CLDk0NzU2MDM10200LP6UGI4m/pdf?s=ap",
+ "last_finalization_error": null,
+ "latest_revision": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 100000,
+ "amount_excluding_tax": 100000,
+ "currency": "usd",
+ "description": "Zulip Cloud Standard",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "il_1OUBQrDEQaroqDjsu5IXdGR1",
+ "invoice_item": "ii_1OUBQrDEQaroqDjsGXVCSEDM",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1704215233,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1OUBQrDEQaroqDjsz0HiNGni",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_OvY3rmiwsD4vFL",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 4000,
+ "unit_amount_decimal": "4000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 25,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "4000"
+ },
+ {
+ "amount": -100000,
+ "amount_excluding_tax": -100000,
+ "currency": "usd",
+ "description": "Payment (Card ending in 4242)",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "il_1OUBQsDEQaroqDjsJJCbshpC",
+ "invoice_item": "ii_1OUBQrDEQaroqDjsBaYDFzhS",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1704215233,
+ "start": 1704215233
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1704215233,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1OUBQrDEQaroqDjszS8LaY14",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_OvY3hKgN66WIeP",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": -100000,
+ "unit_amount_decimal": "-100000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 1,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "-100000"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 2,
+ "url": "/v1/invoices/in_1OUBQrDEQaroqDjsbPLJDgMn/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": null,
+ "number": "9025AB67-0001",
+ "object": "invoice",
+ "on_behalf_of": null,
+ "paid": true,
+ "paid_out_of_band": false,
+ "payment_intent": null,
+ "payment_settings": {
+ "default_mandate": null,
+ "payment_method_options": null,
+ "payment_method_types": null
+ },
+ "period_end": 1704215233,
+ "period_start": 1704215233,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "quote": null,
+ "receipt_number": null,
+ "rendering": {
+ "amount_tax_display": null,
+ "pdf": {
+ "page_size": "letter"
+ }
+ },
+ "rendering_options": null,
+ "shipping_cost": null,
+ "shipping_details": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Cloud Standard",
+ "status": "paid",
+ "status_transitions": {
+ "finalized_at": 1704215234,
+ "marked_uncollectible_at": null,
+ "paid_at": 1704215234,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subscription_details": {
+ "metadata": null
+ },
+ "subtotal": 0,
+ "subtotal_excluding_tax": 0,
+ "tax": null,
+ "test_clock": null,
+ "total": 0,
+ "total_discount_amounts": [],
+ "total_excluding_tax": 0,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": null
+ }
+ },
+ "id": "evt_1OUBQtDEQaroqDjsWwUJZ9hG",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 2,
+ "request": {
+ "id": "req_MtxAFvQJ3mxW7e",
+ "idempotency_key": "73eb781c-3eaf-4db1-a3a0-35dd00794574"
+ },
+ "type": "invoice.paid"
+ },
+ {
+ "api_version": "2020-08-27",
+ "created": 1704215234,
+ "data": {
+ "object": {
+ "account_country": "US",
+ "account_name": "Kandra Labs, Inc.",
+ "account_tax_ids": null,
+ "amount_due": 0,
+ "amount_paid": 0,
+ "amount_remaining": 0,
+ "amount_shipping": 0,
+ "application": null,
+ "application_fee_amount": null,
+ "attempt_count": 0,
+ "attempted": true,
+ "auto_advance": false,
+ "automatic_tax": {
+ "enabled": false,
+ "status": null
+ },
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "charge_automatically",
+ "created": 1704215233,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_PIn0tctXcJ76rV",
+ "customer_address": null,
+ "customer_email": "[email protected]",
+ "customer_name": null,
+ "customer_phone": null,
+ "customer_shipping": null,
+ "customer_tax_exempt": "none",
+ "customer_tax_ids": [],
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "discounts": [],
+ "due_date": null,
+ "effective_at": 1704215234,
+ "ending_balance": 0,
+ "footer": null,
+ "from_invoice": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_17vTkwDEQaroqDjs/test_YWNjdF8xN3ZUa3dERVFhcm9xRGpzLF9QSW4weHJJVU55WG9jZmNISVZpR3pQWTl1V3FUcW9CLDk0NzU2MDM10200LP6UGI4m?s=ap",
+ "id": "in_1OUBQrDEQaroqDjsbPLJDgMn",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_17vTkwDEQaroqDjs/test_YWNjdF8xN3ZUa3dERVFhcm9xRGpzLF9QSW4weHJJVU55WG9jZmNISVZpR3pQWTl1V3FUcW9CLDk0NzU2MDM10200LP6UGI4m/pdf?s=ap",
+ "last_finalization_error": null,
+ "latest_revision": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 100000,
+ "amount_excluding_tax": 100000,
+ "currency": "usd",
+ "description": "Zulip Cloud Standard",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "il_1OUBQrDEQaroqDjsu5IXdGR1",
+ "invoice_item": "ii_1OUBQrDEQaroqDjsGXVCSEDM",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1704215233,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1OUBQrDEQaroqDjsz0HiNGni",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_OvY3rmiwsD4vFL",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 4000,
+ "unit_amount_decimal": "4000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 25,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "4000"
+ },
+ {
+ "amount": -100000,
+ "amount_excluding_tax": -100000,
+ "currency": "usd",
+ "description": "Payment (Card ending in 4242)",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "il_1OUBQsDEQaroqDjsJJCbshpC",
+ "invoice_item": "ii_1OUBQrDEQaroqDjsBaYDFzhS",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1704215233,
+ "start": 1704215233
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1704215233,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1OUBQrDEQaroqDjszS8LaY14",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_OvY3hKgN66WIeP",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": -100000,
+ "unit_amount_decimal": "-100000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 1,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "-100000"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 2,
+ "url": "/v1/invoices/in_1OUBQrDEQaroqDjsbPLJDgMn/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": null,
+ "number": "9025AB67-0001",
+ "object": "invoice",
+ "on_behalf_of": null,
+ "paid": true,
+ "paid_out_of_band": false,
+ "payment_intent": null,
+ "payment_settings": {
+ "default_mandate": null,
+ "payment_method_options": null,
+ "payment_method_types": null
+ },
+ "period_end": 1704215233,
+ "period_start": 1704215233,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "quote": null,
+ "receipt_number": null,
+ "rendering": {
+ "amount_tax_display": null,
+ "pdf": {
+ "page_size": "letter"
+ }
+ },
+ "rendering_options": null,
+ "shipping_cost": null,
+ "shipping_details": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Cloud Standard",
+ "status": "paid",
+ "status_transitions": {
+ "finalized_at": 1704215234,
+ "marked_uncollectible_at": null,
+ "paid_at": 1704215234,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subscription_details": {
+ "metadata": null
+ },
+ "subtotal": 0,
+ "subtotal_excluding_tax": 0,
+ "tax": null,
+ "test_clock": null,
+ "total": 0,
+ "total_discount_amounts": [],
+ "total_excluding_tax": 0,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": null
+ }
+ },
+ "id": "evt_1OUBQtDEQaroqDjsGyxGneve",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 0,
+ "request": {
+ "id": "req_MtxAFvQJ3mxW7e",
+ "idempotency_key": "73eb781c-3eaf-4db1-a3a0-35dd00794574"
+ },
+ "type": "invoice.finalized"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "url": "/v1/events"
+}
diff --git a/corporate/tests/stripe_fixtures/add_minimum_licenses--Event.list.5.json b/corporate/tests/stripe_fixtures/add_minimum_licenses--Event.list.5.json
new file mode 100644
index 00000000000..e22f209fe48
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/add_minimum_licenses--Event.list.5.json
@@ -0,0 +1,230 @@
+{
+ "data": [
+ {
+ "api_version": "2020-08-27",
+ "created": 1704215234,
+ "data": {
+ "object": {
+ "account_country": "US",
+ "account_name": "Kandra Labs, Inc.",
+ "account_tax_ids": null,
+ "amount_due": 0,
+ "amount_paid": 0,
+ "amount_remaining": 0,
+ "amount_shipping": 0,
+ "application": null,
+ "application_fee_amount": null,
+ "attempt_count": 0,
+ "attempted": true,
+ "auto_advance": false,
+ "automatic_tax": {
+ "enabled": false,
+ "status": null
+ },
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "charge_automatically",
+ "created": 1704215233,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_PIn0tctXcJ76rV",
+ "customer_address": null,
+ "customer_email": "[email protected]",
+ "customer_name": null,
+ "customer_phone": null,
+ "customer_shipping": null,
+ "customer_tax_exempt": "none",
+ "customer_tax_ids": [],
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "discounts": [],
+ "due_date": null,
+ "effective_at": 1704215234,
+ "ending_balance": 0,
+ "footer": null,
+ "from_invoice": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_17vTkwDEQaroqDjs/test_YWNjdF8xN3ZUa3dERVFhcm9xRGpzLF9QSW4weHJJVU55WG9jZmNISVZpR3pQWTl1V3FUcW9CLDk0NzU2MDM10200LP6UGI4m?s=ap",
+ "id": "in_1OUBQrDEQaroqDjsbPLJDgMn",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_17vTkwDEQaroqDjs/test_YWNjdF8xN3ZUa3dERVFhcm9xRGpzLF9QSW4weHJJVU55WG9jZmNISVZpR3pQWTl1V3FUcW9CLDk0NzU2MDM10200LP6UGI4m/pdf?s=ap",
+ "last_finalization_error": null,
+ "latest_revision": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 100000,
+ "amount_excluding_tax": 100000,
+ "currency": "usd",
+ "description": "Zulip Cloud Standard",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "il_1OUBQrDEQaroqDjsu5IXdGR1",
+ "invoice_item": "ii_1OUBQrDEQaroqDjsGXVCSEDM",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1704215233,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1OUBQrDEQaroqDjsz0HiNGni",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_OvY3rmiwsD4vFL",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 4000,
+ "unit_amount_decimal": "4000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 25,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "4000"
+ },
+ {
+ "amount": -100000,
+ "amount_excluding_tax": -100000,
+ "currency": "usd",
+ "description": "Payment (Card ending in 4242)",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "il_1OUBQsDEQaroqDjsJJCbshpC",
+ "invoice_item": "ii_1OUBQrDEQaroqDjsBaYDFzhS",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1704215233,
+ "start": 1704215233
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1704215233,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1OUBQrDEQaroqDjszS8LaY14",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_OvY3hKgN66WIeP",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": -100000,
+ "unit_amount_decimal": "-100000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 1,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "-100000"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 2,
+ "url": "/v1/invoices/in_1OUBQrDEQaroqDjsbPLJDgMn/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": null,
+ "number": "9025AB67-0001",
+ "object": "invoice",
+ "on_behalf_of": null,
+ "paid": true,
+ "paid_out_of_band": false,
+ "payment_intent": null,
+ "payment_settings": {
+ "default_mandate": null,
+ "payment_method_options": null,
+ "payment_method_types": null
+ },
+ "period_end": 1704215233,
+ "period_start": 1704215233,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "quote": null,
+ "receipt_number": null,
+ "rendering": {
+ "amount_tax_display": null,
+ "pdf": {
+ "page_size": "letter"
+ }
+ },
+ "rendering_options": null,
+ "shipping_cost": null,
+ "shipping_details": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Cloud Standard",
+ "status": "paid",
+ "status_transitions": {
+ "finalized_at": 1704215234,
+ "marked_uncollectible_at": null,
+ "paid_at": 1704215234,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subscription_details": {
+ "metadata": null
+ },
+ "subtotal": 0,
+ "subtotal_excluding_tax": 0,
+ "tax": null,
+ "test_clock": null,
+ "total": 0,
+ "total_discount_amounts": [],
+ "total_excluding_tax": 0,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": null
+ }
+ },
+ "id": "evt_1OUBQtDEQaroqDjst58Di9VX",
+ "livemode": false,
+ "object": "event",
+ "pending_webhooks": 0,
+ "request": {
+ "id": "req_MtxAFvQJ3mxW7e",
+ "idempotency_key": "73eb781c-3eaf-4db1-a3a0-35dd00794574"
+ },
+ "type": "invoice.payment_succeeded"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "url": "/v1/events"
+}
diff --git a/corporate/tests/stripe_fixtures/add_minimum_licenses--Event.list.6.json b/corporate/tests/stripe_fixtures/add_minimum_licenses--Event.list.6.json
new file mode 100644
index 00000000000..6d922067afe
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/add_minimum_licenses--Event.list.6.json
@@ -0,0 +1,6 @@
+{
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "url": "/v1/events"
+}
diff --git a/corporate/tests/stripe_fixtures/add_minimum_licenses--Invoice.create.1.json b/corporate/tests/stripe_fixtures/add_minimum_licenses--Invoice.create.1.json
new file mode 100644
index 00000000000..67236a97f6a
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/add_minimum_licenses--Invoice.create.1.json
@@ -0,0 +1,208 @@
+{
+ "account_country": "US",
+ "account_name": "Kandra Labs, Inc.",
+ "account_tax_ids": null,
+ "amount_due": 0,
+ "amount_paid": 0,
+ "amount_remaining": 0,
+ "amount_shipping": 0,
+ "application": null,
+ "application_fee_amount": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "automatic_tax": {
+ "enabled": false,
+ "status": null
+ },
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "charge_automatically",
+ "created": 1704215233,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_PIn0tctXcJ76rV",
+ "customer_address": null,
+ "customer_email": "[email protected]",
+ "customer_name": null,
+ "customer_phone": null,
+ "customer_shipping": null,
+ "customer_tax_exempt": "none",
+ "customer_tax_ids": [],
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "discounts": [],
+ "due_date": null,
+ "effective_at": null,
+ "ending_balance": null,
+ "footer": null,
+ "from_invoice": null,
+ "hosted_invoice_url": null,
+ "id": "in_1OUBQrDEQaroqDjsbPLJDgMn",
+ "invoice_pdf": null,
+ "last_finalization_error": null,
+ "latest_revision": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 100000,
+ "amount_excluding_tax": 100000,
+ "currency": "usd",
+ "description": "Zulip Cloud Standard",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "il_1OUBQrDEQaroqDjsu5IXdGR1",
+ "invoice_item": "ii_1OUBQrDEQaroqDjsGXVCSEDM",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1704215233,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1OUBQrDEQaroqDjsz0HiNGni",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_OvY3rmiwsD4vFL",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 4000,
+ "unit_amount_decimal": "4000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 25,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "4000"
+ },
+ {
+ "amount": -100000,
+ "amount_excluding_tax": -100000,
+ "currency": "usd",
+ "description": "Payment (Card ending in 4242)",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "il_1OUBQsDEQaroqDjsJJCbshpC",
+ "invoice_item": "ii_1OUBQrDEQaroqDjsBaYDFzhS",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1704215233,
+ "start": 1704215233
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1704215233,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1OUBQrDEQaroqDjszS8LaY14",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_OvY3hKgN66WIeP",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": -100000,
+ "unit_amount_decimal": "-100000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 1,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "-100000"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 2,
+ "url": "/v1/invoices/in_1OUBQrDEQaroqDjsbPLJDgMn/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": 1704218833,
+ "number": null,
+ "object": "invoice",
+ "on_behalf_of": null,
+ "paid": false,
+ "paid_out_of_band": false,
+ "payment_intent": null,
+ "payment_settings": {
+ "default_mandate": null,
+ "payment_method_options": null,
+ "payment_method_types": null
+ },
+ "period_end": 1704215233,
+ "period_start": 1704215233,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "quote": null,
+ "receipt_number": null,
+ "rendering": {
+ "amount_tax_display": null,
+ "pdf": {
+ "page_size": "auto"
+ }
+ },
+ "rendering_options": null,
+ "shipping_cost": null,
+ "shipping_details": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Cloud Standard",
+ "status": "draft",
+ "status_transitions": {
+ "finalized_at": null,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subscription_details": {
+ "metadata": null
+ },
+ "subtotal": 0,
+ "subtotal_excluding_tax": 0,
+ "tax": null,
+ "test_clock": null,
+ "total": 0,
+ "total_discount_amounts": [],
+ "total_excluding_tax": 0,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": null
+}
diff --git a/corporate/tests/stripe_fixtures/add_minimum_licenses--Invoice.finalize_invoice.1.json b/corporate/tests/stripe_fixtures/add_minimum_licenses--Invoice.finalize_invoice.1.json
new file mode 100644
index 00000000000..e8403cdcff5
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/add_minimum_licenses--Invoice.finalize_invoice.1.json
@@ -0,0 +1,208 @@
+{
+ "account_country": "US",
+ "account_name": "Kandra Labs, Inc.",
+ "account_tax_ids": null,
+ "amount_due": 0,
+ "amount_paid": 0,
+ "amount_remaining": 0,
+ "amount_shipping": 0,
+ "application": null,
+ "application_fee_amount": null,
+ "attempt_count": 0,
+ "attempted": true,
+ "auto_advance": false,
+ "automatic_tax": {
+ "enabled": false,
+ "status": null
+ },
+ "billing_reason": "manual",
+ "charge": null,
+ "collection_method": "charge_automatically",
+ "created": 1704215233,
+ "currency": "usd",
+ "custom_fields": null,
+ "customer": "cus_PIn0tctXcJ76rV",
+ "customer_address": null,
+ "customer_email": "[email protected]",
+ "customer_name": null,
+ "customer_phone": null,
+ "customer_shipping": null,
+ "customer_tax_exempt": "none",
+ "customer_tax_ids": [],
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "discounts": [],
+ "due_date": null,
+ "effective_at": 1704215234,
+ "ending_balance": 0,
+ "footer": null,
+ "from_invoice": null,
+ "hosted_invoice_url": "https://invoice.stripe.com/i/acct_17vTkwDEQaroqDjs/test_YWNjdF8xN3ZUa3dERVFhcm9xRGpzLF9QSW4weHJJVU55WG9jZmNISVZpR3pQWTl1V3FUcW9CLDk0NzU2MDM00200ziCb5TUc?s=ap",
+ "id": "in_1OUBQrDEQaroqDjsbPLJDgMn",
+ "invoice_pdf": "https://pay.stripe.com/invoice/acct_17vTkwDEQaroqDjs/test_YWNjdF8xN3ZUa3dERVFhcm9xRGpzLF9QSW4weHJJVU55WG9jZmNISVZpR3pQWTl1V3FUcW9CLDk0NzU2MDM00200ziCb5TUc/pdf?s=ap",
+ "last_finalization_error": null,
+ "latest_revision": null,
+ "lines": {
+ "data": [
+ {
+ "amount": 100000,
+ "amount_excluding_tax": 100000,
+ "currency": "usd",
+ "description": "Zulip Cloud Standard",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "il_1OUBQrDEQaroqDjsu5IXdGR1",
+ "invoice_item": "ii_1OUBQrDEQaroqDjsGXVCSEDM",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1704215233,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1OUBQrDEQaroqDjsz0HiNGni",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_OvY3rmiwsD4vFL",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 4000,
+ "unit_amount_decimal": "4000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 25,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "4000"
+ },
+ {
+ "amount": -100000,
+ "amount_excluding_tax": -100000,
+ "currency": "usd",
+ "description": "Payment (Card ending in 4242)",
+ "discount_amounts": [],
+ "discountable": false,
+ "discounts": [],
+ "id": "il_1OUBQsDEQaroqDjsJJCbshpC",
+ "invoice_item": "ii_1OUBQrDEQaroqDjsBaYDFzhS",
+ "livemode": false,
+ "metadata": {},
+ "object": "line_item",
+ "period": {
+ "end": 1704215233,
+ "start": 1704215233
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1704215233,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1OUBQrDEQaroqDjszS8LaY14",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_OvY3hKgN66WIeP",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": -100000,
+ "unit_amount_decimal": "-100000"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 1,
+ "subscription": null,
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "invoiceitem",
+ "unit_amount_excluding_tax": "-100000"
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 2,
+ "url": "/v1/invoices/in_1OUBQrDEQaroqDjsbPLJDgMn/lines"
+ },
+ "livemode": false,
+ "metadata": {},
+ "next_payment_attempt": null,
+ "number": "9025AB67-0001",
+ "object": "invoice",
+ "on_behalf_of": null,
+ "paid": true,
+ "paid_out_of_band": false,
+ "payment_intent": null,
+ "payment_settings": {
+ "default_mandate": null,
+ "payment_method_options": null,
+ "payment_method_types": null
+ },
+ "period_end": 1704215233,
+ "period_start": 1704215233,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "quote": null,
+ "receipt_number": null,
+ "rendering": {
+ "amount_tax_display": null,
+ "pdf": {
+ "page_size": "letter"
+ }
+ },
+ "rendering_options": null,
+ "shipping_cost": null,
+ "shipping_details": null,
+ "starting_balance": 0,
+ "statement_descriptor": "Zulip Cloud Standard",
+ "status": "paid",
+ "status_transitions": {
+ "finalized_at": 1704215234,
+ "marked_uncollectible_at": null,
+ "paid_at": 1704215234,
+ "voided_at": null
+ },
+ "subscription": null,
+ "subscription_details": {
+ "metadata": null
+ },
+ "subtotal": 0,
+ "subtotal_excluding_tax": 0,
+ "tax": null,
+ "test_clock": null,
+ "total": 0,
+ "total_discount_amounts": [],
+ "total_excluding_tax": 0,
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": null
+}
diff --git a/corporate/tests/stripe_fixtures/add_minimum_licenses--Invoice.list.1.json b/corporate/tests/stripe_fixtures/add_minimum_licenses--Invoice.list.1.json
new file mode 100644
index 00000000000..e39960ab725
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/add_minimum_licenses--Invoice.list.1.json
@@ -0,0 +1,6 @@
+{
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "url": "/v1/invoices"
+}
diff --git a/corporate/tests/stripe_fixtures/add_minimum_licenses--InvoiceItem.create.1.json b/corporate/tests/stripe_fixtures/add_minimum_licenses--InvoiceItem.create.1.json
new file mode 100644
index 00000000000..08077c6ef91
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/add_minimum_licenses--InvoiceItem.create.1.json
@@ -0,0 +1,47 @@
+{
+ "amount": -100000,
+ "currency": "usd",
+ "customer": "cus_PIn0tctXcJ76rV",
+ "date": 1704215233,
+ "description": "Payment (Card ending in 4242)",
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_1OUBQrDEQaroqDjsBaYDFzhS",
+ "invoice": null,
+ "livemode": false,
+ "metadata": {},
+ "object": "invoiceitem",
+ "period": {
+ "end": 1704215233,
+ "start": 1704215233
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1704215233,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1OUBQrDEQaroqDjszS8LaY14",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_OvY3hKgN66WIeP",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": -100000,
+ "unit_amount_decimal": "-100000"
+ },
+ "proration": false,
+ "quantity": 1,
+ "subscription": null,
+ "tax_rates": [],
+ "test_clock": null,
+ "unit_amount": -100000,
+ "unit_amount_decimal": "-100000"
+}
diff --git a/corporate/tests/stripe_fixtures/add_minimum_licenses--InvoiceItem.create.2.json b/corporate/tests/stripe_fixtures/add_minimum_licenses--InvoiceItem.create.2.json
new file mode 100644
index 00000000000..384b88cc575
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/add_minimum_licenses--InvoiceItem.create.2.json
@@ -0,0 +1,47 @@
+{
+ "amount": 100000,
+ "currency": "usd",
+ "customer": "cus_PIn0tctXcJ76rV",
+ "date": 1704215233,
+ "description": "Zulip Cloud Standard",
+ "discountable": false,
+ "discounts": [],
+ "id": "ii_1OUBQrDEQaroqDjsGXVCSEDM",
+ "invoice": null,
+ "livemode": false,
+ "metadata": {},
+ "object": "invoiceitem",
+ "period": {
+ "end": 1357095845,
+ "start": 1325473445
+ },
+ "plan": null,
+ "price": {
+ "active": false,
+ "billing_scheme": "per_unit",
+ "created": 1704215233,
+ "currency": "usd",
+ "custom_unit_amount": null,
+ "id": "price_1OUBQrDEQaroqDjsz0HiNGni",
+ "livemode": false,
+ "lookup_key": null,
+ "metadata": {},
+ "nickname": null,
+ "object": "price",
+ "product": "prod_OvY3rmiwsD4vFL",
+ "recurring": null,
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "one_time",
+ "unit_amount": 4000,
+ "unit_amount_decimal": "4000"
+ },
+ "proration": false,
+ "quantity": 25,
+ "subscription": null,
+ "tax_rates": [],
+ "test_clock": null,
+ "unit_amount": 4000,
+ "unit_amount_decimal": "4000"
+}
diff --git a/corporate/tests/stripe_fixtures/add_minimum_licenses--PaymentIntent.create.1.json b/corporate/tests/stripe_fixtures/add_minimum_licenses--PaymentIntent.create.1.json
new file mode 100644
index 00000000000..c78da8f35b0
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/add_minimum_licenses--PaymentIntent.create.1.json
@@ -0,0 +1,200 @@
+{
+ "amount": 100000,
+ "amount_capturable": 0,
+ "amount_details": {
+ "tip": {}
+ },
+ "amount_received": 100000,
+ "application": null,
+ "application_fee_amount": null,
+ "automatic_payment_methods": null,
+ "canceled_at": null,
+ "cancellation_reason": null,
+ "capture_method": "automatic",
+ "charges": {
+ "data": [
+ {
+ "amount": 100000,
+ "amount_captured": 100000,
+ "amount_refunded": 0,
+ "application": null,
+ "application_fee": null,
+ "application_fee_amount": null,
+ "balance_transaction": "txn_3OUBQpDEQaroqDjs1fV9FiTT",
+ "billing_details": {
+ "address": {
+ "city": null,
+ "country": null,
+ "line1": null,
+ "line2": null,
+ "postal_code": null,
+ "state": null
+ },
+ "email": null,
+ "name": null,
+ "phone": null
+ },
+ "calculated_statement_descriptor": "ZULIP CLOUD STANDARD",
+ "captured": true,
+ "created": 1704215231,
+ "currency": "usd",
+ "customer": "cus_PIn0tctXcJ76rV",
+ "description": "Upgrade to Zulip Cloud Standard, $40.0 x 25",
+ "destination": null,
+ "dispute": null,
+ "disputed": false,
+ "failure_balance_transaction": null,
+ "failure_code": null,
+ "failure_message": null,
+ "fraud_details": {},
+ "id": "ch_3OUBQpDEQaroqDjs1quOretD",
+ "invoice": null,
+ "livemode": false,
+ "metadata": {
+ "billing_modality": "charge_automatically",
+ "billing_schedule": "1",
+ "license_management": "automatic",
+ "licenses": "25",
+ "plan_tier": "1",
+ "price_per_license": "4000",
+ "realm_id": "2",
+ "realm_str": "zulip",
+ "seat_count": "25",
+ "type": "upgrade",
+ "user_email": "[email protected]",
+ "user_id": "10"
+ },
+ "object": "charge",
+ "on_behalf_of": null,
+ "order": null,
+ "outcome": {
+ "network_status": "approved_by_network",
+ "reason": null,
+ "risk_level": "normal",
+ "risk_score": 3,
+ "seller_message": "Payment complete.",
+ "type": "authorized"
+ },
+ "paid": true,
+ "payment_intent": "pi_3OUBQpDEQaroqDjs11DBy9EQ",
+ "payment_method": "pm_1OUBQlDEQaroqDjsLPwelbF3",
+ "payment_method_details": {
+ "card": {
+ "amount_authorized": 100000,
+ "brand": "visa",
+ "checks": {
+ "address_line1_check": null,
+ "address_postal_code_check": null,
+ "cvc_check": "pass"
+ },
+ "country": "US",
+ "exp_month": 1,
+ "exp_year": 2025,
+ "extended_authorization": {
+ "status": "disabled"
+ },
+ "fingerprint": "9XKsMixKBi6kIIzd",
+ "funding": "credit",
+ "incremental_authorization": {
+ "status": "unavailable"
+ },
+ "installments": null,
+ "last4": "4242",
+ "mandate": null,
+ "multicapture": {
+ "status": "unavailable"
+ },
+ "network": "visa",
+ "network_token": {
+ "used": false
+ },
+ "overcapture": {
+ "maximum_amount_capturable": 100000,
+ "status": "unavailable"
+ },
+ "three_d_secure": null,
+ "wallet": null
+ },
+ "type": "card"
+ },
+ "radar_options": {},
+ "receipt_email": "[email protected]",
+ "receipt_number": null,
+ "receipt_url": "https://pay.stripe.com/receipts/payment/CAcaFwoVYWNjdF8xN3ZUa3dERVFhcm9xRGpzKMCF0awGMgaRT0pgURo6LBakdcrCj9JRDsQPaS7Ys50dh7im1R_xTg6tJqlGxZYjYpQ7PlR0CHQ2325u",
+ "refunded": false,
+ "refunds": {
+ "data": [],
+ "has_more": false,
+ "object": "list",
+ "total_count": 0,
+ "url": "/v1/charges/ch_3OUBQpDEQaroqDjs1quOretD/refunds"
+ },
+ "review": null,
+ "shipping": null,
+ "source": null,
+ "source_transfer": null,
+ "statement_descriptor": "Zulip Cloud Standard",
+ "statement_descriptor_suffix": null,
+ "status": "succeeded",
+ "transfer_data": null,
+ "transfer_group": null
+ }
+ ],
+ "has_more": false,
+ "object": "list",
+ "total_count": 1,
+ "url": "/v1/charges?payment_intent=pi_3OUBQpDEQaroqDjs11DBy9EQ"
+ },
+ "client_secret": "pi_3OUBQpDEQaroqDjs11DBy9EQ_secret_wT6ZX3cY2YshDpg73a3GHvIoF",
+ "confirmation_method": "automatic",
+ "created": 1704215231,
+ "currency": "usd",
+ "customer": "cus_PIn0tctXcJ76rV",
+ "description": "Upgrade to Zulip Cloud Standard, $40.0 x 25",
+ "id": "pi_3OUBQpDEQaroqDjs11DBy9EQ",
+ "invoice": null,
+ "last_payment_error": null,
+ "latest_charge": "ch_3OUBQpDEQaroqDjs1quOretD",
+ "livemode": false,
+ "metadata": {
+ "billing_modality": "charge_automatically",
+ "billing_schedule": "1",
+ "license_management": "automatic",
+ "licenses": "25",
+ "plan_tier": "1",
+ "price_per_license": "4000",
+ "realm_id": "2",
+ "realm_str": "zulip",
+ "seat_count": "25",
+ "type": "upgrade",
+ "user_email": "[email protected]",
+ "user_id": "10"
+ },
+ "next_action": null,
+ "object": "payment_intent",
+ "on_behalf_of": null,
+ "payment_method": "pm_1OUBQlDEQaroqDjsLPwelbF3",
+ "payment_method_configuration_details": null,
+ "payment_method_options": {
+ "card": {
+ "installments": null,
+ "mandate_options": null,
+ "network": null,
+ "request_three_d_secure": "automatic"
+ }
+ },
+ "payment_method_types": [
+ "card"
+ ],
+ "processing": null,
+ "receipt_email": "[email protected]",
+ "review": null,
+ "setup_future_usage": null,
+ "shipping": null,
+ "source": null,
+ "statement_descriptor": "Zulip Cloud Standard",
+ "statement_descriptor_suffix": null,
+ "status": "succeeded",
+ "transfer_data": null,
+ "transfer_group": null
+}
diff --git a/corporate/tests/stripe_fixtures/add_minimum_licenses--SetupIntent.create.1.json b/corporate/tests/stripe_fixtures/add_minimum_licenses--SetupIntent.create.1.json
new file mode 100644
index 00000000000..e0e1e7d3144
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/add_minimum_licenses--SetupIntent.create.1.json
@@ -0,0 +1,34 @@
+{
+ "application": null,
+ "automatic_payment_methods": null,
+ "cancellation_reason": null,
+ "client_secret": "seti_1OUBQlDEQaroqDjsmNU4qxsM_secret_PIn0KOOHPgPyywEV4zmef55UO6jc0lf",
+ "created": 1704215227,
+ "customer": "cus_PIn0tctXcJ76rV",
+ "description": null,
+ "flow_directions": null,
+ "id": "seti_1OUBQlDEQaroqDjsmNU4qxsM",
+ "last_setup_error": null,
+ "latest_attempt": "setatt_1OUBQlDEQaroqDjskKLfnD0I",
+ "livemode": false,
+ "mandate": null,
+ "metadata": {},
+ "next_action": null,
+ "object": "setup_intent",
+ "on_behalf_of": null,
+ "payment_method": "pm_1OUBQlDEQaroqDjsLPwelbF3",
+ "payment_method_configuration_details": null,
+ "payment_method_options": {
+ "card": {
+ "mandate_options": null,
+ "network": null,
+ "request_three_d_secure": "automatic"
+ }
+ },
+ "payment_method_types": [
+ "card"
+ ],
+ "single_use_mandate": null,
+ "status": "succeeded",
+ "usage": "off_session"
+}
diff --git a/corporate/tests/stripe_fixtures/add_minimum_licenses--SetupIntent.list.1.json b/corporate/tests/stripe_fixtures/add_minimum_licenses--SetupIntent.list.1.json
new file mode 100644
index 00000000000..37bfcaa3c19
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/add_minimum_licenses--SetupIntent.list.1.json
@@ -0,0 +1,41 @@
+{
+ "data": [
+ {
+ "application": null,
+ "automatic_payment_methods": null,
+ "cancellation_reason": null,
+ "client_secret": "seti_1OUBQjDEQaroqDjsvfIO3jMV_secret_PIn0y9bfKsoqmuKwLpPUSm2pnsI3Tt0",
+ "created": 1704215225,
+ "customer": "cus_PIn0tctXcJ76rV",
+ "description": null,
+ "flow_directions": null,
+ "id": "seti_1OUBQjDEQaroqDjsvfIO3jMV",
+ "last_setup_error": null,
+ "latest_attempt": null,
+ "livemode": false,
+ "mandate": null,
+ "metadata": {},
+ "next_action": null,
+ "object": "setup_intent",
+ "on_behalf_of": null,
+ "payment_method": null,
+ "payment_method_configuration_details": null,
+ "payment_method_options": {
+ "card": {
+ "mandate_options": null,
+ "network": null,
+ "request_three_d_secure": "automatic"
+ }
+ },
+ "payment_method_types": [
+ "card"
+ ],
+ "single_use_mandate": null,
+ "status": "requires_payment_method",
+ "usage": "off_session"
+ }
+ ],
+ "has_more": true,
+ "object": "list",
+ "url": "/v1/setup_intents"
+}
diff --git a/corporate/tests/stripe_fixtures/add_minimum_licenses--SetupIntent.retrieve.1.json b/corporate/tests/stripe_fixtures/add_minimum_licenses--SetupIntent.retrieve.1.json
new file mode 100644
index 00000000000..e0e1e7d3144
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/add_minimum_licenses--SetupIntent.retrieve.1.json
@@ -0,0 +1,34 @@
+{
+ "application": null,
+ "automatic_payment_methods": null,
+ "cancellation_reason": null,
+ "client_secret": "seti_1OUBQlDEQaroqDjsmNU4qxsM_secret_PIn0KOOHPgPyywEV4zmef55UO6jc0lf",
+ "created": 1704215227,
+ "customer": "cus_PIn0tctXcJ76rV",
+ "description": null,
+ "flow_directions": null,
+ "id": "seti_1OUBQlDEQaroqDjsmNU4qxsM",
+ "last_setup_error": null,
+ "latest_attempt": "setatt_1OUBQlDEQaroqDjskKLfnD0I",
+ "livemode": false,
+ "mandate": null,
+ "metadata": {},
+ "next_action": null,
+ "object": "setup_intent",
+ "on_behalf_of": null,
+ "payment_method": "pm_1OUBQlDEQaroqDjsLPwelbF3",
+ "payment_method_configuration_details": null,
+ "payment_method_options": {
+ "card": {
+ "mandate_options": null,
+ "network": null,
+ "request_three_d_secure": "automatic"
+ }
+ },
+ "payment_method_types": [
+ "card"
+ ],
+ "single_use_mandate": null,
+ "status": "succeeded",
+ "usage": "off_session"
+}
diff --git a/corporate/tests/stripe_fixtures/add_minimum_licenses--checkout.Session.create.1.json b/corporate/tests/stripe_fixtures/add_minimum_licenses--checkout.Session.create.1.json
new file mode 100644
index 00000000000..8b10d7a52ca
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/add_minimum_licenses--checkout.Session.create.1.json
@@ -0,0 +1,74 @@
+{
+ "after_expiration": null,
+ "allow_promotion_codes": null,
+ "amount_subtotal": null,
+ "amount_total": null,
+ "automatic_tax": {
+ "enabled": false,
+ "status": null
+ },
+ "billing_address_collection": null,
+ "cancel_url": "http://zulip.testserver/upgrade/?manual_license_management=false&tier=1",
+ "client_reference_id": null,
+ "client_secret": null,
+ "consent": null,
+ "consent_collection": null,
+ "created": 1704215225,
+ "currency": null,
+ "currency_conversion": null,
+ "custom_fields": [],
+ "custom_text": {
+ "after_submit": null,
+ "shipping_address": null,
+ "submit": null,
+ "terms_of_service_acceptance": null
+ },
+ "customer": "cus_PIn0tctXcJ76rV",
+ "customer_creation": null,
+ "customer_details": {
+ "address": null,
+ "email": "[email protected]",
+ "name": null,
+ "phone": null,
+ "tax_exempt": null,
+ "tax_ids": null
+ },
+ "customer_email": null,
+ "expires_at": 1704301625,
+ "id": "cs_test_c1WxDjzfeRKACUencanGntzhVVcP5VjGsjwd4q3OWrEQMrJgnqi5mLWyWY",
+ "invoice": null,
+ "invoice_creation": null,
+ "livemode": false,
+ "locale": null,
+ "metadata": {
+ "type": "card_update",
+ "user_id": "10"
+ },
+ "mode": "setup",
+ "object": "checkout.session",
+ "payment_intent": null,
+ "payment_link": null,
+ "payment_method_collection": "always",
+ "payment_method_configuration_details": null,
+ "payment_method_options": {},
+ "payment_method_types": [
+ "card"
+ ],
+ "payment_status": "no_payment_required",
+ "phone_number_collection": {
+ "enabled": false
+ },
+ "recovered_from": null,
+ "setup_intent": "seti_1OUBQjDEQaroqDjsvfIO3jMV",
+ "shipping": null,
+ "shipping_address_collection": null,
+ "shipping_options": [],
+ "shipping_rate": null,
+ "status": "open",
+ "submit_type": null,
+ "subscription": null,
+ "success_url": "http://zulip.testserver/billing/event_status?stripe_session_id={CHECKOUT_SESSION_ID}",
+ "total_details": null,
+ "ui_mode": "hosted",
+ "url": "https://checkout.stripe.com/c/pay/cs_test_c1WxDjzfeRKACUencanGntzhVVcP5VjGsjwd4q3OWrEQMrJgnqi5mLWyWY#fid1d2BpamRhQ2prcSc%2FJ1ZqcHdmYCVWZGt2JVV3aicpJ2R1bE5gfCc%2FJ3VuWnFgdnFaXVRmMU5zNkldQTY9SnNRY09XZml2UXNQJyknY3dqaFZgd3Ngdyc%2FcXdwYCknaWR8anBxUXx1YCc%2FJ3Zsa2JpYFpmamlwaGsnKSdga2RnaWBVaWRmYG1qaWFgd3YnP3F3cGB4JSUl"
+}
diff --git a/corporate/tests/stripe_fixtures/add_minimum_licenses--checkout.Session.list.1.json b/corporate/tests/stripe_fixtures/add_minimum_licenses--checkout.Session.list.1.json
new file mode 100644
index 00000000000..066c66be497
--- /dev/null
+++ b/corporate/tests/stripe_fixtures/add_minimum_licenses--checkout.Session.list.1.json
@@ -0,0 +1,81 @@
+{
+ "data": [
+ {
+ "after_expiration": null,
+ "allow_promotion_codes": null,
+ "amount_subtotal": null,
+ "amount_total": null,
+ "automatic_tax": {
+ "enabled": false,
+ "status": null
+ },
+ "billing_address_collection": null,
+ "cancel_url": "http://zulip.testserver/upgrade/?manual_license_management=false&tier=1",
+ "client_reference_id": null,
+ "client_secret": null,
+ "consent": null,
+ "consent_collection": null,
+ "created": 1704215225,
+ "currency": null,
+ "currency_conversion": null,
+ "custom_fields": [],
+ "custom_text": {
+ "after_submit": null,
+ "shipping_address": null,
+ "submit": null,
+ "terms_of_service_acceptance": null
+ },
+ "customer": "cus_PIn0tctXcJ76rV",
+ "customer_creation": null,
+ "customer_details": {
+ "address": null,
+ "email": "[email protected]",
+ "name": null,
+ "phone": null,
+ "tax_exempt": null,
+ "tax_ids": null
+ },
+ "customer_email": null,
+ "expires_at": 1704301625,
+ "id": "cs_test_c1WxDjzfeRKACUencanGntzhVVcP5VjGsjwd4q3OWrEQMrJgnqi5mLWyWY",
+ "invoice": null,
+ "invoice_creation": null,
+ "livemode": false,
+ "locale": null,
+ "metadata": {
+ "type": "card_update",
+ "user_id": "10"
+ },
+ "mode": "setup",
+ "object": "checkout.session",
+ "payment_intent": null,
+ "payment_link": null,
+ "payment_method_collection": "always",
+ "payment_method_configuration_details": null,
+ "payment_method_options": {},
+ "payment_method_types": [
+ "card"
+ ],
+ "payment_status": "no_payment_required",
+ "phone_number_collection": {
+ "enabled": false
+ },
+ "recovered_from": null,
+ "setup_intent": "seti_1OUBQjDEQaroqDjsvfIO3jMV",
+ "shipping": null,
+ "shipping_address_collection": null,
+ "shipping_options": [],
+ "shipping_rate": null,
+ "status": "open",
+ "submit_type": null,
+ "subscription": null,
+ "success_url": "http://zulip.testserver/billing/event_status?stripe_session_id={CHECKOUT_SESSION_ID}",
+ "total_details": null,
+ "ui_mode": "hosted",
+ "url": "https://checkout.stripe.com/c/pay/cs_test_c1WxDjzfeRKACUencanGntzhVVcP5VjGsjwd4q3OWrEQMrJgnqi5mLWyWY#fid1d2BpamRhQ2prcSc%2FJ1ZqcHdmYCVWZGt2JVV3aicpJ2R1bE5gfCc%2FJ3VuWnFgdnFaXVRmMU5zNkldQTY9SnNRY09XZml2UXNQJyknY3dqaFZgd3Ngdyc%2FcXdwYCknaWR8anBxUXx1YCc%2FJ3Zsa2JpYFpmamlwaGsnKSdga2RnaWBVaWRmYG1qaWFgd3YnP3F3cGB4JSUl"
+ }
+ ],
+ "has_more": true,
+ "object": "list",
+ "url": "/v1/checkout/sessions"
+}
diff --git a/corporate/tests/test_stripe.py b/corporate/tests/test_stripe.py
index 1b45b9e9ab1..3b9f2d91264 100644
--- a/corporate/tests/test_stripe.py
+++ b/corporate/tests/test_stripe.py
@@ -5402,6 +5402,50 @@ class TestSupportBillingHelpers(StripeTestCase):
):
billing_session.approve_sponsorship()
+ @mock_stripe()
+ def test_add_minimum_licenses(self, *mocks: Mock) -> None:
+ min_licenses = 25
+ support_view_request = SupportViewRequest(
+ support_type=SupportType.update_minimum_licenses, minimum_licenses=min_licenses
+ )
+ support_admin = self.example_user("iago")
+ user = self.example_user("hamlet")
+ billing_session = RealmBillingSession(support_admin, realm=user.realm, support_session=True)
+
+ billing_session.update_or_create_customer()
+ with self.assertRaisesRegex(
+ SupportRequestError,
+ "Discount for zulip must be updated before setting a minimum number of licenses.",
+ ):
+ billing_session.process_support_view_request(support_view_request)
+
+ billing_session.attach_discount_to_customer(Decimal(50))
+ message = billing_session.process_support_view_request(support_view_request)
+ self.assertEqual("Minimum licenses for zulip changed to 25 from 0.", message)
+ realm_audit_log = RealmAuditLog.objects.filter(
+ event_type=RealmAuditLog.CUSTOMER_MINIMUM_LICENSES_CHANGED
+ ).last()
+ assert realm_audit_log is not None
+ expected_extra_data = {"old_minimum_licenses": None, "new_minimum_licenses": 25}
+ self.assertEqual(realm_audit_log.extra_data, expected_extra_data)
+
+ self.login_user(user)
+ self.add_card_and_upgrade(user)
+ customer = billing_session.get_customer()
+ assert customer is not None
+ [charge] = iter(stripe.Charge.list(customer=customer.stripe_customer_id))
+ self.assertEqual(4000 * min_licenses, charge.amount)
+
+ min_licenses = 50
+ support_view_request = SupportViewRequest(
+ support_type=SupportType.update_minimum_licenses, minimum_licenses=min_licenses
+ )
+ with self.assertRaisesRegex(
+ SupportRequestError,
+ "Cannot set minimum licenses; active plan already exists for zulip.",
+ ):
+ billing_session.process_support_view_request(support_view_request)
+
def test_approve_realm_sponsorship(self) -> None:
realm = get_realm("zulip")
self.assertNotEqual(realm.plan_type, Realm.PLAN_TYPE_STANDARD_FREE)
diff --git a/templates/analytics/sponsorship_forms_support.html b/templates/analytics/sponsorship_forms_support.html
index e6237761d2c..ac9896c8e35 100644
--- a/templates/analytics/sponsorship_forms_support.html
+++ b/templates/analytics/sponsorship_forms_support.html
@@ -33,6 +33,17 @@
{% endif %}
</form>
+{% if not has_fixed_price and (sponsorship_data.default_discount or sponsorship_data.minimum_licenses) %}
+<form method="POST" class="remote-form">
+ <b>Minimum licenses</b>:<br />
+ {{ csrf_input }}
+ <input type="hidden" name="{{ remote_type }}" value="{{ remote_id }}" />
+ <input type="number" name="minimum_licenses" value="{{ sponsorship_data.minimum_licenses }}" required />
+ <button type="submit" class="btn btn-default support-submit-button">Update</button>
+</form>
+{% endif %}
+
+
{% if sponsorship_data.sponsorship_pending %}
<div class="">
<h4>Sponsorship request information:</h4>
diff --git a/zerver/models/realm_audit_logs.py b/zerver/models/realm_audit_logs.py
index ee64b51f33e..5bc70ff9423 100644
--- a/zerver/models/realm_audit_logs.py
+++ b/zerver/models/realm_audit_logs.py
@@ -101,6 +101,7 @@ class AbstractRealmAuditLog(models.Model):
CUSTOMER_PLAN_CREATED = 502
CUSTOMER_SWITCHED_FROM_MONTHLY_TO_ANNUAL_PLAN = 503
CUSTOMER_SWITCHED_FROM_ANNUAL_TO_MONTHLY_PLAN = 504
+ CUSTOMER_MINIMUM_LICENSES_CHANGED = 505
STREAM_CREATED = 601
STREAM_DEACTIVATED = 602