View Source Stripe.Invoice (Striped v0.5.0) (generated)

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.

Link to this section Summary

Types

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

Configuration for eu_bank_transfer funding type.

Additional fields for Financial Connections Session creation

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

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

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

The period associated with this invoice item. When set to different values, the period will be rendered on the invoice.

Data used to generate a new Price object inline.

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

t()

The invoice type.

Tax details about the customer.

If specified, the funds from the invoice will be transferred to the destination and the ID of the resulting transfer will be found on the invoice's charge.

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.

Link to this section 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 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
  ]
}

Additional fields for Financial Connections Session creation

@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

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(),
  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
      | :customer_balance
      | :fpx
      | :giropay
      | :grabpay
      | :ideal
      | :konbini
      | :link
      | :paynow
      | :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 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.

@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_options() :: %{
  optional(:amount_tax_display) => :exclude_tax | :include_inclusive_tax
}
@type shipping() :: %{
  optional(:address) => address(),
  optional(:name) => binary(),
  optional(:phone) => binary()
}
@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(),
  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,
  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_options: term() | nil,
  starting_balance: integer(),
  statement_descriptor: binary() | nil,
  status: binary() | nil,
  status_transitions: term(),
  subscription: (binary() | Stripe.Subscription.t()) | 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.

  • 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.
  • auto_advance Controls whether Stripe will perform automatic collection of the invoice. When false, the invoice's state will not automatically advance without an explicit action.
  • 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.
  • invoice_pdf The link to download the PDF for the invoice. If the invoice has not been finalized yet, this will be null.
  • 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.
  • livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode.
  • 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.
  • 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.
  • 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.
  • 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.
  • last_finalization_error The error encountered during the previous attempt to finalize the invoice. This field is cleared when the invoice is successfully finalized.
  • 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.
  • 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.
  • custom_fields Custom fields displayed on the invoice.
  • 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
  • account_country The country of the business associated with this invoice, most often the business creating the invoice.
  • 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.
  • description An arbitrary string attached to the object. Often useful for displaying to users. Referenced as 'memo' in the Dashboard.
  • 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.
  • pre_payment_credit_notes_amount Total amount of all pre-payment credit notes issued for this invoice.
  • subscription_proration_date Only set for upcoming invoices that preview prorations. The time used to calculate prorations.
  • footer Footer displayed on the invoice.
  • 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.
  • total Total after discounts and taxes.
  • 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.
  • 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.
  • threshold_reason
  • discount Describes the current discount applied to this invoice, if there is one. Not populated if there are multiple discounts.
  • 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.
  • 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.
  • charge ID of the latest charge generated for this invoice, if any.
  • account_name The public name of the business associated with this invoice, most often the business creating the invoice.
  • customer The ID of the customer who will be billed.
  • amount_paid The amount, in %s, that was paid.
  • account_tax_ids The account tax IDs associated with the invoice. Only editable when the invoice is a draft.
  • 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.
  • statement_descriptor Extra information about an invoice for the customer's credit card statement.
  • payment_settings
  • application ID of the Connect Application that created the invoice.
  • due_date The date on which payment for this invoice is due. This value will be null for invoices where collection_method=charge_automatically.
  • rendering_options Options for invoice PDF rendering.
  • 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.
  • receipt_number This is the transaction number that appears on email receipts sent for this invoice.
  • billing_reason Indicates the reason why the invoice was created. subscription_cycle indicates an invoice created by a subscription advancing into a new period. subscription_create indicates an invoice created due to creating a subscription. subscription_update indicates an invoice created due to updating a subscription. subscription is set for all old invoices to indicate either a change to a subscription or a period advancement. manual is set for all invoices unrelated to a subscription (for example: created via the invoice editor). The upcoming value is reserved for simulated invoices per the upcoming invoice endpoint. subscription_threshold indicates an invoice created due to a billing threshold being reached.
  • object String representing the object's type. Objects of the same type share the same value.
  • latest_revision The ID of the most recent non-draft revision of this invoice
  • status_transitions
  • post_payment_credit_notes_amount Total amount of all post-payment credit notes issued for this invoice.
  • test_clock ID of the test clock this invoice belongs to.
  • automatic_tax
  • total_excluding_tax The integer amount in %s representing the total amount of the invoice including all discounts but excluding all tax.
  • subtotal_excluding_tax The integer amount in %s representing the subtotal of the invoice before any invoice level discount or tax is applied. Item discounts are already incorporated
  • currency Three-letter ISO currency code, in lowercase. Must be a supported currency.
  • total_discount_amounts The aggregate amounts calculated per discount across all line items.
  • created Time at which the object was created. Measured in seconds since the Unix epoch.
  • discounts The discounts applied to the invoice. Line item discounts are applied before invoice discounts. Use expand[]=discounts to expand each discount.
  • quote The quote this invoice was generated from.
  • amount_remaining The difference between amount_due and amount_paid, in %s.
  • period_end End of the usage period during which invoice items were added to this invoice.
  • next_payment_attempt The time at which payment will next be attempted. This value will be null for invoices where collection_method=send_invoice.
  • subscription The subscription that this invoice was prepared for, if any.
  • 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.
  • total_tax_amounts The aggregate amounts calculated per tax rate for all line items.
  • from_invoice Details of the invoice that was cloned. See the revision documentation for more details.
  • status The status of the invoice, one of draft, open, paid, uncollectible, or void. Learn more
  • 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.
  • 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.
  • 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.
  • application_fee_amount The fee in %s that will be applied to the invoice and transferred to the application owner's Stripe account when the invoice is paid.
  • tax The amount of tax on this invoice. This is the sum of all the tax amounts on this invoice.
  • period_start Start of the usage period during which invoice items were added to this invoice.
  • 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.
  • 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.
  • 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.
  • default_tax_rates The tax rates applied to this invoice, if any.
  • lines 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.
