The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

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

SYNOPSIS

VERSION

    0.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 (https://stripe.com/docs/currencies#minimum-and-maximum-charge-amounts), the invoice is automatically marked paid, and we add 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 (https://stripe.com/docs/api/customers/object#customer_object-account_balance).

CONSTRUCTOR

new( %ARG )

Creates a new Net::API::Stripe objects. It may also take an hash like arguments, that also are method of the same name.

verbose

Toggles verbose mode on/off

debug

Toggles debug mode on/off

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.

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

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.

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

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

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.

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.

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.

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.

receipt_number string

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

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.

tax integer

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

threshold_reason hash

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

total integer

Total after discounts and taxes.

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.

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_1B9q03CeyNCl6fY2YNPu6oqa",
          "object": "invoice",
          "account_country": "JP",
          "account_name": "Angels, Inc",
          "amount_due": 8000,
          "amount_paid": 8000,
          "amount_remaining": 0,
          "application_fee_amount": null,
          "attempt_count": 1,
          "attempted": true,
          "auto_advance": false,
          "billing": "charge_automatically",
          "billing_reason": "subscription",
          "charge": "ch_1B9q03CeyNCl6fY2wu5siR6R",
          "collection_method": "charge_automatically",
          "created": 1507273919,
          "currency": "jpy",
          "custom_fields": null,
          "customer": "cus_G0vQn57xCoD5rG",
          "customer_address": null,
          "customer_email": "florian@111studio.jp",
          "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,
          "due_date": null,
          "ending_balance": 0,
          "footer": null,
          "hosted_invoice_url": "https://pay.stripe.com/invoice/invst_XvyJuu53kQe203lIDyXEYxa7Lh",
          "invoice_pdf": "https://pay.stripe.com/invoice/invst_XvyJuu53kQe203lIDyXEYxa7Lh/pdf",
          "lines": {
                "data": [
                  {
                        "id": "sli_be2a0c3589f761",
                        "object": "line_item",
                        "amount": 8000,
                        "currency": "jpy",
                        "description": "1 × Angels, Inc professional monthly membership (at ¥8,000 / month)",
                        "discountable": true,
                        "livemode": false,
                        "metadata": {},
                        "period": {
                          "end": 1559441759,
                          "start": 1556763359
                        },
                        "plan": {
                          "id": "professional-monthly-jpy",
                          "object": "plan",
                          "active": true,
                          "aggregate_usage": null,
                          "amount": 8000,
                          "amount_decimal": "8000",
                          "billing_scheme": "per_unit",
                          "created": 1541833564,
                          "currency": "jpy",
                          "interval": "month",
                          "interval_count": 1,
                          "livemode": false,
                          "metadata": {},
                          "nickname": null,
                          "product": "prod_Dwk1QNPjrMJlY8",
                          "tiers": null,
                          "tiers_mode": null,
                          "transform_usage": null,
                          "trial_period_days": null,
                          "usage_type": "licensed"
                        },
                        "proration": false,
                        "quantity": 1,
                        "subscription": "sub_EccdFNq60pUMDL",
                        "subscription_item": "si_Eccd4op26fXydB",
                        "tax_amounts": [],
                        "tax_rates": [],
                        "type": "subscription"
                  }
                ],
                "has_more": false,
                "object": "list",
                "url": "/v1/invoices/in_1B9q03CeyNCl6fY2YNPu6oqa/lines"
          },
          "livemode": false,
          "metadata": {},
          "next_payment_attempt": null,
          "number": "53DB91F-0001",
          "paid": true,
          "payment_intent": null,
          "period_end": 1507273919,
          "period_start": 1507273919,
          "post_payment_credit_notes_amount": 0,
          "pre_payment_credit_notes_amount": 0,
          "receipt_number": "2066-1929",
          "starting_balance": 0,
          "statement_descriptor": null,
          "status": "paid",
          "status_transitions": {
                "finalized_at": 1507273919,
                "marked_uncollectible_at": null,
                "paid_at": 1507273919,
                "voided_at": null
          },
          "subscription": "sub_BWtnk6Km6GOapC",
          "subtotal": 8000,
          "tax": null,
          "tax_percent": null,
          "total": 8000,
          "total_tax_amounts": [],
          "webhooks_delivered_at": 1507273920
        }

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.

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) 2018-2019 DEGUEST Pte. Ltd.

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

1 POD Error

The following errors were encountered while parsing the POD:

Around line 209:

You forgot a '=back' before '=head1'