NAME

Net::API::Stripe::Billing::Invoice - A Stripe Invoice

SYNOPSIS

my $stripe = Net::API::Stripe->new( conf_file => './settings.json', expand => 'all' ) || die( Net::API::Stripe->error );
my $inv = $stripe->invoices( create => 
{
account_country => 'jp',
account_name => 'John Doe',
amount_due => 2000,
amount_paid => 500,
amount_remaining => 1500
billing => 'charge_automatically',
charge => 'ch_fake123456789',
currency => 'jpy',
customer => $customer_object,
customer_address => $stripe->address({
    line1 => '1-2-3 Sugamo, Bukyo-ku',
    line2 => 'Taro Bldg'.
    city => 'Tokyo',
    postal_code => '123-4567',
    country => 'jp',
    }),
customer_email => 'john.doe@example.com',
customer_name => 'John Doe',
description => 'Invoice for professional services',
due_date => '2020-04-01',
}) || die( $stripe->error );

VERSION

v0.101.1

DESCRIPTION

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 (Net::API::Stripe::Billing::Invoice::Item / https://stripe.com/docs/api/invoices#invoiceitems), 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 (https://stripe.com/docs/billing/invoices/workflow/#auto_advance), 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 Stripe adds the amount due to the customer's running account balance which is applied to the next invoice.

More details on the customer's account balance are here.

CONSTRUCTOR

new

Provided with an hash of key-value properties and this creates a new Net::API::Stripe::Billing::Invoice object.

METHODS

id string

Unique identifier for the object.

object string, value is "invoice"

String representing the object’s type. Objects of the same type share the same value.

account_country string

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

account_name string

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

account_tax_ids array containing strings expandable

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

When expanded, this contains an array of Net::API::Stripe::Billing::TaxID objects.

amount_due integer

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 integer

The amount, in JPY, that was paid.

amount_remaining integer

The amount remaining, in JPY, that is due.

application

Expandable.

Set or gets an Net::API::Stripe::Connect::Account object or id.

ID of the Connect Application that created the invoice.

application_fee_amount integer

The fee in JPY that will be applied to the invoice and transferred to the application owner’s Stripe account when the invoice is paid.

attempt_count positive integer or zero

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 boolean

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

automatic_tax hash

Settings and latest results for automatic tax lookup for this invoice.

  • enabled boolean

    Whether Stripe automatically computes tax on this invoice. Note that incompatible invoice items (invoice items with manually specified tax rates, negative amounts, or tax_behavior=unspecified) cannot be added to automatic tax invoices.

  • status enum

    The status of the most recent automated tax calculation for this invoice.

    Possible enum values

    • requires_location_inputs

      The location details supplied on the customer aren’t valid or don’t provide enough location information to accurately determine tax rates for the customer.

    • complete

      Stripe successfully calculated tax automatically on this invoice.

    • failed

      The Stripe Tax service failed, please try again later.

billing string

This is an undocumented property, but that appears in Stripe's own API object example. It contains charge_automatically

billing_reason string

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.

charge string (expandable)

ID of the latest charge generated for this invoice, if any. When expanded, this is a Net::API::Stripe::Charge object.

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.

created timestamp

Time at which the object was created. Measured in seconds since the Unix epoch.

currency currency

Three-letter ISO currency code, in lowercase. Must be a supported currency.

custom_fields array of hashes

Custom fields displayed on the invoice. This is an array of Net::API::Stripe::CustomField objects.

  • <name>

    The name of the custom field.

  • <value>

    The value of the custom field.

customer string (expandable)

This is a Stripe Customer id, or when expanded, this is a Net::API::Stripe::Customer object.

customer_address hash

The customer’s address. Until the invoice is finalized, this field will equal customer.address. Once the invoice is finalised, this field will no longer be updated.

This is a Net::API::Stripe::Address object.

customer_email string

The customer’s email. Until the invoice is finalized, this field will equal customer.email. Once the invoice is finalised, this field will no longer be updated.

customer_name string

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 string

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 hash

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.

This is a Net::API::Stripe::Shipping object.

customer_tax_exempt string

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 array of hashes

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.

This is a Net::API::Stripe::Customer::TaxIds object.

default_payment_method string (expandable)

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.

When expanded, this is a Net::API::Stripe::Payment::Method object.

default_source string (expandable)

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.

When expanded, this is a Net::API::Stripe::Payment::Source object.

default_tax_rates array of hashes

The tax rates applied to this invoice, if any.

This is an array of Net::API::Stripe::Tax::Rate object.

description string

An arbitrary string attached to the object. Often useful for displaying to users. Referenced as ‘memo’ in the Dashboard.

discount hash, discount object

This is a Net::API::Stripe::Billing::Discount object

discounts expandable

The discounts applied to the invoice. Line item discounts are applied before invoice discounts. Use `expand[]=discounts` to expand each discount.

When expanded this is an Net::API::Stripe::Billing::Discount object.

due_date timestamp

The date on which payment for this invoice is due. This value will be null for invoices where collection_method=charge_automatically.

ending_balance integer

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 displayed on the invoice.

forgiven boolean

Boolean value defining if the invoice was paid.

Not part of the Stripe documentation anymore but present in data returned.

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.

invoice_pdf string

The link to download the PDF for the invoice. If the invoice has not been finalized yet, this will be null.

last_finalization_error hash

The error encountered during the previous attempt to finalize the invoice. This field is cleared when the invoice is successfully finalized.

It has the following properties:

code string

For some errors that could be handled programmatically, a short string indicating the [error code](/docs/error-codes) reported.

doc_url string

A URL to more information about the [error code](/docs/error-codes) reported.

message string

A human-readable message providing more details about the error. For card errors, these messages can be shown to your users.

param string

If the error is parameter-specific, the parameter related to the error. For example, you can use this to display a message near the correct form field.

payment_method_type string

If the error is specific to the type of payment method, the payment method type that had a problem. This field is only populated for invoice-related errors.

type string

The type of error returned. One of api_connection_error, api_error, authentication_error, card_error, idempotency_error, invalid_request_error, or rate_limit_error

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.

This is a Net::API::Stripe::Billing::Invoice::Lines object.

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.

next_payment_attempt timestamp

The time at which payment will next be attempted. This value will be null for invoices where collection_method=send_invoice.

number string

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.

on_behalf_of

Expandable

Sets or gets an Net::API::Stripe::Connect::Account object or id.

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.

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

When expanded, this is a Net::API::Stripe::Payment::Intent object.

payment_settings hash

Sets or gets a Net::API::Stripe::Payment::Settings object.

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.

post_payment_credit_notes_amount integer

Total amount of all post-payment credit notes issued for this invoice.

pre_payment_credit_notes_amount integer

Total amount of all pre-payment credit notes issued for this invoice.

quote

Expandable.

Sets or gets a Net::API::Stripe::Billing::Quote object or id.

receipt_number string

This is the transaction number that appears on email receipts sent for this invoice.

rendering_options hash

Options for invoice PDF rendering.

  • amount_tax_display string

    How line-item prices and amounts will be displayed with respect to tax on invoice PDFs.

starting_balance integer

Starting customer balance before the invoice is finalized. If the invoice has not been finalized yet, this will be the current customer balance.

statement_descriptor string

Extra information about an invoice for the customer’s credit card statement.

status string

The status of the invoice, one of draft, open, paid, uncollectible, or void. Learn more

status_transitions hash

This is a Net::API::Stripe::Billing::Invoice::StatusTransition object.

subscription string (expandable)

The subscription that this invoice was prepared for, if any. When expanded, this is a Net::API::Stripe::Billing::Subscription object.

subscription_proration_date integer

Only set for upcoming invoices that preview prorations. The time used to calculate prorations.

subtotal integer

Total of all subscriptions, invoice items, and prorations on the invoice before any discount or tax is applied.

subtotal_excluding_tax integer

The integer amount in JPY representing the subtotal of the invoice before any invoice level discount or tax is applied. Item discounts are already incorporated

tax integer

The amount of tax on this invoice. This is the sum of all the tax amounts on this invoice.

test_clock string

Expandable

Sets or gets the Net::API::Stripe::Billing::TestClock object or ID of the test clock this invoice belongs to.

threshold_reason hash

If billing_reason is set to subscription_threshold this returns more information on which threshold rules triggered the invoice.

  • amount_gte integer

    The total invoice amount threshold boundary if it triggered the threshold invoice.

  • item_reasons array of hashes

    Indicates which line items triggered a threshold invoice.

    • line_item_ids array containing strings

      The IDs of the line items that triggered the threshold invoice.

    • usage_gte integer

      The quantity threshold boundary that applied to the given line item.

total integer

Total after discounts and taxes.

total_discount_amounts array of hashes

The aggregate amounts calculated per discount across all line items.

  • amount integer

    The amount, in JPY, of the discount.

  • discount string

    Expandable

    The discount that was applied to get this discount amount.

total_excluding_tax integer

The integer amount in JPY representing the total amount of the invoice including all discounts but excluding all tax.

Properties are:

amount integer

The amount, in JPY, of the discount.

discount string expandable

The discount that was applied to get this discount amount.

total_tax_amounts array of hashes

The aggregate amounts calculated per tax rate for all line items.

This is an array of Net::API::Stripe::Billing::Invoice::TaxAmount objects.

transfer_data hash

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.

It has the following properties:

amount integer

The amount in JPY that will be transferred to the destination account when the invoice is paid. By default, the entire amount is transferred to the destination.

destination string

The account where funds from the payment will be transferred to upon payment success.

webhooks_delivered_at timestamp

The time at which webhooks for this invoice were successfully delivered (if the invoice had no webhooks to deliver, this will match created). Invoice payment is delayed until webhooks are delivered, or until all webhook delivery attempts have been exhausted.

API SAMPLE

{ "id": "in_fake1234567890", "object": "invoice", "account_country": "JP", "account_name": "Angels, Inc", "account_tax_ids": null, "amount_due": 5300, "amount_paid": 0, "amount_remaining": 5300, "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": 1657660441, "currency": "jpy", "custom_fields": null, "customer": "cus_fake123456789990", "customer_address": null, "customer_email": null, "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_fake1234567890", "object": "line_item", "amount": 5300, "amount_excluding_tax": 5300, "currency": "jpy", "description": "My First Invoice Item (created for API docs)", "discount_amounts": [], "discountable": true, "discounts": [], "invoice_item": "ii_fake1234567890", "livemode": false, "metadata": {}, "period": { "end": 1657660440, "start": 1657660440 }, "price": { "id": "price_fake1234567890", "object": "price", "active": true, "billing_scheme": "per_unit", "created": 1649731261, "currency": "jpy", "custom_unit_amount": null, "livemode": false, "lookup_key": null, "metadata": {}, "nickname": null, "product": "prod_fake1234567890", "recurring": null, "tax_behavior": "unspecified", "tiers_mode": null, "transform_quantity": null, "type": "one_time", "unit_amount": 5300, "unit_amount_decimal": "5300" }, "proration": false, "proration_details": { "credited_items": null }, "quantity": 1, "subscription": null, "tax_amounts": [], "tax_rates": [], "type": "invoiceitem", "unit_amount_excluding_tax": "5300" } ], "has_more": false, "url": "/v1/invoices/in_fake1234567890/lines" }, "livemode": false, "metadata": {}, "next_payment_attempt": 1657664041, "number": null, "on_behalf_of": null, "paid": false, "paid_out_of_band": false, "payment_intent": null, "payment_settings": { "payment_method_options": null, "payment_method_types": null }, "period_end": 1657660440, "period_start": 1657660440, "post_payment_credit_notes_amount": 0, "pre_payment_credit_notes_amount": 0, "quote": null, "receipt_number": 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": 5300, "subtotal_excluding_tax": 5300, "tax": null, "test_clock": null, "total": 5300, "total_discount_amounts": [], "total_excluding_tax": 5300, "total_tax_amounts": [], "transfer_data": null, "webhooks_delivered_at": null }

HISTORY

v0.1

Initial version

STRIPE HISTORY

2019-12-03

Customer balances applied to all invoices are now debited or credited back to the customer when voided. Earlier, applied customer balances were not returned back to the customer and were consumed.

  • To achieve this behavior in earlier API versions:

    • Set consume_applied_balance to false when voiding invoices in /v1/invoices/:id/void.

    • Set invoice_customer_balance_settings[consume_applied_balance_on_void] to false in /v1/subscriptions create or update to force this behavior for Invoices voided by a Subscription.

    • Set subscription_data[invoice_customer_balance_settings][consume_applied_balance_on_void] to false in /v1/checkout/sessions create to force this behavior for Invoices voided by Subscriptions created with Checkout.

2019-03-14

There are a few changes to the invoice object:

  • A status_transitions hash now contains the timestamps when an invoice was finalized, paid, marked uncollectible, or voided.

  • The date property has been renamed to created.

  • The finalized_at property has been moved into the status_transitions hash.

2018-11-08

The closed property on the invoice object controls automatic collection. closed has been deprecated in favor of the more specific auto_advance field. Where you might have set closed=true on invoices in the past, set auto_advance=false.

2018-11-08

Instead of checking the forgiven field on an invoice, check for the uncollectible status.

Instead of setting the forgiven field on an invoice, mark it as uncollectible.

2022-08-27

Stripe has removed "tax_percent" from objects and requests in favor of tax rates.

2022-07-12

The following methods were added by Stripe:

AUTHOR

Jacques Deguest <jack@deguest.jp>

SEE ALSO

Stripe API documentation:

https://stripe.com/docs/api/invoices, https://stripe.com/docs/billing/invoices/sending

COPYRIGHT & LICENSE

Copyright (c) 2019-2020 DEGUEST Pte. Ltd.

You can use, copy, modify and redistribute this package and associated files under the same terms as Perl itself.