View Source Stripe.Invoice (stripity_stripe v3.2.0)

Invoices 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.

Related guide: Send invoices to customers

Summary

Types

Configuration for the bank transfer funding type, if the funding_type is set to bank_transfer.

The estimated range for how long shipping will take, meant to be displayable to the customer. This will appear on CheckoutSessions.

Configuration for eu_bank_transfer funding type.

Additional fields for Financial Connections Session creation

Describes a fixed amount to charge for shipping. Must be present if type is fixed_amount.

Revise an existing invoice. The new invoice will be created in status=draft. See the revision documentation for more details.

Installment configuration for payments attempted on this invoice (Mexico Only).

Additional fields for Mandate creation

The upper bound of the estimated range. If empty, represents no upper bound i.e., infinite.

The lower bound of the estimated range. If empty, represents no lower bound.

Payment-method-specific configuration to provide to the invoice’s PaymentIntent.

Configuration settings for the PaymentIntent that is generated when the invoice is finalized.

Invoice pdf rendering options

The period associated with this invoice item. When set to different values, the period will be rendered on the invoice. If you have Stripe Revenue Recognition enabled, the period will be used to recognize and defer revenue. See the Revenue Recognition documentation for details.

Data used to generate a new Price object inline.

The recurring components of a price such as interval and interval_count.

The rendering-related settings that control how the invoice is displayed on customer-facing surfaces such as PDF and Hosted Invoice Page.

Parameters to create a new ad-hoc shipping rate for this order.

t()

The invoice type.

Tax details about the customer.

Functions

This endpoint creates a draft invoice for a given customer. The invoice remains a draft until you finalize the invoice, which allows you to pay or send the invoice to your customers.

Permanently 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.

Stripe 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.

You 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.

Marking an invoice as uncollectible is useful for keeping track of bad debts that can be written off for accounting purposes.

Stripe 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.

Retrieves the invoice with the given ID.

Search 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.

Stripe 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.

At 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.

When 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.

Draft invoices are fully editable. Once an invoice is finalized,monetary values, as well as collection_method, become uneditable.

Mark 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.

Types

@type acss_debit() :: %{
  optional(:mandate_options) => mandate_options(),
  optional(:verification_method) => :automatic | :instant | :microdeposits
}
@type address() :: %{
  optional(:city) => binary(),
  optional(:country) => binary(),
  optional(:line1) => binary(),
  optional(:line2) => binary(),
  optional(:postal_code) => binary(),
  optional(:state) => binary()
}
@type automatic_tax() :: %{optional(:enabled) => boolean()}
@type bancontact() :: %{optional(:preferred_language) => :de | :en | :fr | :nl}
@type bank_transfer() :: %{
  optional(:eu_bank_transfer) => eu_bank_transfer(),
  optional(:type) => binary()
}

Configuration for the bank transfer funding type, if the funding_type is set to bank_transfer.

@type billing_thresholds() :: %{optional(:usage_gte) => integer()}
@type card() :: %{
  optional(:installments) => installments(),
  optional(:request_three_d_secure) => :any | :automatic
}
@type created() :: %{
  optional(:gt) => integer(),
  optional(:gte) => integer(),
  optional(:lt) => integer(),
  optional(:lte) => integer()
}
@type custom_fields() :: %{optional(:name) => binary(), optional(:value) => binary()}
@type customer_balance() :: %{
  optional(:bank_transfer) => bank_transfer(),
  optional(:funding_type) => binary()
}
@type customer_details() :: %{
  optional(:address) => address() | binary(),
  optional(:shipping) => shipping() | binary(),
  optional(:tax) => tax(),
  optional(:tax_exempt) => :exempt | :none | :reverse,
  optional(:tax_ids) => [tax_ids()]
}
@type delivery_estimate() :: %{
  optional(:maximum) => maximum(),
  optional(:minimum) => minimum()
}

The estimated range for how long shipping will take, meant to be displayable to the customer. This will appear on CheckoutSessions.

@type discounts() :: %{optional(:coupon) => binary(), optional(:discount) => binary()}
@type due_date() :: %{
  optional(:gt) => integer(),
  optional(:gte) => integer(),
  optional(:lt) => integer(),
  optional(:lte) => integer()
}
@type eu_bank_transfer() :: %{optional(:country) => binary()}

Configuration for eu_bank_transfer funding type.

Link to this type

financial_connections()

View Source
@type financial_connections() :: %{
  optional(:permissions) => [
    :balances | :ownership | :payment_method | :transactions
  ],
  optional(:prefetch) => [:balances | :transactions]
}

Additional fields for Financial Connections Session creation

@type fixed_amount() :: %{
  optional(:amount) => integer(),
  optional(:currency) => binary(),
  optional(:currency_options) => map()
}

Describes a fixed amount to charge for shipping. Must be present if type is fixed_amount.

@type from_invoice() :: %{
  optional(:action) => :revision,
  optional(:invoice) => binary()
}

Revise an existing invoice. The new invoice will be created in status=draft. See the revision documentation for more details.

@type installments() :: %{
  optional(:enabled) => boolean(),
  optional(:plan) => plan() | binary()
}

Installment configuration for payments attempted on this invoice (Mexico Only).

For more information, see the installments integration guide.

@type invoice_items() :: %{
  optional(:amount) => integer(),
  optional(:currency) => binary(),
  optional(:description) => binary(),
  optional(:discountable) => boolean(),
  optional(:discounts) => [discounts()] | binary(),
  optional(:invoiceitem) => binary(),
  optional(:metadata) => %{optional(binary()) => binary()} | binary(),
  optional(:period) => period(),
  optional(:price) => binary(),
  optional(:price_data) => price_data(),
  optional(:quantity) => integer(),
  optional(:tax_behavior) => :exclusive | :inclusive | :unspecified,
  optional(:tax_code) => binary() | binary(),
  optional(:tax_rates) => [binary()] | binary(),
  optional(:unit_amount) => integer(),
  optional(:unit_amount_decimal) => binary()
}
@type mandate_options() :: %{optional(:transaction_type) => :business | :personal}

Additional fields for Mandate creation

@type maximum() :: %{
  optional(:unit) => :business_day | :day | :hour | :month | :week,
  optional(:value) => integer()
}

The upper bound of the estimated range. If empty, represents no upper bound i.e., infinite.

@type minimum() :: %{
  optional(:unit) => :business_day | :day | :hour | :month | :week,
  optional(:value) => integer()
}

The lower bound of the estimated range. If empty, represents no lower bound.

Link to this type

payment_method_options()

View Source
@type payment_method_options() :: %{
  optional(:acss_debit) => acss_debit() | binary(),
  optional(:bancontact) => bancontact() | binary(),
  optional(:card) => card() | binary(),
  optional(:customer_balance) => customer_balance() | binary(),
  optional(:konbini) => map() | binary(),
  optional(:us_bank_account) => us_bank_account() | binary()
}

Payment-method-specific configuration to provide to the invoice’s PaymentIntent.

@type payment_settings() :: %{
  optional(:default_mandate) => binary() | binary(),
  optional(:payment_method_options) => payment_method_options(),
  optional(:payment_method_types) =>
    [
      :ach_credit_transfer
      | :ach_debit
      | :acss_debit
      | :au_becs_debit
      | :bacs_debit
      | :bancontact
      | :boleto
      | :card
      | :cashapp
      | :customer_balance
      | :eps
      | :fpx
      | :giropay
      | :grabpay
      | :ideal
      | :konbini
      | :link
      | :p24
      | :paynow
      | :paypal
      | :promptpay
      | :sepa_credit_transfer
      | :sepa_debit
      | :sofort
      | :us_bank_account
      | :wechat_pay
    ]
    | binary()
}

Configuration settings for the PaymentIntent that is generated when the invoice is finalized.

@type pdf() :: %{optional(:page_size) => :a4 | :auto | :letter}

Invoice pdf rendering options

@type period() :: %{optional(:end) => integer(), optional(:start) => integer()}

The period associated with this invoice item. When set to different values, the period will be rendered on the invoice. If you have Stripe Revenue Recognition enabled, the period will be used to recognize and defer revenue. See the Revenue Recognition documentation for details.

@type plan() :: %{
  optional(:count) => integer(),
  optional(:interval) => :month,
  optional(:type) => :fixed_count
}
@type price_data() :: %{
  optional(:currency) => binary(),
  optional(:product) => binary(),
  optional(:recurring) => recurring(),
  optional(:tax_behavior) => :exclusive | :inclusive | :unspecified,
  optional(:unit_amount) => integer(),
  optional(:unit_amount_decimal) => binary()
}

Data used to generate a new Price object inline.

@type recurring() :: %{
  optional(:interval) => :day | :month | :week | :year,
  optional(:interval_count) => integer()
}

The recurring components of a price such as interval and interval_count.

