invoice

package
v78.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 17, 2024 License: MIT Imports: 3 Imported by: 2

Documentation

Overview

Package invoice provides the /invoices APIs

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreatePreview added in v78.3.0

func CreatePreview(params *stripe.InvoiceCreatePreviewParams) (*stripe.Invoice, error)

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 the subscription_details.proration_date parameter when doing the actual subscription update. 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_details.proration_date value passed in the request.

Note: Currency conversion calculations use the latest exchange rates. Exchange rates may vary between the time of the preview and the time of the actual invoice creation. [Learn more](https://docs.stripe.com/currencies/conversions)

func Del

func Del(id string, params *stripe.InvoiceParams) (*stripe.Invoice, error)

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](https://stripe.com/docs/api#void_invoice).

func FinalizeInvoice

func FinalizeInvoice(id string, params *stripe.InvoiceFinalizeInvoiceParams) (*stripe.Invoice, error)

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.

func Get

func Get(id string, params *stripe.InvoiceParams) (*stripe.Invoice, error)

Retrieves the invoice with the given ID.

func MarkUncollectible

func MarkUncollectible(id string, params *stripe.InvoiceMarkUncollectibleParams) (*stripe.Invoice, error)

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

func New

func New(params *stripe.InvoiceParams) (*stripe.Invoice, error)

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](#pay_invoice) or <a href="#send_invoice">send](https://stripe.com/docs/api#finalize_invoice) the invoice to your customers.

func Pay

func Pay(id string, params *stripe.InvoicePayParams) (*stripe.Invoice, error)

Stripe automatically creates and then attempts to collect payment on invoices for customers on subscriptions according to your [subscriptions settings](https://dashboard.stripe.com/account/billing/automatic). 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.

func SendInvoice

func SendInvoice(id string, params *stripe.InvoiceSendInvoiceParams) (*stripe.Invoice, error)

Stripe will automatically send invoices to customers according to your [subscriptions settings](https://dashboard.stripe.com/account/billing/automatic). 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.

func Upcoming

func Upcoming(params *stripe.InvoiceUpcomingParams) (*stripe.Invoice, error)

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 the subscription_details.proration_date parameter when doing the actual subscription update. 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_details.proration_date value passed in the request.

Note: Currency conversion calculations use the latest exchange rates. Exchange rates may vary between the time of the preview and the time of the actual invoice creation. [Learn more](https://docs.stripe.com/currencies/conversions)

func Update

func Update(id string, params *stripe.InvoiceParams) (*stripe.Invoice, error)

Draft invoices are fully editable. Once an invoice is [finalized](https://stripe.com/docs/billing/invoices/workflow#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](https://stripe.com/docs/billing/invoices/reconciliation) invoices, pass auto_advance=false.

func VoidInvoice

func VoidInvoice(id string, params *stripe.InvoiceVoidInvoiceParams) (*stripe.Invoice, error)

Mark a finalized invoice as void. This cannot be undone. Voiding an invoice is similar to [deletion](https://stripe.com/docs/api#delete_invoice), however it only applies to finalized invoices and maintains a papertrail where the invoice can still be found.

Consult with local regulations to determine whether and how an invoice might be amended, canceled, or voided in the jurisdiction you're doing business in. You might need to [issue another invoice or <a href="#create_credit_note">credit note](https://stripe.com/docs/api#create_invoice) instead. Stripe recommends that you consult with your legal counsel for advice specific to your business.

Types

type Client

type Client struct {
	B   stripe.Backend
	Key string
}

Client is used to invoke /invoices APIs.

func (Client) CreatePreview added in v78.3.0

func (c Client) CreatePreview(params *stripe.InvoiceCreatePreviewParams) (*stripe.Invoice, error)

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 the subscription_details.proration_date parameter when doing the actual subscription update. 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_details.proration_date value passed in the request.

Note: Currency conversion calculations use the latest exchange rates. Exchange rates may vary between the time of the preview and the time of the actual invoice creation. [Learn more](https://docs.stripe.com/currencies/conversions)

func (Client) Del

func (c Client) Del(id string, params *stripe.InvoiceParams) (*stripe.Invoice, error)

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](https://stripe.com/docs/api#void_invoice).

func (Client) FinalizeInvoice

func (c Client) FinalizeInvoice(id string, params *stripe.InvoiceFinalizeInvoiceParams) (*stripe.Invoice, error)

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.

func (Client) Get

func (c Client) Get(id string, params *stripe.InvoiceParams) (*stripe.Invoice, error)

Retrieves the invoice with the given ID.

func (Client) List

func (c Client) List(listParams *stripe.InvoiceListParams) *Iter

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.

func (Client) ListLines

func (c Client) ListLines(listParams *stripe.InvoiceListLinesParams) *LineItemIter

When retrieving an invoice, you'll get a lines property containing the total count of line items and the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items.

func (Client) MarkUncollectible

func (c Client) MarkUncollectible(id string, params *stripe.InvoiceMarkUncollectibleParams) (*stripe.Invoice, error)

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

func (Client) New

func (c Client) New(params *stripe.InvoiceParams) (*stripe.Invoice, error)

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](#pay_invoice) or <a href="#send_invoice">send](https://stripe.com/docs/api#finalize_invoice) the invoice to your customers.

func (Client) Pay

func (c Client) Pay(id string, params *stripe.InvoicePayParams) (*stripe.Invoice, error)

Stripe automatically creates and then attempts to collect payment on invoices for customers on subscriptions according to your [subscriptions settings](https://dashboard.stripe.com/account/billing/automatic). 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.

func (Client) Search

func (c Client) Search(params *stripe.InvoiceSearchParams) *SearchIter

Search for invoices you've previously created using Stripe's [Search Query Language](https://stripe.com/docs/search#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.

func (Client) SendInvoice

func (c Client) SendInvoice(id string, params *stripe.InvoiceSendInvoiceParams) (*stripe.Invoice, error)

Stripe will automatically send invoices to customers according to your [subscriptions settings](https://dashboard.stripe.com/account/billing/automatic). 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.

func (Client) Upcoming

func (c Client) Upcoming(params *stripe.InvoiceUpcomingParams) (*stripe.Invoice, error)

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 the subscription_details.proration_date parameter when doing the actual subscription update. 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_details.proration_date value passed in the request.

Note: Currency conversion calculations use the latest exchange rates. Exchange rates may vary between the time of the preview and the time of the actual invoice creation. [Learn more](https://docs.stripe.com/currencies/conversions)

func (Client) UpcomingLines

func (c Client) UpcomingLines(listParams *stripe.InvoiceUpcomingLinesParams) *LineItemIter

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.

func (Client) Update

func (c Client) Update(id string, params *stripe.InvoiceParams) (*stripe.Invoice, error)

Draft invoices are fully editable. Once an invoice is [finalized](https://stripe.com/docs/billing/invoices/workflow#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](https://stripe.com/docs/billing/invoices/reconciliation) invoices, pass auto_advance=false.

func (Client) VoidInvoice

func (c Client) VoidInvoice(id string, params *stripe.InvoiceVoidInvoiceParams) (*stripe.Invoice, error)

Mark a finalized invoice as void. This cannot be undone. Voiding an invoice is similar to [deletion](https://stripe.com/docs/api#delete_invoice), however it only applies to finalized invoices and maintains a papertrail where the invoice can still be found.

Consult with local regulations to determine whether and how an invoice might be amended, canceled, or voided in the jurisdiction you're doing business in. You might need to [issue another invoice or <a href="#create_credit_note">credit note](https://stripe.com/docs/api#create_invoice) instead. Stripe recommends that you consult with your legal counsel for advice specific to your business.

type Iter

type Iter struct {
	*stripe.Iter
}

Iter is an iterator for invoices.

func List

func List(params *stripe.InvoiceListParams) *Iter

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.

func (*Iter) Invoice

func (i *Iter) Invoice() *stripe.Invoice

Invoice returns the invoice which the iterator is currently pointing to.

func (*Iter) InvoiceList

func (i *Iter) InvoiceList() *stripe.InvoiceList

InvoiceList returns the current list object which the iterator is currently using. List objects will change as new API calls are made to continue pagination.

type LineItemIter

type LineItemIter struct {
	*stripe.Iter
}

LineItemIter is an iterator for invoice line items.

func ListLines

func ListLines(params *stripe.InvoiceListLinesParams) *LineItemIter

When retrieving an invoice, you'll get a lines property containing the total count of line items and the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items.

func UpcomingLines

func UpcomingLines(params *stripe.InvoiceUpcomingLinesParams) *LineItemIter

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.

func (*LineItemIter) InvoiceLineItem

func (i *LineItemIter) InvoiceLineItem() *stripe.InvoiceLineItem

InvoiceLineItem returns the invoice line item which the iterator is currently pointing to.

func (*LineItemIter) InvoiceLineItemList

func (i *LineItemIter) InvoiceLineItemList() *stripe.InvoiceLineItemList

InvoiceLineItemList returns the current list object which the iterator is currently using. List objects will change as new API calls are made to continue pagination.

type SearchIter

type SearchIter struct {
	*stripe.SearchIter
}

SearchIter is an iterator for invoices.

func Search(params *stripe.InvoiceSearchParams) *SearchIter

Search for invoices you've previously created using Stripe's [Search Query Language](https://stripe.com/docs/search#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.

func (*SearchIter) Invoice

func (i *SearchIter) Invoice() *stripe.Invoice

Invoice returns the invoice which the iterator is currently pointing to.

func (*SearchIter) InvoiceSearchResult

func (i *SearchIter) InvoiceSearchResult() *stripe.InvoiceSearchResult

InvoiceSearchResult returns the current list object which the iterator is currently using. List objects will change as new API calls are made to continue pagination.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL