snapshot of https://github.com/zulip/zulip.git @ 48c69911c7dd4e03b20552eb3bd77ad8151c1357 (2026-09-15)
Some checks failed
Code scanning / CodeQL (push) Failing after 15s
Zulip production suite / Ubuntu 22.04 production build (push) Failing after 26s
Zulip production suite / Debian 12 production install with custom db name and user (push) Has been skipped
Zulip production suite / Ubuntu 22.04 production install and PostgreSQL upgrade with pgroonga (push) Has been skipped
Zulip production suite / Ubuntu 24.04 production install (push) Has been skipped
Zulip production suite / Ubuntu 26.04 production install (push) Has been skipped
Zulip production suite / Debian 13 production install (push) Has been skipped
Zulip production suite / 7.0 Version Upgrade (push) Has been skipped
Zulip production suite / 8.0 Version Upgrade (push) Has been skipped
Zulip production suite / 6.0 Version Upgrade (push) Has been skipped
Zulip production suite / 10.0 Version Upgrade (push) Has been skipped
Zulip production suite / 9.0 Version Upgrade (push) Has been skipped
Zulip production suite / 12.0 Version Upgrade (push) Has been skipped
Zulip production suite / 11.0 Version Upgrade (push) Has been skipped
GitHub Actions Security Analysis with zizmor / zizmor (push) Failing after 3s
Zulip CI / Debian 12 (Python 3.11, backend + documentation) (push) Failing after 26s
Zulip CI / Ubuntu 22.04 (Python 3.10, backend + frontend) (push) Failing after 3s
Zulip CI / Ubuntu 24.04 (Python 3.12, backend) (push) Failing after 25s
Zulip CI / Ubuntu 26.04 (Python 3.14, backend) (push) Failing after 25s
Zulip CI / Debian 13 (Python 3.13, backend) (push) Failing after 28s
Zulip production suite / Required jobs (push) Has been cancelled
Zulip CI / Required jobs (push) Has been cancelled
API Documentation Update Check / check-feature-level-updated (push) Has been cancelled
API Documentation Update Check / notify-if-api-docs-changed (push) Has been cancelled

This commit is contained in:
upstream-mirror
2026-09-15 15:05:30 +05:00
commit 64898b2c79
8999 changed files with 1757358 additions and 0 deletions

View File

View File

@@ -0,0 +1,88 @@
from typing import Any
from django.conf import settings
from django.core.management.base import CommandError, CommandParser
from typing_extensions import override
from zerver.lib.timestamp import timestamp_to_datetime
if settings.BILLING_ENABLED:
from corporate.lib.billing_management import BillingSessionCommand
from corporate.lib.stripe import BillingError, get_configured_fixed_price_plan_offer
from corporate.models.plans import CustomerPlan
class Command(BillingSessionCommand):
help = """
Initialize a paid fixed-price plan for a billing customer (Realm, RemoteRealm or RemoteZulipServer).
Defaults to `--dry-run=True` so that the billing changes are run in preview mode first.
"""
@override
def add_arguments(self, parser: CommandParser) -> None:
parser.add_argument(
"--plan-tier",
dest="plan_tier",
type=int,
required=True,
help="The CustomerPlan tier for the fixed-price plan.",
)
parser.add_argument(
"--billing-anchor",
dest="billing_cycle_anchor",
type=float,
required=False,
help="Adjusted billing cycle anchor timestamp. Must be in the past.",
)
self.add_billing_entity_args(parser)
parser.add_argument(
"--dry-run",
dest="dry_run",
action="store_true",
default=True,
required=False,
help="Check for errors before initializing paid fixed-price plan. Default value is True.",
)
@override
def handle(self, *args: Any, **options: Any) -> None:
if not settings.BILLING_ENABLED:
raise CommandError("Billing system not enabled.")
plan_tier = options["plan_tier"]
if plan_tier not in CustomerPlan.PAID_PLAN_TIERS:
raise CommandError("Invalid tier for paid plan.")
billing_cycle_anchor = None
if options["billing_cycle_anchor"]:
anchor_timestamp = options["billing_cycle_anchor"]
billing_cycle_anchor = timestamp_to_datetime(anchor_timestamp)
billing_session = self.get_billing_session_from_args(options)
if options["dry_run"]:
try:
billing_session.check_can_configure_prepaid_fixed_price_plan(plan_tier)
customer = billing_session.get_customer()
assert customer is not None
fixed_price_plan_offer = get_configured_fixed_price_plan_offer(customer, plan_tier)
assert fixed_price_plan_offer is not None
anchor_date_string = (
billing_cycle_anchor.strftime("%B %d, %Y") if billing_cycle_anchor else "today"
)
print(
f"Will initialize {fixed_price_plan_offer} with anchor date of {anchor_date_string}."
)
return
except BillingError as e:
raise CommandError(e.msg)
except AssertionError as e:
raise CommandError(e)
else:
try:
billing_session.initialize_prepaid_fixed_price_plan(plan_tier, billing_cycle_anchor)
print("Done! Check support panel for customer to review active fixed-price plan.")
except BillingError as e:
raise CommandError(e.msg)
except AssertionError as e:
raise CommandError(e)

View File

@@ -0,0 +1,78 @@
from typing import Any
from django.conf import settings
from django.core.management.base import CommandError, CommandParser
from typing_extensions import override
if settings.BILLING_ENABLED:
from corporate.lib.billing_management import BillingSessionCommand
from corporate.lib.stripe import BillingError, stripe_get_customer
from corporate.models.plans import get_current_plan_by_customer
class Command(BillingSessionCommand):
help = """Link a Customer object to a Stripe customer ID."""
@override
def add_arguments(self, parser: CommandParser) -> None:
parser.add_argument(
"--stripe-id",
dest="stripe_id",
required=True,
help="The ID of the customer in Stripe.",
)
self.add_billing_entity_args(parser)
@override
def handle(self, *args: Any, **options: Any) -> None:
if not settings.BILLING_ENABLED:
raise CommandError("Billing system not enabled.")
stripe_id = options["stripe_id"]
try:
stripe_get_customer(stripe_id)
except BillingError:
raise CommandError(f"Error checking for Stripe Customer with ID {stripe_id}. Aborting.")
billing_session = self.get_billing_session_from_args(options)
customer = billing_session.get_customer()
if customer is None:
print(f"No Customer object for {billing_session.billing_entity_display_name}.")
no_customer_object_prompt = input(
f"Do you want to create one and link it to Stripe customer with ID {stripe_id}? [Y/n]"
)
print()
if not (
no_customer_object_prompt.lower() == "y"
or no_customer_object_prompt.lower() == ""
or no_customer_object_prompt.lower() == "yes"
):
return
print("Creating Customer object...")
customer = billing_session.update_or_create_customer()
print(f"Linking {customer} to Stripe customer with ID {stripe_id}...")
billing_session.link_stripe_customer_id(stripe_id)
print("Done!")
return
plan = get_current_plan_by_customer(customer)
if plan is not None and plan.is_a_paid_plan():
raise CommandError(f"{customer} has an active paid plan! Aborting.")
if customer.stripe_customer_id is not None:
existing_id_prompt = input(
f"Do you want to overwrite the current stripe_customer_id for {customer}? [Y/n]"
)
print()
if not (
existing_id_prompt.lower() == "y"
or existing_id_prompt.lower() == ""
or existing_id_prompt.lower() == "yes"
):
return
print(f"Linking {customer} to Stripe customer with ID {stripe_id}...")
billing_session.link_stripe_customer_id(stripe_id)
print("Done!")