@type rendering() :: %{
  optional(:amount_tax_display) => :exclude_tax | :include_inclusive_tax,
  optional(:pdf) => pdf()
}

The rendering-related settings that control how the invoice is displayed on customer-facing surfaces such as PDF and Hosted Invoice Page.

@type rendering_options() :: %{
  optional(:amount_tax_display) => :exclude_tax | :include_inclusive_tax
}
@type shipping() :: %{
  optional(:address) => address(),
  optional(:name) => binary(),
  optional(:phone) => binary()
}
@type shipping_cost() :: %{
  optional(:shipping_rate) => binary(),
  optional(:shipping_rate_data) => shipping_rate_data()
}
@type shipping_details() :: %{
  optional(:address) => address(),
  optional(:name) => binary(),
  optional(:phone) => binary() | binary()
}
@type shipping_rate_data() :: %{
  optional(:delivery_estimate) => delivery_estimate(),
  optional(:display_name) => binary(),
  optional(:fixed_amount) => fixed_amount(),
  optional(:metadata) => %{optional(binary()) => binary()},
  optional(:tax_behavior) => :exclusive | :inclusive | :unspecified,
  optional(:tax_code) => binary(),
  optional(:type) => :fixed_amount
}

Parameters to create a new ad-hoc shipping rate for this order.

@type subscription_items() :: %{
  optional(:billing_thresholds) => billing_thresholds() | binary(),
  optional(:clear_usage) => boolean(),
  optional(:deleted) => boolean(),
  optional(:id) => binary(),
  optional(:metadata) => %{optional(binary()) => binary()} | binary(),
  optional(:plan) => binary(),
  optional(:price) => binary(),
  optional(:price_data) => price_data(),
  optional(:quantity) => integer(),
  optional(:tax_rates) => [binary()] | binary()
}
@type t() :: %Stripe.Invoice{
  account_country: binary() | nil,
  account_name: binary() | nil,
  account_tax_ids: term() | nil,
  amount_due: integer(),
  amount_paid: integer(),
  amount_remaining: integer(),
  amount_shipping: integer(),
  application: (binary() | term() | term()) | nil,
  application_fee_amount: integer() | nil,
  attempt_count: integer(),
  attempted: boolean(),
  auto_advance: boolean(),
  automatic_tax: term(),
  billing_reason: binary() | nil,
  charge: (binary() | Stripe.Charge.t()) | nil,
  collection_method: binary(),
  created: integer(),
  currency: binary(),
  custom_fields: term() | nil,
  customer: (binary() | Stripe.Customer.t() | Stripe.DeletedCustomer.t()) | nil,
  customer_address: term() | nil,
  customer_email: binary() | nil,
  customer_name: binary() | nil,
  customer_phone: binary() | nil,
  customer_shipping: term() | nil,
  customer_tax_exempt: binary() | nil,
  customer_tax_ids: term() | nil,
  default_payment_method: (binary() | Stripe.PaymentMethod.t()) | nil,
  default_source: (binary() | Stripe.PaymentSource.t()) | nil,
  default_tax_rates: term(),
  description: binary() | nil,
  discount: term() | nil,
  discounts: term() | nil,
  due_date: integer() | nil,
  effective_at: integer() | nil,
  ending_balance: integer() | nil,
  footer: binary() | nil,
  from_invoice: term() | nil,
  hosted_invoice_url: binary() | nil,
  id: binary(),
  invoice_pdf: binary() | nil,
  last_finalization_error: Stripe.ApiErrors.t() | nil,
  latest_revision: (binary() | t()) | nil,
  lines: term(),
  livemode: boolean(),
  metadata: term() | nil,
  next_payment_attempt: integer() | nil,
  number: binary() | nil,
  object: binary(),
  on_behalf_of: (binary() | Stripe.Account.t()) | nil,
  paid: boolean(),
  paid_out_of_band: boolean(),
  payment_intent: (binary() | Stripe.PaymentIntent.t()) | nil,
  payment_settings: term(),
  period_end: integer(),
  period_start: integer(),
  post_payment_credit_notes_amount: integer(),
  pre_payment_credit_notes_amount: integer(),
  quote: (binary() | Stripe.Quote.t()) | nil,
  receipt_number: binary() | nil,
  rendering: term() | nil,
  rendering_options: term() | nil,
  shipping_cost: term() | nil,
  shipping_details: term() | nil,
  starting_balance: integer(),
  statement_descriptor: binary() | nil,
  status: binary() | nil,
  status_transitions: term(),
  subscription: (binary() | Stripe.Subscription.t()) | nil,
  subscription_details: term() | nil,
  subscription_proration_date: integer(),
  subtotal: integer(),
  subtotal_excluding_tax: integer() | nil,
  tax: integer() | nil,
  test_clock: (binary() | Stripe.TestHelpers.TestClock.t()) | nil,
  threshold_reason: term(),
  total: integer(),
  total_discount_amounts: term() | nil,
  total_excluding_tax: integer() | nil,
  total_tax_amounts: term(),
  transfer_data: term() | nil,
  webhooks_delivered_at: integer() | nil
}

