stripe: Use absent days_until_due rather than invalid None.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit 228ade86be)
This commit is contained in:
Anders Kaseorg
2024-04-30 10:37:55 -07:00
committed by Tim Abbott
parent 1327db6e9c
commit c67f08b58a
2 changed files with 8 additions and 5 deletions

View File

@@ -1320,13 +1320,15 @@ class BillingSession(ABC):
collection_method = "send_invoice"
days_until_due = DEFAULT_INVOICE_DAYS_UNTIL_DUE
stripe_invoice = stripe.Invoice.create(
invoice_params = stripe.Invoice.CreateParams(
auto_advance=True,
collection_method=collection_method,
customer=customer.stripe_customer_id,
days_until_due=days_until_due,
statement_descriptor=plan.name,
)
if days_until_due is not None:
invoice_params["days_until_due"] = days_until_due
stripe_invoice = stripe.Invoice.create(**invoice_params)
stripe.Invoice.finalize_invoice(stripe_invoice)
if plan.status < CustomerPlan.LIVE_STATUS_THRESHOLD:
@@ -2264,13 +2266,15 @@ class BillingSession(ABC):
else:
collection_method = "send_invoice"
days_until_due = DEFAULT_INVOICE_DAYS_UNTIL_DUE
stripe_invoice = stripe.Invoice.create(
invoice_params = stripe.Invoice.CreateParams(
auto_advance=True,
collection_method=collection_method,
customer=plan.customer.stripe_customer_id,
days_until_due=days_until_due,
statement_descriptor=plan.name,
)
if days_until_due is not None:
invoice_params["days_until_due"] = days_until_due
stripe_invoice = stripe.Invoice.create(**invoice_params)
stripe.Invoice.finalize_invoice(stripe_invoice)
plan.next_invoice_date = next_invoice_date(plan)

View File

@@ -134,7 +134,6 @@ def handle_payment_intent_succeeded_event(
auto_advance=True,
collection_method="charge_automatically",
customer=stripe_payment_intent.customer,
days_until_due=None,
statement_descriptor=CustomerPlan.name_from_tier(plan_tier).replace("Zulip ", "")
+ " Credit",
)