@type tax() :: %{optional(:ip_address) => binary() | binary()}

Tax details about the customer.

@type tax_ids() :: %{
  optional(:type) =>
    :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
    | :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
    | :ph_tin
    | :ru_inn
    | :ru_kpp
    | :sa_vat
    | :sg_gst
    | :sg_uen
    | :si_tin
    | :th_vat
    | :tr_tin
    | :tw_vat
    | :ua_vat
    | :us_ein
    | :za_vat,
  optional(:value) => binary()
}
@type transfer_data() :: %{
  optional(:amount) => integer(),
  optional(:destination) => binary()
}

If specified, the funds from the invoice will be transferred to the destination and the ID of the resulting transfer will be found on the invoice's charge.

@type us_bank_account() :: %{
  optional(:financial_connections) => financial_connections(),
  optional(:verification_method) => :automatic | :instant | :microdeposits
}

Link to this section Functions

Link to this function

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

View Source
@spec create(
  client :: Stripe.t(),
  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(: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_options) => rendering_options() | binary(),
    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(client, invoice, opts \\ [])

View Source
@spec delete(client :: Stripe.t(), 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(client, invoice, params \\ %{}, opts \\ [])

View Source
@spec finalize_invoice(
  client :: Stripe.t(),
  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(client, params \\ %{}, opts \\ [])

View Source
@spec list(
  client :: Stripe.t(),
  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(client, invoice, params \\ %{}, opts \\ [])

View Source
@spec mark_uncollectible(
  client :: Stripe.t(),
  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(client, invoice, params \\ %{}, opts \\ [])

View Source
@spec pay(
  client :: Stripe.t(),
  invoice :: binary(),
  params :: %{
    optional(:expand) => [binary()],
    optional(:forgive) => boolean(),
    optional(:mandate) => 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(client, invoice, params \\ %{}, opts \\ [])

View Source
@spec retrieve(
  client :: Stripe.t(),
  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(client, params \\ %{}, opts \\ [])

View Source
@spec search(
  client :: Stripe.t(),
  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(client, invoice, params \\ %{}, opts \\ [])

View Source
@spec send_invoice(
  client :: Stripe.t(),
  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(client, params \\ %{}, opts \\ [])

View Source
@spec upcoming(
  client :: Stripe.t(),
  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_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(client, params \\ %{}, opts \\ [])

View Source
@spec upcoming_lines(
  client :: Stripe.t(),
  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_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(client, invoice, params \\ %{}, opts \\ [])

View Source
@spec update(
  client :: Stripe.t(),
  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(),
    optional(:default_tax_rates) => [binary()] | binary(),
    optional(:description) => binary(),
    optional(:discounts) => [discounts()] | binary(),
    optional(:due_date) => integer(),
    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_options) => rendering_options() | 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(client, invoice, params \\ %{}, opts \\ [])

View Source
@spec void_invoice(
  client :: Stripe.t(),
  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