The invoice type.

  • account_country The country of the business associated with this invoice, most often the business creating the invoice.

  • account_name The public name of the business associated with this invoice, most often the business creating the invoice.

  • account_tax_ids The account tax IDs associated with the invoice. Only editable when the invoice is a draft.

  • amount_due Final amount due at this time for this invoice. If the invoice's total is smaller than the minimum charge amount, for example, or if there is account credit that can be applied to the invoice, the amount_due may be 0. If there is a positive starting_balance for the invoice (the customer owes money), the amount_due will also take that into account. The charge that gets generated for the invoice will be for the amount specified in amount_due.

  • amount_paid The amount, in cents (or local equivalent), that was paid.

  • amount_remaining The difference between amount_due and amount_paid, in cents (or local equivalent).

  • amount_shipping This is the sum of all the shipping amounts.

  • application ID of the Connect Application that created the invoice.

  • application_fee_amount The fee in cents (or local equivalent) that will be applied to the invoice and transferred to the application owner's Stripe account when the invoice is paid.

  • attempt_count Number of payment attempts made for this invoice, from the perspective of the payment retry schedule. Any payment attempt counts as the first attempt, and subsequently only automatic retries increment the attempt count. In other words, manual payment attempts after the first attempt do not affect the retry schedule.

  • attempted Whether an attempt has been made to pay the invoice. An invoice is not attempted until 1 hour after the invoice.created webhook, for example, so you might not want to display that invoice as unpaid to your users.

  • auto_advance Controls whether Stripe performs automatic collection of the invoice. If false, the invoice's state doesn't automatically advance without an explicit action.

  • automatic_tax

  • billing_reason Indicates the reason why the invoice was created.

  • manual: Unrelated to a subscription, for example, created via the invoice editor.

  • subscription: No longer in use. Applies to subscriptions from before May 2018 where no distinction was made between updates, cycles, and thresholds.

  • subscription_create: A new subscription was created.

  • subscription_cycle: A subscription advanced into a new period.

  • subscription_threshold: A subscription reached a billing threshold.

  • subscription_update: A subscription was updated.

  • upcoming: Reserved for simulated invoices, per the upcoming invoice endpoint.

    • charge ID of the latest charge generated for this invoice, if any.
    • collection_method 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.
    • created Time at which the object was created. Measured in seconds since the Unix epoch.
    • currency Three-letter ISO currency code, in lowercase. Must be a supported currency.
    • custom_fields Custom fields displayed on the invoice.
    • customer The ID of the customer who will be billed.
    • customer_address The customer's address. Until the invoice is finalized, this field will equal customer.address. Once the invoice is finalized, this field will no longer be updated.
    • customer_email The customer's email. Until the invoice is finalized, this field will equal customer.email. Once the invoice is finalized, this field will no longer be updated.
    • customer_name The customer's name. Until the invoice is finalized, this field will equal customer.name. Once the invoice is finalized, this field will no longer be updated.
    • customer_phone The customer's phone number. Until the invoice is finalized, this field will equal customer.phone. Once the invoice is finalized, this field will no longer be updated.
    • customer_shipping The customer's shipping information. Until the invoice is finalized, this field will equal customer.shipping. Once the invoice is finalized, this field will no longer be updated.
    • customer_tax_exempt The customer's tax exempt status. Until the invoice is finalized, this field will equal customer.tax_exempt. Once the invoice is finalized, this field will no longer be updated.
    • customer_tax_ids The customer's tax IDs. Until the invoice is finalized, this field will contain the same tax IDs as customer.tax_ids. Once the invoice is finalized, this field will no longer be updated.
    • default_payment_method ID of the default payment method for the invoice. It must belong to the customer associated with the invoice. If not set, defaults to the subscription's default payment method, if any, or to the default payment method in the customer's invoice settings.
    • default_source ID of the default payment source for the invoice. It must belong to the customer associated with the invoice and be in a chargeable state. If not set, defaults to the subscription's default source, if any, or to the customer's default source.
    • default_tax_rates The tax rates applied to this invoice, if any.
    • description An arbitrary string attached to the object. Often useful for displaying to users. Referenced as 'memo' in the Dashboard.
    • discount Describes the current discount applied to this invoice, if there is one. Not populated if there are multiple discounts.
    • discounts The discounts applied to the invoice. Line item discounts are applied before invoice discounts. Use expand[]=discounts to expand each discount.
    • due_date The date on which payment for this invoice is due. This value will be null for invoices where collection_method=charge_automatically.
    • effective_at The date when this invoice is in effect. Same as finalized_at unless overwritten. When defined, this value replaces the system-generated 'Date of issue' printed on the invoice PDF and receipt.
    • ending_balance Ending customer balance after the invoice is finalized. Invoices are finalized approximately an hour after successful webhook delivery or when payment collection is attempted for the invoice. If the invoice has not been finalized yet, this will be null.
    • footer Footer displayed on the invoice.
    • from_invoice Details of the invoice that was cloned. See the revision documentation for more details.
    • hosted_invoice_url 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.
    • id Unique identifier for the object. This property is always present unless the invoice is an upcoming invoice. See Retrieve an upcoming invoice for more details.
    • invoice_pdf The link to download the PDF for the invoice. If the invoice has not been finalized yet, this will be null.
    • last_finalization_error The error encountered during the previous attempt to finalize the invoice. This field is cleared when the invoice is successfully finalized.
    • latest_revision The ID of the most recent non-draft revision of this invoice
    • lines The individual line items that make up the invoice. lines is sorted as follows: (1) pending invoice items (including prorations) in reverse chronological order, (2) subscription items in reverse chronological order, and (3) invoice items added after invoice creation in chronological order.
    • livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode.
    • metadata 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.
    • next_payment_attempt The time at which payment will next be attempted. This value will be null for invoices where collection_method=send_invoice.
    • number A unique, identifying string that appears on emails sent to the customer for this invoice. This starts with the customer's unique invoice_prefix if it is specified.
    • object String representing the object's type. Objects of the same type share the same value.
    • on_behalf_of The account (if any) for which the funds of the invoice payment are intended. If set, the invoice will be presented with the branding and support information of the specified account. See the Invoices with Connect documentation for details.
    • paid Whether payment was successfully collected for this invoice. An invoice can be paid (most commonly) with a charge or with credit from the customer's account balance.
    • paid_out_of_band Returns true if the invoice was manually marked paid, returns false if the invoice hasn't been paid yet or was paid on Stripe.
    • payment_intent 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.
    • payment_settings
    • period_end End of the usage period during which invoice items were added to this invoice.
    • period_start Start of the usage period during which invoice items were added to this invoice.
    • post_payment_credit_notes_amount Total amount of all post-payment credit notes issued for this invoice.
    • pre_payment_credit_notes_amount Total amount of all pre-payment credit notes issued for this invoice.
    • quote The quote this invoice was generated from.
    • receipt_number This is the transaction number that appears on email receipts sent for this invoice.
    • rendering The rendering-related settings that control how the invoice is displayed on customer-facing surfaces such as PDF and Hosted Invoice Page.
    • rendering_options This is a legacy field that will be removed soon. For details about rendering_options, refer to rendering instead. Options for invoice PDF rendering.
    • shipping_cost The details of the cost of shipping, including the ShippingRate applied on the invoice.
    • shipping_details Shipping details for the invoice. The Invoice PDF will use the shipping_details value if it is set, otherwise the PDF will render the shipping address from the customer.
    • starting_balance Starting customer balance before the invoice is finalized. If the invoice has not been finalized yet, this will be the current customer balance. For revision invoices, this also includes any customer balance that was applied to the original invoice.
    • statement_descriptor Extra information about an invoice for the customer's credit card statement.
    • status The status of the invoice, one of draft, open, paid, uncollectible, or void. Learn more
    • status_transitions
    • subscription The subscription that this invoice was prepared for, if any.
    • subscription_details Details about the subscription that created this invoice.
    • subscription_proration_date Only set for upcoming invoices that preview prorations. The time used to calculate prorations.
    • subtotal Total of all subscriptions, invoice items, and prorations on the invoice before any invoice level discount or exclusive tax is applied. Item discounts are already incorporated
    • subtotal_excluding_tax The integer amount in cents (or local equivalent) representing the subtotal of the invoice before any invoice level discount or tax is applied. Item discounts are already incorporated
    • tax The amount of tax on this invoice. This is the sum of all the tax amounts on this invoice.
    • test_clock ID of the test clock this invoice belongs to.
    • threshold_reason
    • total Total after discounts and taxes.
    • total_discount_amounts The aggregate amounts calculated per discount across all line items.
    • total_excluding_tax The integer amount in cents (or local equivalent) representing the total amount of the invoice including all discounts but excluding all tax.
    • total_tax_amounts The aggregate amounts calculated per tax rate for all line items.
    • transfer_data The account (if any) the payment will be attributed to for tax reporting, and where funds from the payment will be transferred to for the invoice.
    • webhooks_delivered_at Invoices are automatically paid or sent 1 hour after webhooks are delivered, or until all webhook delivery attempts have been exhausted. This field tracks the time when webhooks for this invoice were successfully delivered. If the invoice had no webhooks to deliver, this will be set while the invoice is being created.
