forked from zulip/zulip
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
billing: Fix the type annotation of Customer.stripe_customer_id.
This also fixes a bug in void_all_open_invoices function. If a realm with a local Customer object but without an associated stripe.Customer is passed to void_all_open_invoices, then the function will end up voiding the last 10 invoices created by billing system instead of voiding no invoices at all. This is because stripe.Invoice.list(customer=None) return last 10 invoices across all customers. But this bug won't cauuse any issue in production since void_all_open_invoices can be only invoked from /support page. And we show the option to void invoices in support page only if the realm has a paid plan. And it's not really possible for a realm to have a paid plan without having an associated stripe_customer_id. Plus I went through the void events in stripe stream since the PR to add void invoices was merged and there does not seems to be any suspicious events.
- Loading branch information
Showing
17 changed files
with
933 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
corporate/tests/stripe_fixtures/void_all_open_invoices--Customer.create.2.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{ | ||
"account_balance": 0, | ||
"address": null, | ||
"balance": 0, | ||
"created": 1000000000, | ||
"currency": null, | ||
"default_source": null, | ||
"delinquent": false, | ||
"description": "lear (Lear & Co.)", | ||
"discount": null, | ||
"email": "[email protected]", | ||
"id": "cus_NORMALIZED0002", | ||
"invoice_prefix": "NORMA02", | ||
"invoice_settings": { | ||
"custom_fields": null, | ||
"default_payment_method": null, | ||
"footer": null | ||
}, | ||
"livemode": false, | ||
"metadata": { | ||
"realm_id": "2", | ||
"realm_str": "lear" | ||
}, | ||
"name": null, | ||
"next_invoice_sequence": 1, | ||
"object": "customer", | ||
"phone": null, | ||
"preferred_locales": [], | ||
"shipping": null, | ||
"sources": { | ||
"data": [], | ||
"has_more": false, | ||
"object": "list", | ||
"total_count": 0, | ||
"url": "/v1/customers/cus_NORMALIZED0002/sources" | ||
}, | ||
"subscriptions": { | ||
"data": [], | ||
"has_more": false, | ||
"object": "list", | ||
"total_count": 0, | ||
"url": "/v1/customers/cus_NORMALIZED0002/subscriptions" | ||
}, | ||
"tax_exempt": "none", | ||
"tax_ids": { | ||
"data": [], | ||
"has_more": false, | ||
"object": "list", | ||
"total_count": 0, | ||
"url": "/v1/customers/cus_NORMALIZED0002/tax_ids" | ||
}, | ||
"tax_info": null, | ||
"tax_info_verification": null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
133 changes: 133 additions & 0 deletions
133
corporate/tests/stripe_fixtures/void_all_open_invoices--Invoice.create.2.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
{ | ||
"account_country": "US", | ||
"account_name": "NORMALIZED-1", | ||
"account_tax_ids": null, | ||
"amount_due": 6400, | ||
"amount_paid": 0, | ||
"amount_remaining": 6400, | ||
"application_fee": null, | ||
"attempt_count": 0, | ||
"attempted": false, | ||
"auto_advance": true, | ||
"automatic_tax": { | ||
"enabled": false, | ||
"status": null | ||
}, | ||
"billing": "send_invoice", | ||
"billing_reason": "manual", | ||
"charge": null, | ||
"collection_method": "send_invoice", | ||
"created": 1000000000, | ||
"currency": "usd", | ||
"custom_fields": null, | ||
"customer": "cus_NORMALIZED0002", | ||
"customer_address": null, | ||
"customer_email": "[email protected]", | ||
"customer_name": null, | ||
"customer_phone": null, | ||
"customer_shipping": null, | ||
"customer_tax_exempt": "none", | ||
"customer_tax_ids": [], | ||
"date": 1000000000, | ||
"default_payment_method": null, | ||
"default_source": null, | ||
"default_tax_rates": [], | ||
"description": null, | ||
"discount": null, | ||
"discounts": [], | ||
"due_date": 1000000000, | ||
"ending_balance": null, | ||
"finalized_at": null, | ||
"footer": null, | ||
"hosted_invoice_url": null, | ||
"id": "in_NORMALIZED00000000000002", | ||
"invoice_pdf": null, | ||
"last_finalization_error": null, | ||
"lines": { | ||
"data": [ | ||
{ | ||
"amount": 6400, | ||
"currency": "usd", | ||
"description": "Zulip standard upgrade", | ||
"discount_amounts": [], | ||
"discountable": false, | ||
"discounts": [], | ||
"id": "ii_NORMALIZED00000000000002", | ||
"invoice_item": "ii_NORMALIZED00000000000002", | ||
"livemode": false, | ||
"metadata": {}, | ||
"object": "line_item", | ||
"period": { | ||
"end": 1000000000, | ||
"start": 1000000000 | ||
}, | ||
"plan": null, | ||
"price": { | ||
"active": false, | ||
"billing_scheme": "per_unit", | ||
"created": 1000000000, | ||
"currency": "usd", | ||
"id": "price_1J3ngOD2X8vgpBNG4pn2DcHN", | ||
"livemode": false, | ||
"lookup_key": null, | ||
"metadata": {}, | ||
"nickname": null, | ||
"object": "price", | ||
"product": "prod_JhC4jKCcSa3kkS", | ||
"recurring": null, | ||
"tiers_mode": null, | ||
"transform_quantity": null, | ||
"type": "one_time", | ||
"unit_amount": 800, | ||
"unit_amount_decimal": "800" | ||
}, | ||
"proration": false, | ||
"quantity": 8, | ||
"subscription": null, | ||
"tax_amounts": [], | ||
"tax_rates": [], | ||
"type": "invoiceitem", | ||
"unique_id": "il_1J3ngOD2X8vgpBNG5FHfGv4J" | ||
} | ||
], | ||
"has_more": false, | ||
"object": "list", | ||
"total_count": 1, | ||
"url": "/v1/invoices/in_NORMALIZED00000000000002/lines" | ||
}, | ||
"livemode": false, | ||
"metadata": {}, | ||
"next_payment_attempt": null, | ||
"number": "NORMALI-0002", | ||
"object": "invoice", | ||
"on_behalf_of": null, | ||
"paid": false, | ||
"payment_intent": null, | ||
"payment_settings": { | ||
"payment_method_options": null, | ||
"payment_method_types": null | ||
}, | ||
"period_end": 1000000000, | ||
"period_start": 1000000000, | ||
"post_payment_credit_notes_amount": 0, | ||
"pre_payment_credit_notes_amount": 0, | ||
"receipt_number": null, | ||
"starting_balance": 0, | ||
"statement_descriptor": "Zulip Standard", | ||
"status": "draft", | ||
"status_transitions": { | ||
"finalized_at": null, | ||
"marked_uncollectible_at": null, | ||
"paid_at": null, | ||
"voided_at": null | ||
}, | ||
"subscription": null, | ||
"subtotal": 6400, | ||
"tax": null, | ||
"tax_percent": null, | ||
"total": 6400, | ||
"total_discount_amounts": [], | ||
"total_tax_amounts": [], | ||
"transfer_data": null, | ||
"webhooks_delivered_at": null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.