mirror of
https://github.com/zulip/zulip.git
synced 2025-11-07 07:23:22 +00:00
stripe: Create get_all_invoices function.
stripe.Invoice.list by default would only get 10 invoices at a time. So a function like this would be really handy if we have to go through a lot of invoices. This also means void_all_open_invoices used to void only the last 10 invoices. The main reason we implemented this function was to void the invoices generated by realms on free trial so I don't think there were cases where we had to void realms with more than 10 invoices.
This commit is contained in:
@@ -5,7 +5,7 @@ import secrets
|
||||
from datetime import datetime, timedelta
|
||||
from decimal import Decimal
|
||||
from functools import wraps
|
||||
from typing import Callable, Dict, Optional, Tuple, TypeVar, cast
|
||||
from typing import Callable, Dict, Generator, Optional, Tuple, TypeVar, cast
|
||||
|
||||
import orjson
|
||||
import stripe
|
||||
@@ -961,13 +961,25 @@ def downgrade_at_the_end_of_billing_cycle(realm: Realm) -> None:
|
||||
do_change_plan_status(plan, CustomerPlan.DOWNGRADE_AT_END_OF_CYCLE)
|
||||
|
||||
|
||||
def get_all_invoices_for_customer(customer: Customer) -> Generator[stripe.Invoice, None, None]:
|
||||
if customer.stripe_customer_id is None:
|
||||
return
|
||||
|
||||
invoices = stripe.Invoice.list(customer=customer.stripe_customer_id, limit=100)
|
||||
while len(invoices):
|
||||
for invoice in invoices:
|
||||
yield invoice
|
||||
last_invoice = invoice
|
||||
invoices = stripe.Invoice.list(
|
||||
customer=customer.stripe_customer_id, starting_after=last_invoice, limit=100
|
||||
)
|
||||
|
||||
|
||||
def void_all_open_invoices(realm: Realm) -> int:
|
||||
customer = get_customer_by_realm(realm)
|
||||
if customer is None:
|
||||
return 0
|
||||
if customer.stripe_customer_id is None:
|
||||
return 0
|
||||
invoices = stripe.Invoice.list(customer=customer.stripe_customer_id)
|
||||
invoices = get_all_invoices_for_customer(customer)
|
||||
voided_invoices_count = 0
|
||||
for invoice in invoices:
|
||||
if invoice.status == "open":
|
||||
|
||||
@@ -67,13 +67,13 @@
|
||||
"billing_scheme": "per_unit",
|
||||
"created": 1000000000,
|
||||
"currency": "usd",
|
||||
"id": "price_1J3ngLD2X8vgpBNGNhl10Ejf",
|
||||
"id": "price_1J4k5WD2X8vgpBNGcuW1tN2f",
|
||||
"livemode": false,
|
||||
"lookup_key": null,
|
||||
"metadata": {},
|
||||
"nickname": null,
|
||||
"object": "price",
|
||||
"product": "prod_JhC49N48jYmZQ8",
|
||||
"product": "prod_JiAQvZofvelKZX",
|
||||
"recurring": null,
|
||||
"tiers_mode": null,
|
||||
"transform_quantity": null,
|
||||
@@ -87,7 +87,7 @@
|
||||
"tax_amounts": [],
|
||||
"tax_rates": [],
|
||||
"type": "invoiceitem",
|
||||
"unique_id": "il_1J3ngLD2X8vgpBNGyyqmhLYe"
|
||||
"unique_id": "il_1J4k5WD2X8vgpBNGE21GzpwP"
|
||||
}
|
||||
],
|
||||
"has_more": false,
|
||||
|
||||
@@ -67,13 +67,13 @@
|
||||
"billing_scheme": "per_unit",
|
||||
"created": 1000000000,
|
||||
"currency": "usd",
|
||||
"id": "price_1J3ngOD2X8vgpBNG4pn2DcHN",
|
||||
"id": "price_1J4k5YD2X8vgpBNGNd7J1uOm",
|
||||
"livemode": false,
|
||||
"lookup_key": null,
|
||||
"metadata": {},
|
||||
"nickname": null,
|
||||
"object": "price",
|
||||
"product": "prod_JhC4jKCcSa3kkS",
|
||||
"product": "prod_JiAQjioBLzz20A",
|
||||
"recurring": null,
|
||||
"tiers_mode": null,
|
||||
"transform_quantity": null,
|
||||
@@ -87,7 +87,7 @@
|
||||
"tax_amounts": [],
|
||||
"tax_rates": [],
|
||||
"type": "invoiceitem",
|
||||
"unique_id": "il_1J3ngOD2X8vgpBNG5FHfGv4J"
|
||||
"unique_id": "il_1J4k5YD2X8vgpBNGTl8t3uQk"
|
||||
}
|
||||
],
|
||||
"has_more": false,
|
||||
|
||||
@@ -39,9 +39,9 @@
|
||||
"ending_balance": 0,
|
||||
"finalized_at": 1000000000,
|
||||
"footer": null,
|
||||
"hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000001avHhX",
|
||||
"hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000001GUCdm",
|
||||
"id": "in_NORMALIZED00000000000001",
|
||||
"invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000001avHhX/pdf",
|
||||
"invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000001GUCdm/pdf",
|
||||
"last_finalization_error": null,
|
||||
"lines": {
|
||||
"data": [
|
||||
@@ -67,13 +67,13 @@
|
||||
"billing_scheme": "per_unit",
|
||||
"created": 1000000000,
|
||||
"currency": "usd",
|
||||
"id": "price_1J3ngLD2X8vgpBNGNhl10Ejf",
|
||||
"id": "price_1J4k5WD2X8vgpBNGcuW1tN2f",
|
||||
"livemode": false,
|
||||
"lookup_key": null,
|
||||
"metadata": {},
|
||||
"nickname": null,
|
||||
"object": "price",
|
||||
"product": "prod_JhC49N48jYmZQ8",
|
||||
"product": "prod_JiAQvZofvelKZX",
|
||||
"recurring": null,
|
||||
"tiers_mode": null,
|
||||
"transform_quantity": null,
|
||||
@@ -87,7 +87,7 @@
|
||||
"tax_amounts": [],
|
||||
"tax_rates": [],
|
||||
"type": "invoiceitem",
|
||||
"unique_id": "il_1J3ngLD2X8vgpBNGyyqmhLYe"
|
||||
"unique_id": "il_1J4k5WD2X8vgpBNGE21GzpwP"
|
||||
}
|
||||
],
|
||||
"has_more": false,
|
||||
@@ -102,7 +102,7 @@
|
||||
"object": "invoice",
|
||||
"on_behalf_of": null,
|
||||
"paid": false,
|
||||
"payment_intent": "pi_1J3ngND2X8vgpBNGOtTRK3Kn",
|
||||
"payment_intent": "pi_1J4k5YD2X8vgpBNGTHOok8yX",
|
||||
"payment_settings": {
|
||||
"payment_method_options": null,
|
||||
"payment_method_types": null
|
||||
|
||||
@@ -39,9 +39,9 @@
|
||||
"ending_balance": 0,
|
||||
"finalized_at": 1000000000,
|
||||
"footer": null,
|
||||
"hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED00000000000000027mazH",
|
||||
"hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000002rAehP",
|
||||
"id": "in_NORMALIZED00000000000002",
|
||||
"invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED00000000000000027mazH/pdf",
|
||||
"invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000002rAehP/pdf",
|
||||
"last_finalization_error": null,
|
||||
"lines": {
|
||||
"data": [
|
||||
@@ -67,13 +67,13 @@
|
||||
"billing_scheme": "per_unit",
|
||||
"created": 1000000000,
|
||||
"currency": "usd",
|
||||
"id": "price_1J3ngOD2X8vgpBNG4pn2DcHN",
|
||||
"id": "price_1J4k5YD2X8vgpBNGNd7J1uOm",
|
||||
"livemode": false,
|
||||
"lookup_key": null,
|
||||
"metadata": {},
|
||||
"nickname": null,
|
||||
"object": "price",
|
||||
"product": "prod_JhC4jKCcSa3kkS",
|
||||
"product": "prod_JiAQjioBLzz20A",
|
||||
"recurring": null,
|
||||
"tiers_mode": null,
|
||||
"transform_quantity": null,
|
||||
@@ -87,7 +87,7 @@
|
||||
"tax_amounts": [],
|
||||
"tax_rates": [],
|
||||
"type": "invoiceitem",
|
||||
"unique_id": "il_1J3ngOD2X8vgpBNG5FHfGv4J"
|
||||
"unique_id": "il_1J4k5YD2X8vgpBNGTl8t3uQk"
|
||||
}
|
||||
],
|
||||
"has_more": false,
|
||||
@@ -102,7 +102,7 @@
|
||||
"object": "invoice",
|
||||
"on_behalf_of": null,
|
||||
"paid": false,
|
||||
"payment_intent": "pi_1J3ngPD2X8vgpBNGYKpQXe19",
|
||||
"payment_intent": "pi_1J4k5aD2X8vgpBNGM1GaJWq6",
|
||||
"payment_settings": {
|
||||
"payment_method_options": null,
|
||||
"payment_method_types": null
|
||||
@@ -129,5 +129,5 @@
|
||||
"total_discount_amounts": [],
|
||||
"total_tax_amounts": [],
|
||||
"transfer_data": null,
|
||||
"webhooks_delivered_at": 1000000000
|
||||
"webhooks_delivered_at": null
|
||||
}
|
||||
|
||||
@@ -41,9 +41,9 @@
|
||||
"ending_balance": 0,
|
||||
"finalized_at": 1000000000,
|
||||
"footer": null,
|
||||
"hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000001avHhX",
|
||||
"hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000001GUCdm",
|
||||
"id": "in_NORMALIZED00000000000001",
|
||||
"invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000001avHhX/pdf",
|
||||
"invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000001GUCdm/pdf",
|
||||
"last_finalization_error": null,
|
||||
"lines": {
|
||||
"data": [
|
||||
@@ -69,13 +69,13 @@
|
||||
"billing_scheme": "per_unit",
|
||||
"created": 1000000000,
|
||||
"currency": "usd",
|
||||
"id": "price_1J3ngLD2X8vgpBNGNhl10Ejf",
|
||||
"id": "price_1J4k5WD2X8vgpBNGcuW1tN2f",
|
||||
"livemode": false,
|
||||
"lookup_key": null,
|
||||
"metadata": {},
|
||||
"nickname": null,
|
||||
"object": "price",
|
||||
"product": "prod_JhC49N48jYmZQ8",
|
||||
"product": "prod_JiAQvZofvelKZX",
|
||||
"recurring": null,
|
||||
"tiers_mode": null,
|
||||
"transform_quantity": null,
|
||||
@@ -89,7 +89,7 @@
|
||||
"tax_amounts": [],
|
||||
"tax_rates": [],
|
||||
"type": "invoiceitem",
|
||||
"unique_id": "il_1J3ngLD2X8vgpBNGyyqmhLYe"
|
||||
"unique_id": "il_1J4k5WD2X8vgpBNGE21GzpwP"
|
||||
}
|
||||
],
|
||||
"has_more": false,
|
||||
@@ -104,7 +104,7 @@
|
||||
"object": "invoice",
|
||||
"on_behalf_of": null,
|
||||
"paid": false,
|
||||
"payment_intent": "pi_1J3ngND2X8vgpBNGOtTRK3Kn",
|
||||
"payment_intent": "pi_1J4k5YD2X8vgpBNGTHOok8yX",
|
||||
"payment_settings": {
|
||||
"payment_method_options": null,
|
||||
"payment_method_types": null
|
||||
|
||||
@@ -1,139 +1,5 @@
|
||||
{
|
||||
"data": [
|
||||
{
|
||||
"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": false,
|
||||
"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_NORMALIZED0001",
|
||||
"customer_address": null,
|
||||
"customer_email": "iago@zulip.com",
|
||||
"customer_name": null,
|
||||
"customer_phone": null,
|
||||
"customer_shipping": null,
|
||||
"customer_tax_exempt": "none",
|
||||
"customer_tax_ids": [],
|
||||
"date": 1000000000,
|
||||
"default_payment_method": null,
|
||||
"default_source": null,
|
||||
"default_tax_rates": [],
|
||||
"description": null,
|
||||
"discount": null,
|
||||
"discounts": [],
|
||||
"due_date": 1000000000,
|
||||
"ending_balance": 0,
|
||||
"finalized_at": 1000000000,
|
||||
"footer": null,
|
||||
"hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000001avHhX",
|
||||
"id": "in_NORMALIZED00000000000001",
|
||||
"invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000001avHhX/pdf",
|
||||
"last_finalization_error": null,
|
||||
"lines": {
|
||||
"data": [
|
||||
{
|
||||
"amount": 6400,
|
||||
"currency": "usd",
|
||||
"description": "Zulip standard upgrade",
|
||||
"discount_amounts": [],
|
||||
"discountable": false,
|
||||
"discounts": [],
|
||||
"id": "ii_NORMALIZED00000000000001",
|
||||
"invoice_item": "ii_NORMALIZED00000000000001",
|
||||
"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_1J3ngLD2X8vgpBNGNhl10Ejf",
|
||||
"livemode": false,
|
||||
"lookup_key": null,
|
||||
"metadata": {},
|
||||
"nickname": null,
|
||||
"object": "price",
|
||||
"product": "prod_JhC49N48jYmZQ8",
|
||||
"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_1J3ngLD2X8vgpBNGyyqmhLYe"
|
||||
}
|
||||
],
|
||||
"has_more": false,
|
||||
"object": "list",
|
||||
"total_count": 1,
|
||||
"url": "/v1/invoices/in_NORMALIZED00000000000001/lines"
|
||||
},
|
||||
"livemode": false,
|
||||
"metadata": {},
|
||||
"next_payment_attempt": null,
|
||||
"number": "NORMALI-0001",
|
||||
"object": "invoice",
|
||||
"on_behalf_of": null,
|
||||
"paid": false,
|
||||
"payment_intent": "pi_1J3ngND2X8vgpBNGOtTRK3Kn",
|
||||
"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": "void",
|
||||
"status_transitions": {
|
||||
"finalized_at": 1000000000,
|
||||
"marked_uncollectible_at": null,
|
||||
"paid_at": null,
|
||||
"voided_at": 1000000000
|
||||
},
|
||||
"subscription": null,
|
||||
"subtotal": 6400,
|
||||
"tax": null,
|
||||
"tax_percent": null,
|
||||
"total": 6400,
|
||||
"total_discount_amounts": [],
|
||||
"total_tax_amounts": [],
|
||||
"transfer_data": null,
|
||||
"webhooks_delivered_at": 1000000000
|
||||
}
|
||||
],
|
||||
"data": [],
|
||||
"has_more": false,
|
||||
"object": "list",
|
||||
"url": "/v1/invoices"
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"application_fee": null,
|
||||
"attempt_count": 0,
|
||||
"attempted": false,
|
||||
"auto_advance": true,
|
||||
"auto_advance": false,
|
||||
"automatic_tax": {
|
||||
"enabled": false,
|
||||
"status": null
|
||||
@@ -22,9 +22,9 @@
|
||||
"created": 1000000000,
|
||||
"currency": "usd",
|
||||
"custom_fields": null,
|
||||
"customer": "cus_NORMALIZED0002",
|
||||
"customer": "cus_NORMALIZED0001",
|
||||
"customer_address": null,
|
||||
"customer_email": "king@lear.org",
|
||||
"customer_email": "iago@zulip.com",
|
||||
"customer_name": null,
|
||||
"customer_phone": null,
|
||||
"customer_shipping": null,
|
||||
@@ -41,9 +41,9 @@
|
||||
"ending_balance": 0,
|
||||
"finalized_at": 1000000000,
|
||||
"footer": null,
|
||||
"hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED00000000000000027mazH",
|
||||
"id": "in_NORMALIZED00000000000002",
|
||||
"invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED00000000000000027mazH/pdf",
|
||||
"hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000001GUCdm",
|
||||
"id": "in_NORMALIZED00000000000001",
|
||||
"invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000001GUCdm/pdf",
|
||||
"last_finalization_error": null,
|
||||
"lines": {
|
||||
"data": [
|
||||
@@ -54,8 +54,8 @@
|
||||
"discount_amounts": [],
|
||||
"discountable": false,
|
||||
"discounts": [],
|
||||
"id": "ii_NORMALIZED00000000000002",
|
||||
"invoice_item": "ii_NORMALIZED00000000000002",
|
||||
"id": "ii_NORMALIZED00000000000001",
|
||||
"invoice_item": "ii_NORMALIZED00000000000001",
|
||||
"livemode": false,
|
||||
"metadata": {},
|
||||
"object": "line_item",
|
||||
@@ -69,13 +69,13 @@
|
||||
"billing_scheme": "per_unit",
|
||||
"created": 1000000000,
|
||||
"currency": "usd",
|
||||
"id": "price_1J3ngOD2X8vgpBNG4pn2DcHN",
|
||||
"id": "price_1J4k5WD2X8vgpBNGcuW1tN2f",
|
||||
"livemode": false,
|
||||
"lookup_key": null,
|
||||
"metadata": {},
|
||||
"nickname": null,
|
||||
"object": "price",
|
||||
"product": "prod_JhC4jKCcSa3kkS",
|
||||
"product": "prod_JiAQvZofvelKZX",
|
||||
"recurring": null,
|
||||
"tiers_mode": null,
|
||||
"transform_quantity": null,
|
||||
@@ -89,22 +89,22 @@
|
||||
"tax_amounts": [],
|
||||
"tax_rates": [],
|
||||
"type": "invoiceitem",
|
||||
"unique_id": "il_1J3ngOD2X8vgpBNG5FHfGv4J"
|
||||
"unique_id": "il_1J4k5WD2X8vgpBNGE21GzpwP"
|
||||
}
|
||||
],
|
||||
"has_more": false,
|
||||
"object": "list",
|
||||
"total_count": 1,
|
||||
"url": "/v1/invoices/in_NORMALIZED00000000000002/lines"
|
||||
"url": "/v1/invoices/in_NORMALIZED00000000000001/lines"
|
||||
},
|
||||
"livemode": false,
|
||||
"metadata": {},
|
||||
"next_payment_attempt": null,
|
||||
"number": "NORMALI-0002",
|
||||
"number": "NORMALI-0001",
|
||||
"object": "invoice",
|
||||
"on_behalf_of": null,
|
||||
"paid": false,
|
||||
"payment_intent": "pi_1J3ngPD2X8vgpBNGYKpQXe19",
|
||||
"payment_intent": "pi_1J4k5YD2X8vgpBNGTHOok8yX",
|
||||
"payment_settings": {
|
||||
"payment_method_options": null,
|
||||
"payment_method_types": null
|
||||
@@ -116,12 +116,12 @@
|
||||
"receipt_number": null,
|
||||
"starting_balance": 0,
|
||||
"statement_descriptor": "Zulip Standard",
|
||||
"status": "open",
|
||||
"status": "void",
|
||||
"status_transitions": {
|
||||
"finalized_at": 1000000000,
|
||||
"marked_uncollectible_at": null,
|
||||
"paid_at": null,
|
||||
"voided_at": null
|
||||
"voided_at": 1000000000
|
||||
},
|
||||
"subscription": null,
|
||||
"subtotal": 6400,
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"application_fee": null,
|
||||
"attempt_count": 0,
|
||||
"attempted": false,
|
||||
"auto_advance": false,
|
||||
"auto_advance": true,
|
||||
"automatic_tax": {
|
||||
"enabled": false,
|
||||
"status": null
|
||||
@@ -41,9 +41,9 @@
|
||||
"ending_balance": 0,
|
||||
"finalized_at": 1000000000,
|
||||
"footer": null,
|
||||
"hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED00000000000000027mazH",
|
||||
"hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000002rAehP",
|
||||
"id": "in_NORMALIZED00000000000002",
|
||||
"invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED00000000000000027mazH/pdf",
|
||||
"invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000002rAehP/pdf",
|
||||
"last_finalization_error": null,
|
||||
"lines": {
|
||||
"data": [
|
||||
@@ -69,13 +69,13 @@
|
||||
"billing_scheme": "per_unit",
|
||||
"created": 1000000000,
|
||||
"currency": "usd",
|
||||
"id": "price_1J3ngOD2X8vgpBNG4pn2DcHN",
|
||||
"id": "price_1J4k5YD2X8vgpBNGNd7J1uOm",
|
||||
"livemode": false,
|
||||
"lookup_key": null,
|
||||
"metadata": {},
|
||||
"nickname": null,
|
||||
"object": "price",
|
||||
"product": "prod_JhC4jKCcSa3kkS",
|
||||
"product": "prod_JiAQjioBLzz20A",
|
||||
"recurring": null,
|
||||
"tiers_mode": null,
|
||||
"transform_quantity": null,
|
||||
@@ -89,7 +89,7 @@
|
||||
"tax_amounts": [],
|
||||
"tax_rates": [],
|
||||
"type": "invoiceitem",
|
||||
"unique_id": "il_1J3ngOD2X8vgpBNG5FHfGv4J"
|
||||
"unique_id": "il_1J4k5YD2X8vgpBNGTl8t3uQk"
|
||||
}
|
||||
],
|
||||
"has_more": false,
|
||||
@@ -104,7 +104,7 @@
|
||||
"object": "invoice",
|
||||
"on_behalf_of": null,
|
||||
"paid": false,
|
||||
"payment_intent": "pi_1J3ngPD2X8vgpBNGYKpQXe19",
|
||||
"payment_intent": "pi_1J4k5aD2X8vgpBNGM1GaJWq6",
|
||||
"payment_settings": {
|
||||
"payment_method_options": null,
|
||||
"payment_method_types": null
|
||||
@@ -116,12 +116,12 @@
|
||||
"receipt_number": null,
|
||||
"starting_balance": 0,
|
||||
"statement_descriptor": "Zulip Standard",
|
||||
"status": "void",
|
||||
"status": "open",
|
||||
"status_transitions": {
|
||||
"finalized_at": 1000000000,
|
||||
"marked_uncollectible_at": null,
|
||||
"paid_at": null,
|
||||
"voided_at": 1000000000
|
||||
"voided_at": null
|
||||
},
|
||||
"subscription": null,
|
||||
"subtotal": 6400,
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"data": [],
|
||||
"has_more": false,
|
||||
"object": "list",
|
||||
"url": "/v1/invoices"
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
{
|
||||
"data": [
|
||||
{
|
||||
"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": false,
|
||||
"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": "king@lear.org",
|
||||
"customer_name": null,
|
||||
"customer_phone": null,
|
||||
"customer_shipping": null,
|
||||
"customer_tax_exempt": "none",
|
||||
"customer_tax_ids": [],
|
||||
"date": 1000000000,
|
||||
"default_payment_method": null,
|
||||
"default_source": null,
|
||||
"default_tax_rates": [],
|
||||
"description": null,
|
||||
"discount": null,
|
||||
"discounts": [],
|
||||
"due_date": 1000000000,
|
||||
"ending_balance": 0,
|
||||
"finalized_at": 1000000000,
|
||||
"footer": null,
|
||||
"hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000002rAehP",
|
||||
"id": "in_NORMALIZED00000000000002",
|
||||
"invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000002rAehP/pdf",
|
||||
"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_1J4k5YD2X8vgpBNGNd7J1uOm",
|
||||
"livemode": false,
|
||||
"lookup_key": null,
|
||||
"metadata": {},
|
||||
"nickname": null,
|
||||
"object": "price",
|
||||
"product": "prod_JiAQjioBLzz20A",
|
||||
"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_1J4k5YD2X8vgpBNGTl8t3uQk"
|
||||
}
|
||||
],
|
||||
"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": "pi_1J4k5aD2X8vgpBNGM1GaJWq6",
|
||||
"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": "void",
|
||||
"status_transitions": {
|
||||
"finalized_at": 1000000000,
|
||||
"marked_uncollectible_at": null,
|
||||
"paid_at": null,
|
||||
"voided_at": 1000000000
|
||||
},
|
||||
"subscription": null,
|
||||
"subtotal": 6400,
|
||||
"tax": null,
|
||||
"tax_percent": null,
|
||||
"total": 6400,
|
||||
"total_discount_amounts": [],
|
||||
"total_tax_amounts": [],
|
||||
"transfer_data": null,
|
||||
"webhooks_delivered_at": 1000000000
|
||||
}
|
||||
],
|
||||
"has_more": false,
|
||||
"object": "list",
|
||||
"url": "/v1/invoices"
|
||||
}
|
||||
@@ -39,9 +39,9 @@
|
||||
"ending_balance": 0,
|
||||
"finalized_at": 1000000000,
|
||||
"footer": null,
|
||||
"hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000001avHhX",
|
||||
"hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000001GUCdm",
|
||||
"id": "in_NORMALIZED00000000000001",
|
||||
"invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000001avHhX/pdf",
|
||||
"invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000001GUCdm/pdf",
|
||||
"last_finalization_error": null,
|
||||
"lines": {
|
||||
"data": [
|
||||
@@ -67,13 +67,13 @@
|
||||
"billing_scheme": "per_unit",
|
||||
"created": 1000000000,
|
||||
"currency": "usd",
|
||||
"id": "price_1J3ngLD2X8vgpBNGNhl10Ejf",
|
||||
"id": "price_1J4k5WD2X8vgpBNGcuW1tN2f",
|
||||
"livemode": false,
|
||||
"lookup_key": null,
|
||||
"metadata": {},
|
||||
"nickname": null,
|
||||
"object": "price",
|
||||
"product": "prod_JhC49N48jYmZQ8",
|
||||
"product": "prod_JiAQvZofvelKZX",
|
||||
"recurring": null,
|
||||
"tiers_mode": null,
|
||||
"transform_quantity": null,
|
||||
@@ -87,7 +87,7 @@
|
||||
"tax_amounts": [],
|
||||
"tax_rates": [],
|
||||
"type": "invoiceitem",
|
||||
"unique_id": "il_1J3ngLD2X8vgpBNGyyqmhLYe"
|
||||
"unique_id": "il_1J4k5WD2X8vgpBNGE21GzpwP"
|
||||
}
|
||||
],
|
||||
"has_more": false,
|
||||
@@ -102,7 +102,7 @@
|
||||
"object": "invoice",
|
||||
"on_behalf_of": null,
|
||||
"paid": false,
|
||||
"payment_intent": "pi_1J3ngND2X8vgpBNGOtTRK3Kn",
|
||||
"payment_intent": "pi_1J4k5YD2X8vgpBNGTHOok8yX",
|
||||
"payment_settings": {
|
||||
"payment_method_options": null,
|
||||
"payment_method_types": null
|
||||
|
||||
@@ -39,9 +39,9 @@
|
||||
"ending_balance": 0,
|
||||
"finalized_at": 1000000000,
|
||||
"footer": null,
|
||||
"hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED00000000000000027mazH",
|
||||
"hosted_invoice_url": "https://invoice.stripe.com/i/acct_NORMALIZED000001/invst_NORMALIZED0000000000000002rAehP",
|
||||
"id": "in_NORMALIZED00000000000002",
|
||||
"invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED00000000000000027mazH/pdf",
|
||||
"invoice_pdf": "https://pay.stripe.com/invoice/acct_NORMALIZED000001/invst_NORMALIZED0000000000000002rAehP/pdf",
|
||||
"last_finalization_error": null,
|
||||
"lines": {
|
||||
"data": [
|
||||
@@ -67,13 +67,13 @@
|
||||
"billing_scheme": "per_unit",
|
||||
"created": 1000000000,
|
||||
"currency": "usd",
|
||||
"id": "price_1J3ngOD2X8vgpBNG4pn2DcHN",
|
||||
"id": "price_1J4k5YD2X8vgpBNGNd7J1uOm",
|
||||
"livemode": false,
|
||||
"lookup_key": null,
|
||||
"metadata": {},
|
||||
"nickname": null,
|
||||
"object": "price",
|
||||
"product": "prod_JhC4jKCcSa3kkS",
|
||||
"product": "prod_JiAQjioBLzz20A",
|
||||
"recurring": null,
|
||||
"tiers_mode": null,
|
||||
"transform_quantity": null,
|
||||
@@ -87,7 +87,7 @@
|
||||
"tax_amounts": [],
|
||||
"tax_rates": [],
|
||||
"type": "invoiceitem",
|
||||
"unique_id": "il_1J3ngOD2X8vgpBNG5FHfGv4J"
|
||||
"unique_id": "il_1J4k5YD2X8vgpBNGTl8t3uQk"
|
||||
}
|
||||
],
|
||||
"has_more": false,
|
||||
@@ -102,7 +102,7 @@
|
||||
"object": "invoice",
|
||||
"on_behalf_of": null,
|
||||
"paid": false,
|
||||
"payment_intent": "pi_1J3ngPD2X8vgpBNGYKpQXe19",
|
||||
"payment_intent": "pi_1J4k5aD2X8vgpBNGM1GaJWq6",
|
||||
"payment_settings": {
|
||||
"payment_method_options": null,
|
||||
"payment_method_types": null
|
||||
|
||||
@@ -21,13 +21,13 @@
|
||||
"billing_scheme": "per_unit",
|
||||
"created": 1000000000,
|
||||
"currency": "usd",
|
||||
"id": "price_1J3ngLD2X8vgpBNGNhl10Ejf",
|
||||
"id": "price_1J4k5WD2X8vgpBNGcuW1tN2f",
|
||||
"livemode": false,
|
||||
"lookup_key": null,
|
||||
"metadata": {},
|
||||
"nickname": null,
|
||||
"object": "price",
|
||||
"product": "prod_JhC49N48jYmZQ8",
|
||||
"product": "prod_JiAQvZofvelKZX",
|
||||
"recurring": null,
|
||||
"tiers_mode": null,
|
||||
"transform_quantity": null,
|
||||
|
||||
@@ -21,13 +21,13 @@
|
||||
"billing_scheme": "per_unit",
|
||||
"created": 1000000000,
|
||||
"currency": "usd",
|
||||
"id": "price_1J3ngOD2X8vgpBNG4pn2DcHN",
|
||||
"id": "price_1J4k5YD2X8vgpBNGNd7J1uOm",
|
||||
"livemode": false,
|
||||
"lookup_key": null,
|
||||
"metadata": {},
|
||||
"nickname": null,
|
||||
"object": "price",
|
||||
"product": "prod_JhC4jKCcSa3kkS",
|
||||
"product": "prod_JiAQjioBLzz20A",
|
||||
"recurring": null,
|
||||
"tiers_mode": null,
|
||||
"transform_quantity": null,
|
||||
|
||||
@@ -65,8 +65,10 @@ class Invoice:
|
||||
...
|
||||
|
||||
@staticmethod
|
||||
def list(billing: str=..., customer: str=..., limit: Optional[int]=...,
|
||||
status: str=...) -> List[Invoice]:
|
||||
def list(billing: str=..., customer: str=...,
|
||||
status: str=..., limit: Optional[int]=...,
|
||||
starting_after: Optional[Invoice]=...,
|
||||
) -> List[Invoice]:
|
||||
...
|
||||
|
||||
@staticmethod
|
||||
|
||||
Reference in New Issue
Block a user