@type tax() :: %{optional(:ip_address) => binary() | binary()}

Tax details about the customer.

@type tax_ids() :: %{
  optional(:type) =>
    :ad_nrt
    | :ae_trn
    | :ar_cuit
    | :au_abn
    | :au_arn
    | :bg_uic
    | :bo_tin
    | :br_cnpj
    | :br_cpf
    | :ca_bn
    | :ca_gst_hst
    | :ca_pst_bc
    | :ca_pst_mb
    | :ca_pst_sk
    | :ca_qst
    | :ch_vat
    | :cl_tin
    | :cn_tin
    | :co_nit
    | :cr_tin
    | :do_rcn
    | :ec_ruc
    | :eg_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
    | :jp_trn
    | :ke_pin
    | :kr_brn
    | :li_uid
    | :mx_rfc
    | :my_frp
    | :my_itn
    | :my_sst
    | :no_vat
    | :nz_gst
    | :pe_ruc
    | :ph_tin
    | :ro_tin
    | :rs_pib
    | :ru_inn
    | :ru_kpp
    | :sa_vat
    | :sg_gst
    | :sg_uen
    | :si_tin
    | :sv_nit
    | :th_vat
    | :tr_tin
    | :tw_vat
    | :ua_vat
    | :us_ein
    | :uy_ruc
    | :ve_rif
    | :vn_tin
    | :za_vat,
  optional(:value) => binary()
}
@type transfer_data() :: %{
  optional(:amount) => integer(),
  optional(:destination) => binary()
}
@type us_bank_account() :: %{
  optional(:financial_connections) => financial_connections(),
  optional(:verification_method) => :automatic | :instant | :microdeposits
}

Functions

Link to this function

create(params \\ %{}, opts \\ [])

View Source
@spec create(
  params :: %{
    optional(:account_tax_ids) => [binary()] | binary(),
    optional(:application_fee_amount) => integer(),
    optional(:auto_advance) => boolean(),
    optional(:automatic_tax) => automatic_tax(),
    optional(:collection_method) => :charge_automatically | :send_invoice,
    optional(:currency) => binary(),
    optional(:custom_fields) => [custom_fields()] | binary(),
    optional(:customer) => binary(),
    optional(:days_until_due) => integer(),
    optional(:default_payment_method) => binary(),
    optional(:default_source) => binary(),
    optional(:default_tax_rates) => [binary()],
    optional(:description) => binary(),
    optional(:discounts) => [discounts()] | binary(),
    optional(:due_date) => integer(),
    optional(:effective_at) => integer(),
    optional(:expand) => [binary()],
    optional(:footer) => binary(),
    optional(:from_invoice) => from_invoice(),
    optional(:metadata) => %{optional(binary()) => binary()} | binary(),
    optional(:on_behalf_of) => binary(),
    optional(:payment_settings) => payment_settings(),
    optional(:pending_invoice_items_behavior) =>
      :exclude | :include | :include_and_require,
    optional(:rendering) => rendering(),
    optional(:rendering_options) => rendering_options() | binary(),
    optional(:shipping_cost) => shipping_cost(),
    optional(:shipping_details) => shipping_details(),
    optional(:statement_descriptor) => binary(),
    optional(:subscription) => binary(),
    optional(:transfer_data) => transfer_data()
  },
  opts :: Keyword.t()
) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

This endpoint creates a draft invoice for a given customer. The invoice remains a draft until you finalize the invoice, which allows you to pay or send the invoice to your customers.

