code
stringlengths
34
10.1k
nl
stringlengths
52
6.18k
import stripe stripe.api_key = "sk_test_your_key" stripe.checkout.Session.retrieve( "cs_test_a15vFKPu138xjcETgEZfTyxnbkKfnzQK1lY1QsG5fRTht29TiQtRu6BG2I", ) '''Response { "id": "cs_test_a15vFKPu138xjcETgEZfTyxnbkKfnzQK1lY1QsG5fRTht29TiQtRu6BG2I", "object": "checkout.session", "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": "https://example.com/cancel", "client_reference_id": null, "consent": null, "consent_collection": null, "currency": null, "customer": null, "customer_creation": null, "customer_details": null, "customer_email": null, "expires_at": 1659518871, "livemode": false, "locale": null, "metadata": {}, "mode": "payment", "payment_intent": "pi_1DrPsv2eZvKYlo2CEDzqXfPH", "payment_link": null, "payment_method_options": {}, "payment_method_types": [ "card" ], "payment_status": "unpaid", "phone_number_collection": { "enabled": false }, "recovered_from": null, "redaction": null, "setup_intent": null, "shipping_address_collection": null, "shipping_cost": null, "shipping_details": null, "shipping_options": [], "status": "expired", "submit_type": null, "subscription": null, "success_url": "https://example.com/success", "total_details": null, "url": null }'''
Retrieve a SessionRetrieves a Session object.ParametersNo parameters.ReturnsReturns a Session object
import stripe stripe.api_key = "sk_test_your_key" stripe.checkout.Session.list(limit=3) '''Response { "object": "list", "url": "/v1/checkout/sessions", "has_more": false, "data": [ { "id": "cs_test_a15vFKPu138xjcETgEZfTyxnbkKfnzQK1lY1QsG5fRTht29TiQtRu6BG2I", "object": "checkout.session", "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": "https://example.com/cancel", "client_reference_id": null, "consent": null, "consent_collection": null, "currency": null, "customer": null, "customer_creation": null, "customer_details": null, "customer_email": null, "expires_at": 1659518871, "livemode": false, "locale": null, "metadata": {}, "mode": "payment", "payment_intent": "pi_1DrPsv2eZvKYlo2CEDzqXfPH", "payment_link": null, "payment_method_options": {}, "payment_method_types": [ "card" ], "payment_status": "unpaid", "phone_number_collection": { "enabled": false }, "recovered_from": null, "redaction": null, "setup_intent": null, "shipping_address_collection": null, "shipping_cost": null, "shipping_details": null, "shipping_options": [], "status": "expired", "submit_type": null, "subscription": null, "success_url": "https://example.com/success", "total_details": null, "url": null }, {...}, {...} ] }'''
List all Checkout SessionsReturns a list of Checkout Sessions.Parameters payment_intent optional Only return the Checkout Session for the PaymentIntent specified. subscription optional Only return the Checkout Session for the subscription specified.More parametersExpand all customer optional customer_details optional dictionary ending_before optional limit optional starting_after optional ReturnsA dictionary with a data property that contains an array of up to limit Checkout Sessions, starting after Checkout Session starting_after. Each entry in the array is a separate Checkout Session object. If no more Checkout Sessions are available, the resulting array will be empty.
import stripe stripe.api_key = "sk_test_your_key" line_items = stripe.checkout.Session.list_line_items('cs_test_a15vFKPu138xjcETgEZfTyxnbkKfnzQK1lY1QsG5fRTht29TiQtRu6BG2I', limit=5) '''Response { "object": "list", "url": "/v1/checkout/sessions/cs_test_a15vFKPu138xjcETgEZfTyxnbkKfnzQK1lY1QsG5fRTht29TiQtRu6BG2I/line_items", "has_more": false, "data": [ { "id": "li_1LSdrn2eZvKYlo2C0Ue410Gc", "object": "item", "amount_discount": 0, "amount_subtotal": 0, "amount_tax": 0, "amount_total": 0, "currency": "usd", "description": "auto topup addtional_viewer", "price": { "id": "price_1LScCX2eZvKYlo2C1Z9zPyXF", "object": "price", "active": true, "billing_scheme": "per_unit", "created": 1659512469, "currency": "usd", "custom_unit_amount": null, "livemode": false, "lookup_key": null, "metadata": {}, "nickname": null, "product": "prod_MAy8UvSA0uRRju", "recurring": null, "tax_behavior": "unspecified", "tiers_mode": null, "transform_quantity": null, "type": "one_time", "unit_amount": 300, "unit_amount_decimal": "300" }, "quantity": 1 }, {...}, {...} ] }'''
Retrieve a Checkout Session's line itemsWhen retrieving a Checkout Session, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items.ParametersExpand all ending_before optional limit optional starting_after optional ReturnsA dictionary with a data property that contains an array of up to limit Checkout Session line items, starting after Line Item starting_after. Each entry in the array is a separate Line Item object. If no more line items are available, the resulting array will be empty.
'''Endpoints  POST /v1/payment_links   GET /v1/payment_links/:id  POST /v1/payment_links/:id   GET /v1/payment_links   GET /v1/payment_links/:id/line_items '''
Payment LinkA payment link is a shareable URL that will take your customers to a hosted payment page. A payment link can be shared and used multiple times.When a customer opens a payment link it will open a new checkout session to render the payment page. You can use checkout session events to track payments through payment links.
'''The payment link object { "id": "plink_1LSdsx2eZvKYlo2CdmenOg9N", "object": "payment_link", "active": true, "after_completion": { "hosted_confirmation": { "custom_message": null }, "type": "hosted_confirmation" }, "allow_promotion_codes": false, "application_fee_amount": null, "application_fee_percent": null, "automatic_tax": { "enabled": false }, "billing_address_collection": "auto", "consent_collection": null, "currency": "usd", "customer_creation": "always", "livemode": false, "metadata": {}, "on_behalf_of": null, "payment_intent_data": null, "payment_method_types": null, "phone_number_collection": { "enabled": false }, "shipping_address_collection": null, "shipping_options": [], "submit_type": "auto", "subscription_data": null, "tax_id_collection": { "enabled": false }, "transfer_data": null, "url": "https://buy.stripe.com/test_5kAcPyarJaIPaQg4gg" } '''
The payment link objectAttributes id string Unique identifier for the object. active boolean Whether the payment link’s url is active. If false, customers visiting the URL will be shown a page saying that the link has been deactivated. line_items list expandable The line items representing what is being sold. This field is not included by default. To include it in the response, expand the line_items field.Show child attributes metadata hash Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. payment_method_types array of enum values The list of payment method types that customers can use. When null, Stripe will dynamically show relevant payment methods you’ve enabled in your payment method settings.Possible enum valuescard affirm promptpay bacs_debit bancontact blik boleto Show 17 more url string The public URL that can be shared with customers.More attributesExpand all object string, value is "payment_link" after_completion hash allow_promotion_codes boolean application_fee_amount integer Connect only application_fee_percent decimal Connect only automatic_tax hash billing_address_collection enum consent_collection hash currency currency preview feature customer_creation enum livemode boolean on_behalf_of string expandable Connect only payment_intent_data hash phone_number_collection hash shipping_address_collection hash shipping_options array of hashes submit_type enum subscription_data hash tax_id_collection hash transfer_data hash Connect only
import stripe stripe.api_key = "sk_test_your_key" stripe.PaymentLink.create( line_items=[ { "price": "price_1LSTX02eZvKYlo2CrKMGl6Dy", "quantity": 1, }, ], ) '''Response { "id": "plink_1LSdsx2eZvKYlo2CdmenOg9N", "object": "payment_link", "active": true, "after_completion": { "hosted_confirmation": { "custom_message": null }, "type": "hosted_confirmation" }, "allow_promotion_codes": false, "application_fee_amount": null, "application_fee_percent": null, "automatic_tax": { "enabled": false }, "billing_address_collection": "auto", "consent_collection": null, "currency": "usd", "customer_creation": "always", "livemode": false, "metadata": {}, "on_behalf_of": null, "payment_intent_data": null, "payment_method_types": null, "phone_number_collection": { "enabled": false }, "shipping_address_collection": null, "shipping_options": [], "submit_type": "auto", "subscription_data": null, "tax_id_collection": { "enabled": false }, "transfer_data": null, "url": "https://buy.stripe.com/test_5kAcPyarJaIPaQg4gg" }'''
Create a payment linkCreates a payment link.Parameters line_items required The line items representing what is being sold. Each line item represents an item being sold. Up to 20 line items are supported.Show child parameters metadata optional dictionary Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to metadata. Metadata associated with this Payment Link will automatically be copied to checkout sessions created by this payment link. payment_method_types optional enum The list of payment method types that customers can use. If no value is passed, Stripe will dynamically show relevant payment methods from your payment method settings (20+ payment methods supported).Possible enum valuescard affirm promptpay bacs_debit bancontact blik boleto Show 17 moreMore parametersExpand all after_completion optional dictionary allow_promotion_codes optional application_fee_amount optional Connect only application_fee_percent optional Connect only automatic_tax optional dictionary billing_address_collection optional enum consent_collection optional dictionary currency optional preview feature customer_creation optional enum on_behalf_of optional Connect only payment_intent_data optional dictionary phone_number_collection optional dictionary shipping_address_collection optional dictionary shipping_options optional array of hashes submit_type optional enum subscription_data optional dictionary tax_id_collection optional dictionary transfer_data optional dictionary Connect only ReturnsReturns the payment link
import stripe stripe.api_key = "sk_test_your_key" stripe.PaymentLink.retrieve( "plink_1LSdsx2eZvKYlo2CdmenOg9N", ) '''Response { "id": "plink_1LSdsx2eZvKYlo2CdmenOg9N", "object": "payment_link", "active": true, "after_completion": { "hosted_confirmation": { "custom_message": null }, "type": "hosted_confirmation" }, "allow_promotion_codes": false, "application_fee_amount": null, "application_fee_percent": null, "automatic_tax": { "enabled": false }, "billing_address_collection": "auto", "consent_collection": null, "currency": "usd", "customer_creation": "always", "livemode": false, "metadata": {}, "on_behalf_of": null, "payment_intent_data": null, "payment_method_types": null, "phone_number_collection": { "enabled": false }, "shipping_address_collection": null, "shipping_options": [], "submit_type": "auto", "subscription_data": null, "tax_id_collection": { "enabled": false }, "transfer_data": null, "url": "https://buy.stripe.com/test_5kAcPyarJaIPaQg4gg" }'''
Retrieve payment linkRetrieve a payment link.ParametersNo parameters.ReturnsReturns the payment link
import stripe stripe.api_key = "sk_test_your_key" stripe.PaymentLink.modify( "plink_1LSdsx2eZvKYlo2CdmenOg9N", active=False, ) '''Response { "id": "plink_1LSdsx2eZvKYlo2CdmenOg9N", "object": "payment_link", "active": false, "after_completion": { "hosted_confirmation": { "custom_message": null }, "type": "hosted_confirmation" }, "allow_promotion_codes": false, "application_fee_amount": null, "application_fee_percent": null, "automatic_tax": { "enabled": false }, "billing_address_collection": "auto", "consent_collection": null, "currency": "usd", "customer_creation": "always", "livemode": false, "metadata": {}, "on_behalf_of": null, "payment_intent_data": null, "payment_method_types": null, "phone_number_collection": { "enabled": false }, "shipping_address_collection": null, "shipping_options": [], "submit_type": "auto", "subscription_data": null, "tax_id_collection": { "enabled": false }, "transfer_data": null, "url": "https://buy.stripe.com/test_5kAcPyarJaIPaQg4gg" }'''
Update a payment linkUpdates a payment link.Parameters active optional Whether the payment link’s url is active. If false, customers visiting the URL will be shown a page saying that the link has been deactivated. line_items optional array of hashes The line items representing what is being sold. Each line item represents an item being sold. Up to 20 line items are supported.Show child parameters metadata optional dictionary Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to metadata. Metadata associated with this Payment Link will automatically be copied to checkout sessions created by this payment link. payment_method_types optional enum The list of payment method types that customers can use. Pass an empty string to enable automatic payment methods that use your payment method settings.Possible enum valuescard affirm promptpay bacs_debit bancontact blik boleto Show 17 moreMore parametersExpand all after_completion optional dictionary allow_promotion_codes optional automatic_tax optional dictionary billing_address_collection optional enum customer_creation optional enum shipping_address_collection optional dictionary ReturnsUpdated payment link
import stripe stripe.api_key = "sk_test_your_key" stripe.PaymentLink.list(limit=3) '''Response { "object": "list", "url": "/v1/payment_links", "has_more": false, "data": [ { "id": "plink_1LSdsx2eZvKYlo2CdmenOg9N", "object": "payment_link", "active": true, "after_completion": { "hosted_confirmation": { "custom_message": null }, "type": "hosted_confirmation" }, "allow_promotion_codes": false, "application_fee_amount": null, "application_fee_percent": null, "automatic_tax": { "enabled": false }, "billing_address_collection": "auto", "consent_collection": null, "currency": "usd", "customer_creation": "always", "livemode": false, "metadata": {}, "on_behalf_of": null, "payment_intent_data": null, "payment_method_types": null, "phone_number_collection": { "enabled": false }, "shipping_address_collection": null, "shipping_options": [], "submit_type": "auto", "subscription_data": null, "tax_id_collection": { "enabled": false }, "transfer_data": null, "url": "https://buy.stripe.com/test_5kAcPyarJaIPaQg4gg" }, {...}, {...} ] }'''
List all payment linksReturns a list of your payment links.Parameters active optional Only return payment links that are active or inactive (e.g., pass false to list all inactive payment links).More parametersExpand all ending_before optional limit optional starting_after optional ReturnsA dictionary with a data property that contains an array of up to limit payment links, starting after payment link starting_after. Each entry in the array is a separate payment link object. If no more payment links are available, the resulting array will be empty. This request should never raise an error
import stripe stripe.api_key = "sk_test_your_key" line_items = stripe.PaymentLink.list_line_items('plink_1LSdsx2eZvKYlo2CdmenOg9N', limit=3) '''Response { "object": "list", "url": "/v1/payment_links/plink_1LSdsx2eZvKYlo2CdmenOg9N/line_items", "has_more": false, "data": [ { "id": "li_1LSdsx2eZvKYlo2C8QCXS44I", "object": "item", "amount_discount": 0, "amount_subtotal": 0, "amount_tax": 0, "amount_total": 0, "currency": "usd", "description": "auto topup addtional_viewer", "price": { "id": "price_1LScCX2eZvKYlo2C1Z9zPyXF", "object": "price", "active": true, "billing_scheme": "per_unit", "created": 1659512469, "currency": "usd", "custom_unit_amount": null, "livemode": false, "lookup_key": null, "metadata": {}, "nickname": null, "product": "prod_MAy8UvSA0uRRju", "recurring": null, "tax_behavior": "unspecified", "tiers_mode": null, "transform_quantity": null, "type": "one_time", "unit_amount": 300, "unit_amount_decimal": "300" }, "quantity": 1 }, {...}, {...} ] }'''
Retrieve a payment link's line itemsWhen retrieving a payment link, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items.ParametersExpand all ending_before optional limit optional starting_after optional ReturnsA dictionary with a data property that contains an array of up to limit payment link line items, starting after Line Item starting_after. Each entry in the array is a separate Line Item object. If no more line items are available, the resulting array will be empty.
'''Endpoints   GET /v1/credit_notes/preview  POST /v1/credit_notes   GET /v1/credit_notes/:id  POST /v1/credit_notes/:id   GET /v1/credit_notes/:credit_note/lines   GET /v1/credit_notes/preview/lines  POST /v1/credit_notes/:id/void   GET /v1/credit_notes '''
Credit NoteIssue a credit note to adjust an invoice's amount after the invoice is finalized.
'''The credit note object { "id": "cn_1LSdb92eZvKYlo2C0JdIQVHd", "object": "credit_note", "amount": 857, "created": 1659517839, "currency": "usd", "customer": "cus_8TEMHVY5moxIPI", "customer_balance_transaction": null, "discount_amount": 0, "discount_amounts": [], "invoice": "in_1LSdb92eZvKYlo2CJvl4iJuW", "lines": { "object": "list", "data": [ { "id": "cnli_1LSdb92eZvKYlo2Cu4lDIS7X", "object": "credit_note_line_item", "amount": 357, "amount_excluding_tax": 357, "description": "My First Invoice Item (created for API docs)", "discount_amount": 0, "discount_amounts": [], "invoice_line_item": "il_1LSdb92eZvKYlo2Cg5Kr2nEp", "livemode": false, "quantity": 1, "tax_amounts": [ { "amount": 57, "inclusive": false, "tax_rate": "txr_1LSdb92eZvKYlo2CboQRs5G6" } ], "tax_rates": [ { "id": "txr_1LSdb92eZvKYlo2CboQRs5G6", "object": "tax_rate", "active": true, "country": "DE", "created": 1659517839, "description": "VAT Germany", "display_name": "VAT", "inclusive": false, "jurisdiction": "DE", "livemode": false, "metadata": {}, "percentage": 19.0, "state": null, "tax_type": "vat" } ], "type": "invoice_line_item", "unit_amount": null, "unit_amount_decimal": null, "unit_amount_excluding_tax": "357" }, { "id": "cnli_1LSdb92eZvKYlo2C9yhKwMbp", "object": "credit_note_line_item", "amount": 500, "amount_excluding_tax": 500, "description": "Service credit", "discount_amount": 0, "discount_amounts": [], "livemode": false, "quantity": 1, "tax_amounts": [], "tax_rates": [], "type": "custom_line_item", "unit_amount": 500, "unit_amount_decimal": "500", "unit_amount_excluding_tax": "500" } ], "has_more": false, "url": "/v1/credit_notes/cn_1LSdb92eZvKYlo2C0JdIQVHd/lines" }, "livemode": false, "memo": null, "metadata": {}, "number": "ABCD-1234-CN-01", "out_of_band_amount": null, "pdf": "https://pay.stripe.com/credit_notes/acct_1032D82eZvKYlo2C/cnst_123456789/pdf?s=ap", "reason": null, "refund": null, "status": "issued", "subtotal": 857, "subtotal_excluding_tax": 857, "tax_amounts": [ { "amount": 57, "inclusive": false, "tax_rate": "txr_1LSdb92eZvKYlo2CboQRs5G6" } ], "total": 857, "total_excluding_tax": null, "type": "pre_payment", "voided_at": null } '''
The credit note objectAttributes id string Unique identifier for the object. currency currency Three-letter ISO currency code, in lowercase. Must be a supported currency. invoice string expandable ID of the invoice. lines list Line items that make up the credit noteShow child attributes memo string Customer-facing text that appears on the credit note PDF. metadata hash Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. reason string Reason for issuing this credit note, one of duplicate, fraudulent, order_change, or product_unsatisfactory status string Status of this credit note, one of issued or void. Learn more about voiding credit notes. subtotal integer The integer amount in pence representing the amount of the credit note, excluding exclusive tax and invoice level discounts. total integer The integer amount in pence representing the total amount of the credit note, including tax and all discount.More attributesExpand all object string, value is "credit_note" amount integer created timestamp customer string expandable customer_balance_transaction string expandable discount_amount integer Deprecated discount_amounts array of hashes livemode boolean number string out_of_band_amount integer pdf string refund string expandable subtotal_excluding_tax integer tax_amounts array of hashes total_excluding_tax integer type string voided_at timestamp
'''The (Credit Note) line item object { "id": "cnli_1LSdbA2eZvKYlo2CIWP5viuG", "object": "credit_note_line_item", "amount": 300, "amount_excluding_tax": 300, "description": "My First Invoice Item (created for API docs)", "discount_amount": 0, "discount_amounts": [], "invoice_line_item": "il_1LSdb92eZvKYlo2CH1Ktfo7J", "livemode": false, "quantity": 1, "tax_amounts": [], "tax_rates": [], "type": "invoice_line_item", "unit_amount": null, "unit_amount_decimal": null, "unit_amount_excluding_tax": "300" } '''
The (Credit Note) line item objectAttributes id string Unique identifier for the object. object string, value is "credit_note_line_item" String representing the object’s type. Objects of the same type share the same value. amount integer The integer amount in pence representing the gross amount being credited for this line item, excluding (exclusive) tax and discounts. amount_excluding_tax integer The integer amount in pence representing the amount being credited for this line item, excluding all tax and discounts. description string Description of the item being credited. discount_amount integer Deprecated The integer amount in pence representing the discount being credited for this line item. discount_amounts array of hashes The amount of discount calculated per discount for this line itemShow child attributes invoice_line_item string ID of the invoice line item being credited livemode boolean Has the value true if the object exists in live mode or the value false if the object exists in test mode. quantity integer The number of units of product being credited. tax_amounts array of hashes The amount of tax calculated per tax rate for this line itemShow child attributes tax_rates array of hashes The tax rates which apply to the line item.Show child attributes type string The type of the credit note line item, one of invoice_line_item or custom_line_item. When the type is invoice_line_item there is an additional invoice_line_item property on the resource the value of which is the id of the credited line item on the invoice. unit_amount integer The cost of each unit of product being credited. unit_amount_decimal decimal string Same as unit_amount, but contains a decimal value with at most 12 decimal places. unit_amount_excluding_tax decimal string The amount in pence representing the unit amount being credited for this line item, excluding all tax and discounts
import stripe stripe.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" stripe.CreditNote.preview( invoice="in_1LSdb92eZvKYlo2CJvl4iJuW", lines=[ { "type": "invoice_line_item", "invoice_line_item": "il_1LSdb92eZvKYlo2Cg5Kr2nEp", "quantity": 1, }, ], ) '''Response { "id": "cn_1LSdb92eZvKYlo2C0JdIQVHd", "object": "credit_note", "amount": 857, "created": 1659517839, "currency": "usd", "customer": "cus_8TEMHVY5moxIPI", "customer_balance_transaction": null, "discount_amount": 0, "discount_amounts": [], "invoice": "in_1LSdb92eZvKYlo2CJvl4iJuW", "lines": { "object": "list", "data": [ { "id": "cnli_1LSdb92eZvKYlo2Cu4lDIS7X", "object": "credit_note_line_item", "amount": 357, "amount_excluding_tax": 357, "description": "My First Invoice Item (created for API docs)", "discount_amount": 0, "discount_amounts": [], "invoice_line_item": "il_1LSdb92eZvKYlo2Cg5Kr2nEp", "livemode": false, "quantity": 1, "tax_amounts": [ { "amount": 57, "inclusive": false, "tax_rate": "txr_1LSdb92eZvKYlo2CboQRs5G6" } ], "tax_rates": [ { "id": "txr_1LSdb92eZvKYlo2CboQRs5G6", "object": "tax_rate", "active": true, "country": "DE", "created": 1659517839, "description": "VAT Germany", "display_name": "VAT", "inclusive": false, "jurisdiction": "DE", "livemode": false, "metadata": {}, "percentage": 19.0, "state": null, "tax_type": "vat" } ], "type": "invoice_line_item", "unit_amount": null, "unit_amount_decimal": null, "unit_amount_excluding_tax": "357" }, { "id": "cnli_1LSdb92eZvKYlo2C9yhKwMbp", "object": "credit_note_line_item", "amount": 500, "amount_excluding_tax": 500, "description": "Service credit", "discount_amount": 0, "discount_amounts": [], "livemode": false, "quantity": 1, "tax_amounts": [], "tax_rates": [], "type": "custom_line_item", "unit_amount": 500, "unit_amount_decimal": "500", "unit_amount_excluding_tax": "500" } ], "has_more": false, "url": "/v1/credit_notes/cn_1LSdb92eZvKYlo2C0JdIQVHd/lines" }, "livemode": false, "memo": null, "metadata": {}, "number": "ABCD-1234-CN-01", "out_of_band_amount": null, "pdf": "https://pay.stripe.com/credit_notes/acct_1032D82eZvKYlo2C/cnst_123456789/pdf?s=ap", "reason": null, "refund": null, "status": "issued", "subtotal": 857, "subtotal_excluding_tax": 857, "tax_amounts": [ { "amount": 57, "inclusive": false, "tax_rate": "txr_1LSdb92eZvKYlo2CboQRs5G6" } ], "total": 857, "total_excluding_tax": null, "type": "pre_payment", "voided_at": null }'''
Preview a credit noteGet a preview of a credit note without creating it.Parameters invoice required ID of the invoice. lines optional array of hashes Line items that make up the credit note.Show child parameters memo optional The credit note’s memo appears on the credit note PDF. metadata optional dictionary Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to metadata. reason optional Reason for issuing this credit note, one of duplicate, fraudulent, order_change, or product_unsatisfactoryMore parametersExpand all amount optional credit_amount optional out_of_band_amount optional refund optional refund_amount optional ReturnsReturns a credit note object
import stripe stripe.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" stripe.CreditNote.create( invoice="in_1LSdb92eZvKYlo2CJvl4iJuW", lines=[ { "type": "invoice_line_item", "invoice_line_item": "il_1LSdb92eZvKYlo2Cg5Kr2nEp", "quantity": 1, }, ], ) '''Response { "id": "cn_1LSdb92eZvKYlo2C0JdIQVHd", "object": "credit_note", "amount": 857, "created": 1659517839, "currency": "usd", "customer": "cus_8TEMHVY5moxIPI", "customer_balance_transaction": null, "discount_amount": 0, "discount_amounts": [], "invoice": "in_1LSdb92eZvKYlo2CJvl4iJuW", "lines": { "object": "list", "data": [ { "id": "cnli_1LSdb92eZvKYlo2Cu4lDIS7X", "object": "credit_note_line_item", "amount": 357, "amount_excluding_tax": 357, "description": "My First Invoice Item (created for API docs)", "discount_amount": 0, "discount_amounts": [], "invoice_line_item": "il_1LSdb92eZvKYlo2Cg5Kr2nEp", "livemode": false, "quantity": 1, "tax_amounts": [ { "amount": 57, "inclusive": false, "tax_rate": "txr_1LSdb92eZvKYlo2CboQRs5G6" } ], "tax_rates": [ { "id": "txr_1LSdb92eZvKYlo2CboQRs5G6", "object": "tax_rate", "active": true, "country": "DE", "created": 1659517839, "description": "VAT Germany", "display_name": "VAT", "inclusive": false, "jurisdiction": "DE", "livemode": false, "metadata": {}, "percentage": 19.0, "state": null, "tax_type": "vat" } ], "type": "invoice_line_item", "unit_amount": null, "unit_amount_decimal": null, "unit_amount_excluding_tax": "357" }, { "id": "cnli_1LSdb92eZvKYlo2C9yhKwMbp", "object": "credit_note_line_item", "amount": 500, "amount_excluding_tax": 500, "description": "Service credit", "discount_amount": 0, "discount_amounts": [], "livemode": false, "quantity": 1, "tax_amounts": [], "tax_rates": [], "type": "custom_line_item", "unit_amount": 500, "unit_amount_decimal": "500", "unit_amount_excluding_tax": "500" } ], "has_more": false, "url": "/v1/credit_notes/cn_1LSdb92eZvKYlo2C0JdIQVHd/lines" }, "livemode": false, "memo": null, "metadata": {}, "number": "ABCD-1234-CN-01", "out_of_band_amount": null, "pdf": "https://pay.stripe.com/credit_notes/acct_1032D82eZvKYlo2C/cnst_123456789/pdf?s=ap", "reason": null, "refund": null, "status": "issued", "subtotal": 857, "subtotal_excluding_tax": 857, "tax_amounts": [ { "amount": 57, "inclusive": false, "tax_rate": "txr_1LSdb92eZvKYlo2CboQRs5G6" } ], "total": 857, "total_excluding_tax": null, "type": "pre_payment", "voided_at": null }'''
Create a credit noteIssue a credit note to adjust the amount of a finalized invoice. For a status=open invoice, a credit note reduces its amount_due. For a status=paid invoice, a credit note does not affect its amount_due. Instead, it can result in any combination of the following: Refund: create a new refund (using refund_amount) or link an existing refund (using refund). Customer balance credit: credit the customer’s balance (using credit_amount) which will be automatically applied to their next invoice when it’s finalized. Outside of Stripe credit: record the amount that is or will be credited outside of Stripe (using out_of_band_amount). For post-payment credit notes the sum of the refund, credit and outside of Stripe amounts must equal the credit note total. You may issue multiple credit notes for an invoice. Each credit note will increment the invoice’s pre_payment_credit_notes_amount or post_payment_credit_notes_amount depending on its status at the time of credit note creation.Parameters invoice required ID of the invoice. lines optional array of hashes Line items that make up the credit note.Show child parameters memo optional The credit note’s memo appears on the credit note PDF. metadata optional dictionary Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to metadata. reason optional Reason for issuing this credit note, one of duplicate, fraudulent, order_change, or product_unsatisfactoryMore parametersExpand all amount optional credit_amount optional out_of_band_amount optional refund optional refund_amount optional ReturnsReturns a credit note object if the call succeeded
import stripe stripe.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" stripe.CreditNote.retrieve( "cn_1LSdb92eZvKYlo2C0JdIQVHd", ) '''Response { "id": "cn_1LSdb92eZvKYlo2C0JdIQVHd", "object": "credit_note", "amount": 857, "created": 1659517839, "currency": "usd", "customer": "cus_8TEMHVY5moxIPI", "customer_balance_transaction": null, "discount_amount": 0, "discount_amounts": [], "invoice": "in_1LSdb92eZvKYlo2CJvl4iJuW", "lines": { "object": "list", "data": [ { "id": "cnli_1LSdb92eZvKYlo2Cu4lDIS7X", "object": "credit_note_line_item", "amount": 357, "amount_excluding_tax": 357, "description": "My First Invoice Item (created for API docs)", "discount_amount": 0, "discount_amounts": [], "invoice_line_item": "il_1LSdb92eZvKYlo2Cg5Kr2nEp", "livemode": false, "quantity": 1, "tax_amounts": [ { "amount": 57, "inclusive": false, "tax_rate": "txr_1LSdb92eZvKYlo2CboQRs5G6" } ], "tax_rates": [ { "id": "txr_1LSdb92eZvKYlo2CboQRs5G6", "object": "tax_rate", "active": true, "country": "DE", "created": 1659517839, "description": "VAT Germany", "display_name": "VAT", "inclusive": false, "jurisdiction": "DE", "livemode": false, "metadata": {}, "percentage": 19.0, "state": null, "tax_type": "vat" } ], "type": "invoice_line_item", "unit_amount": null, "unit_amount_decimal": null, "unit_amount_excluding_tax": "357" }, { "id": "cnli_1LSdb92eZvKYlo2C9yhKwMbp", "object": "credit_note_line_item", "amount": 500, "amount_excluding_tax": 500, "description": "Service credit", "discount_amount": 0, "discount_amounts": [], "livemode": false, "quantity": 1, "tax_amounts": [], "tax_rates": [], "type": "custom_line_item", "unit_amount": 500, "unit_amount_decimal": "500", "unit_amount_excluding_tax": "500" } ], "has_more": false, "url": "/v1/credit_notes/cn_1LSdb92eZvKYlo2C0JdIQVHd/lines" }, "livemode": false, "memo": null, "metadata": {}, "number": "ABCD-1234-CN-01", "out_of_band_amount": null, "pdf": "https://pay.stripe.com/credit_notes/acct_1032D82eZvKYlo2C/cnst_123456789/pdf?s=ap", "reason": null, "refund": null, "status": "issued", "subtotal": 857, "subtotal_excluding_tax": 857, "tax_amounts": [ { "amount": 57, "inclusive": false, "tax_rate": "txr_1LSdb92eZvKYlo2CboQRs5G6" } ], "total": 857, "total_excluding_tax": null, "type": "pre_payment", "voided_at": null }'''
Retrieve a credit noteRetrieves the credit note object with the given identifier.ParametersNo parameters.ReturnsReturns a credit note object if a valid identifier was provided
import stripe stripe.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" stripe.CreditNote.modify( "cn_1LSdb92eZvKYlo2C0JdIQVHd", metadata={"order_id": "6735"}, ) '''Response { "id": "cn_1LSdb92eZvKYlo2C0JdIQVHd", "object": "credit_note", "amount": 857, "created": 1659517839, "currency": "usd", "customer": "cus_8TEMHVY5moxIPI", "customer_balance_transaction": null, "discount_amount": 0, "discount_amounts": [], "invoice": "in_1LSdb92eZvKYlo2CJvl4iJuW", "lines": { "object": "list", "data": [ { "id": "cnli_1LSdb92eZvKYlo2Cu4lDIS7X", "object": "credit_note_line_item", "amount": 357, "amount_excluding_tax": 357, "description": "My First Invoice Item (created for API docs)", "discount_amount": 0, "discount_amounts": [], "invoice_line_item": "il_1LSdb92eZvKYlo2Cg5Kr2nEp", "livemode": false, "quantity": 1, "tax_amounts": [ { "amount": 57, "inclusive": false, "tax_rate": "txr_1LSdb92eZvKYlo2CboQRs5G6" } ], "tax_rates": [ { "id": "txr_1LSdb92eZvKYlo2CboQRs5G6", "object": "tax_rate", "active": true, "country": "DE", "created": 1659517839, "description": "VAT Germany", "display_name": "VAT", "inclusive": false, "jurisdiction": "DE", "livemode": false, "metadata": {}, "percentage": 19.0, "state": null, "tax_type": "vat" } ], "type": "invoice_line_item", "unit_amount": null, "unit_amount_decimal": null, "unit_amount_excluding_tax": "357" }, { "id": "cnli_1LSdb92eZvKYlo2C9yhKwMbp", "object": "credit_note_line_item", "amount": 500, "amount_excluding_tax": 500, "description": "Service credit", "discount_amount": 0, "discount_amounts": [], "livemode": false, "quantity": 1, "tax_amounts": [], "tax_rates": [], "type": "custom_line_item", "unit_amount": 500, "unit_amount_decimal": "500", "unit_amount_excluding_tax": "500" } ], "has_more": false, "url": "/v1/credit_notes/cn_1LSdb92eZvKYlo2C0JdIQVHd/lines" }, "livemode": false, "memo": null, "metadata": { "order_id": "6735" }, "number": "ABCD-1234-CN-01", "out_of_band_amount": null, "pdf": "https://pay.stripe.com/credit_notes/acct_1032D82eZvKYlo2C/cnst_123456789/pdf?s=ap", "reason": null, "refund": null, "status": "issued", "subtotal": 857, "subtotal_excluding_tax": 857, "tax_amounts": [ { "amount": 57, "inclusive": false, "tax_rate": "txr_1LSdb92eZvKYlo2CboQRs5G6" } ], "total": 857, "total_excluding_tax": null, "type": "pre_payment", "voided_at": null }'''
Update a credit noteUpdates an existing credit note.Parameters memo optional Credit note memo. metadata optional dictionary Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to metadata.ReturnsReturns the updated credit note object if the call succeeded
import stripe stripe.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" credit_note = stripe.CreditNote.retrieve('cn_1LSdb92eZvKYlo2C0JdIQVHd') lines = credit_note.lines.list(limit=5) '''Response { "object": "list", "url": "/v1/credit_notes/cn_1LSdb92eZvKYlo2C0JdIQVHd/lines", "has_more": false, "data": [ { "id": "cnli_1LSdbA2eZvKYlo2CIWP5viuG", "object": "credit_note_line_item", "amount": 300, "amount_excluding_tax": 300, "description": "My First Invoice Item (created for API docs)", "discount_amount": 0, "discount_amounts": [], "invoice_line_item": "il_1LSdb92eZvKYlo2CH1Ktfo7J", "livemode": false, "quantity": 1, "tax_amounts": [], "tax_rates": [], "type": "invoice_line_item", "unit_amount": null, "unit_amount_decimal": null, "unit_amount_excluding_tax": "300" }, {...}, {...} ] }'''
Retrieve a credit note's line itemsWhen retrieving a credit note, you’ll get a lines property containing the the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items.ParametersExpand all ending_before optional limit optional starting_after optional ReturnsReturns a list of line_item objects
import stripe stripe.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" stripe.CreditNote.preview( invoice="in_1LSdb92eZvKYlo2CJvl4iJuW", lines=[ { "type": "invoice_line_item", "invoice_line_item": "il_1LSdb92eZvKYlo2Cg5Kr2nEp", "quantity": 1, }, ], ) credit_note = stripe.CreditNote.retrieve('cn_1LSdb92eZvKYlo2C0JdIQVHd') lines = credit_note.lines.list(limit=5) '''Response { "object": "list", "url": "/v1/credit_notes/preview/lines", "has_more": false, "data": [ { "id": "cnli_1LSdbA2eZvKYlo2CIWP5viuG", "object": "credit_note_line_item", "amount": 300, "amount_excluding_tax": 300, "description": "My First Invoice Item (created for API docs)", "discount_amount": 0, "discount_amounts": [], "invoice_line_item": "il_1LSdb92eZvKYlo2CH1Ktfo7J", "livemode": false, "quantity": 1, "tax_amounts": [], "tax_rates": [], "type": "invoice_line_item", "unit_amount": null, "unit_amount_decimal": null, "unit_amount_excluding_tax": "300" }, {...}, {...} ] }'''
Retrieve a credit note preview's line itemsWhen retrieving a credit note preview, you’ll get a lines property containing the first handful of those items. This URL you can retrieve the full (paginated) list of line items.Parameters invoice required ID of the invoice. lines optional array of hashes Line items that make up the credit note.Show child parameters memo optional The credit note’s memo appears on the credit note PDF. metadata optional dictionary Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to metadata. reason optional Reason for issuing this credit note, one of duplicate, fraudulent, order_change, or product_unsatisfactoryMore parametersExpand all amount optional credit_amount optional ending_before optional limit optional out_of_band_amount optional refund optional refund_amount optional starting_after optional ReturnsReturns a list of line_item objects
import stripe stripe.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" stripe.CreditNote.void_credit_note( "cn_1LSdb92eZvKYlo2C0JdIQVHd", ) '''Response { "id": "cn_1LSdb92eZvKYlo2C0JdIQVHd", "object": "credit_note", "amount": 857, "created": 1659517839, "currency": "usd", "customer": "cus_8TEMHVY5moxIPI", "customer_balance_transaction": null, "discount_amount": 0, "discount_amounts": [], "invoice": "in_1LSdb92eZvKYlo2CJvl4iJuW", "lines": { "object": "list", "data": [ { "id": "cnli_1LSdb92eZvKYlo2Cu4lDIS7X", "object": "credit_note_line_item", "amount": 357, "amount_excluding_tax": 357, "description": "My First Invoice Item (created for API docs)", "discount_amount": 0, "discount_amounts": [], "invoice_line_item": "il_1LSdb92eZvKYlo2Cg5Kr2nEp", "livemode": false, "quantity": 1, "tax_amounts": [ { "amount": 57, "inclusive": false, "tax_rate": "txr_1LSdb92eZvKYlo2CboQRs5G6" } ], "tax_rates": [ { "id": "txr_1LSdb92eZvKYlo2CboQRs5G6", "object": "tax_rate", "active": true, "country": "DE", "created": 1659517839, "description": "VAT Germany", "display_name": "VAT", "inclusive": false, "jurisdiction": "DE", "livemode": false, "metadata": {}, "percentage": 19.0, "state": null, "tax_type": "vat" } ], "type": "invoice_line_item", "unit_amount": null, "unit_amount_decimal": null, "unit_amount_excluding_tax": "357" }, { "id": "cnli_1LSdb92eZvKYlo2C9yhKwMbp", "object": "credit_note_line_item", "amount": 500, "amount_excluding_tax": 500, "description": "Service credit", "discount_amount": 0, "discount_amounts": [], "livemode": false, "quantity": 1, "tax_amounts": [], "tax_rates": [], "type": "custom_line_item", "unit_amount": 500, "unit_amount_decimal": "500", "unit_amount_excluding_tax": "500" } ], "has_more": false, "url": "/v1/credit_notes/cn_1LSdb92eZvKYlo2C0JdIQVHd/lines" }, "livemode": false, "memo": null, "metadata": {}, "number": "ABCD-1234-CN-01", "out_of_band_amount": null, "pdf": "https://pay.stripe.com/credit_notes/acct_1032D82eZvKYlo2C/cnst_123456789/pdf?s=ap", "reason": null, "refund": null, "status": "void", "subtotal": 857, "subtotal_excluding_tax": 857, "tax_amounts": [ { "amount": 57, "inclusive": false, "tax_rate": "txr_1LSdb92eZvKYlo2CboQRs5G6" } ], "total": 857, "total_excluding_tax": null, "type": "pre_payment", "voided_at": 1659517840 }'''
Void a credit noteMarks a credit note as void. Learn more about voiding credit notes.ParametersNo parameters.ReturnsReturns the voided credit note object if the call succeeded
import stripe stripe.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" stripe.CreditNote.list(limit=3) '''Response { "object": "list", "url": "/v1/credit_notes", "has_more": false, "data": [ { "id": "cn_1LSdb92eZvKYlo2C0JdIQVHd", "object": "credit_note", "amount": 857, "created": 1659517839, "currency": "usd", "customer": "cus_8TEMHVY5moxIPI", "customer_balance_transaction": null, "discount_amount": 0, "discount_amounts": [], "invoice": "in_1LSdb92eZvKYlo2CJvl4iJuW", "lines": { "object": "list", "data": [ { "id": "cnli_1LSdb92eZvKYlo2Cu4lDIS7X", "object": "credit_note_line_item", "amount": 357, "amount_excluding_tax": 357, "description": "My First Invoice Item (created for API docs)", "discount_amount": 0, "discount_amounts": [], "invoice_line_item": "il_1LSdb92eZvKYlo2Cg5Kr2nEp", "livemode": false, "quantity": 1, "tax_amounts": [ { "amount": 57, "inclusive": false, "tax_rate": "txr_1LSdb92eZvKYlo2CboQRs5G6" } ], "tax_rates": [ { "id": "txr_1LSdb92eZvKYlo2CboQRs5G6", "object": "tax_rate", "active": true, "country": "DE", "created": 1659517839, "description": "VAT Germany", "display_name": "VAT", "inclusive": false, "jurisdiction": "DE", "livemode": false, "metadata": {}, "percentage": 19.0, "state": null, "tax_type": "vat" } ], "type": "invoice_line_item", "unit_amount": null, "unit_amount_decimal": null, "unit_amount_excluding_tax": "357" }, { "id": "cnli_1LSdb92eZvKYlo2C9yhKwMbp", "object": "credit_note_line_item", "amount": 500, "amount_excluding_tax": 500, "description": "Service credit", "discount_amount": 0, "discount_amounts": [], "livemode": false, "quantity": 1, "tax_amounts": [], "tax_rates": [], "type": "custom_line_item", "unit_amount": 500, "unit_amount_decimal": "500", "unit_amount_excluding_tax": "500" } ], "has_more": false, "url": "/v1/credit_notes/cn_1LSdb92eZvKYlo2C0JdIQVHd/lines" }, "livemode": false, "memo": null, "metadata": {}, "number": "ABCD-1234-CN-01", "out_of_band_amount": null, "pdf": "https://pay.stripe.com/credit_notes/acct_1032D82eZvKYlo2C/cnst_123456789/pdf?s=ap", "reason": null, "refund": null, "status": "issued", "subtotal": 857, "subtotal_excluding_tax": 857, "tax_amounts": [ { "amount": 57, "inclusive": false, "tax_rate": "txr_1LSdb92eZvKYlo2CboQRs5G6" } ], "total": 857, "total_excluding_tax": null, "type": "pre_payment", "voided_at": null }, {...}, {...} ] }'''
List all credit notesReturns a list of credit notes.Parameters invoice optional Only return credit notes for the invoice specified by this invoice ID.More parametersExpand all customer optional ending_before optional limit optional starting_after optional ReturnsA dictionary with a data property that contains an array of up to limit credit notes, starting after credit note starting_after. Each entry in the array is a separate credit note object. If no more credit notes are available, the resulting array will be empty.
'''Endpoints  POST /v1/customers/:id/balance_transactions   GET /v1/customers/:id/balance_transactions/:id  POST /v1/customers/:id/balance_transactions/:id   GET /v1/customers/:id/balance_transactions '''
Customer Balance TransactionEach customer has a balance value, which denotes a debit or credit that's automatically applied to their next invoice upon finalization. You may modify the value directly by using the update customer API, or by creating a Customer Balance Transaction, which increments or decrements the customer's balance by the specified amount.
'''The customer balance transaction object { "id": "cbtxn_1LSe4H2eZvKYlo2CfH2vNRxz", "object": "customer_balance_transaction", "amount": -500, "created": 1659519645, "credit_note": null, "currency": "usd", "customer": "cus_8TEMHVY5moxIPI", "description": null, "ending_balance": -500, "invoice": null, "livemode": false, "metadata": null, "type": "adjustment" } '''
The customer balance transaction objectAttributes id string Unique identifier for the object. amount integer The amount of the transaction. A negative value is a credit for the customer’s balance, and a positive value is a debit to the customer’s balance. currency currency Three-letter ISO currency code, in lowercase. Must be a supported currency. customer string expandable The ID of the customer the transaction belongs to. description string An arbitrary string attached to the object. Often useful for displaying to users. ending_balance integer The customer’s balance after the transaction was applied. A negative value decreases the amount due on the customer’s next invoice. A positive value increases the amount due on the customer’s next invoice. metadata hash Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. type string Transaction type: adjustment, applied_to_invoice, credit_note, initial, invoice_too_large, invoice_too_small, unspent_receiver_credit, or unapplied_from_invoice. See the Customer Balance page to learn more about transaction types.More attributesExpand all object string, value is "customer_balance_transaction" created timestamp credit_note string expandable invoice string expandable livemode boolean
import stripe stripe.api_key = "sk_test_your_key" stripe.Customer.create_balance_transaction( "cus_8TEMHVY5moxIPI", amount=-500, currency="usd", ) '''Response { "id": "cbtxn_1LSe4H2eZvKYlo2CfH2vNRxz", "object": "customer_balance_transaction", "amount": -500, "created": 1659519645, "credit_note": null, "currency": "usd", "customer": "cus_8TEMHVY5moxIPI", "description": null, "ending_balance": -500, "invoice": null, "livemode": false, "metadata": null, "type": "adjustment" }'''
Create a customer balance transactionCreates an immutable transaction that updates the customer’s credit balance.Parameters amount required The integer amount in cents to apply to the customer’s credit balance. currency required Three-letter ISO currency code, in lowercase. Must be a supported currency. If the customer’s currency is set, this value must match it. If the customer’s currency is not set, it will be updated to this value. description optional An arbitrary string attached to the object. Often useful for displaying to users. metadata optional dictionary Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to metadata.ReturnsReturns a customer balance transaction object if the call succeeded
import stripe stripe.api_key = "sk_test_your_key" stripe.Customer.retrieve_balance_transaction( "cus_8TEMHVY5moxIPI", "cbtxn_1LSe4H2eZvKYlo2CfH2vNRxz", ) '''Response { "id": "cbtxn_1LSe4H2eZvKYlo2CfH2vNRxz", "object": "customer_balance_transaction", "amount": -500, "created": 1659519645, "credit_note": null, "currency": "usd", "customer": "cus_8TEMHVY5moxIPI", "description": null, "ending_balance": -500, "invoice": null, "livemode": false, "metadata": null, "type": "adjustment" }'''
Retrieve a customer balance transactionRetrieves a specific customer balance transaction that updated the customer’s balances.ParametersNo parameters.ReturnsReturns a customer balance transaction object if a valid identifier was provided
import stripe stripe.api_key = "sk_test_your_key" stripe.Customer.modify_balance_transaction( "cus_8TEMHVY5moxIPI", "cbtxn_1LSe4H2eZvKYlo2CfH2vNRxz", metadata={"order_id": "6735"}, ) '''Response { "id": "cbtxn_1LSe4H2eZvKYlo2CfH2vNRxz", "object": "customer_balance_transaction", "amount": -500, "created": 1659519645, "credit_note": null, "currency": "usd", "customer": "cus_8TEMHVY5moxIPI", "description": null, "ending_balance": -500, "invoice": null, "livemode": false, "metadata": { "order_id": "6735" }, "type": "adjustment" }'''
Update a customer credit balance transactionMost credit balance transaction fields are immutable, but you may update its description and metadata.Parameters description optional An arbitrary string attached to the object. Often useful for displaying to users. metadata optional dictionary Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to metadata.ReturnsReturns a customer balance transaction object if the call succeeded
import stripe stripe.api_key = "sk_test_your_key" stripe.Customer.list_balance_transactions( "cus_8TEMHVY5moxIPI", limit=3, ) '''Response { "object": "list", "url": "/v1/customers/cus_8TEMHVY5moxIPI/customer_balance_transactions", "has_more": false, "data": [ { "id": "cbtxn_1LSe4H2eZvKYlo2CfH2vNRxz", "object": "customer_balance_transaction", "amount": -500, "created": 1659519645, "credit_note": null, "currency": "usd", "customer": "cus_8TEMHVY5moxIPI", "description": null, "ending_balance": -500, "invoice": null, "livemode": false, "metadata": null, "type": "adjustment" }, {...}, {...} ] }'''
List customer balance transactionsReturns a list of transactions that updated the customer’s balances.ParametersExpand all ending_before optional limit optional starting_after optional ReturnsA dictionary with a data property that contains an array of up to limit customer balance transactions, starting after item starting_after. Each entry in the array is a separate customer balance transaction object. If no more items are available, the resulting array will be empty. This request should never raise an error
'''Endpoints  POST /v1/billing_portal/sessions  POST /v1/billing_portal/configurations  POST /v1/billing_portal/configurations/:id   GET /v1/billing_portal/configurations/:id   GET /v1/billing_portal/configurations '''
Customer PortalThe Billing customer portal is a Stripe-hosted UI for subscription and billing management.A portal configuration describes the functionality and features that you want to provide to your customers through the portal.A portal session describes the instantiation of the customer portal for a particular customer. By visiting the session's URL, the customer can manage their subscriptions and billing details. For security reasons, sessions are short-lived and will expire if the customer does not visit the URL. Create sessions on-demand when customers intend to manage their subscriptions and billing details.Learn more in the integration guide
'''The portal session object { "id": "bps_1LSdxb2eZvKYlo2Cugji56Uy", "object": "billing_portal.session", "configuration": "bpc_1LSdxb2eZvKYlo2CdKPl5uH4", "created": 1659519231, "customer": "cus_8TEMHVY5moxIPI", "livemode": true, "locale": null, "on_behalf_of": null, "return_url": "https://example.com/account", "url": "https://billing.stripe.com/session/{SESSION_SECRET}" } '''
The portal session objectAttributes id string Unique identifier for the object. object string, value is "billing_portal.session" String representing the object’s type. Objects of the same type share the same value. configuration string expandable The configuration used by this session, describing the features available. created timestamp Time at which the object was created. Measured in seconds since the Unix epoch. customer string The ID of the customer for this session. livemode boolean Has the value true if the object exists in live mode or the value false if the object exists in test mode. locale enum The IETF language tag of the locale Customer Portal is displayed in. If blank or auto, the customer’s preferred_locales or browser’s locale is used.Possible enum valuesauto bg cs da de el en Show 40 more on_behalf_of string Connect only The account for which the session was created on behalf of. When specified, only subscriptions and invoices with this on_behalf_of account appear in the portal. For more information, see the docs. Use the Accounts API to modify the on_behalf_of account’s branding settings, which the portal displays. return_url string The URL to redirect customers to when they click on the portal’s link to return to your website. url string The short-lived URL of the session that gives customers access to the customer portal
'''The portal configuration object { "id": "bpc_1LSdxb2eZvKYlo2CcDwiZ8Hp", "object": "billing_portal.configuration", "active": true, "application": null, "business_profile": { "headline": null, "privacy_policy_url": "https://example.com/privacy", "terms_of_service_url": "https://example.com/terms" }, "created": 1659519231, "default_return_url": null, "features": { "customer_update": { "allowed_updates": [ "email", "tax_id" ], "enabled": true }, "invoice_history": { "enabled": true }, "payment_method_update": { "enabled": false }, "subscription_cancel": { "cancellation_reason": { "enabled": false, "options": [] }, "enabled": false, "mode": "at_period_end", "proration_behavior": "none" }, "subscription_pause": { "enabled": false }, "subscription_update": { "default_allowed_updates": [], "enabled": false, "proration_behavior": "none" } }, "is_default": true, "livemode": true, "metadata": null, "updated": 1659519231 } '''
The portal configuration objectAttributes id string Unique identifier for the object. object string, value is "billing_portal.configuration" String representing the object’s type. Objects of the same type share the same value. active boolean Whether the configuration is active and can be used to create portal sessions. application string expandable "application" Connect only ID of the Connect Application that created the configuration. business_profile hash The business information shown to customers in the portal.Show child attributes created timestamp Time at which the object was created. Measured in seconds since the Unix epoch. default_return_url string The default URL to redirect customers to when they click on the portal’s link to return to your website. This can be overriden when creating the session. features hash Information about the features available in the portal.Show child attributes is_default boolean Whether the configuration is the default. If true, this configuration can be managed in the Dashboard and portal sessions will use this configuration unless it is overriden when creating the session. livemode boolean Has the value true if the object exists in live mode or the value false if the object exists in test mode. metadata hash Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. updated timestamp Time at which the object was last updated. Measured in seconds since the Unix epoch
import stripe stripe.api_key = "sk_test_your_key" stripe.billing_portal.Session.create( customer="cus_8TEMHVY5moxIPI", return_url="https://example.com/account", ) '''Response { "id": "bps_1LSdxb2eZvKYlo2Cugji56Uy", "object": "billing_portal.session", "configuration": "bpc_1LSdxb2eZvKYlo2CdKPl5uH4", "created": 1659519231, "customer": "cus_8TEMHVY5moxIPI", "livemode": true, "locale": null, "on_behalf_of": null, "return_url": "https://example.com/account", "url": "https://billing.stripe.com/session/{SESSION_SECRET}" }'''
Create a portal sessionCreates a session of the customer portal.Parameters customer required The ID of an existing customer. configuration optional The ID of an existing configuration to use for this session, describing its functionality and features. If not specified, the session uses the default configuration. locale optional enum The IETF language tag of the locale Customer Portal is displayed in. If blank or auto, the customer’s preferred_locales or browser’s locale is used.Possible enum valuesauto bg cs da de el en Show 40 more on_behalf_of optional Connect only The on_behalf_of account to use for this session. When specified, only subscriptions and invoices with this on_behalf_of account appear in the portal. For more information, see the docs. Use the Accounts API to modify the on_behalf_of account’s branding settings, which the portal displays. return_url optional The default URL to redirect customers to when they click on the portal’s link to return to your website.ReturnsReturns a portal session object
import stripe stripe.api_key = "sk_test_your_key" stripe.billing_portal.Configuration.create( features={ "customer_update": { "allowed_updates": ["email", "tax_id"], "enabled": True, }, "invoice_history": {"enabled": True}, }, business_profile={ "privacy_policy_url": "https://example.com/privacy", "terms_of_service_url": "https://example.com/terms", }, ) '''Response { "id": "bpc_1LSdxb2eZvKYlo2CcDwiZ8Hp", "object": "billing_portal.configuration", "active": true, "application": null, "business_profile": { "headline": null, "privacy_policy_url": "https://example.com/privacy", "terms_of_service_url": "https://example.com/terms" }, "created": 1659519231, "default_return_url": null, "features": { "customer_update": { "allowed_updates": [ "email", "tax_id" ], "enabled": true }, "invoice_history": { "enabled": true }, "payment_method_update": { "enabled": false }, "subscription_cancel": { "cancellation_reason": { "enabled": false, "options": [] }, "enabled": false, "mode": "at_period_end", "proration_behavior": "none" }, "subscription_pause": { "enabled": false }, "subscription_update": { "default_allowed_updates": [], "enabled": false, "proration_behavior": "none" } }, "is_default": true, "livemode": true, "metadata": null, "updated": 1659519231, "customer": "cus_8TEMHVY5moxIPI" }'''
Create a portal configurationCreates a configuration that describes the functionality and behavior of a PortalSessionParameters business_profile required The business information shown to customers in the portal.Show child parameters features required Information about the features available in the portal.Show child parameters default_return_url optional The default URL to redirect customers to when they click on the portal’s link to return to your website. This can be overriden when creating the session. metadata optional dictionary Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to metadata.ReturnsReturns a portal configuration object
import stripe stripe.api_key = "sk_test_your_key" stripe.billing_portal.Configuration.modify( "bpc_1LSdxb2eZvKYlo2CcDwiZ8Hp", business_profile={ "privacy_policy_url": "https://example.com/privacy", "terms_of_service_url": "https://example.com/terms", }, ) '''Response { "id": "bpc_1LSdxb2eZvKYlo2CcDwiZ8Hp", "object": "billing_portal.configuration", "active": true, "application": null, "business_profile": { "headline": null, "privacy_policy_url": "https://example.com/privacy", "terms_of_service_url": "https://example.com/terms" }, "created": 1659519231, "default_return_url": null, "features": { "customer_update": { "allowed_updates": [ "email", "tax_id" ], "enabled": true }, "invoice_history": { "enabled": true }, "payment_method_update": { "enabled": false }, "subscription_cancel": { "cancellation_reason": { "enabled": false, "options": [] }, "enabled": false, "mode": "at_period_end", "proration_behavior": "none" }, "subscription_pause": { "enabled": false }, "subscription_update": { "default_allowed_updates": [], "enabled": false, "proration_behavior": "none" } }, "is_default": true, "livemode": true, "metadata": null, "updated": 1659519231, "customer": "cus_8TEMHVY5moxIPI" }'''
Update a portal configurationUpdates a configuration that describes the functionality of the customer portal.Parameters active optional Whether the configuration is active and can be used to create portal sessions. business_profile optional dictionary The business information shown to customers in the portal.Show child parameters default_return_url optional The default URL to redirect customers to when they click on the portal’s link to return to your website. This can be overriden when creating the session. features optional dictionary Information about the features available in the portal.Show child parameters metadata optional dictionary Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to metadata.ReturnsReturns a portal configuration object
import stripe stripe.api_key = "sk_test_your_key" stripe.billing_portal.Configuration.retrieve( "bpc_1LSdxb2eZvKYlo2CcDwiZ8Hp", ) '''Response { "id": "bpc_1LSdxb2eZvKYlo2CcDwiZ8Hp", "object": "billing_portal.configuration", "active": true, "application": null, "business_profile": { "headline": null, "privacy_policy_url": "https://example.com/privacy", "terms_of_service_url": "https://example.com/terms" }, "created": 1659519231, "default_return_url": null, "features": { "customer_update": { "allowed_updates": [ "email", "tax_id" ], "enabled": true }, "invoice_history": { "enabled": true }, "payment_method_update": { "enabled": false }, "subscription_cancel": { "cancellation_reason": { "enabled": false, "options": [] }, "enabled": false, "mode": "at_period_end", "proration_behavior": "none" }, "subscription_pause": { "enabled": false }, "subscription_update": { "default_allowed_updates": [], "enabled": false, "proration_behavior": "none" } }, "is_default": true, "livemode": true, "metadata": null, "updated": 1659519231 }'''
Retrieve a portal configurationRetrieves a configuration that describes the functionality of the customer portal.ParametersNo parameters.ReturnsReturns a portal configuration object
import stripe stripe.api_key = "sk_test_your_key" stripe.billing_portal.Configuration.list(limit=3) '''Response { "object": "list", "url": "/v1/billing_portal/configurations", "has_more": false, "data": [ { "id": "bpc_1LSdxb2eZvKYlo2CcDwiZ8Hp", "object": "billing_portal.configuration", "active": true, "application": null, "business_profile": { "headline": null, "privacy_policy_url": "https://example.com/privacy", "terms_of_service_url": "https://example.com/terms" }, "created": 1659519231, "default_return_url": null, "features": { "customer_update": { "allowed_updates": [ "email", "tax_id" ], "enabled": true }, "invoice_history": { "enabled": true }, "payment_method_update": { "enabled": false }, "subscription_cancel": { "cancellation_reason": { "enabled": false, "options": [] }, "enabled": false, "mode": "at_period_end", "proration_behavior": "none" }, "subscription_pause": { "enabled": false }, "subscription_update": { "default_allowed_updates": [], "enabled": false, "proration_behavior": "none" } }, "is_default": true, "livemode": true, "metadata": null, "updated": 1659519231 }, {...}, {...} ] }'''
List portal configurationsReturns a list of configurations that describe the functionality of the customer portal.Parameters active optional Only return configurations that are active or inactive (e.g., pass true to only list active configurations). is_default optional Only return the default or non-default configurations (e.g., pass true to only list the default configuration).More parametersExpand all ending_before optional limit optional starting_after optional ReturnsReturns a list of portal configuration objects
'''Endpoints  POST /v1/customers/:id/tax_ids   GET /v1/customers/:id/tax_ids/:idDELETE /v1/customers/:id/tax_ids/:id   GET /v1/customers/:id/tax_ids '''
Customer Tax IDsYou can add one or multiple tax IDs to a customer. A customer's tax IDs are displayed on invoices and credit notes issued for the customer.
'''The tax ID object { "id": "txi_1LSe4P2eZvKYlo2CBGmuOEro", "object": "tax_id", "country": "DE", "created": 123456789, "customer": "cus_8TEMHVY5moxIPI", "livemode": false, "type": "eu_vat", "value": "DE123456789", "verification": { "status": "pending", "verified_address": null, "verified_name": null } } '''
The tax ID objectAttributes id string Unique identifier for the object. country string Two-letter ISO code representing the country of the tax ID. customer string expandable ID of the customer. type string Type of the tax ID, one of ae_trn, au_abn, au_arn, bg_uic, br_cnpj, br_cpf, ca_bn, ca_gst_hst, ca_pst_bc, ca_pst_mb, ca_pst_sk, ca_qst, ch_vat, cl_tin, es_cif, eu_oss_vat, eu_vat, gb_vat, ge_vat, hk_br, hu_tin, id_npwp, il_vat, in_gst, is_vat, jp_cn, jp_rn, kr_brn, li_uid, mx_rfc, my_frp, my_itn, my_sst, no_vat, nz_gst, ru_inn, ru_kpp, sa_vat, sg_gst, sg_uen, si_tin, th_vat, tw_vat, ua_vat, us_ein, or za_vat. Note that some legacy tax IDs have type unknown value string Value of the tax ID.More attributesExpand all object string, value is "tax_id" created timestamp livemode boolean verification hash
import stripe stripe.api_key = "sk_test_your_key" stripe.Customer.create_tax_id( "cus_8TEMHVY5moxIPI", type="eu_vat", value="DE123456789", ) '''Response { "id": "txi_1LSe4P2eZvKYlo2CBGmuOEro", "object": "tax_id", "country": "DE", "created": 123456789, "customer": "cus_8TEMHVY5moxIPI", "livemode": false, "type": "eu_vat", "value": "DE123456789", "verification": { "status": "pending", "verified_address": null, "verified_name": null } }'''
Create a tax IDCreates a new TaxID object for a customer.Parameters type required Type of the tax ID, one of ae_trn, au_abn, au_arn, bg_uic, br_cnpj, br_cpf, ca_bn, ca_gst_hst, ca_pst_bc, ca_pst_mb, ca_pst_sk, ca_qst, ch_vat, cl_tin, es_cif, eu_oss_vat, eu_vat, gb_vat, ge_vat, hk_br, hu_tin, id_npwp, il_vat, in_gst, is_vat, jp_cn, jp_rn, kr_brn, li_uid, mx_rfc, my_frp, my_itn, my_sst, no_vat, nz_gst, ru_inn, ru_kpp, sa_vat, sg_gst, sg_uen, si_tin, th_vat, tw_vat, ua_vat, us_ein, or za_vat value required Value of the tax ID.ReturnsThe created TaxID object
import stripe stripe.api_key = "sk_test_your_key" stripe.Customer.retrieve_tax_id( "cus_8TEMHVY5moxIPI", "txi_1LSe4P2eZvKYlo2CBGmuOEro", ) '''Response { "id": "txi_1LSe4P2eZvKYlo2CBGmuOEro", "object": "tax_id", "country": "DE", "created": 123456789, "customer": "cus_8TEMHVY5moxIPI", "livemode": false, "type": "eu_vat", "value": "DE123456789", "verification": { "status": "pending", "verified_address": null, "verified_name": null } }'''
Retrieve a tax IDRetrieves the TaxID object with the given identifier.ParametersNo parameters.ReturnsReturns a TaxID object if a valid identifier was provided
import stripe stripe.api_key = "sk_test_your_key" stripe.Customer.delete_tax_id( "cus_8TEMHVY5moxIPI", "txi_1LSe4P2eZvKYlo2CBGmuOEro", ) '''Response { "id": "txi_1LSe4P2eZvKYlo2CBGmuOEro", "object": "tax_id", "deleted": true }'''
Delete a tax IDDeletes an existing TaxID object.ParametersNo parameters.ReturnsReturns an object with a deleted parameter on success. If the TaxID object does not exist, this call raises an error
import stripe stripe.api_key = "sk_test_your_key" stripe.Customer.list_tax_ids( "cus_8TEMHVY5moxIPI", limit=3, ) '''Response { "object": "list", "url": "/v1/customers/cus_8TEMHVY5moxIPI/tax_ids", "has_more": false, "data": [ { "id": "txi_1LSe4P2eZvKYlo2CBGmuOEro", "object": "tax_id", "country": "DE", "created": 123456789, "customer": "cus_8TEMHVY5moxIPI", "livemode": false, "type": "eu_vat", "value": "DE123456789", "verification": { "status": "pending", "verified_address": null, "verified_name": null } }, {...}, {...} ] }'''
List all tax IDsReturns a list of tax IDs for a customer.ParametersExpand all ending_before optional limit optional starting_after optional ReturnsA dictionary with a data property that contains an array of up to limit tax IDs, starting after tax ID starting_after. Each entry in the array is a separate TaxID object. If no more tax IDs are available, the resulting array will be empty. Raises an error if the customer ID is invalid
'''Endpoints  POST /v1/invoices   GET /v1/invoices/:id  POST /v1/invoices/:idDELETE /v1/invoices/:id  POST /v1/invoices/:id/finalize  POST /v1/invoices/:id/pay  POST /v1/invoices/:id/send  POST /v1/invoices/:id/void  POST /v1/invoices/:id/mark_uncollectible   GET /v1/invoices/:id/lines   GET /v1/invoices/upcoming   GET /v1/invoices/upcoming/lines   GET /v1/invoices   GET /v1/invoices/search '''
InvoicesInvoices are statements of amounts owed by a customer, and are either generated one-off, or generated periodically from a subscription.They contain invoice items, and proration adjustments that may be caused by subscription upgrades/downgrades (if necessary).If your invoice is configured to be billed through automatic charges, Stripe automatically finalizes your invoice and attempts payment. Note that finalizing the invoice, when automatic, does not happen immediately as the invoice is created. Stripe waits until one hour after the last webhook was successfully sent (or the last webhook timed out after failing). If you (and the platforms you may have connected to) have no webhooks configured, Stripe waits one hour after creation to finalize the invoice.If your invoice is configured to be billed by sending an email, then based on your email settings, Stripe will email the invoice to your customer and await payment. These emails can contain a link to a hosted page to pay the invoice.Stripe applies any customer credit on the account before determining the amount due for the invoice (i.e., the amount that will be actually charged). If the amount due for the invoice is less than Stripe's minimum allowed charge per currency, the invoice is automatically marked paid, and we add the amount due to the customer's credit balance which is applied to the next invoice.More details on the customer's credit balance are here.
'''The Invoice object { "id": "in_1LSdrX2eZvKYlo2Cy1kxMopu", "object": "invoice", "account_country": "US", "account_name": "Stripe.com", "account_tax_ids": null, "amount_due": 300, "amount_paid": 0, "amount_remaining": 300, "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": 1659518855, "currency": "usd", "custom_fields": null, "customer": "cus_8TEMHVY5moxIPI", "customer_address": null, "customer_email": "ava.anderson.22@example.com", "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, "ending_balance": null, "footer": null, "hosted_invoice_url": null, "invoice_pdf": null, "last_finalization_error": null, "lines": { "object": "list", "data": [ { "id": "il_1LSdrX2eZvKYlo2CwVfODzHa", "object": "line_item", "amount": 300, "amount_excluding_tax": 300, "currency": "usd", "description": "My First Invoice Item (created for API docs)", "discount_amounts": [], "discountable": true, "discounts": [], "invoice_item": "ii_1LSdrX2eZvKYlo2Crz8rasOM", "livemode": false, "metadata": {}, "period": { "end": 1659518855, "start": 1659518855 }, "price": { "id": "price_1LScCX2eZvKYlo2C1Z9zPyXF", "object": "price", "active": true, "billing_scheme": "per_unit", "created": 1659512469, "currency": "usd", "custom_unit_amount": null, "livemode": false, "lookup_key": null, "metadata": {}, "nickname": null, "product": "prod_MAy8UvSA0uRRju", "recurring": null, "tax_behavior": "unspecified", "tiers_mode": null, "transform_quantity": null, "type": "one_time", "unit_amount": 300, "unit_amount_decimal": "300" }, "proration": false, "proration_details": { "credited_items": null }, "quantity": 1, "subscription": null, "tax_amounts": [], "tax_rates": [], "type": "invoiceitem", "unit_amount_excluding_tax": "300" } ], "has_more": false, "url": "/v1/invoices/in_1LSdrX2eZvKYlo2Cy1kxMopu/lines" }, "livemode": false, "metadata": {}, "next_payment_attempt": 1659522455, "number": null, "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": 1659518855, "period_start": 1659518855, "post_payment_credit_notes_amount": 0, "pre_payment_credit_notes_amount": 0, "quote": null, "receipt_number": null, "redaction": null, "rendering_options": null, "starting_balance": 0, "statement_descriptor": null, "status": "draft", "status_transitions": { "finalized_at": null, "marked_uncollectible_at": null, "paid_at": null, "voided_at": null }, "subscription": null, "subtotal": 300, "subtotal_excluding_tax": 300, "tax": null, "test_clock": null, "total": 300, "total_discount_amounts": [], "total_excluding_tax": 300, "total_tax_amounts": [], "transfer_data": null, "webhooks_delivered_at": null } '''
The Invoice objectAttributes id string Unique identifier for the object. auto_advance boolean Controls whether Stripe will perform automatic collection of the invoice. When false, the invoice’s state will not automatically advance without an explicit action. charge string expandable ID of the latest charge generated for this invoice, if any. collection_method string Either charge_automatically, or send_invoice. When charging automatically, Stripe will attempt to pay this invoice using the default source attached to the customer. When sending an invoice, Stripe will email this invoice to the customer with payment instructions. currency currency Three-letter ISO currency code, in lowercase. Must be a supported currency. customer string expandable The ID of the customer who will be billed. description string An arbitrary string attached to the object. Often useful for displaying to users. Referenced as ‘memo’ in the Dashboard. hosted_invoice_url string The URL for the hosted invoice page, which allows customers to view and pay an invoice. If the invoice has not been finalized yet, this will be null. lines list The individual line items that make up the invoice. lines is sorted as follows: invoice items in reverse chronological order, followed by the subscription, if any.Show child attributes metadata hash Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. payment_intent string expandable The PaymentIntent associated with this invoice. The PaymentIntent is generated when the invoice is finalized, and can then be used to pay the invoice. Note that voiding an invoice will cancel the PaymentIntent. period_end timestamp End of the usage period during which invoice items were added to this invoice. period_start timestamp Start of the usage period during which invoice items were added to this invoice. status string The status of the invoice, one of draft, open, paid, uncollectible, or void. Learn more subscription string expandable The subscription that this invoice was prepared for, if any. total integer Total after discounts and taxes.More attributesExpand all object string, value is "invoice" account_country string account_name string account_tax_ids array containing strings expandable amount_due integer amount_paid integer amount_remaining integer application string expandable "application" Connect only application_fee_amount integer Connect only attempt_count positive integer or zero attempted boolean automatic_tax hash billing_reason string created timestamp custom_fields array of hashes customer_address hash customer_email string customer_name string customer_phone string customer_shipping hash customer_tax_exempt string customer_tax_ids array of hashes default_payment_method string expandable default_source string expandable bank account, card, or source (e.g., card) default_tax_rates array of hashes discount hash, discount object Deprecated discounts array containing strings expandable due_date timestamp ending_balance integer footer string invoice_pdf string last_finalization_error hash livemode boolean next_payment_attempt timestamp number string on_behalf_of string expandable Connect only paid boolean paid_out_of_band boolean payment_settings hash post_payment_credit_notes_amount integer pre_payment_credit_notes_amount integer quote string expandable receipt_number string rendering_options hash starting_balance integer statement_descriptor string status_transitions hash subscription_proration_date integer subtotal integer subtotal_excluding_tax integer tax integer test_clock string expandable threshold_reason hash total_discount_amounts array of hashes total_excluding_tax integer total_tax_amounts array of hashes transfer_data hash Connect only webhooks_delivered_at timestamp
'''The (Invoice) Line Item object { "id": "il_tmp_1LSdra2eZvKYlo2COW02i0Bc", "object": "line_item", "amount": 300, "amount_excluding_tax": 300, "currency": "usd", "description": "My First Invoice Item (created for API docs)", "discount_amounts": [], "discountable": true, "discounts": [], "invoice_item": "ii_1LSdra2eZvKYlo2COW02i0Bc", "livemode": false, "metadata": {}, "period": { "end": 1659518858, "start": 1659518858 }, "price": { "id": "price_1LScCX2eZvKYlo2C1Z9zPyXF", "object": "price", "active": true, "billing_scheme": "per_unit", "created": 1659512469, "currency": "usd", "custom_unit_amount": null, "livemode": false, "lookup_key": null, "metadata": {}, "nickname": null, "product": "prod_MAy8UvSA0uRRju", "recurring": null, "tax_behavior": "unspecified", "tiers_mode": null, "transform_quantity": null, "type": "one_time", "unit_amount": 300, "unit_amount_decimal": "300" }, "proration": false, "proration_details": { "credited_items": null }, "quantity": 1, "subscription": null, "tax_amounts": [], "tax_rates": [], "type": "invoiceitem", "unit_amount_excluding_tax": "300" } '''
The (Invoice) Line Item objectAttributes id string Unique identifier for the object. amount integer The amount, in cents. currency currency Three-letter ISO currency code, in lowercase. Must be a supported currency. description string An arbitrary string attached to the object. Often useful for displaying to users. metadata hash Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Note that for line items with type=subscription this will reflect the metadata of the subscription that caused the line item to be created. period hash The period this line_item covers. For subscription line items, this is the subscription period. For prorations, this starts when the proration was calculated, and ends at the period end of the subscription. For invoice items, this is the time at which the invoice item was created or the period of the item.Show child attributes price hash The price of the line item.Show child attributes proration boolean Whether this is a proration. quantity integer The quantity of the subscription, if the line item is a subscription or a proration. type string A string identifying the type of the source of this line item, either an invoiceitem or a subscription.More attributesExpand all object string, value is "line_item" amount_excluding_tax integer discount_amounts array of hashes discountable boolean discounts array containing strings expandable invoice_item string livemode boolean proration_details hash subscription string subscription_item string tax_amounts array of hashes tax_rates array of hashes unit_amount_excluding_tax decimal string
import stripe stripe.api_key = "sk_test_your_key" stripe.Invoice.create( customer="cus_8TEMHVY5moxIPI", ) '''Response { "id": "in_1LSdrX2eZvKYlo2Cy1kxMopu", "object": "invoice", "account_country": "US", "account_name": "Stripe.com", "account_tax_ids": null, "amount_due": 300, "amount_paid": 0, "amount_remaining": 300, "application": null, "application_fee_amount": null, "attempt_count": 0, "attempted": false, "auto_advance": false, "automatic_tax": { "enabled": false, "status": null }, "billing_reason": "manual", "charge": null, "collection_method": "charge_automatically", "created": 1659518855, "currency": "usd", "custom_fields": null, "customer": "cus_8TEMHVY5moxIPI", "customer_address": null, "customer_email": "ava.anderson.22@example.com", "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, "ending_balance": null, "footer": null, "hosted_invoice_url": null, "invoice_pdf": null, "last_finalization_error": null, "lines": { "object": "list", "data": [ { "id": "il_1LSdrX2eZvKYlo2CwVfODzHa", "object": "line_item", "amount": 300, "amount_excluding_tax": 300, "currency": "usd", "description": "My First Invoice Item (created for API docs)", "discount_amounts": [], "discountable": true, "discounts": [], "invoice_item": "ii_1LSdrX2eZvKYlo2Crz8rasOM", "livemode": false, "metadata": {}, "period": { "end": 1659518855, "start": 1659518855 }, "price": { "id": "price_1LScCX2eZvKYlo2C1Z9zPyXF", "object": "price", "active": true, "billing_scheme": "per_unit", "created": 1659512469, "currency": "usd", "custom_unit_amount": null, "livemode": false, "lookup_key": null, "metadata": {}, "nickname": null, "product": "prod_MAy8UvSA0uRRju", "recurring": null, "tax_behavior": "unspecified", "tiers_mode": null, "transform_quantity": null, "type": "one_time", "unit_amount": 300, "unit_amount_decimal": "300" }, "proration": false, "proration_details": { "credited_items": null }, "quantity": 1, "subscription": null, "tax_amounts": [], "tax_rates": [], "type": "invoiceitem", "unit_amount_excluding_tax": "300" } ], "has_more": false, "url": "/v1/invoices/in_1LSdrX2eZvKYlo2Cy1kxMopu/lines" }, "livemode": false, "metadata": {}, "next_payment_attempt": 1659522455, "number": null, "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": 1659518855, "period_start": 1659518855, "post_payment_credit_notes_amount": 0, "pre_payment_credit_notes_amount": 0, "quote": null, "receipt_number": null, "redaction": null, "rendering_options": null, "starting_balance": 0, "statement_descriptor": null, "status": "draft", "status_transitions": { "finalized_at": null, "marked_uncollectible_at": null, "paid_at": null, "voided_at": null }, "subscription": null, "subtotal": 300, "subtotal_excluding_tax": 300, "tax": null, "test_clock": null, "total": 300, "total_discount_amounts": [], "total_excluding_tax": 300, "total_tax_amounts": [], "transfer_data": null, "webhooks_delivered_at": null }'''
Create an invoiceThis endpoint creates a draft invoice for a given customer. The draft invoice created pulls in all pending invoice items on that customer, including prorations. The invoice remains a draft until you finalize the invoice, which allows you to pay or send the invoice to your customers.Parameters auto_advance optional Controls whether Stripe will perform automatic collection of the invoice. When false, the invoice’s state will not automatically advance without an explicit action. collection_method optional Either charge_automatically, or send_invoice. When charging automatically, Stripe will attempt to pay this invoice using the default source attached to the customer. When sending an invoice, Stripe will email this invoice to the customer with payment instructions. Defaults to charge_automatically. customer optional The ID of the customer who will be billed. description optional An arbitrary string attached to the object. Often useful for displaying to users. Referenced as ‘memo’ in the Dashboard. metadata optional dictionary Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to metadata. subscription optional The ID of the subscription to invoice, if any. If set, the created invoice will only include pending invoice items for that subscription and pending invoice items not associated with any subscription if pending_invoice_items_behavior is include. The subscription’s billing cycle and regular subscription events won’t be affected.More parametersExpand all account_tax_ids optional application_fee_amount optional Connect only automatic_tax optional dictionary currency optional custom_fields optional array of hashes days_until_due optional default_payment_method optional default_source optional default_tax_rates optional discounts optional array of hashes due_date optional footer optional on_behalf_of optional Connect only payment_settings optional dictionary pending_invoice_items_behavior optional rendering_options optional dictionary statement_descriptor optional transfer_data optional dictionary Connect only ReturnsReturns the invoice object if there are pending invoice items to invoice. Raises an error if there are no pending invoice items or if the customer ID provided is invalid
import stripe stripe.api_key = "sk_test_your_key" stripe.Invoice.retrieve( "in_1LSdrX2eZvKYlo2Cy1kxMopu", ) '''Response { "id": "in_1LSdrX2eZvKYlo2Cy1kxMopu", "object": "invoice", "account_country": "US", "account_name": "Stripe.com", "account_tax_ids": null, "amount_due": 300, "amount_paid": 0, "amount_remaining": 300, "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": 1659518855, "currency": "usd", "custom_fields": null, "customer": "cus_8TEMHVY5moxIPI", "customer_address": null, "customer_email": "ava.anderson.22@example.com", "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, "ending_balance": null, "footer": null, "hosted_invoice_url": null, "invoice_pdf": null, "last_finalization_error": null, "lines": { "object": "list", "data": [ { "id": "il_1LSdrX2eZvKYlo2CwVfODzHa", "object": "line_item", "amount": 300, "amount_excluding_tax": 300, "currency": "usd", "description": "My First Invoice Item (created for API docs)", "discount_amounts": [], "discountable": true, "discounts": [], "invoice_item": "ii_1LSdrX2eZvKYlo2Crz8rasOM", "livemode": false, "metadata": {}, "period": { "end": 1659518855, "start": 1659518855 }, "price": { "id": "price_1LScCX2eZvKYlo2C1Z9zPyXF", "object": "price", "active": true, "billing_scheme": "per_unit", "created": 1659512469, "currency": "usd", "custom_unit_amount": null, "livemode": false, "lookup_key": null, "metadata": {}, "nickname": null, "product": "prod_MAy8UvSA0uRRju", "recurring": null, "tax_behavior": "unspecified", "tiers_mode": null, "transform_quantity": null, "type": "one_time", "unit_amount": 300, "unit_amount_decimal": "300" }, "proration": false, "proration_details": { "credited_items": null }, "quantity": 1, "subscription": null, "tax_amounts": [], "tax_rates": [], "type": "invoiceitem", "unit_amount_excluding_tax": "300" } ], "has_more": false, "url": "/v1/invoices/in_1LSdrX2eZvKYlo2Cy1kxMopu/lines" }, "livemode": false, "metadata": {}, "next_payment_attempt": 1659522455, "number": null, "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": 1659518855, "period_start": 1659518855, "post_payment_credit_notes_amount": 0, "pre_payment_credit_notes_amount": 0, "quote": null, "receipt_number": null, "redaction": null, "rendering_options": null, "starting_balance": 0, "statement_descriptor": null, "status": "draft", "status_transitions": { "finalized_at": null, "marked_uncollectible_at": null, "paid_at": null, "voided_at": null }, "subscription": null, "subtotal": 300, "subtotal_excluding_tax": 300, "tax": null, "test_clock": null, "total": 300, "total_discount_amounts": [], "total_excluding_tax": 300, "total_tax_amounts": [], "transfer_data": null, "webhooks_delivered_at": null }'''
Retrieve an invoiceRetrieves the invoice with the given ID.ParametersNo parameters.ReturnsReturns an invoice object if a valid invoice ID was provided. Raises an error otherwise. The invoice object contains a lines hash that contains information about the subscriptions and invoice items that have been applied to the invoice, as well as any prorations that Stripe has automatically calculated. Each line on the invoice has an amount attribute that represents the amount actually contributed to the invoice’s total. For invoice items and prorations, the amount attribute is the same as for the invoice item or proration respectively. For subscriptions, the amount may be different from the plan’s regular price depending on whether the invoice covers a trial period or the invoice period differs from the plan’s usual interval. The invoice object has both a subtotal and a total. The subtotal represents the total before any discounts, while the total is the final amount to be charged to the customer after all coupons have been applied. The invoice also has a next_payment_attempt attribute that tells you the next time (as a Unix timestamp) payment for the invoice will be automatically attempted. For invoices with manual payment collection, that have been closed, or that have reached the maximum number of retries (specified in your subscriptions settings), the next_payment_attempt will be None
import stripe stripe.api_key = "sk_test_your_key" stripe.Invoice.modify( "in_1LSdrX2eZvKYlo2Cy1kxMopu", metadata={"order_id": "6735"}, ) '''Response { "id": "in_1LSdrX2eZvKYlo2Cy1kxMopu", "object": "invoice", "account_country": "US", "account_name": "Stripe.com", "account_tax_ids": null, "amount_due": 300, "amount_paid": 0, "amount_remaining": 300, "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": 1659518855, "currency": "usd", "custom_fields": null, "customer": "cus_8TEMHVY5moxIPI", "customer_address": null, "customer_email": "ava.anderson.22@example.com", "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, "ending_balance": null, "footer": null, "hosted_invoice_url": null, "invoice_pdf": null, "last_finalization_error": null, "lines": { "object": "list", "data": [ { "id": "il_1LSdrX2eZvKYlo2CwVfODzHa", "object": "line_item", "amount": 300, "amount_excluding_tax": 300, "currency": "usd", "description": "My First Invoice Item (created for API docs)", "discount_amounts": [], "discountable": true, "discounts": [], "invoice_item": "ii_1LSdrX2eZvKYlo2Crz8rasOM", "livemode": false, "metadata": {}, "period": { "end": 1659518855, "start": 1659518855 }, "price": { "id": "price_1LScCX2eZvKYlo2C1Z9zPyXF", "object": "price", "active": true, "billing_scheme": "per_unit", "created": 1659512469, "currency": "usd", "custom_unit_amount": null, "livemode": false, "lookup_key": null, "metadata": {}, "nickname": null, "product": "prod_MAy8UvSA0uRRju", "recurring": null, "tax_behavior": "unspecified", "tiers_mode": null, "transform_quantity": null, "type": "one_time", "unit_amount": 300, "unit_amount_decimal": "300" }, "proration": false, "proration_details": { "credited_items": null }, "quantity": 1, "subscription": null, "tax_amounts": [], "tax_rates": [], "type": "invoiceitem", "unit_amount_excluding_tax": "300" } ], "has_more": false, "url": "/v1/invoices/in_1LSdrX2eZvKYlo2Cy1kxMopu/lines" }, "livemode": false, "metadata": { "order_id": "6735" }, "next_payment_attempt": 1659522455, "number": null, "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": 1659518855, "period_start": 1659518855, "post_payment_credit_notes_amount": 0, "pre_payment_credit_notes_amount": 0, "quote": null, "receipt_number": null, "redaction": null, "rendering_options": null, "starting_balance": 0, "statement_descriptor": null, "status": "draft", "status_transitions": { "finalized_at": null, "marked_uncollectible_at": null, "paid_at": null, "voided_at": null }, "subscription": null, "subtotal": 300, "subtotal_excluding_tax": 300, "tax": null, "test_clock": null, "total": 300, "total_discount_amounts": [], "total_excluding_tax": 300, "total_tax_amounts": [], "transfer_data": null, "webhooks_delivered_at": null }'''
Update an invoiceDraft invoices are fully editable. Once an invoice is finalized, monetary values, as well as collection_method, become uneditable. If you would like to stop the Stripe Billing engine from automatically finalizing, reattempting payments on, sending reminders for, or automatically reconciling invoices, pass auto_advance=false.Parameters auto_advance optional Controls whether Stripe will perform automatic collection of the invoice. collection_method optional Either charge_automatically or send_invoice. This field can be updated only on draft invoices. description optional An arbitrary string attached to the object. Often useful for displaying to users. Referenced as ‘memo’ in the Dashboard. metadata optional dictionary Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to metadata.More parametersExpand all account_tax_ids optional application_fee_amount optional Connect only automatic_tax optional dictionary custom_fields optional array of hashes days_until_due optional default_payment_method optional default_source optional default_tax_rates optional discounts optional array of hashes due_date optional footer optional on_behalf_of optional Connect only payment_settings optional dictionary rendering_options optional dictionary statement_descriptor optional transfer_data optional dictionary Connect only ReturnsReturns the invoice object
import stripe stripe.api_key = "sk_test_your_key" stripe.Invoice.delete( "in_1LSdrX2eZvKYlo2Cy1kxMopu", ) '''Response { "id": "in_1LSdrX2eZvKYlo2Cy1kxMopu", "object": "invoice", "deleted": true }'''
Delete a draft invoicePermanently deletes a one-off invoice draft. This cannot be undone. Attempts to delete invoices that are no longer in a draft state will fail; once an invoice has been finalized or if an invoice is for a subscription, it must be voided.ParametersNo parameters.ReturnsA successfully deleted invoice. Otherwise, this call raises an error, such as if the invoice has already been deleted
import stripe stripe.api_key = "sk_test_your_key" stripe.Invoice.finalize_invoice( "in_1LSdrX2eZvKYlo2Cy1kxMopu", ) '''Response { "id": "in_1LSdrX2eZvKYlo2Cy1kxMopu", "object": "invoice", "account_country": "US", "account_name": "Stripe.com", "account_tax_ids": null, "amount_due": 300, "amount_paid": 0, "amount_remaining": 300, "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": 1659518855, "currency": "usd", "custom_fields": null, "customer": "cus_8TEMHVY5moxIPI", "customer_address": null, "customer_email": "ava.anderson.22@example.com", "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, "ending_balance": null, "footer": null, "hosted_invoice_url": null, "invoice_pdf": null, "last_finalization_error": null, "lines": { "object": "list", "data": [ { "id": "il_1LSdrX2eZvKYlo2CwVfODzHa", "object": "line_item", "amount": 300, "amount_excluding_tax": 300, "currency": "usd", "description": "My First Invoice Item (created for API docs)", "discount_amounts": [], "discountable": true, "discounts": [], "invoice_item": "ii_1LSdrX2eZvKYlo2Crz8rasOM", "livemode": false, "metadata": {}, "period": { "end": 1659518855, "start": 1659518855 }, "price": { "id": "price_1LScCX2eZvKYlo2C1Z9zPyXF", "object": "price", "active": true, "billing_scheme": "per_unit", "created": 1659512469, "currency": "usd", "custom_unit_amount": null, "livemode": false, "lookup_key": null, "metadata": {}, "nickname": null, "product": "prod_MAy8UvSA0uRRju", "recurring": null, "tax_behavior": "unspecified", "tiers_mode": null, "transform_quantity": null, "type": "one_time", "unit_amount": 300, "unit_amount_decimal": "300" }, "proration": false, "proration_details": { "credited_items": null }, "quantity": 1, "subscription": null, "tax_amounts": [], "tax_rates": [], "type": "invoiceitem", "unit_amount_excluding_tax": "300" } ], "has_more": false, "url": "/v1/invoices/in_1LSdrX2eZvKYlo2Cy1kxMopu/lines" }, "livemode": false, "metadata": {}, "next_payment_attempt": 1659522455, "number": null, "on_behalf_of": null, "paid": false, "paid_out_of_band": false, "payment_intent": "pi_1DrPsv2eZvKYlo2CEDzqXfPH", "payment_settings": { "default_mandate": null, "payment_method_options": null, "payment_method_types": null }, "period_end": 1659518855, "period_start": 1659518855, "post_payment_credit_notes_amount": 0, "pre_payment_credit_notes_amount": 0, "quote": null, "receipt_number": null, "redaction": null, "rendering_options": null, "starting_balance": 0, "statement_descriptor": null, "status": "open", "status_transitions": { "finalized_at": 1659518858, "marked_uncollectible_at": null, "paid_at": null, "voided_at": null }, "subscription": null, "subtotal": 300, "subtotal_excluding_tax": 300, "tax": null, "test_clock": null, "total": 300, "total_discount_amounts": [], "total_excluding_tax": 300, "total_tax_amounts": [], "transfer_data": null, "webhooks_delivered_at": 1659518858, "closed": false, "issued_at": 1659518858 }'''
Finalize an invoiceStripe automatically finalizes drafts before sending and attempting payment on invoices. However, if you’d like to finalize a draft invoice manually, you can do so using this method.Parameters auto_advance optional Controls whether Stripe will perform automatic collection of the invoice. When false, the invoice’s state will not automatically advance without an explicit action.ReturnsReturns an invoice object with status=open
import stripe stripe.api_key = "sk_test_your_key" stripe.Invoice.pay("in_1LSdrX2eZvKYlo2Cy1kxMopu") '''Response { "id": "in_1LSdrX2eZvKYlo2Cy1kxMopu", "object": "invoice", "account_country": "US", "account_name": "Stripe.com", "account_tax_ids": null, "amount_due": 300, "amount_paid": 0, "amount_remaining": 300, "application": null, "application_fee_amount": null, "attempt_count": 0, "attempted": true, "auto_advance": true, "automatic_tax": { "enabled": false, "status": null }, "billing_reason": "manual", "charge": "ch_3LSdrX2eZvKYlo2C0Gaq4Obr", "collection_method": "charge_automatically", "created": 1659518855, "currency": "usd", "custom_fields": null, "customer": "cus_8TEMHVY5moxIPI", "customer_address": null, "customer_email": "ava.anderson.22@example.com", "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, "ending_balance": null, "footer": null, "hosted_invoice_url": null, "invoice_pdf": null, "last_finalization_error": null, "lines": { "object": "list", "data": [ { "id": "il_1LSdrX2eZvKYlo2CwVfODzHa", "object": "line_item", "amount": 300, "amount_excluding_tax": 300, "currency": "usd", "description": "My First Invoice Item (created for API docs)", "discount_amounts": [], "discountable": true, "discounts": [], "invoice_item": "ii_1LSdrX2eZvKYlo2Crz8rasOM", "livemode": false, "metadata": {}, "period": { "end": 1659518855, "start": 1659518855 }, "price": { "id": "price_1LScCX2eZvKYlo2C1Z9zPyXF", "object": "price", "active": true, "billing_scheme": "per_unit", "created": 1659512469, "currency": "usd", "custom_unit_amount": null, "livemode": false, "lookup_key": null, "metadata": {}, "nickname": null, "product": "prod_MAy8UvSA0uRRju", "recurring": null, "tax_behavior": "unspecified", "tiers_mode": null, "transform_quantity": null, "type": "one_time", "unit_amount": 300, "unit_amount_decimal": "300" }, "proration": false, "proration_details": { "credited_items": null }, "quantity": 1, "subscription": null, "tax_amounts": [], "tax_rates": [], "type": "invoiceitem", "unit_amount_excluding_tax": "300" } ], "has_more": false, "url": "/v1/invoices/in_1LSdrX2eZvKYlo2Cy1kxMopu/lines" }, "livemode": false, "metadata": {}, "next_payment_attempt": 1659522455, "number": null, "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": 1659518855, "period_start": 1659518855, "post_payment_credit_notes_amount": 0, "pre_payment_credit_notes_amount": 0, "quote": null, "receipt_number": null, "redaction": null, "rendering_options": null, "starting_balance": 0, "statement_descriptor": null, "status": "paid", "status_transitions": { "finalized_at": null, "marked_uncollectible_at": null, "paid_at": null, "voided_at": null }, "subscription": null, "subtotal": 300, "subtotal_excluding_tax": 300, "tax": null, "test_clock": null, "total": 300, "total_discount_amounts": [], "total_excluding_tax": 300, "total_tax_amounts": [], "transfer_data": null, "webhooks_delivered_at": null, "last_payment_attempt": null }'''
Pay an invoiceStripe automatically creates and then attempts to collect payment on invoices for customers on subscriptions according to your subscriptions settings. However, if you’d like to attempt payment on an invoice out of the normal collection schedule or for some other reason, you can do so.ParametersExpand all forgive optional mandate optional off_session optional paid_out_of_band optional payment_method optional source optional ReturnsReturns the invoice object
import stripe stripe.api_key = "sk_test_your_key" stripe.Invoice.send_invoice( "in_1LSdrX2eZvKYlo2Cy1kxMopu", ) '''Response { "id": "in_1LSdrX2eZvKYlo2Cy1kxMopu", "object": "invoice", "account_country": "US", "account_name": "Stripe.com", "account_tax_ids": null, "amount_due": 300, "amount_paid": 0, "amount_remaining": 300, "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": "send_invoice", "created": 1659518855, "currency": "usd", "custom_fields": null, "customer": "cus_8TEMHVY5moxIPI", "customer_address": null, "customer_email": "ava.anderson.22@example.com", "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, "ending_balance": null, "footer": null, "hosted_invoice_url": null, "invoice_pdf": null, "last_finalization_error": null, "lines": { "object": "list", "data": [ { "id": "il_1LSdrX2eZvKYlo2CwVfODzHa", "object": "line_item", "amount": 300, "amount_excluding_tax": 300, "currency": "usd", "description": "My First Invoice Item (created for API docs)", "discount_amounts": [], "discountable": true, "discounts": [], "invoice_item": "ii_1LSdrX2eZvKYlo2Crz8rasOM", "livemode": false, "metadata": {}, "period": { "end": 1659518855, "start": 1659518855 }, "price": { "id": "price_1LScCX2eZvKYlo2C1Z9zPyXF", "object": "price", "active": true, "billing_scheme": "per_unit", "created": 1659512469, "currency": "usd", "custom_unit_amount": null, "livemode": false, "lookup_key": null, "metadata": {}, "nickname": null, "product": "prod_MAy8UvSA0uRRju", "recurring": null, "tax_behavior": "unspecified", "tiers_mode": null, "transform_quantity": null, "type": "one_time", "unit_amount": 300, "unit_amount_decimal": "300" }, "proration": false, "proration_details": { "credited_items": null }, "quantity": 1, "subscription": null, "tax_amounts": [], "tax_rates": [], "type": "invoiceitem", "unit_amount_excluding_tax": "300" } ], "has_more": false, "url": "/v1/invoices/in_1LSdrX2eZvKYlo2Cy1kxMopu/lines" }, "livemode": false, "metadata": {}, "next_payment_attempt": 1659522455, "number": null, "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": 1659518855, "period_start": 1659518855, "post_payment_credit_notes_amount": 0, "pre_payment_credit_notes_amount": 0, "quote": null, "receipt_number": null, "redaction": null, "rendering_options": null, "starting_balance": 0, "statement_descriptor": null, "status": "open", "status_transitions": { "finalized_at": 1659518858.39303, "marked_uncollectible_at": null, "paid_at": null, "voided_at": null }, "subscription": null, "subtotal": 300, "subtotal_excluding_tax": 300, "tax": null, "test_clock": null, "total": 300, "total_discount_amounts": [], "total_excluding_tax": 300, "total_tax_amounts": [], "transfer_data": null, "webhooks_delivered_at": null }'''
Send an invoice for manual paymentStripe will automatically send invoices to customers according to your subscriptions settings. However, if you’d like to manually send an invoice to your customer out of the normal schedule, you can do so. When sending invoices that have already been paid, there will be no reference to the payment in the email. Requests made in test-mode result in no emails being sent, despite sending an invoice.sent event.ParametersNo parameters.ReturnsReturns the invoice object
import stripe stripe.api_key = "sk_test_your_key" stripe.Invoice.void_invoice( "in_1LSdrX2eZvKYlo2Cy1kxMopu", ) '''Response { "id": "in_1LSdrX2eZvKYlo2Cy1kxMopu", "object": "invoice", "account_country": "US", "account_name": "Stripe.com", "account_tax_ids": null, "amount_due": 300, "amount_paid": 0, "amount_remaining": 300, "application": null, "application_fee_amount": null, "attempt_count": 0, "attempted": false, "auto_advance": false, "automatic_tax": { "enabled": false, "status": null }, "billing_reason": "manual", "charge": null, "collection_method": "charge_automatically", "created": 1659518855, "currency": "usd", "custom_fields": null, "customer": "cus_8TEMHVY5moxIPI", "customer_address": null, "customer_email": "ava.anderson.22@example.com", "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, "ending_balance": null, "footer": null, "hosted_invoice_url": null, "invoice_pdf": null, "last_finalization_error": null, "lines": { "object": "list", "data": [ { "id": "il_1LSdrX2eZvKYlo2CwVfODzHa", "object": "line_item", "amount": 300, "amount_excluding_tax": 300, "currency": "usd", "description": "My First Invoice Item (created for API docs)", "discount_amounts": [], "discountable": true, "discounts": [], "invoice_item": "ii_1LSdrX2eZvKYlo2Crz8rasOM", "livemode": false, "metadata": {}, "period": { "end": 1659518855, "start": 1659518855 }, "price": { "id": "price_1LScCX2eZvKYlo2C1Z9zPyXF", "object": "price", "active": true, "billing_scheme": "per_unit", "created": 1659512469, "currency": "usd", "custom_unit_amount": null, "livemode": false, "lookup_key": null, "metadata": {}, "nickname": null, "product": "prod_MAy8UvSA0uRRju", "recurring": null, "tax_behavior": "unspecified", "tiers_mode": null, "transform_quantity": null, "type": "one_time", "unit_amount": 300, "unit_amount_decimal": "300" }, "proration": false, "proration_details": { "credited_items": null }, "quantity": 1, "subscription": null, "tax_amounts": [], "tax_rates": [], "type": "invoiceitem", "unit_amount_excluding_tax": "300" } ], "has_more": false, "url": "/v1/invoices/in_1LSdrX2eZvKYlo2Cy1kxMopu/lines" }, "livemode": false, "metadata": {}, "next_payment_attempt": 1659522455, "number": null, "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": 1659518855, "period_start": 1659518855, "post_payment_credit_notes_amount": 0, "pre_payment_credit_notes_amount": 0, "quote": null, "receipt_number": null, "redaction": null, "rendering_options": null, "starting_balance": 0, "statement_descriptor": null, "status": "void", "status_transitions": { "finalized_at": null, "marked_uncollectible_at": null, "paid_at": null, "voided_at": null }, "subscription": null, "subtotal": 300, "subtotal_excluding_tax": 300, "tax": null, "test_clock": null, "total": 300, "total_discount_amounts": [], "total_excluding_tax": 300, "total_tax_amounts": [], "transfer_data": null, "webhooks_delivered_at": null, "closed": true, "forgiven": false }'''
Void an invoiceMark a finalized invoice as void. This cannot be undone. Voiding an invoice is similar to deletion, however it only applies to finalized invoices and maintains a papertrail where the invoice can still be found.ParametersNo parameters.ReturnsReturns the voided invoice object
import stripe stripe.api_key = "sk_test_your_key" stripe.Invoice.mark_uncollectible( "in_1LSdrX2eZvKYlo2Cy1kxMopu", ) '''Response { "id": "in_1LSdrX2eZvKYlo2Cy1kxMopu", "object": "invoice", "account_country": "US", "account_name": "Stripe.com", "account_tax_ids": null, "amount_due": 300, "amount_paid": 0, "amount_remaining": 300, "application": null, "application_fee_amount": null, "attempt_count": 0, "attempted": false, "auto_advance": false, "automatic_tax": { "enabled": false, "status": null }, "billing_reason": "manual", "charge": null, "collection_method": "charge_automatically", "created": 1659518855, "currency": "usd", "custom_fields": null, "customer": "cus_8TEMHVY5moxIPI", "customer_address": null, "customer_email": "ava.anderson.22@example.com", "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, "ending_balance": null, "footer": null, "hosted_invoice_url": null, "invoice_pdf": null, "last_finalization_error": null, "lines": { "object": "list", "data": [ { "id": "il_1LSdrX2eZvKYlo2CwVfODzHa", "object": "line_item", "amount": 300, "amount_excluding_tax": 300, "currency": "usd", "description": "My First Invoice Item (created for API docs)", "discount_amounts": [], "discountable": true, "discounts": [], "invoice_item": "ii_1LSdrX2eZvKYlo2Crz8rasOM", "livemode": false, "metadata": {}, "period": { "end": 1659518855, "start": 1659518855 }, "price": { "id": "price_1LScCX2eZvKYlo2C1Z9zPyXF", "object": "price", "active": true, "billing_scheme": "per_unit", "created": 1659512469, "currency": "usd", "custom_unit_amount": null, "livemode": false, "lookup_key": null, "metadata": {}, "nickname": null, "product": "prod_MAy8UvSA0uRRju", "recurring": null, "tax_behavior": "unspecified", "tiers_mode": null, "transform_quantity": null, "type": "one_time", "unit_amount": 300, "unit_amount_decimal": "300" }, "proration": false, "proration_details": { "credited_items": null }, "quantity": 1, "subscription": null, "tax_amounts": [], "tax_rates": [], "type": "invoiceitem", "unit_amount_excluding_tax": "300" } ], "has_more": false, "url": "/v1/invoices/in_1LSdrX2eZvKYlo2Cy1kxMopu/lines" }, "livemode": false, "metadata": {}, "next_payment_attempt": 1659522455, "number": null, "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": 1659518855, "period_start": 1659518855, "post_payment_credit_notes_amount": 0, "pre_payment_credit_notes_amount": 0, "quote": null, "receipt_number": null, "redaction": null, "rendering_options": null, "starting_balance": 0, "statement_descriptor": null, "status": "uncollectible", "status_transitions": { "finalized_at": null, "marked_uncollectible_at": null, "paid_at": null, "voided_at": null }, "subscription": null, "subtotal": 300, "subtotal_excluding_tax": 300, "tax": null, "test_clock": null, "total": 300, "total_discount_amounts": [], "total_excluding_tax": 300, "total_tax_amounts": [], "transfer_data": null, "webhooks_delivered_at": null, "closed": true, "forgiven": true }'''
Mark an invoice as uncollectibleMarking an invoice as uncollectible is useful for keeping track of bad debts that can be written off for accounting purposes.ParametersNo parameters.ReturnsReturns the invoice object
import stripe stripe.api_key = "sk_test_your_key" invoice = stripe.Invoice.retrieve('in_1LSdrX2eZvKYlo2Cy1kxMopu') lines = invoice.lines.list(limit=5) '''Response { "object": "list", "url": "/v1/invoices/in_1LSdrX2eZvKYlo2Cy1kxMopu/lines", "has_more": false, "data": [ { "id": "il_tmp_1LSdra2eZvKYlo2COW02i0Bc", "object": "line_item", "amount": 300, "amount_excluding_tax": 300, "currency": "usd", "description": "My First Invoice Item (created for API docs)", "discount_amounts": [], "discountable": true, "discounts": [], "invoice_item": "ii_1LSdra2eZvKYlo2COW02i0Bc", "livemode": false, "metadata": {}, "period": { "end": 1659518858, "start": 1659518858 }, "price": { "id": "price_1LScCX2eZvKYlo2C1Z9zPyXF", "object": "price", "active": true, "billing_scheme": "per_unit", "created": 1659512469, "currency": "usd", "custom_unit_amount": null, "livemode": false, "lookup_key": null, "metadata": {}, "nickname": null, "product": "prod_MAy8UvSA0uRRju", "recurring": null, "tax_behavior": "unspecified", "tiers_mode": null, "transform_quantity": null, "type": "one_time", "unit_amount": 300, "unit_amount_decimal": "300" }, "proration": false, "proration_details": { "credited_items": null }, "quantity": 1, "subscription": null, "tax_amounts": [], "tax_rates": [], "type": "invoiceitem", "unit_amount_excluding_tax": "300" }, {...}, {...} ] }'''
Retrieve an invoice's line itemsWhen retrieving an invoice, you’ll get a lines property containing the total count of line items and the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items.ParametersExpand all ending_before optional limit optional starting_after optional ReturnsReturns a list of line_item objects
import stripe stripe.api_key = "sk_test_your_key" stripe.Invoice.upcoming( customer='cus_8TEMHVY5moxIPI', ) '''Response { "object": "invoice", "account_country": "US", "account_name": "Stripe.com", "account_tax_ids": null, "amount_due": 300, "amount_paid": 0, "amount_remaining": 300, "application": null, "application_fee_amount": null, "attempt_count": 0, "attempted": false, "automatic_tax": { "enabled": false, "status": null }, "billing_reason": "manual", "charge": null, "collection_method": "charge_automatically", "created": 1659518855, "currency": "usd", "custom_fields": null, "customer": "cus_8TEMHVY5moxIPI", "customer_address": null, "customer_email": "ava.anderson.22@example.com", "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, "ending_balance": null, "footer": null, "last_finalization_error": null, "lines": { "object": "list", "data": [ { "id": "il_1LSdrX2eZvKYlo2CwVfODzHa", "object": "line_item", "amount": 300, "amount_excluding_tax": 300, "currency": "usd", "description": "My First Invoice Item (created for API docs)", "discount_amounts": [], "discountable": true, "discounts": [], "invoice_item": "ii_1LSdrX2eZvKYlo2Crz8rasOM", "livemode": false, "metadata": {}, "period": { "end": 1659518855, "start": 1659518855 }, "price": { "id": "price_1LScCX2eZvKYlo2C1Z9zPyXF", "object": "price", "active": true, "billing_scheme": "per_unit", "created": 1659512469, "currency": "usd", "custom_unit_amount": null, "livemode": false, "lookup_key": null, "metadata": {}, "nickname": null, "product": "prod_MAy8UvSA0uRRju", "recurring": null, "tax_behavior": "unspecified", "tiers_mode": null, "transform_quantity": null, "type": "one_time", "unit_amount": 300, "unit_amount_decimal": "300" }, "proration": false, "proration_details": { "credited_items": null }, "quantity": 1, "subscription": null, "tax_amounts": [], "tax_rates": [], "type": "invoiceitem", "unit_amount_excluding_tax": "300" } ], "has_more": false, "url": "/v1/invoices/upcoming/lines?customer=cu_18CHts2eZvKYlo2CbmAAQORe" }, "livemode": false, "metadata": {}, "next_payment_attempt": null, "number": null, "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": 1659518855, "period_start": 1659518855, "post_payment_credit_notes_amount": 0, "pre_payment_credit_notes_amount": 0, "quote": null, "receipt_number": null, "redaction": null, "rendering_options": null, "starting_balance": 0, "statement_descriptor": null, "status": "draft", "status_transitions": { "finalized_at": null, "marked_uncollectible_at": null, "paid_at": null, "voided_at": null }, "subscription": null, "subtotal": 300, "subtotal_excluding_tax": 300, "tax": null, "test_clock": null, "total": 300, "total_discount_amounts": [], "total_excluding_tax": 300, "total_tax_amounts": [], "transfer_data": null, "webhooks_delivered_at": null }'''
Retrieve an upcoming invoiceAt any time, you can preview the upcoming invoice for a customer. This will show you all the charges that are pending, including subscription renewal charges, invoice item charges, etc. It will also show you any discounts that are applicable to the invoice. Note that when you are viewing an upcoming invoice, you are simply viewing a preview – the invoice has not yet been created. As such, the upcoming invoice will not show up in invoice listing calls, and you cannot use the API to pay or edit the invoice. If you want to change the amount that your customer will be billed, you can add, remove, or update pending invoice items, or update the customer’s discount. You can preview the effects of updating a subscription, including a preview of what proration will take place. To ensure that the actual proration is calculated exactly the same as the previewed proration, you should pass a proration_date parameter when doing the actual subscription update. The value passed in should be the same as the subscription_proration_date returned on the upcoming invoice resource. The recommended way to get only the prorations being previewed is to consider only proration line items where period[start] is equal to the subscription_proration_date on the upcoming invoice resource.Parameters customer Required if subscription unset The identifier of the customer whose upcoming invoice you’d like to retrieve. subscription optional The identifier of the subscription for which you’d like to retrieve the upcoming invoice. If not provided, but a subscription_items is provided, you will preview creating a subscription with those items. If neither subscription nor subscription_items is provided, you will retrieve the next upcoming invoice from among the customer’s subscriptions.More parametersExpand all customer_details Required if subscription and customer unset automatic_tax optional dictionary coupon optional currency optional discounts optional array of hashes invoice_items optional array of hashes schedule optional subscription_billing_cycle_anchor optional subscription_cancel_at optional subscription_cancel_at_period_end optional subscription_cancel_now optional subscription_default_tax_rates optional subscription_items optional array of hashes subscription_proration_behavior optional subscription_proration_date optional subscription_start_date optional subscription_trial_end optional subscription_trial_from_plan optional ReturnsReturns an invoice if valid customer information is provided. Raises an error otherwise
import stripe stripe.api_key = "sk_test_your_key" invoice = stripe.Invoice.upcoming( customer='cus_8TEMHVY5moxIPI', ) invoice.lines.list(limit=5) '''Response { "object": "list", "url": "/v1/invoices/upcoming/lines", "has_more": false, "data": [ { "id": "il_tmp_1LSdra2eZvKYlo2COW02i0Bc", "object": "line_item", "amount": 300, "amount_excluding_tax": 300, "currency": "usd", "description": "My First Invoice Item (created for API docs)", "discount_amounts": [], "discountable": true, "discounts": [], "invoice_item": "ii_1LSdra2eZvKYlo2COW02i0Bc", "livemode": false, "metadata": {}, "period": { "end": 1659518858, "start": 1659518858 }, "price": { "id": "price_1LScCX2eZvKYlo2C1Z9zPyXF", "object": "price", "active": true, "billing_scheme": "per_unit", "created": 1659512469, "currency": "usd", "custom_unit_amount": null, "livemode": false, "lookup_key": null, "metadata": {}, "nickname": null, "product": "prod_MAy8UvSA0uRRju", "recurring": null, "tax_behavior": "unspecified", "tiers_mode": null, "transform_quantity": null, "type": "one_time", "unit_amount": 300, "unit_amount_decimal": "300" }, "proration": false, "proration_details": { "credited_items": null }, "quantity": 1, "subscription": null, "tax_amounts": [], "tax_rates": [], "type": "invoiceitem", "unit_amount_excluding_tax": "300" }, {...}, {...} ] }'''
Retrieve an upcoming invoice's line itemsWhen retrieving an upcoming invoice, you’ll get a lines property containing the total count of line items and the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items.Parameters customer Required if subscription unset The identifier of the customer whose upcoming invoice you’d like to retrieve. subscription optional The identifier of the subscription for which you’d like to retrieve the upcoming invoice. If not provided, but a subscription_items is provided, you will preview creating a subscription with those items. If neither subscription nor subscription_items is provided, you will retrieve the next upcoming invoice from among the customer’s subscriptions.More parametersExpand all customer_details Required if subscription and customer unset automatic_tax optional dictionary coupon optional currency optional discounts optional array of hashes ending_before optional invoice_items optional array of hashes limit optional schedule optional starting_after optional subscription_billing_cycle_anchor optional subscription_cancel_at optional subscription_cancel_at_period_end optional subscription_cancel_now optional subscription_default_tax_rates optional subscription_items optional array of hashes subscription_proration_behavior optional subscription_proration_date optional subscription_start_date optional subscription_trial_end optional subscription_trial_from_plan optional ReturnsReturns a list of line_item objects
import stripe stripe.api_key = "sk_test_your_key" stripe.Invoice.list(limit=3) '''Response { "object": "list", "url": "/v1/invoices", "has_more": false, "data": [ { "id": "in_1LSdrX2eZvKYlo2Cy1kxMopu", "object": "invoice", "account_country": "US", "account_name": "Stripe.com", "account_tax_ids": null, "amount_due": 300, "amount_paid": 0, "amount_remaining": 300, "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": 1659518855, "currency": "usd", "custom_fields": null, "customer": "cus_8TEMHVY5moxIPI", "customer_address": null, "customer_email": "ava.anderson.22@example.com", "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, "ending_balance": null, "footer": null, "hosted_invoice_url": null, "invoice_pdf": null, "last_finalization_error": null, "lines": { "object": "list", "data": [ { "id": "il_1LSdrX2eZvKYlo2CwVfODzHa", "object": "line_item", "amount": 300, "amount_excluding_tax": 300, "currency": "usd", "description": "My First Invoice Item (created for API docs)", "discount_amounts": [], "discountable": true, "discounts": [], "invoice_item": "ii_1LSdrX2eZvKYlo2Crz8rasOM", "livemode": false, "metadata": {}, "period": { "end": 1659518855, "start": 1659518855 }, "price": { "id": "price_1LScCX2eZvKYlo2C1Z9zPyXF", "object": "price", "active": true, "billing_scheme": "per_unit", "created": 1659512469, "currency": "usd", "custom_unit_amount": null, "livemode": false, "lookup_key": null, "metadata": {}, "nickname": null, "product": "prod_MAy8UvSA0uRRju", "recurring": null, "tax_behavior": "unspecified", "tiers_mode": null, "transform_quantity": null, "type": "one_time", "unit_amount": 300, "unit_amount_decimal": "300" }, "proration": false, "proration_details": { "credited_items": null }, "quantity": 1, "subscription": null, "tax_amounts": [], "tax_rates": [], "type": "invoiceitem", "unit_amount_excluding_tax": "300" } ], "has_more": false, "url": "/v1/invoices/in_1LSdrX2eZvKYlo2Cy1kxMopu/lines" }, "livemode": false, "metadata": {}, "next_payment_attempt": 1659522455, "number": null, "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": 1659518855, "period_start": 1659518855, "post_payment_credit_notes_amount": 0, "pre_payment_credit_notes_amount": 0, "quote": null, "receipt_number": null, "redaction": null, "rendering_options": null, "starting_balance": 0, "statement_descriptor": null, "status": "draft", "status_transitions": { "finalized_at": null, "marked_uncollectible_at": null, "paid_at": null, "voided_at": null }, "subscription": null, "subtotal": 300, "subtotal_excluding_tax": 300, "tax": null, "test_clock": null, "total": 300, "total_discount_amounts": [], "total_excluding_tax": 300, "total_tax_amounts": [], "transfer_data": null, "webhooks_delivered_at": null }, {...}, {...} ] }'''
List all invoicesYou can list all invoices, or list the invoices for a specific customer. The invoices are returned sorted by creation date, with the most recently created invoices appearing first.Parameters customer optional Only return invoices for the customer specified by this customer ID. status optional The status of the invoice, one of draft, open, paid, uncollectible, or void. Learn more subscription optional Only return invoices for the subscription specified by this subscription ID.More parametersExpand all collection_method optional created optional dictionary due_date optional dictionary ending_before optional limit optional starting_after optional ReturnsA dictionary with a data property that contains an array invoice attachments,
import stripe stripe.api_key = "sk_test_your_key" stripe.Invoice.search( query="total>999 AND metadata['order_id']:'6735'", ) '''Response { "object": "search_result", "url": "/v1/invoices/search", "has_more": false, "data": [ { "id": "in_1LSdrX2eZvKYlo2Cy1kxMopu", "object": "invoice", "account_country": "US", "account_name": "Stripe.com", "account_tax_ids": null, "amount_due": 300, "amount_paid": 0, "amount_remaining": 300, "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": 1659518855, "currency": "usd", "custom_fields": null, "customer": "cus_8TEMHVY5moxIPI", "customer_address": null, "customer_email": "ava.anderson.22@example.com", "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, "ending_balance": null, "footer": null, "hosted_invoice_url": null, "invoice_pdf": null, "last_finalization_error": null, "lines": { "object": "list", "data": [ { "id": "il_1LSdrX2eZvKYlo2CwVfODzHa", "object": "line_item", "amount": 300, "amount_excluding_tax": 300, "currency": "usd", "description": "My First Invoice Item (created for API docs)", "discount_amounts": [], "discountable": true, "discounts": [], "invoice_item": "ii_1LSdrX2eZvKYlo2Crz8rasOM", "livemode": false, "metadata": {}, "period": { "end": 1659518855, "start": 1659518855 }, "price": { "id": "price_1LScCX2eZvKYlo2C1Z9zPyXF", "object": "price", "active": true, "billing_scheme": "per_unit", "created": 1659512469, "currency": "usd", "custom_unit_amount": null, "livemode": false, "lookup_key": null, "metadata": {}, "nickname": null, "product": "prod_MAy8UvSA0uRRju", "recurring": null, "tax_behavior": "unspecified", "tiers_mode": null, "transform_quantity": null, "type": "one_time", "unit_amount": 300, "unit_amount_decimal": "300" }, "proration": false, "proration_details": { "credited_items": null }, "quantity": 1, "subscription": null, "tax_amounts": [], "tax_rates": [], "type": "invoiceitem", "unit_amount_excluding_tax": "300" } ], "has_more": false, "url": "/v1/invoices/in_1LSdrX2eZvKYlo2Cy1kxMopu/lines" }, "livemode": false, "metadata": { "order_id": "6735" }, "next_payment_attempt": 1659522455, "number": null, "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": 1659518855, "period_start": 1659518855, "post_payment_credit_notes_amount": 0, "pre_payment_credit_notes_amount": 0, "quote": null, "receipt_number": null, "redaction": null, "rendering_options": null, "starting_balance": 0, "statement_descriptor": null, "status": "draft", "status_transitions": { "finalized_at": null, "marked_uncollectible_at": null, "paid_at": null, "voided_at": null }, "subscription": null, "subtotal": 300, "subtotal_excluding_tax": 300, "tax": null, "test_clock": null, "total": 1000, "total_discount_amounts": [], "total_excluding_tax": 300, "total_tax_amounts": [], "transfer_data": null, "webhooks_delivered_at": null }, {...}, {...} ] }'''
Search invoicesSearch for invoices you’ve previously created using Stripe’s Search Query Language. Don’t use search in read-after-write flows where strict consistency is necessary. Under normal operating conditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up to an hour behind during outages. Search functionality is not available to merchants in India.Parameters query required The search query string. See search query language and the list of supported query fields for invoices. limit optional A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10. page optional A cursor for pagination across multiple pages of results. Don’t include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results.ReturnsA dictionary with a data property that contains an array of up to limit invoices. If no objects match the query, the resulting array will be empty. See the related guide on expanding properties in lists
'''Endpoints  POST /v1/invoiceitems   GET /v1/invoiceitems/:id  POST /v1/invoiceitems/:idDELETE /v1/invoiceitems/:id   GET /v1/invoiceitems '''
Invoice ItemsSometimes you want to add a charge or credit to a customer, but actually charge or credit the customer's card only at the end of a regular billing cycle. This is useful for combining several charges (to minimize per-transaction fees), or for having Stripe tabulate your usage-based billing totals.
'''The invoiceitem object { "id": "ii_1LSe4Q2eZvKYlo2CYN9PE9sv", "object": "invoiceitem", "amount": 300, "currency": "usd", "customer": "cus_8TEMHVY5moxIPI", "date": 1659519654, "description": "My First Invoice Item (created for API docs)", "discountable": true, "discounts": [], "invoice": null, "livemode": false, "metadata": {}, "period": { "end": 1659519654, "start": 1659519654 }, "price": { "id": "price_1LScCX2eZvKYlo2C1Z9zPyXF", "object": "price", "active": true, "billing_scheme": "per_unit", "created": 1659512469, "currency": "usd", "custom_unit_amount": null, "livemode": false, "lookup_key": null, "metadata": {}, "nickname": null, "product": "prod_MAy8UvSA0uRRju", "recurring": null, "tax_behavior": "unspecified", "tiers_mode": null, "transform_quantity": null, "type": "one_time", "unit_amount": 300, "unit_amount_decimal": "300" }, "proration": false, "quantity": 1, "subscription": null, "tax_rates": [], "test_clock": null, "unit_amount": 300, "unit_amount_decimal": "300" } '''
The invoiceitem objectAttributes id string Unique identifier for the object. amount integer Amount (in the currency specified) of the invoice item. This should always be equal to unit_amount * quantity. currency currency Three-letter ISO currency code, in lowercase. Must be a supported currency. customer string expandable The ID of the customer who will be billed when this invoice item is billed. description string An arbitrary string attached to the object. Often useful for displaying to users. metadata hash Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. period hash The period associated with this invoice item. When set to different values, the period will be rendered on the invoice.Show child attributes price hash The price of the invoice item.Show child attributes proration boolean Whether the invoice item was created automatically as a proration adjustment when the customer switched plans.More attributesExpand all object string, value is "invoiceitem" date timestamp discountable boolean discounts array containing strings expandable invoice string expandable livemode boolean quantity integer subscription string expandable subscription_item string tax_rates array of hashes test_clock string expandable unit_amount integer unit_amount_decimal decimal string
import stripe stripe.api_key = "sk_test_your_key" stripe.InvoiceItem.create( customer="cus_8TEMHVY5moxIPI", price="price_1LScCX2eZvKYlo2C1Z9zPyXF", ) '''Response { "id": "ii_1LSe4Q2eZvKYlo2CYN9PE9sv", "object": "invoiceitem", "amount": 300, "currency": "usd", "customer": "cus_8TEMHVY5moxIPI", "date": 1659519654, "description": "My First Invoice Item (created for API docs)", "discountable": true, "discounts": [], "invoice": null, "livemode": false, "metadata": {}, "period": { "end": 1659519654, "start": 1659519654 }, "price": "price_1LScCX2eZvKYlo2C1Z9zPyXF", "proration": false, "quantity": 1, "subscription": null, "tax_rates": [], "test_clock": null, "unit_amount": 300, "unit_amount_decimal": "300" }'''
Create an invoice itemCreates an item to be added to a draft invoice (up to 250 items per invoice). If no invoice is specified, the item will be on the next invoice created for the customer specified.Parameters customer required The ID of the customer who will be billed when this invoice item is billed. amount optional The integer amount in cents of the charge to be applied to the upcoming invoice. Passing in a negative amount will reduce the amount_due on the invoice. currency optional Three-letter ISO currency code, in lowercase. Must be a supported currency. description optional An arbitrary string which you can attach to the invoice item. The description is displayed in the invoice for easy tracking. metadata optional dictionary Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to metadata. period optional dictionary The period associated with this invoice item. When set to different values, the period will be rendered on the invoice.Show child parameters price optional The ID of the price object.More parametersExpand all discountable optional discounts optional array of hashes invoice optional price_data optional dictionary quantity optional subscription optional tax_rates optional unit_amount optional unit_amount_decimal optional ReturnsThe created invoice item object is returned if successful. Otherwise, this call raises an error
import stripe stripe.api_key = "sk_test_your_key" stripe.InvoiceItem.retrieve( "ii_1LSe4Q2eZvKYlo2CYN9PE9sv", ) '''Response { "id": "ii_1LSe4Q2eZvKYlo2CYN9PE9sv", "object": "invoiceitem", "amount": 300, "currency": "usd", "customer": "cus_8TEMHVY5moxIPI", "date": 1659519654, "description": "My First Invoice Item (created for API docs)", "discountable": true, "discounts": [], "invoice": null, "livemode": false, "metadata": {}, "period": { "end": 1659519654, "start": 1659519654 }, "price": { "id": "price_1LScCX2eZvKYlo2C1Z9zPyXF", "object": "price", "active": true, "billing_scheme": "per_unit", "created": 1659512469, "currency": "usd", "custom_unit_amount": null, "livemode": false, "lookup_key": null, "metadata": {}, "nickname": null, "product": "prod_MAy8UvSA0uRRju", "recurring": null, "tax_behavior": "unspecified", "tiers_mode": null, "transform_quantity": null, "type": "one_time", "unit_amount": 300, "unit_amount_decimal": "300" }, "proration": false, "quantity": 1, "subscription": null, "tax_rates": [], "test_clock": null, "unit_amount": 300, "unit_amount_decimal": "300" }'''
Retrieve an invoice itemRetrieves the invoice item with the given ID.ParametersNo parameters.ReturnsReturns an invoice item if a valid invoice item ID was provided. Raises an error otherwise
import stripe stripe.api_key = "sk_test_your_key" stripe.InvoiceItem.modify( "ii_1LSe4Q2eZvKYlo2CYN9PE9sv", metadata={"order_id": "6735"}, ) '''Response { "id": "ii_1LSe4Q2eZvKYlo2CYN9PE9sv", "object": "invoiceitem", "amount": 300, "currency": "usd", "customer": "cus_8TEMHVY5moxIPI", "date": 1659519654, "description": "My First Invoice Item (created for API docs)", "discountable": true, "discounts": [], "invoice": null, "livemode": false, "metadata": { "order_id": "6735" }, "period": { "end": 1659519654, "start": 1659519654 }, "price": { "id": "price_1LScCX2eZvKYlo2C1Z9zPyXF", "object": "price", "active": true, "billing_scheme": "per_unit", "created": 1659512469, "currency": "usd", "custom_unit_amount": null, "livemode": false, "lookup_key": null, "metadata": {}, "nickname": null, "product": "prod_MAy8UvSA0uRRju", "recurring": null, "tax_behavior": "unspecified", "tiers_mode": null, "transform_quantity": null, "type": "one_time", "unit_amount": 300, "unit_amount_decimal": "300" }, "proration": false, "quantity": 1, "subscription": null, "tax_rates": [], "test_clock": null, "unit_amount": 300, "unit_amount_decimal": "300" }'''
Update an invoice itemUpdates the amount or description of an invoice item on an upcoming invoice. Updating an invoice item is only possible before the invoice it’s attached to is closed.Parameters amount optional The integer amount in cents of the charge to be applied to the upcoming invoice. If you want to apply a credit to the customer’s account, pass a negative amount. description optional An arbitrary string which you can attach to the invoice item. The description is displayed in the invoice for easy tracking. metadata optional dictionary Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to metadata. period optional dictionary The period associated with this invoice item. When set to different values, the period will be rendered on the invoice.Show child parameters price optional The ID of the price object.More parametersExpand all discountable optional discounts optional array of hashes price_data optional dictionary quantity optional tax_rates optional unit_amount optional unit_amount_decimal optional ReturnsThe updated invoice item object is returned upon success. Otherwise, this call raises an error
import stripe stripe.api_key = "sk_test_your_key" stripe.InvoiceItem.delete( "ii_1LSe4Q2eZvKYlo2CYN9PE9sv", ) '''Response { "id": "ii_1LSe4Q2eZvKYlo2CYN9PE9sv", "object": "invoiceitem", "deleted": true }'''
Delete an invoice itemDeletes an invoice item, removing it from an invoice. Deleting invoice items is only possible when they’re not attached to invoices, or if it’s attached to a draft invoice.ParametersNo parameters.ReturnsAn object with the deleted invoice item’s ID and a deleted flag upon success. Otherwise, this call raises an error, such as if the invoice item has already been deleted
import stripe stripe.api_key = "sk_test_your_key" stripe.InvoiceItem.list(limit=3) '''Response { "object": "list", "url": "/v1/invoiceitems", "has_more": false, "data": [ { "id": "ii_1LSe4Q2eZvKYlo2CYN9PE9sv", "object": "invoiceitem", "amount": 300, "currency": "usd", "customer": "cus_8TEMHVY5moxIPI", "date": 1659519654, "description": "My First Invoice Item (created for API docs)", "discountable": true, "discounts": [], "invoice": null, "livemode": false, "metadata": {}, "period": { "end": 1659519654, "start": 1659519654 }, "price": { "id": "price_1LScCX2eZvKYlo2C1Z9zPyXF", "object": "price", "active": true, "billing_scheme": "per_unit", "created": 1659512469, "currency": "usd", "custom_unit_amount": null, "livemode": false, "lookup_key": null, "metadata": {}, "nickname": null, "product": "prod_MAy8UvSA0uRRju", "recurring": null, "tax_behavior": "unspecified", "tiers_mode": null, "transform_quantity": null, "type": "one_time", "unit_amount": 300, "unit_amount_decimal": "300" }, "proration": false, "quantity": 1, "subscription": null, "tax_rates": [], "test_clock": null, "unit_amount": 300, "unit_amount_decimal": "300" }, {...}, {...} ] }'''
List all invoice itemsReturns a list of your invoice items. Invoice items are returned sorted by creation date, with the most recently created invoice items appearing first.Parameters customer optional The identifier of the customer whose invoice items to return. If none is provided, all invoice items will be returned.More parametersExpand all created optional dictionary ending_before optional invoice optional limit optional pending optional starting_after optional ReturnsA dictionary with a data property that contains an array of up to limit invoice items, starting after invoice item starting_after. Each entry in the array is a separate invoice item object. If no more invoice items are available, the resulting array will be empty. This request should never raise an error
'''Endpoints  POST /v1/plans   GET /v1/plans/:id  POST /v1/plans/:idDELETE /v1/plans/:id   GET /v1/plans '''
PlansYou can now model subscriptions more flexibly using the Prices API. It replaces the Plans API and is backwards compatible to simplify your migration.Plans define the base price, currency, and billing cycle for recurring purchases of products. Products help you track inventory or provisioning, and plans help you track pricing. Different physical goods or levels of service should be represented by products, and pricing options should be represented by plans. This approach lets you change prices without having to change your provisioning scheme.For example, you might have a single "gold" product that has plans for $10/month, $100/year, €9/month, and €90/year.
'''The plan object { "id": "price_1LSTX02eZvKYlo2CrKMGl6Dy", "object": "plan", "active": true, "aggregate_usage": null, "amount": 1200, "amount_decimal": "1200", "billing_scheme": "per_unit", "created": 1659479142, "currency": "usd", "interval": "month", "interval_count": 1, "livemode": false, "metadata": {}, "nickname": null, "product": "prod_MApBpixJvIPdF1", "tiers_mode": null, "transform_usage": null, "trial_period_days": null, "usage_type": "licensed" } '''
The plan objectAttributes id string Unique identifier for the object. active boolean Whether the plan can be used for new purchases. amount positive integer or zero The unit amount in cents to be charged, represented as a whole integer if possible. Only set if billing_scheme=per_unit. currency currency Three-letter ISO currency code, in lowercase. Must be a supported currency. interval enum The frequency at which a subscription is billed. One of day, week, month or year.Possible enum valuesmonth year week day metadata hash Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. nickname string A brief description of the plan, hidden from customers. product string expandable The product whose pricing this plan determines.More attributesExpand all object string, value is "plan" aggregate_usage string amount_decimal decimal string billing_scheme string created timestamp interval_count positive integer livemode boolean tiers array of hashes expandable tiers_mode string transform_usage hash trial_period_days positive integer usage_type enum
import stripe stripe.api_key = "sk_test_your_key" stripe.Plan.create( amount=1200, currency="usd", interval="month", product="prod_MApBpixJvIPdF1", ) '''Response { "id": "price_1LSTX02eZvKYlo2CrKMGl6Dy", "object": "plan", "active": true, "aggregate_usage": null, "amount": 1200, "amount_decimal": "1200", "billing_scheme": "per_unit", "created": 1659479142, "currency": "usd", "interval": "month", "interval_count": 1, "livemode": false, "metadata": {}, "nickname": null, "product": "prod_MApBpixJvIPdF1", "tiers_mode": null, "transform_usage": null, "trial_period_days": null, "usage_type": "licensed" }'''
Create a planYou can now model subscriptions more flexibly using the Prices API. It replaces the Plans API and is backwards compatible to simplify your migration.Parameters amount Required unless billing_scheme=tiered A positive integer in cents (or 0 for a free plan) representing how much to charge on a recurring basis. currency required Three-letter ISO currency code, in lowercase. Must be a supported currency. interval required Specifies billing frequency. Either day, week, month or year. product required The product whose pricing the created plan will represent. This can either be the ID of an existing product, or a dictionary containing fields used to create a service product.Show child parameters active optional Whether the plan is currently available for new subscriptions. Defaults to true. metadata optional dictionary Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to metadata. nickname optional A brief description of the plan, hidden from customers.More parametersExpand all id optional tiers Required if billing_scheme=tiered tiers_mode Required if billing_scheme=tiered aggregate_usage optional amount_decimal optional billing_scheme optional interval_count optional transform_usage optional dictionary trial_period_days optional usage_type optional ReturnsReturns the plan object
import stripe stripe.api_key = "sk_test_your_key" stripe.Plan.retrieve( "price_1LSTX02eZvKYlo2CrKMGl6Dy", ) '''Response { "id": "price_1LSTX02eZvKYlo2CrKMGl6Dy", "object": "plan", "active": true, "aggregate_usage": null, "amount": 1200, "amount_decimal": "1200", "billing_scheme": "per_unit", "created": 1659479142, "currency": "usd", "interval": "month", "interval_count": 1, "livemode": false, "metadata": {}, "nickname": null, "product": "prod_MApBpixJvIPdF1", "tiers_mode": null, "transform_usage": null, "trial_period_days": null, "usage_type": "licensed" }'''
Retrieve a planRetrieves the plan with the given ID.ParametersNo parameters.ReturnsReturns a plan if a valid plan ID was provided. Raises an error otherwise
import stripe stripe.api_key = "sk_test_your_key" stripe.Plan.modify( "price_1LSTX02eZvKYlo2CrKMGl6Dy", metadata={"order_id": "6735"}, ) '''Response { "id": "price_1LSTX02eZvKYlo2CrKMGl6Dy", "object": "plan", "active": true, "aggregate_usage": null, "amount": 1200, "amount_decimal": "1200", "billing_scheme": "per_unit", "created": 1659479142, "currency": "usd", "interval": "month", "interval_count": 1, "livemode": false, "metadata": { "order_id": "6735" }, "nickname": null, "product": "prod_MApBpixJvIPdF1", "tiers_mode": null, "transform_usage": null, "trial_period_days": null, "usage_type": "licensed" }'''
Update a planUpdates the specified plan by setting the values of the parameters passed. Any parameters not provided are left unchanged. By design, you cannot change a plan’s ID, amount, currency, or billing cycle.Parameters active optional Whether the plan is currently available for new subscriptions. metadata optional dictionary Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to metadata. nickname optional A brief description of the plan, hidden from customers.More parametersExpand all product optional trial_period_days optional ReturnsThe updated plan object is returned upon success. Otherwise, this call raises an error
import stripe stripe.api_key = "sk_test_your_key" stripe.Plan.delete( "price_1LSTX02eZvKYlo2CrKMGl6Dy", ) '''Response { "id": "price_1LSTX02eZvKYlo2CrKMGl6Dy", "object": "plan", "deleted": true }'''
Delete a planDeleting plans means new subscribers can’t be added. Existing subscribers aren’t affected.ParametersNo parameters.ReturnsAn object with the deleted plan’s ID and a deleted flag upon success. Otherwise, this call raises an error, such as if the plan has already been deleted
import stripe stripe.api_key = "sk_test_your_key" stripe.Plan.list(limit=3) '''Response { "object": "list", "url": "/v1/plans", "has_more": false, "data": [ { "id": "price_1LSTX02eZvKYlo2CrKMGl6Dy", "object": "plan", "active": true, "aggregate_usage": null, "amount": 1200, "amount_decimal": "1200", "billing_scheme": "per_unit", "created": 1659479142, "currency": "usd", "interval": "month", "interval_count": 1, "livemode": false, "metadata": {}, "nickname": null, "product": "prod_MApBpixJvIPdF1", "tiers_mode": null, "transform_usage": null, "trial_period_days": null, "usage_type": "licensed" }, {...}, {...} ] }'''
List all plansReturns a list of your plans.Parameters active optional Only return plans that are active or inactive (e.g., pass false to list all inactive plans). product optional Only return plans for the given product.More parametersExpand all created optional dictionary ending_before optional limit optional starting_after optional ReturnsA dictionary with a data property that contains an array of up to limit plans, starting after plan starting_after. Each entry in the array is a separate plan object. If no more plans are available, the resulting array will be empty. This request should never raise an error
'''Endpoints  POST /v1/quotes   GET /v1/quotes/:id  POST /v1/quotes/:id  POST /v1/quotes/:id/finalize  POST /v1/quotes/:id/accept  POST /v1/quotes/:id/cancel   GET https://files.stripe.com/v1/quotes/:id/pdf   GET /v1/quotes   GET /v1/quotes/:id/line_items   GET /v1/quotes/:id/computed_upfront_line_items '''
QuoteA Quote is a way to model prices that you'd like to provide to a customer. Once accepted, it will automatically create an invoice, subscription or subscription schedule
'''The quote object { "id": "qt_1LSdva2eZvKYlo2CKJMWruHa", "object": "quote", "amount_subtotal": 0, "amount_total": 0, "application": null, "application_fee_amount": null, "application_fee_percent": null, "automatic_tax": { "enabled": false, "status": null }, "collection_method": "charge_automatically", "computed": { "recurring": null, "upfront": { "amount_subtotal": 0, "amount_total": 0, "total_details": { "amount_discount": 0, "amount_shipping": 0, "amount_tax": 0 } } }, "created": 1659519106, "currency": "usd", "customer": "cus_8TEMHVY5moxIPI", "default_tax_rates": [], "description": null, "discounts": [], "expires_at": 1662111106, "footer": null, "from_quote": null, "header": null, "invoice": null, "invoice_settings": { "days_until_due": null }, "livemode": false, "metadata": {}, "number": null, "on_behalf_of": null, "status": "draft", "status_transitions": { "accepted_at": null, "canceled_at": null, "finalized_at": null }, "subscription": null, "subscription_data": { "effective_date": null, "trial_period_days": null }, "subscription_schedule": null, "test_clock": null, "total_details": { "amount_discount": 0, "amount_shipping": 0, "amount_tax": 0 }, "transfer_data": null } '''
The quote objectAttributes id string Unique identifier for the object. line_items list expandable A list of items the customer is being quoted for. This field is not included by default. To include it in the response, expand the line_items field.Show child attributes metadata hash Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.More attributesExpand all object string, value is "quote" amount_subtotal integer amount_total integer application string expandable "application" Connect only application_fee_amount integer Connect only application_fee_percent decimal Connect only automatic_tax hash collection_method string computed hash created timestamp currency string customer string expandable default_tax_rates array containing strings expandable description string discounts array containing strings expandable expires_at timestamp footer string from_quote hash header string invoice string expandable invoice_settings hash livemode boolean number string on_behalf_of string expandable Connect only status enum status_transitions hash subscription string expandable subscription_data hash subscription_schedule string expandable test_clock string expandable total_details hash transfer_data hash Connect only
import stripe stripe.api_key = "sk_test_your_key" stripe.Quote.create( customer="cus_8TEMHVY5moxIPI", line_items=[ { "price": "price_1LSTX02eZvKYlo2CrKMGl6Dy", "quantity": 2, }, ], ) '''Response { "id": "qt_1LSdva2eZvKYlo2CKJMWruHa", "object": "quote", "amount_subtotal": 2400, "amount_total": 2400, "application": null, "application_fee_amount": null, "application_fee_percent": null, "automatic_tax": { "enabled": false, "status": null }, "collection_method": "charge_automatically", "computed": { "recurring": null, "upfront": { "amount_subtotal": 2400, "amount_total": 2400, "total_details": { "amount_discount": 0, "amount_shipping": 0, "amount_tax": 0 } } }, "created": 1659519106, "currency": "usd", "customer": "cus_8TEMHVY5moxIPI", "default_tax_rates": [], "description": null, "discounts": [], "expires_at": 1662111106, "footer": null, "from_quote": null, "header": null, "invoice": null, "invoice_settings": { "days_until_due": null }, "livemode": false, "metadata": {}, "number": null, "on_behalf_of": null, "status": "draft", "status_transitions": { "accepted_at": null, "canceled_at": null, "finalized_at": null }, "subscription": null, "subscription_data": { "effective_date": null, "trial_period_days": null }, "subscription_schedule": null, "test_clock": null, "total_details": { "amount_discount": 0, "amount_shipping": 0, "amount_tax": 0 }, "transfer_data": null }'''
Create a quoteA quote models prices and services for a customer. Default options for header, description, footer, and expires_at can be set in the dashboard via the quote template.Parameters line_items optional array of hashes A list of line items the customer is being quoted for. Each line item includes information about the product, the quantity, and the resulting cost.Show child parameters metadata optional dictionary Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to metadata.More parametersExpand all application_fee_amount optional Connect only application_fee_percent optional Connect only automatic_tax optional dictionary collection_method optional customer optional default_tax_rates optional description optional discounts optional array of hashes expires_at optional footer optional from_quote optional dictionary header optional invoice_settings optional dictionary on_behalf_of optional Connect only subscription_data optional dictionary test_clock optional transfer_data optional dictionary Connect only ReturnsReturns the quote object
import stripe stripe.api_key = "sk_test_your_key" stripe.Quote.retrieve( "qt_1LSdva2eZvKYlo2CKJMWruHa", ) '''Response { "id": "qt_1LSdva2eZvKYlo2CKJMWruHa", "object": "quote", "amount_subtotal": 0, "amount_total": 0, "application": null, "application_fee_amount": null, "application_fee_percent": null, "automatic_tax": { "enabled": false, "status": null }, "collection_method": "charge_automatically", "computed": { "recurring": null, "upfront": { "amount_subtotal": 0, "amount_total": 0, "total_details": { "amount_discount": 0, "amount_shipping": 0, "amount_tax": 0 } } }, "created": 1659519106, "currency": "usd", "customer": "cus_8TEMHVY5moxIPI", "default_tax_rates": [], "description": null, "discounts": [], "expires_at": 1662111106, "footer": null, "from_quote": null, "header": null, "invoice": null, "invoice_settings": { "days_until_due": null }, "livemode": false, "metadata": {}, "number": null, "on_behalf_of": null, "status": "draft", "status_transitions": { "accepted_at": null, "canceled_at": null, "finalized_at": null }, "subscription": null, "subscription_data": { "effective_date": null, "trial_period_days": null }, "subscription_schedule": null, "test_clock": null, "total_details": { "amount_discount": 0, "amount_shipping": 0, "amount_tax": 0 }, "transfer_data": null }'''
Retrieve a quoteRetrieves the quote with the given ID.ParametersNo parameters.ReturnsReturns a quote if a valid quote ID was provided. Raises an error otherwise
import stripe stripe.api_key = "sk_test_your_key" stripe.Quote.modify( "qt_1LSdva2eZvKYlo2CKJMWruHa", metadata={"order_id": "6735"}, ) '''Response { "id": "qt_1LSdva2eZvKYlo2CKJMWruHa", "object": "quote", "amount_subtotal": 0, "amount_total": 0, "application": null, "application_fee_amount": null, "application_fee_percent": null, "automatic_tax": { "enabled": false, "status": null }, "collection_method": "charge_automatically", "computed": { "recurring": null, "upfront": { "amount_subtotal": 0, "amount_total": 0, "total_details": { "amount_discount": 0, "amount_shipping": 0, "amount_tax": 0 } } }, "created": 1659519106, "currency": "usd", "customer": "cus_8TEMHVY5moxIPI", "default_tax_rates": [], "description": null, "discounts": [], "expires_at": 1662111106, "footer": null, "from_quote": null, "header": null, "invoice": null, "invoice_settings": { "days_until_due": null }, "livemode": false, "metadata": { "order_id": "6735" }, "number": null, "on_behalf_of": null, "status": "draft", "status_transitions": { "accepted_at": null, "canceled_at": null, "finalized_at": null }, "subscription": null, "subscription_data": { "effective_date": null, "trial_period_days": null }, "subscription_schedule": null, "test_clock": null, "total_details": { "amount_discount": 0, "amount_shipping": 0, "amount_tax": 0 }, "transfer_data": null }'''
Update a quoteA quote models prices and services for a customer.Parameters line_items optional array of hashes A list of line items the customer is being quoted for. Each line item includes information about the product, the quantity, and the resulting cost.Show child parameters metadata optional dictionary Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to metadata.More parametersExpand all application_fee_amount optional Connect only application_fee_percent optional Connect only automatic_tax optional dictionary collection_method optional customer optional default_tax_rates optional description optional discounts optional array of hashes expires_at optional footer optional header optional invoice_settings optional dictionary on_behalf_of optional Connect only subscription_data optional dictionary transfer_data optional dictionary Connect only ReturnsReturns the updated quote object
import stripe stripe.api_key = "sk_test_your_key" stripe.Quote.finalize_quote( "qt_1LSdva2eZvKYlo2CKJMWruHa", ) '''Response { "id": "qt_1LSdva2eZvKYlo2CKJMWruHa", "object": "quote", "amount_subtotal": 1200, "amount_total": 1200, "application": null, "application_fee_amount": null, "application_fee_percent": null, "automatic_tax": { "enabled": false, "status": null }, "collection_method": "charge_automatically", "computed": { "recurring": null, "upfront": { "amount_subtotal": 1200, "amount_total": 1200, "total_details": { "amount_discount": 0, "amount_shipping": 0, "amount_tax": 0 } } }, "created": 1659519106, "currency": "usd", "customer": "cus_8TEMHVY5moxIPI", "default_tax_rates": [], "description": null, "discounts": [], "expires_at": 1662111106, "footer": null, "from_quote": null, "header": null, "invoice": null, "invoice_settings": { "days_until_due": null }, "livemode": false, "metadata": {}, "number": "QT-63F854F-0001-01", "on_behalf_of": null, "status": "open", "status_transitions": { "accepted_at": null, "canceled_at": null, "finalized_at": 1659519107 }, "subscription": null, "subscription_data": { "effective_date": null, "trial_period_days": null }, "subscription_schedule": null, "test_clock": null, "total_details": { "amount_discount": 0, "amount_shipping": 0, "amount_tax": 0 }, "transfer_data": null }'''
Finalize a quoteFinalizes the quote.ParametersExpand all expires_at optional ReturnsReturns an open quote. Raises an error otherwise
import stripe stripe.api_key = "sk_test_your_key" stripe.Quote.accept("qt_1LSdva2eZvKYlo2CKJMWruHa") '''Response { "id": "qt_1LSdva2eZvKYlo2CKJMWruHa", "object": "quote", "amount_subtotal": 1200, "amount_total": 1200, "application": null, "application_fee_amount": null, "application_fee_percent": null, "automatic_tax": { "enabled": false, "status": null }, "collection_method": "charge_automatically", "computed": { "recurring": null, "upfront": { "amount_subtotal": 1200, "amount_total": 1200, "total_details": { "amount_discount": 0, "amount_shipping": 0, "amount_tax": 0 } } }, "created": 1659519106, "currency": "usd", "customer": "cus_8TEMHVY5moxIPI", "default_tax_rates": [], "description": null, "discounts": [], "expires_at": 1662111106, "footer": null, "from_quote": null, "header": null, "invoice": "in_1LSdvX2eZvKYlo2CZYmxkhXJ", "invoice_settings": { "days_until_due": null }, "livemode": false, "metadata": {}, "number": "QT-63F854F-0001-01", "on_behalf_of": null, "status": "accepted", "status_transitions": { "accepted_at": 1659519107, "canceled_at": null, "finalized_at": 1659259907 }, "subscription": null, "subscription_data": { "effective_date": null, "trial_period_days": null }, "subscription_schedule": null, "test_clock": null, "total_details": { "amount_discount": 0, "amount_shipping": 0, "amount_tax": 0 }, "transfer_data": null }'''
Accept a quoteAccepts the specified quote.ParametersNo parameters.ReturnsReturns an accepted quote and creates an invoice, subscription or subscription schedule. Raises an error otherwise
import stripe stripe.api_key = "sk_test_your_key" stripe.Quote.cancel("qt_1LSdva2eZvKYlo2CKJMWruHa") '''Response { "id": "qt_1LSdva2eZvKYlo2CKJMWruHa", "object": "quote", "amount_subtotal": 0, "amount_total": 0, "application": null, "application_fee_amount": null, "application_fee_percent": null, "automatic_tax": { "enabled": false, "status": null }, "collection_method": "charge_automatically", "computed": { "recurring": null, "upfront": { "amount_subtotal": 0, "amount_total": 0, "total_details": { "amount_discount": 0, "amount_shipping": 0, "amount_tax": 0 } } }, "created": 1659519106, "currency": "usd", "customer": "cus_8TEMHVY5moxIPI", "default_tax_rates": [], "description": null, "discounts": [], "expires_at": 1662111106, "footer": null, "from_quote": null, "header": null, "invoice": null, "invoice_settings": { "days_until_due": null }, "livemode": false, "metadata": {}, "number": null, "on_behalf_of": null, "status": "canceled", "status_transitions": { "accepted_at": null, "canceled_at": 1659519107, "finalized_at": null }, "subscription": null, "subscription_data": { "effective_date": null, "trial_period_days": null }, "subscription_schedule": null, "test_clock": null, "total_details": { "amount_discount": 0, "amount_shipping": 0, "amount_tax": 0 }, "transfer_data": null }'''
Cancel a quoteCancels the quote.ParametersNo parameters.ReturnsReturns a canceled quote. Raises an error otherwise
GET https://files.stripe.com/v1/quotes/:id/pdfPythoncURLStripe CLIRubyPythonPHPJavaNode.jsGo.NET12345stripe.api_key = "sk_test_your_key" resp = stripe.Quote.pdf('qt_1LSdva2eZvKYlo2CKJMWruHa') file = open("/tmp/tmp.pdf", "wb") file.write(resp.io.read()) file.close() '''Response null'''
Download quote PDFDownload the PDF for a finalized quoteParametersNo parameters.ReturnsThe PDF file for the quote
import stripe stripe.api_key = "sk_test_your_key" stripe.Quote.list(limit=3) '''Response { "object": "list", "url": "/v1/quotes", "has_more": false, "data": [ { "id": "qt_1LSdva2eZvKYlo2CKJMWruHa", "object": "quote", "amount_subtotal": 0, "amount_total": 0, "application": null, "application_fee_amount": null, "application_fee_percent": null, "automatic_tax": { "enabled": false, "status": null }, "collection_method": "charge_automatically", "computed": { "recurring": null, "upfront": { "amount_subtotal": 0, "amount_total": 0, "total_details": { "amount_discount": 0, "amount_shipping": 0, "amount_tax": 0 } } }, "created": 1659519106, "currency": "usd", "customer": "cus_8TEMHVY5moxIPI", "default_tax_rates": [], "description": null, "discounts": [], "expires_at": 1662111106, "footer": null, "from_quote": null, "header": null, "invoice": null, "invoice_settings": { "days_until_due": null }, "livemode": false, "metadata": {}, "number": null, "on_behalf_of": null, "status": "draft", "status_transitions": { "accepted_at": null, "canceled_at": null, "finalized_at": null }, "subscription": null, "subscription_data": { "effective_date": null, "trial_period_days": null }, "subscription_schedule": null, "test_clock": null, "total_details": { "amount_discount": 0, "amount_shipping": 0, "amount_tax": 0 }, "transfer_data": null }, {...}, {...} ] }'''
List all quotesReturns a list of your quotes.Parameters customer optional The ID of the customer whose quotes will be retrieved. status optional enum The status of the quote.Possible enum valuesdraft open accepted canceled More parametersExpand all ending_before optional limit optional starting_after optional test_clock optional ReturnsA dictionary with a data property that contains an array of up to limit quotes, starting after quote starting_after. Each entry in the array is a separate quote object. If no more quotes are available, the resulting array will be empty. This request should never raise an error
import stripe stripe.api_key = "sk_test_your_key" line_items = stripe.Quote.list_line_items('qt_1LSdva2eZvKYlo2CKJMWruHa', limit=3) '''Response { "object": "list", "url": "/v1/quotes/qt_1LSdva2eZvKYlo2CKJMWruHa/line_items", "has_more": false, "data": [ { "id": "li_1LSdva2eZvKYlo2CFMsy4nIF", "object": "item", "amount_discount": 0, "amount_subtotal": 0, "amount_tax": 0, "amount_total": 0, "currency": "usd", "description": "auto topup addtional_viewer", "price": { "id": "price_1LScCX2eZvKYlo2C1Z9zPyXF", "object": "price", "active": true, "billing_scheme": "per_unit", "created": 1659512469, "currency": "usd", "custom_unit_amount": null, "livemode": false, "lookup_key": null, "metadata": {}, "nickname": null, "product": "prod_MAy8UvSA0uRRju", "recurring": null, "tax_behavior": "unspecified", "tiers_mode": null, "transform_quantity": null, "type": "one_time", "unit_amount": 300, "unit_amount_decimal": "300" }, "quantity": 1 }, {...}, {...} ] }'''
Retrieve a quote's line itemsWhen retrieving a quote, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items.ParametersExpand all ending_before optional limit optional starting_after optional ReturnsA dictionary with a data property that contains an array of up to limit quote line items, starting after Line Item starting_after. Each entry in the array is a separate Line Item object. If no more line items are available, the resulting array will be empty.
import stripe stripe.api_key = "sk_test_your_key" line_items = stripe.Quote.list_computed_upfront_line_items('qt_1LSdva2eZvKYlo2CKJMWruHa', limit=3) '''Response { "object": "list", "url": "/v1/quotes/qt_1LSdva2eZvKYlo2CKJMWruHa/computed_upfront_line_items", "has_more": false, "data": [ { "id": "li_1LSdva2eZvKYlo2CFMsy4nIF", "object": "item", "amount_discount": 0, "amount_subtotal": 0, "amount_tax": 0, "amount_total": 0, "currency": "usd", "description": "auto topup addtional_viewer", "price": { "id": "price_1LScCX2eZvKYlo2C1Z9zPyXF", "object": "price", "active": true, "billing_scheme": "per_unit", "created": 1659512469, "currency": "usd", "custom_unit_amount": null, "livemode": false, "lookup_key": null, "metadata": {}, "nickname": null, "product": "prod_MAy8UvSA0uRRju", "recurring": null, "tax_behavior": "unspecified", "tiers_mode": null, "transform_quantity": null, "type": "one_time", "unit_amount": 300, "unit_amount_decimal": "300" }, "quantity": 1 }, {...}, {...} ] }'''
Retrieve a quote's upfront line itemsWhen retrieving a quote, there is an includable computed.upfront.line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of upfront line items.ParametersExpand all ending_before optional limit optional starting_after optional ReturnsA dictionary with a data property that contains an array of up to limit upfront line items, starting after Line Item starting_after. Each entry in the array is a separate Line Item object. If no more upfront line items are available, the resulting array will be empty.
'''Endpoints  POST /v1/subscriptions   GET /v1/subscriptions/:id  POST /v1/subscriptions/:idDELETE /v1/subscriptions/:id   GET /v1/subscriptions   GET /v1/subscriptions/search '''
SubscriptionsSubscriptions allow you to charge a customer on a recurring basis.
'''The subscription object { "id": "sub_1JbiLB2eZvKYlo2CNHnqfMzf", "object": "subscription", "application": null, "application_fee_percent": null, "automatic_tax": { "enabled": false }, "billing_cycle_anchor": 1633337949, "billing_thresholds": null, "cancel_at": null, "cancel_at_period_end": false, "canceled_at": null, "collection_method": "charge_automatically", "created": 1632128349, "currency": "usd", "current_period_end": 1660553949, "current_period_start": 1658739549, "customer": "cus_KGEouBKGmh7mXW", "days_until_due": null, "default_payment_method": "pm_1JbiL92eZvKYlo2CuiUB2nL1", "default_source": null, "default_tax_rates": [], "description": null, "discount": null, "ended_at": null, "items": { "object": "list", "data": [ { "id": "si_KGEo6oKuLzcuYw", "object": "subscription_item", "billing_thresholds": null, "created": 1632128350, "metadata": {}, "price": { "id": "15", "object": "price", "active": true, "billing_scheme": "per_unit", "created": 1386685951, "currency": "usd", "custom_unit_amount": null, "livemode": false, "lookup_key": null, "metadata": { "charset": "utf-8", "content": "15" }, "nickname": null, "product": "prod_BTdpcRLIUTfsFR", "recurring": { "aggregate_usage": null, "interval": "week", "interval_count": 3, "usage_type": "licensed" }, "tax_behavior": "unspecified", "tiers_mode": null, "transform_quantity": null, "type": "recurring", "unit_amount": 444, "unit_amount_decimal": "444" }, "quantity": 1, "subscription": "sub_1JbiLB2eZvKYlo2CNHnqfMzf", "tax_rates": [] } ], "has_more": false, "url": "/v1/subscription_items?subscription=sub_1JbiLB2eZvKYlo2CNHnqfMzf" }, "latest_invoice": "in_1LPN8U2eZvKYlo2C2h002pSa", "livemode": false, "metadata": {}, "next_pending_invoice_item_invoice": null, "pause_collection": null, "payment_settings": { "payment_method_options": null, "payment_method_types": null, "save_default_payment_method": null }, "pending_invoice_item_interval": null, "pending_setup_intent": null, "pending_update": null, "schedule": null, "start_date": 1632128349, "status": "active", "test_clock": null, "transfer_data": null, "trial_end": 1633337949, "trial_start": 1632128349 } '''
The subscription objectAttributes id string Unique identifier for the object. cancel_at_period_end boolean If the subscription has been canceled with the at_period_end flag set to true, cancel_at_period_end on the subscription will be true. You can use this attribute to determine whether a subscription that has a status of active is scheduled to be canceled at the end of the current period. currency currency preview feature Three-letter ISO currency code, in lowercase. Must be a supported currency. current_period_end timestamp End of the current period that the subscription has been invoiced for. At the end of this period, a new invoice will be created. current_period_start timestamp Start of the current period that the subscription has been invoiced for. customer string expandable ID of the customer who owns the subscription. default_payment_method string expandable ID of the default payment method for the subscription. It must belong to the customer associated with the subscription. This takes precedence over default_source. If neither are set, invoices will use the customer’s invoice_settings.default_payment_method or default_source. description string The subscription’s description, meant to be displayable to the customer. Use this field to optionally store an explanation of the subscription for rendering in Stripe surfaces. items list List of subscription items, each with an attached price.Show child attributes latest_invoice string expandable The most recent invoice this subscription has generated. metadata hash Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. pending_setup_intent string expandable You can use this SetupIntent to collect user authentication when creating a subscription without immediate payment or updating a subscription’s payment method, allowing you to optimize for off-session payments. Learn more in the SCA Migration Guide. pending_update hash If specified, pending updates that will be applied to the subscription once the latest_invoice has been paid.Show child attributes status enum Possible values are incomplete, incomplete_expired, trialing, active, past_due, canceled, or unpaid. For collection_method=charge_automatically a subscription moves into incomplete if the initial payment attempt fails. A subscription in this state can only have metadata and default_source updated. Once the first invoice is paid, the subscription moves into an active state. If the first invoice is not paid within 23 hours, the subscription transitions to incomplete_expired. This is a terminal state, the open invoice will be voided and no further invoices will be generated. A subscription that is currently in a trial period is trialing and moves to active when the trial period is over. If subscription collection_method=charge_automatically it becomes past_due when payment to renew it fails and canceled or unpaid (depending on your subscriptions settings) when Stripe has exhausted all payment retry attempts. If subscription collection_method=send_invoice it becomes past_due when its invoice is not paid by the due date, and canceled or unpaid if it is still not paid by an additional deadline after that. Note that when a subscription has a status of unpaid, no subsequent invoices will be attempted (invoices will be created, but then immediately automatically closed). After receiving updated payment information from a customer, you may choose to reopen and pay their closed invoices.Possible enum valuesactive past_due unpaid canceled incomplete incomplete_expired trialing More attributesExpand all object string, value is "subscription" application string expandable "application" Connect only application_fee_percent decimal Connect only automatic_tax hash billing_cycle_anchor timestamp billing_thresholds hash cancel_at timestamp canceled_at timestamp collection_method string created timestamp days_until_due integer default_source string expandable bank account, card, or source (e.g., card) default_tax_rates array of hashes discount hash, discount object ended_at timestamp livemode boolean next_pending_invoice_item_invoice timestamp pause_collection hash payment_settings hash pending_invoice_item_interval hash schedule string expandable start_date timestamp test_clock string expandable transfer_data hash Connect only trial_end timestamp trial_start timestamp
import stripe stripe.api_key = "sk_test_your_key" stripe.Subscription.create( customer="cus_8TEMHVY5moxIPI", items=[ {"price": "price_1LSTX02eZvKYlo2CrKMGl6Dy"}, ], ) '''Response { "id": "sub_1JbiLB2eZvKYlo2CNHnqfMzf", "object": "subscription", "application": null, "application_fee_percent": null, "automatic_tax": { "enabled": false }, "billing_cycle_anchor": 1633337949, "billing_thresholds": null, "cancel_at": null, "cancel_at_period_end": false, "canceled_at": null, "collection_method": "charge_automatically", "created": 1632128349, "currency": "usd", "current_period_end": 1660553949, "current_period_start": 1658739549, "customer": "cus_8TEMHVY5moxIPI", "days_until_due": null, "default_payment_method": "pm_1JbiL92eZvKYlo2CuiUB2nL1", "default_source": null, "default_tax_rates": [], "description": null, "discount": null, "ended_at": null, "items": { "object": "list", "data": [ { "id": "si_KGEo6oKuLzcuYw", "object": "subscription_item", "billing_thresholds": null, "created": 1632128350, "metadata": {}, "price": { "id": "15", "object": "price", "active": true, "billing_scheme": "per_unit", "created": 1386685951, "currency": "usd", "custom_unit_amount": null, "livemode": false, "lookup_key": null, "metadata": { "charset": "utf-8", "content": "15" }, "nickname": null, "product": "prod_BTdpcRLIUTfsFR", "recurring": { "aggregate_usage": null, "interval": "week", "interval_count": 3, "usage_type": "licensed" }, "tax_behavior": "unspecified", "tiers_mode": null, "transform_quantity": null, "type": "recurring", "unit_amount": 444, "unit_amount_decimal": "444" }, "quantity": 1, "subscription": "sub_1JbiLB2eZvKYlo2CNHnqfMzf", "tax_rates": [] } ], "has_more": false, "url": "/v1/subscription_items?subscription=sub_1JbiLB2eZvKYlo2CNHnqfMzf" }, "latest_invoice": "in_1LPN8U2eZvKYlo2C2h002pSa", "livemode": false, "metadata": {}, "next_pending_invoice_item_invoice": null, "pause_collection": null, "payment_settings": { "payment_method_options": null, "payment_method_types": null, "save_default_payment_method": null }, "pending_invoice_item_interval": null, "pending_setup_intent": null, "pending_update": null, "schedule": null, "start_date": 1632128349, "status": "active", "test_clock": null, "transfer_data": null, "trial_end": 1633337949, "trial_start": 1632128349 }'''
Create a subscriptionCreates a new subscription on an existing customer. Each customer can have up to 500 active or scheduled subscriptions. When you create a subscription with collection_method=charge_automatically, the first invoice is finalized as part of the request. The payment_behavior parameter determines the exact behavior of the initial payment. To start subscriptions where the first invoice always begins in a draft status, use subscription schedules instead. Schedules provide the flexibility to model more complex billing configurations that change over time.Parameters customer required The identifier of the customer to subscribe. items required A list of up to 20 subscription items, each with an attached price.Show child parameters cancel_at_period_end optional Boolean indicating whether this subscription should cancel at the end of the current period. currency optional preview feature Three-letter ISO currency code, in lowercase. Must be a supported currency. default_payment_method optional ID of the default payment method for the subscription. It must belong to the customer associated with the subscription. This takes precedence over default_source. If neither are set, invoices will use the customer’s invoice_settings.default_payment_method or default_source. description optional The subscription’s description, meant to be displayable to the customer. Use this field to optionally store an explanation of the subscription for rendering in Stripe surfaces. metadata optional dictionary Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to metadata. payment_behavior optional enum Use allow_incomplete to create subscriptions with status=incomplete if the first invoice cannot be paid. Creating subscriptions with this status allows you to manage scenarios where additional user actions are needed to pay a subscription’s invoice. For example, SCA regulation may require 3DS authentication to complete payment. See the SCA Migration Guide for Billing to learn more. This is the default behavior. Use default_incomplete to create Subscriptions with status=incomplete when the first invoice requires payment, otherwise start as active. Subscriptions transition to status=active when successfully confirming the payment intent on the first invoice. This allows simpler management of scenarios where additional user actions are needed to pay a subscription’s invoice. Such as failed payments, SCA regulation, or collecting a mandate for a bank debit payment method. If the payment intent is not confirmed within 23 hours subscriptions transition to status=incomplete_expired, which is a terminal state. Use error_if_incomplete if you want Stripe to return an HTTP 402 status code if a subscription’s first invoice cannot be paid. For example, if a payment method requires 3DS authentication due to SCA regulation and further user action is needed, this parameter does not create a subscription and returns an error instead. This was the default behavior for API versions prior to 2019-03-14. See the changelog to learn more. pending_if_incomplete is only used with updates and cannot be passed when creating a subscription.Possible enum valuesallow_incomplete error_if_incomplete pending_if_incomplete default_incomplete More parametersExpand all add_invoice_items optional array of hashes application_fee_percent optional Connect only automatic_tax optional dictionary backdate_start_date optional billing_cycle_anchor optional billing_thresholds optional dictionary cancel_at optional collection_method optional coupon optional days_until_due optional default_source optional default_tax_rates optional off_session optional payment_settings optional dictionary pending_invoice_item_interval optional dictionary promotion_code optional proration_behavior optional enum transfer_data optional dictionary Connect only trial_end optional trial_from_plan optional trial_period_days optional ReturnsThe newly created Subscription object, if the call succeeded. If the attempted charge fails, the subscription is created in an incomplete status
import stripe stripe.api_key = "sk_test_your_key" stripe.Subscription.retrieve( "sub_1JbiLB2eZvKYlo2CNHnqfMzf", ) '''Response { "id": "sub_1JbiLB2eZvKYlo2CNHnqfMzf", "object": "subscription", "application": null, "application_fee_percent": null, "automatic_tax": { "enabled": false }, "billing_cycle_anchor": 1633337949, "billing_thresholds": null, "cancel_at": null, "cancel_at_period_end": false, "canceled_at": null, "collection_method": "charge_automatically", "created": 1632128349, "currency": "usd", "current_period_end": 1660553949, "current_period_start": 1658739549, "customer": "cus_KGEouBKGmh7mXW", "days_until_due": null, "default_payment_method": "pm_1JbiL92eZvKYlo2CuiUB2nL1", "default_source": null, "default_tax_rates": [], "description": null, "discount": null, "ended_at": null, "items": { "object": "list", "data": [ { "id": "si_KGEo6oKuLzcuYw", "object": "subscription_item", "billing_thresholds": null, "created": 1632128350, "metadata": {}, "price": { "id": "15", "object": "price", "active": true, "billing_scheme": "per_unit", "created": 1386685951, "currency": "usd", "custom_unit_amount": null, "livemode": false, "lookup_key": null, "metadata": { "charset": "utf-8", "content": "15" }, "nickname": null, "product": "prod_BTdpcRLIUTfsFR", "recurring": { "aggregate_usage": null, "interval": "week", "interval_count": 3, "usage_type": "licensed" }, "tax_behavior": "unspecified", "tiers_mode": null, "transform_quantity": null, "type": "recurring", "unit_amount": 444, "unit_amount_decimal": "444" }, "quantity": 1, "subscription": "sub_1JbiLB2eZvKYlo2CNHnqfMzf", "tax_rates": [] } ], "has_more": false, "url": "/v1/subscription_items?subscription=sub_1JbiLB2eZvKYlo2CNHnqfMzf" }, "latest_invoice": "in_1LPN8U2eZvKYlo2C2h002pSa", "livemode": false, "metadata": {}, "next_pending_invoice_item_invoice": null, "pause_collection": null, "payment_settings": { "payment_method_options": null, "payment_method_types": null, "save_default_payment_method": null }, "pending_invoice_item_interval": null, "pending_setup_intent": null, "pending_update": null, "schedule": null, "start_date": 1632128349, "status": "active", "test_clock": null, "transfer_data": null, "trial_end": 1633337949, "trial_start": 1632128349 }'''
Retrieve a subscriptionRetrieves the subscription with the given ID.ParametersNo parameters.ReturnsReturns the subscription object
import stripe stripe.api_key = "sk_test_your_key" stripe.Subscription.modify( "sub_1JbiLB2eZvKYlo2CNHnqfMzf", metadata={"order_id": "6735"}, ) '''Response { "id": "sub_1JbiLB2eZvKYlo2CNHnqfMzf", "object": "subscription", "application": null, "application_fee_percent": null, "automatic_tax": { "enabled": false }, "billing_cycle_anchor": 1633337949, "billing_thresholds": null, "cancel_at": null, "cancel_at_period_end": false, "canceled_at": null, "collection_method": "charge_automatically", "created": 1632128349, "currency": "usd", "current_period_end": 1660553949, "current_period_start": 1658739549, "customer": "cus_KGEouBKGmh7mXW", "days_until_due": null, "default_payment_method": "pm_1JbiL92eZvKYlo2CuiUB2nL1", "default_source": null, "default_tax_rates": [], "description": null, "discount": null, "ended_at": null, "items": { "object": "list", "data": [ { "id": "si_KGEo6oKuLzcuYw", "object": "subscription_item", "billing_thresholds": null, "created": 1632128350, "metadata": {}, "price": { "id": "15", "object": "price", "active": true, "billing_scheme": "per_unit", "created": 1386685951, "currency": "usd", "custom_unit_amount": null, "livemode": false, "lookup_key": null, "metadata": { "charset": "utf-8", "content": "15" }, "nickname": null, "product": "prod_BTdpcRLIUTfsFR", "recurring": { "aggregate_usage": null, "interval": "week", "interval_count": 3, "usage_type": "licensed" }, "tax_behavior": "unspecified", "tiers_mode": null, "transform_quantity": null, "type": "recurring", "unit_amount": 444, "unit_amount_decimal": "444" }, "quantity": 1, "subscription": "sub_1JbiLB2eZvKYlo2CNHnqfMzf", "tax_rates": [] } ], "has_more": false, "url": "/v1/subscription_items?subscription=sub_1JbiLB2eZvKYlo2CNHnqfMzf" }, "latest_invoice": "in_1LPN8U2eZvKYlo2C2h002pSa", "livemode": false, "metadata": { "order_id": "6735" }, "next_pending_invoice_item_invoice": null, "pause_collection": null, "payment_settings": { "payment_method_options": null, "payment_method_types": null, "save_default_payment_method": null }, "pending_invoice_item_interval": null, "pending_setup_intent": null, "pending_update": null, "schedule": null, "start_date": 1632128349, "status": "active", "test_clock": null, "transfer_data": null, "trial_end": 1633337949, "trial_start": 1632128349 }'''
Update a subscriptionUpdates an existing subscription to match the specified parameters. When changing prices or quantities, we will optionally prorate the price we charge next month to make up for any price changes. To preview how the proration will be calculated, use the upcoming invoice endpoint. By default, we prorate subscription changes. For example, if a customer signs up on May 1 for a $100 price, she'll be billed $100 immediately. If on May 15 she switches to a $200 price, then on June 1 she'll be billed $250 ($200 for a renewal of her subscription, plus a $50 prorating adjustment for half of the previous month's $100 difference). Similarly, a downgrade will generate a credit to be applied to the next invoice. We also prorate when you make quantity changes. Switching prices does not normally change the billing date or generate an immediate charge unless: The billing interval is changed (e.g., monthly to yearly). The subscription moves from free to paid, or paid to free. A trial starts or ends. In these cases, we apply a credit for the time unused on the previous price and the customer is immediately charged using the new price. This also resets the billing date. If you'd like to charge for an upgrade immediately, just pass proration_behavior as create_prorations (the default), and then invoice the customer as soon as you make the subscription change. That will collect the proration adjustments into a new invoice, and Stripe will automatically attempt to collect payment on the invoice. If you don't want to prorate at all, set the proration_behavior option to none and the customer would be billed $100 on May 1 and $200 on June 1. Similarly, if you set proration_behavior to none when switching between different billing intervals (monthly to yearly, for example), we won't generate any credits for the old subscription's unused time—although we will still reset the billing date and will bill immediately for the new subscription. Updating the quantity on a subscription many times in an hour may result in rate limiting. If you need to bill for a frequently changing quantity, consider integrating metered billing instead. Parameters cancel_at_period_end optional Boolean indicating whether this subscription should cancel at the end of the current period. default_payment_method optional ID of the default payment method for the subscription. It must belong to the customer associated with the subscription. This takes precedence over default_source. If neither are set, invoices will use the customer’s invoice_settings.default_payment_method or default_source. description optional The subscription’s description, meant to be displayable to the customer. Use this field to optionally store an explanation of the subscription for rendering in Stripe surfaces. items optional array of hashes A list of up to 20 subscription items, each with an attached price.Show child parameters metadata optional dictionary Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to metadata. payment_behavior optional enum Use allow_incomplete to transition the subscription to status=past_due if a payment is required but cannot be paid. This allows you to manage scenarios where additional user actions are needed to pay a subscription’s invoice. For example, SCA regulation may require 3DS authentication to complete payment. See the SCA Migration Guide for Billing to learn more. This is the default behavior. Use default_incomplete to transition the subscription to status=past_due when payment is required and await explicit confirmation of the invoice’s payment intent. This allows simpler management of scenarios where additional user actions are needed to pay a subscription’s invoice. Such as failed payments, SCA regulation, or collecting a mandate for a bank debit payment method. Use pending_if_incomplete to update the subscription using pending updates. When you use pending_if_incomplete you can only pass the parameters supported by pending updates. Use error_if_incomplete if you want Stripe to return an HTTP 402 status code if a subscription’s invoice cannot be paid. For example, if a payment method requires 3DS authentication due to SCA regulation and further user action is needed, this parameter does not update the subscription and returns an error instead. This was the default behavior for API versions prior to 2019-03-14. See the changelog to learn more.Possible enum valuesallow_incomplete error_if_incomplete pending_if_incomplete default_incomplete proration_behavior optional enum Determines how to handle prorations when the billing cycle changes (e.g., when switching plans, resetting billing_cycle_anchor=now, or starting a trial), or if an item’s quantity changes.Possible enum valuescreate_prorations Will cause proration invoice items to be created when applicable. These proration items will only be invoiced immediately under certain conditions.none Disable creating prorations in this request.always_invoice Always invoice immediately for prorations.More parametersExpand all add_invoice_items optional array of hashes application_fee_percent optional Connect only automatic_tax optional dictionary billing_cycle_anchor optional billing_thresholds optional dictionary cancel_at optional collection_method optional coupon optional days_until_due optional default_source optional default_tax_rates optional off_session optional pause_collection optional dictionary payment_settings optional dictionary pending_invoice_item_interval optional dictionary promotion_code optional proration_date optional transfer_data optional dictionary Connect only trial_end optional trial_from_plan optional Returns The newly updated Subscription object, if the call succeeded. If payment_behavior is error_if_incomplete and a charge is required for the update and it fails, this call raises an error, and the subscription update does not go into effect.
import stripe stripe.api_key = "sk_test_your_key" stripe.Subscription.delete( "sub_1JbiLB2eZvKYlo2CNHnqfMzf", ) '''Response { "id": "sub_1JbiLB2eZvKYlo2CNHnqfMzf", "object": "subscription", "application": null, "application_fee_percent": null, "automatic_tax": { "enabled": false }, "billing_cycle_anchor": 1633337949, "billing_thresholds": null, "cancel_at": null, "cancel_at_period_end": false, "canceled_at": 1659519611, "collection_method": "charge_automatically", "created": 1632128349, "currency": "usd", "current_period_end": 1660553949, "current_period_start": 1658739549, "customer": "cus_8TEMHVY5moxIPI", "days_until_due": null, "default_payment_method": "pm_1JbiL92eZvKYlo2CuiUB2nL1", "default_source": null, "default_tax_rates": [], "description": null, "discount": null, "ended_at": null, "items": { "object": "list", "data": [ { "id": "si_KGEo6oKuLzcuYw", "object": "subscription_item", "billing_thresholds": null, "created": 1632128350, "metadata": {}, "price": { "id": "15", "object": "price", "active": true, "billing_scheme": "per_unit", "created": 1386685951, "currency": "usd", "custom_unit_amount": null, "livemode": false, "lookup_key": null, "metadata": { "charset": "utf-8", "content": "15" }, "nickname": null, "product": "prod_BTdpcRLIUTfsFR", "recurring": { "aggregate_usage": null, "interval": "week", "interval_count": 3, "usage_type": "licensed" }, "tax_behavior": "unspecified", "tiers_mode": null, "transform_quantity": null, "type": "recurring", "unit_amount": 444, "unit_amount_decimal": "444" }, "quantity": 1, "subscription": "sub_1JbiLB2eZvKYlo2CNHnqfMzf", "tax_rates": [] } ], "has_more": false, "url": "/v1/subscription_items?subscription=sub_1JbiLB2eZvKYlo2CNHnqfMzf" }, "latest_invoice": "in_1LPN8U2eZvKYlo2C2h002pSa", "livemode": false, "metadata": {}, "next_pending_invoice_item_invoice": null, "pause_collection": null, "payment_settings": { "payment_method_options": null, "payment_method_types": null, "save_default_payment_method": null }, "pending_invoice_item_interval": null, "pending_setup_intent": null, "pending_update": null, "schedule": null, "start_date": 1632128349, "status": "canceled", "test_clock": null, "transfer_data": null, "trial_end": 1633337949, "trial_start": 1632128349 }'''
Cancel a subscriptionCancels a customer’s subscription immediately. The customer will not be charged again for the subscription. Note, however, that any pending invoice items that you’ve created will still be charged for at the end of the period, unless manually deleted. If you’ve set the subscription to cancel at the end of the period, any pending prorations will also be left in place and collected at the end of the period. But if the subscription is set to cancel immediately, pending prorations will be removed. By default, upon subscription cancellation, Stripe will stop automatic collection of all finalized invoices for the customer. This is intended to prevent unexpected payment attempts after the customer has canceled a subscription. However, you can resume automatic collection of the invoices manually after subscription cancellation to have us proceed. Or, you could check for unpaid invoices before allowing the customer to cancel the subscription at all.ParametersExpand all invoice_now optional prorate optional ReturnsThe canceled Subscription object. Its subscription status will be set to canceled
import stripe stripe.api_key = "sk_test_your_key" stripe.Subscription.list(limit=3) '''Response { "object": "list", "url": "/v1/subscriptions", "has_more": false, "data": [ { "id": "su_1JbiLB2eZvKYlo2CRmgET2WF", "object": "subscription", "application": null, "application_fee_percent": null, "automatic_tax": { "enabled": false }, "billing_cycle_anchor": 1633337949, "billing_thresholds": null, "cancel_at": null, "cancel_at_period_end": false, "canceled_at": null, "collection_method": "charge_automatically", "created": 1632128349, "currency": "usd", "current_period_end": 1660553949, "current_period_start": 1658739549, "customer": "cus_KGEouBKGmh7mXW", "days_until_due": null, "default_payment_method": "pm_1JbiL92eZvKYlo2CuiUB2nL1", "default_source": null, "default_tax_rates": [], "description": null, "discount": null, "ended_at": null, "items": { "object": "list", "data": [ { "id": "si_KGEo6oKuLzcuYw", "object": "subscription_item", "billing_thresholds": null, "created": 1632128350, "metadata": {}, "price": { "id": "15", "object": "price", "active": true, "billing_scheme": "per_unit", "created": 1386685951, "currency": "usd", "custom_unit_amount": null, "livemode": false, "lookup_key": null, "metadata": { "charset": "utf-8", "content": "15" }, "nickname": null, "product": "prod_BTdpcRLIUTfsFR", "recurring": { "aggregate_usage": null, "interval": "week", "interval_count": 3, "usage_type": "licensed" }, "tax_behavior": "unspecified", "tiers_mode": null, "transform_quantity": null, "type": "recurring", "unit_amount": 444, "unit_amount_decimal": "444" }, "quantity": 1, "subscription": "sub_1JbiLB2eZvKYlo2CNHnqfMzf", "tax_rates": [] } ], "has_more": false, "url": "/v1/subscription_items?subscription=sub_1JbiLB2eZvKYlo2CNHnqfMzf" }, "latest_invoice": "in_1LPN8U2eZvKYlo2C2h002pSa", "livemode": false, "metadata": {}, "next_pending_invoice_item_invoice": null, "pause_collection": null, "payment_settings": { "payment_method_options": null, "payment_method_types": null, "save_default_payment_method": null }, "pending_invoice_item_interval": null, "pending_setup_intent": null, "pending_update": null, "schedule": null, "start_date": 1632128349, "status": "active", "test_clock": null, "transfer_data": null, "trial_end": 1633337949, "trial_start": 1632128349 }, {...}, {...} ] }'''
List subscriptionsBy default, returns a list of subscriptions that have not been canceled. In order to list canceled subscriptions, specify status=canceled.Parameters customer optional The ID of the customer whose subscriptions will be retrieved. price optional Filter for subscriptions that contain this recurring price ID. status optional enum The status of the subscriptions to retrieve. Passing in a value of canceled will return all canceled subscriptions, including those belonging to deleted customers. Pass ended to find subscriptions that are canceled and subscriptions that are expired due to incomplete payment. Passing in a value of all will return subscriptions of all statuses. If no value is supplied, all subscriptions that have not been canceled are returned.Possible enum valuesactive past_due unpaid canceled incomplete incomplete_expired trialing all ended More parametersExpand all collection_method optional created optional dictionary current_period_end optional dictionary current_period_start optional dictionary ending_before optional limit optional starting_after optional test_clock optional ReturnsReturns a list of subscriptions
import stripe stripe.api_key = "sk_test_your_key" stripe.Subscription.search( query="status:'active' AND metadata['order_id']:'6735'", ) '''Response { "object": "search_result", "url": "/v1/subscriptions/search", "has_more": false, "data": [ { "id": "su_1JbiLB2eZvKYlo2CRmgET2WF", "object": "subscription", "application": null, "application_fee_percent": null, "automatic_tax": { "enabled": false }, "billing_cycle_anchor": 1633337949, "billing_thresholds": null, "cancel_at": null, "cancel_at_period_end": false, "canceled_at": null, "collection_method": "charge_automatically", "created": 1632128349, "currency": "usd", "current_period_end": 1660553949, "current_period_start": 1658739549, "customer": "cus_KGEouBKGmh7mXW", "days_until_due": null, "default_payment_method": "pm_1JbiL92eZvKYlo2CuiUB2nL1", "default_source": null, "default_tax_rates": [], "description": null, "discount": null, "ended_at": null, "items": { "object": "list", "data": [ { "id": "si_KGEo6oKuLzcuYw", "object": "subscription_item", "billing_thresholds": null, "created": 1632128350, "metadata": {}, "price": { "id": "15", "object": "price", "active": true, "billing_scheme": "per_unit", "created": 1386685951, "currency": "usd", "custom_unit_amount": null, "livemode": false, "lookup_key": null, "metadata": { "charset": "utf-8", "content": "15" }, "nickname": null, "product": "prod_BTdpcRLIUTfsFR", "recurring": { "aggregate_usage": null, "interval": "week", "interval_count": 3, "usage_type": "licensed" }, "tax_behavior": "unspecified", "tiers_mode": null, "transform_quantity": null, "type": "recurring", "unit_amount": 444, "unit_amount_decimal": "444" }, "quantity": 1, "subscription": "sub_1JbiLB2eZvKYlo2CNHnqfMzf", "tax_rates": [] } ], "has_more": false, "url": "/v1/subscription_items?subscription=sub_1JbiLB2eZvKYlo2CNHnqfMzf" }, "latest_invoice": "in_1LPN8U2eZvKYlo2C2h002pSa", "livemode": false, "metadata": { "order_id": "6735" }, "next_pending_invoice_item_invoice": null, "pause_collection": null, "payment_settings": { "payment_method_options": null, "payment_method_types": null, "save_default_payment_method": null }, "pending_invoice_item_interval": null, "pending_setup_intent": null, "pending_update": null, "schedule": null, "start_date": 1632128349, "status": "active", "test_clock": null, "transfer_data": null, "trial_end": 1633337949, "trial_start": 1632128349 }, {...}, {...} ] }'''
Search subscriptionsSearch for subscriptions you’ve previously created using Stripe’s Search Query Language. Don’t use search in read-after-write flows where strict consistency is necessary. Under normal operating conditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up to an hour behind during outages. Search functionality is not available to merchants in India.Parameters query required The search query string. See search query language and the list of supported query fields for subscriptions. limit optional A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10. page optional A cursor for pagination across multiple pages of results. Don’t include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results.ReturnsA dictionary with a data property that contains an array of up to limit subscriptions. If no objects match the query, the resulting array will be empty. See the related guide on expanding properties in lists
'''Endpoints  POST /v1/subscription_items   GET /v1/subscription_items/:id  POST /v1/subscription_items/:idDELETE /v1/subscription_items/:id   GET /v1/subscription_items '''
Subscription ItemsSubscription items allow you to create customer subscriptions with more than one plan, making it easy to represent complex billing relationships
'''The subscription item object { "id": "si_MAzroazQBGguLd", "object": "subscription_item", "billing_thresholds": null, "created": 1659518859, "metadata": {}, "price": { "id": "price_1LSTX02eZvKYlo2CrKMGl6Dy", "object": "price", "active": true, "billing_scheme": "per_unit", "created": 1659479142, "currency": "usd", "custom_unit_amount": null, "livemode": false, "lookup_key": null, "metadata": {}, "nickname": null, "product": "prod_MApBpixJvIPdF1", "recurring": { "aggregate_usage": null, "interval": "month", "interval_count": 1, "usage_type": "licensed" }, "tax_behavior": "unspecified", "tiers_mode": null, "transform_quantity": null, "type": "recurring", "unit_amount": 1200, "unit_amount_decimal": "1200" }, "quantity": 1, "subscription": "sub_1LSdra2eZvKYlo2CbANuqqoc", "tax_rates": [] } '''
The subscription item objectAttributes id string Unique identifier for the object. metadata hash Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. price hash The price the customer is subscribed to.Show child attributes quantity positive integer or zero The quantity of the plan to which the customer should be subscribed. subscription string The subscription this subscription_item belongs to.More attributesExpand all object string, value is "subscription_item" billing_thresholds hash created integer tax_rates array of hashes
import stripe stripe.api_key = "sk_test_your_key" stripe.SubscriptionItem.create( subscription="sub_1JbiLB2eZvKYlo2CNHnqfMzf", price="price_1LSTX02eZvKYlo2CrKMGl6Dy", quantity=2, ) '''Response { "id": "si_MAzroazQBGguLd", "object": "subscription_item", "billing_thresholds": null, "created": 1659518859, "metadata": {}, "price": "price_1LSTX02eZvKYlo2CrKMGl6Dy", "quantity": 2, "subscription": "sub_1JbiLB2eZvKYlo2CNHnqfMzf", "tax_rates": [] }'''
Create a subscription itemAdds a new item to an existing subscription. No existing items will be changed or replaced.Parameters subscription required The identifier of the subscription to modify. metadata optional dictionary Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to metadata. payment_behavior optional enum Use allow_incomplete to transition the subscription to status=past_due if a payment is required but cannot be paid. This allows you to manage scenarios where additional user actions are needed to pay a subscription’s invoice. For example, SCA regulation may require 3DS authentication to complete payment. See the SCA Migration Guide for Billing to learn more. This is the default behavior. Use default_incomplete to transition the subscription to status=past_due when payment is required and await explicit confirmation of the invoice’s payment intent. This allows simpler management of scenarios where additional user actions are needed to pay a subscription’s invoice. Such as failed payments, SCA regulation, or collecting a mandate for a bank debit payment method. Use pending_if_incomplete to update the subscription using pending updates. When you use pending_if_incomplete you can only pass the parameters supported by pending updates. Use error_if_incomplete if you want Stripe to return an HTTP 402 status code if a subscription’s invoice cannot be paid. For example, if a payment method requires 3DS authentication due to SCA regulation and further user action is needed, this parameter does not update the subscription and returns an error instead. This was the default behavior for API versions prior to 2019-03-14. See the changelog to learn more.Possible enum valuesallow_incomplete error_if_incomplete pending_if_incomplete default_incomplete price optional The ID of the price object. proration_behavior optional enum Determines how to handle prorations when the billing cycle changes (e.g., when switching plans, resetting billing_cycle_anchor=now, or starting a trial), or if an item’s quantity changes.Possible enum valuescreate_prorations Will cause proration invoice items to be created when applicable. These proration items will only be invoiced immediately under certain conditions.none Disable creating prorations in this request.always_invoice Always invoice immediately for prorations. quantity optional The quantity you’d like to apply to the subscription item you’re creating.More parametersExpand all billing_thresholds optional dictionary price_data optional dictionary proration_date optional tax_rates optional ReturnsReturns the created Subscription Item object, if successful. Otherwise, this call raises an error
import stripe stripe.api_key = "sk_test_your_key" stripe.SubscriptionItem.retrieve( "si_MAzroazQBGguLd", ) '''Response { "id": "si_MAzroazQBGguLd", "object": "subscription_item", "billing_thresholds": null, "created": 1659518859, "metadata": {}, "price": { "id": "price_1LSTX02eZvKYlo2CrKMGl6Dy", "object": "price", "active": true, "billing_scheme": "per_unit", "created": 1659479142, "currency": "usd", "custom_unit_amount": null, "livemode": false, "lookup_key": null, "metadata": {}, "nickname": null, "product": "prod_MApBpixJvIPdF1", "recurring": { "aggregate_usage": null, "interval": "month", "interval_count": 1, "usage_type": "licensed" }, "tax_behavior": "unspecified", "tiers_mode": null, "transform_quantity": null, "type": "recurring", "unit_amount": 1200, "unit_amount_decimal": "1200" }, "quantity": 1, "subscription": "sub_1LSdra2eZvKYlo2CbANuqqoc", "tax_rates": [] }'''
Retrieve a subscription itemRetrieves the subscription item with the given ID.ParametersNo parameters.ReturnsReturns a subscription item if a valid subscription item ID was provided. Raises an error otherwise
import stripe stripe.api_key = "sk_test_your_key" stripe.SubscriptionItem.modify( "si_MAzroazQBGguLd", metadata={"order_id": "6735"}, ) '''Response { "id": "si_MAzroazQBGguLd", "object": "subscription_item", "billing_thresholds": null, "created": 1659518859, "metadata": { "order_id": "6735" }, "price": { "id": "price_1LSTX02eZvKYlo2CrKMGl6Dy", "object": "price", "active": true, "billing_scheme": "per_unit", "created": 1659479142, "currency": "usd", "custom_unit_amount": null, "livemode": false, "lookup_key": null, "metadata": {}, "nickname": null, "product": "prod_MApBpixJvIPdF1", "recurring": { "aggregate_usage": null, "interval": "month", "interval_count": 1, "usage_type": "licensed" }, "tax_behavior": "unspecified", "tiers_mode": null, "transform_quantity": null, "type": "recurring", "unit_amount": 1200, "unit_amount_decimal": "1200" }, "quantity": 1, "subscription": "sub_1LSdra2eZvKYlo2CbANuqqoc", "tax_rates": [] }'''
Update a subscription itemUpdates the plan or quantity of an item on a current subscription.Parameters metadata optional dictionary Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to metadata. payment_behavior optional enum Use allow_incomplete to transition the subscription to status=past_due if a payment is required but cannot be paid. This allows you to manage scenarios where additional user actions are needed to pay a subscription’s invoice. For example, SCA regulation may require 3DS authentication to complete payment. See the SCA Migration Guide for Billing to learn more. This is the default behavior. Use default_incomplete to transition the subscription to status=past_due when payment is required and await explicit confirmation of the invoice’s payment intent. This allows simpler management of scenarios where additional user actions are needed to pay a subscription’s invoice. Such as failed payments, SCA regulation, or collecting a mandate for a bank debit payment method. Use pending_if_incomplete to update the subscription using pending updates. When you use pending_if_incomplete you can only pass the parameters supported by pending updates. Use error_if_incomplete if you want Stripe to return an HTTP 402 status code if a subscription’s invoice cannot be paid. For example, if a payment method requires 3DS authentication due to SCA regulation and further user action is needed, this parameter does not update the subscription and returns an error instead. This was the default behavior for API versions prior to 2019-03-14. See the changelog to learn more.Possible enum valuesallow_incomplete error_if_incomplete pending_if_incomplete default_incomplete price optional The ID of the price object. When changing a subscription item’s price, quantity is set to 1 unless a quantity parameter is provided. proration_behavior optional enum Determines how to handle prorations when the billing cycle changes (e.g., when switching plans, resetting billing_cycle_anchor=now, or starting a trial), or if an item’s quantity changes.Possible enum valuescreate_prorations Will cause proration invoice items to be created when applicable. These proration items will only be invoiced immediately under certain conditions.none Disable creating prorations in this request.always_invoice Always invoice immediately for prorations. quantity optional The quantity you’d like to apply to the subscription item you’re creating.More parametersExpand all billing_thresholds optional dictionary off_session optional price_data optional dictionary proration_date optional tax_rates optional Return
import stripe stripe.api_key = "sk_test_your_key" stripe.SubscriptionItem.delete( "si_MAzroazQBGguLd", ) '''Response { "id": "si_MAzroazQBGguLd", "object": "subscription_item", "deleted": true }'''
Delete a subscription itemDeletes an item from the subscription. Removing a subscription item from a subscription will not cancel the subscription.Parameters proration_behavior optional enum Determines how to handle prorations when the billing cycle changes (e.g., when switching plans, resetting billing_cycle_anchor=now, or starting a trial), or if an item’s quantity changes.Possible enum valuescreate_prorations Will cause proration invoice items to be created when applicable. These proration items will only be invoiced immediately under certain conditions.none Disable creating prorations in this request.always_invoice Always invoice immediately for prorations.More parametersExpand all clear_usage optional proration_date optional ReturnsAn subscription item object with a deleted flag upon success. Otherwise, this call raises an error, such as if the subscription item has already been deleted
import stripe stripe.api_key = "sk_test_your_key" stripe.SubscriptionItem.list( subscription="sub_1JbiLB2eZvKYlo2CNHnqfMzf", ) '''Response { "object": "list", "url": "/v1/subscription_items", "has_more": false, "data": [ { "id": "si_MAzroazQBGguLd", "object": "subscription_item", "billing_thresholds": null, "created": 1659518859, "metadata": {}, "price": { "id": "price_1LSTX02eZvKYlo2CrKMGl6Dy", "object": "price", "active": true, "billing_scheme": "per_unit", "created": 1659479142, "currency": "usd", "custom_unit_amount": null, "livemode": false, "lookup_key": null, "metadata": {}, "nickname": null, "product": "prod_MApBpixJvIPdF1", "recurring": { "aggregate_usage": null, "interval": "month", "interval_count": 1, "usage_type": "licensed" }, "tax_behavior": "unspecified", "tiers_mode": null, "transform_quantity": null, "type": "recurring", "unit_amount": 1200, "unit_amount_decimal": "1200" }, "quantity": 1, "subscription": "sub_1LSdra2eZvKYlo2CbANuqqoc", "tax_rates": [] }, {...}, {...} ] }'''
List all subscription itemsReturns a list of your subscription items for a given subscription.Parameters subscription required The ID of the subscription whose items will be retrieved.More parametersExpand all ending_before optional limit optional starting_after optional ReturnsA dictionary with a data property that contains an array of up to limit subscription items, starting after subscription item starting_after. Each entry in the array is a separate subscription item object. If no more subscription items are available, the resulting array will be empty. This request should never raise an error
'''Endpoints  POST /v1/subscription_schedules   GET /v1/subscription_schedules/:id  POST /v1/subscription_schedules/:id  POST /v1/subscription_schedules/:id/cancel  POST /v1/subscription_schedules/:id/release   GET /v1/subscription_schedules '''
Subscription ScheduleA subscription schedule allows you to create and manage the lifecycle of a subscription by predefining expected changes.