Details

  • Method: post
  • Path: /v1/invoices
Link to this function

delete(invoice, opts \\ [])

View Source
@spec delete(invoice :: binary(), opts :: Keyword.t()) ::
  {:ok, Stripe.DeletedInvoice.t()}
  | {:error, Stripe.ApiErrors.t()}
  | {:error, term()}

Permanently 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.

Details

  • Method: delete
  • Path: /v1/invoices/{invoice}
Link to this function

finalize_invoice(invoice, params \\ %{}, opts \\ [])

View Source
@spec finalize_invoice(
  invoice :: binary(),
  params :: %{
    optional(:auto_advance) => boolean(),
    optional(:expand) => [binary()]
  },
  opts :: Keyword.t()
) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

Stripe 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.

Details

  • Method: post
  • Path: /v1/invoices/{invoice}/finalize
Link to this function

list(params \\ %{}, opts \\ [])

View Source
@spec list(
  params :: %{
    optional(:collection_method) => :charge_automatically | :send_invoice,
    optional(:created) => created() | integer(),
    optional(:customer) => binary(),
    optional(:due_date) => due_date() | integer(),
    optional(:ending_before) => binary(),
    optional(:expand) => [binary()],
    optional(:limit) => integer(),
    optional(:starting_after) => binary(),
    optional(:status) => :draft | :open | :paid | :uncollectible | :void,
    optional(:subscription) => binary()
  },
  opts :: Keyword.t()
) ::
  {:ok, Stripe.List.t(t())} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

You 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.

Details

  • Method: get
  • Path: /v1/invoices
Link to this function

mark_uncollectible(invoice, params \\ %{}, opts \\ [])

View Source
@spec mark_uncollectible(
  invoice :: binary(),
  params :: %{optional(:expand) => [binary()]},
  opts :: Keyword.t()
) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

Marking an invoice as uncollectible is useful for keeping track of bad debts that can be written off for accounting purposes.

Details

  • Method: post
  • Path: /v1/invoices/{invoice}/mark_uncollectible
Link to this function

pay(invoice, params \\ %{}, opts \\ [])

View Source
@spec pay(
  invoice :: binary(),
  params :: %{
    optional(:expand) => [binary()],
    optional(:forgive) => boolean(),
    optional(:mandate) => binary() | binary(),
    optional(:off_session) => boolean(),
    optional(:paid_out_of_band) => boolean(),
    optional(:payment_method) => binary(),
    optional(:source) => binary()
  },
  opts :: Keyword.t()
) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

Stripe 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.

Details

  • Method: post
  • Path: /v1/invoices/{invoice}/pay
Link to this function

retrieve(invoice, params \\ %{}, opts \\ [])

View Source
@spec retrieve(
  invoice :: binary(),
  params :: %{optional(:expand) => [binary()]},
  opts :: Keyword.t()
) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

Retrieves the invoice with the given ID.

Details

  • Method: get
  • Path: /v1/invoices/{invoice}
Link to this function

search(params \\ %{}, opts \\ [])

View Source
@spec search(
  params :: %{
    optional(:expand) => [binary()],
    optional(:limit) => integer(),
    optional(:page) => binary(),
    optional(:query) => binary()
  },
  opts :: Keyword.t()
) ::
  {:ok, Stripe.SearchResult.t(t())}
  | {:error, Stripe.ApiErrors.t()}
  | {:error, term()}

Search 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.

#### Details * Method: `get` * Path: `/v1/invoices/search`

Link to this function

send_invoice(invoice, params \\ %{}, opts \\ [])

View Source
@spec send_invoice(
  invoice :: binary(),
  params :: %{optional(:expand) => [binary()]},
  opts :: Keyword.t()
) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

Stripe 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.

Details

  • Method: post
  • Path: /v1/invoices/{invoice}/send
Link to this function

upcoming(params \\ %{}, opts \\ [])

View Source
@spec upcoming(
  params :: %{
    optional(:automatic_tax) => automatic_tax(),
    optional(:coupon) => binary(),
    optional(:currency) => binary(),
    optional(:customer) => binary(),
    optional(:customer_details) => customer_details(),
    optional(:discounts) => [discounts()] | binary(),
    optional(:expand) => [binary()],
    optional(:invoice_items) => [invoice_items()],
    optional(:schedule) => binary(),
    optional(:subscription) => binary(),
    optional(:subscription_billing_cycle_anchor) =>
      (:now | :unchanged) | integer(),
    optional(:subscription_cancel_at) => integer() | binary(),
    optional(:subscription_cancel_at_period_end) => boolean(),
    optional(:subscription_cancel_now) => boolean(),
    optional(:subscription_default_tax_rates) => [binary()] | binary(),
    optional(:subscription_items) => [subscription_items()],
    optional(:subscription_proration_behavior) =>
      :always_invoice | :create_prorations | :none,
    optional(:subscription_proration_date) => integer(),
    optional(:subscription_resume_at) => :now,
    optional(:subscription_start_date) => integer(),
    optional(:subscription_trial_end) => :now | integer(),
    optional(:subscription_trial_from_plan) => boolean()
  },
  opts :: Keyword.t()
) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

At 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.

Details

  • Method: get
  • Path: /v1/invoices/upcoming
Link to this function

upcoming_lines(params \\ %{}, opts \\ [])

View Source
@spec upcoming_lines(
  params :: %{
    optional(:automatic_tax) => automatic_tax(),
    optional(:coupon) => binary(),
    optional(:currency) => binary(),
    optional(:customer) => binary(),
    optional(:customer_details) => customer_details(),
    optional(:discounts) => [discounts()] | binary(),
    optional(:ending_before) => binary(),
    optional(:expand) => [binary()],
    optional(:invoice_items) => [invoice_items()],
    optional(:limit) => integer(),
    optional(:schedule) => binary(),
    optional(:starting_after) => binary(),
    optional(:subscription) => binary(),
    optional(:subscription_billing_cycle_anchor) =>
      (:now | :unchanged) | integer(),
    optional(:subscription_cancel_at) => integer() | binary(),
    optional(:subscription_cancel_at_period_end) => boolean(),
    optional(:subscription_cancel_now) => boolean(),
    optional(:subscription_default_tax_rates) => [binary()] | binary(),
    optional(:subscription_items) => [subscription_items()],
    optional(:subscription_proration_behavior) =>
      :always_invoice | :create_prorations | :none,
    optional(:subscription_proration_date) => integer(),
    optional(:subscription_resume_at) => :now,
    optional(:subscription_start_date) => integer(),
    optional(:subscription_trial_end) => :now | integer(),
    optional(:subscription_trial_from_plan) => boolean()
  },
  opts :: Keyword.t()
) ::
  {:ok, Stripe.List.t(Stripe.LineItem.t())}
  | {:error, Stripe.ApiErrors.t()}
  | {:error, term()}

When 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.

Details

  • Method: get
  • Path: /v1/invoices/upcoming/lines
Link to this function

update(invoice, params \\ %{}, opts \\ [])

View Source
@spec update(
  invoice :: binary(),
  params :: %{
    optional(:account_tax_ids) => [binary()] | binary(),
    optional(:application_fee_amount) => integer(),
    optional(:auto_advance) => boolean(),
    optional(:automatic_tax) => automatic_tax(),
    optional(:collection_method) => :charge_automatically | :send_invoice,
    optional(:custom_fields) => [custom_fields()] | binary(),
    optional(:days_until_due) => integer(),
    optional(:default_payment_method) => binary(),
    optional(:default_source) => binary() | binary(),
    optional(:default_tax_rates) => [binary()] | binary(),
    optional(:description) => binary(),
    optional(:discounts) => [discounts()] | binary(),
    optional(:due_date) => integer(),
    optional(:effective_at) => integer() | binary(),
    optional(:expand) => [binary()],
    optional(:footer) => binary(),
    optional(:metadata) => %{optional(binary()) => binary()} | binary(),
    optional(:on_behalf_of) => binary() | binary(),
    optional(:payment_settings) => payment_settings(),
    optional(:rendering) => rendering(),
    optional(:rendering_options) => rendering_options() | binary(),
    optional(:shipping_cost) => shipping_cost() | binary(),
    optional(:shipping_details) => shipping_details() | binary(),
    optional(:statement_descriptor) => binary(),
    optional(:transfer_data) => transfer_data() | binary()
  },
  opts :: Keyword.t()
) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

Draft 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.

#### Details * Method: `post` * Path: `/v1/invoices/{invoice}`

Link to this function

void_invoice(invoice, params \\ %{}, opts \\ [])

View Source
@spec void_invoice(
  invoice :: binary(),
  params :: %{optional(:expand) => [binary()]},
  opts :: Keyword.t()
) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

Mark 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.

Details

  • Method: post
  • Path: /v1/invoices/{invoice}/void