Skip to content
This repository was archived by the owner on Mar 15, 2018. It is now read-only.

Invoice Items

bradrydzewski edited this page Jun 5, 2012 · 4 revisions

Sometimes you want to add a charge or credit to a customer but only actually charge the customer's card at the end of a regular billing cycle. This is useful for combining several charges to minimize per-transaction fees or having Stripe tabulate your usage-based billing totals.

The invoice item object

Godoc:
http://go.pkgdoc.org/github.com/bradrydzewski/go.stripe#InvoiceItem

Official Stripe Documentation:
https://stripe.com/docs/api#invoiceitem_object

Create a new invoice item

Adds an arbitrary charge or credit to the customer's upcoming invoice.

stripe.SetKey("vtUQeOtUnYr7PGCLQ96Ul4zqpDUO4sOE")

params := stripe.InvoiceItemParams {
	Customer : "cus_Lt6VFhU30fptWh",
	Amount   : 2000,
	Currency : "usd",
	Desc     : "One-time setup fee",
}

item, err := stripe.InvoiceItems.Create(&params)

Input Parameters:
http://go.pkgdoc.org/github.com/bradrydzewski/go.stripe#InvoiceItemParams

Official Stripe Documentation:
https://stripe.com/docs/api#create_invoiceitem

Retrieve an existing invoice item

Retrieves the invoice item with the given ID.

stripe.SetKey("vtUQeOtUnYr7PGCLQ96Ul4zqpDUO4sOE")

item, err := stripe.InvoiceItems.Retrieve("ii_LL5ruCWcwjqQIQ")

Official Stripe Documentation:
https://stripe.com/docs/api#retrieve_invoiceitem

Update an invoice item

Updates the amount or description of an invoice item on an upcoming invoice. Updating an invoice item is only possible before the invoice it's attached to is closed.

stripe.SetKey("vtUQeOtUnYr7PGCLQ96Ul4zqpDUO4sOE")

params := stripe.InvoiceItemParams {
	Amount   : 1500,
	Desc     : "Customer for [email protected]"
}

item, err := stripe.InvoiceItems.Update("ii_LL5ruCWcwjqQIQ", &params)

Official Stripe Documentation:
https://stripe.com/docs/api#update_invoiceitem

Delete an invoice item

Removes an invoice item from the upcoming invoice. Removing an invoice item is only possible before the invoice it's attached to is closed.

stripe.SetKey("vtUQeOtUnYr7PGCLQ96Ul4zqpDUO4sOE")

_, err := stripe.InvoiceItems.Delete("ii_LL5ruCWcwjqQIQ")

Official Stripe Documentation:
https://stripe.com/docs/api#delete_invoiceitem

List all invoice items

Returns a list of your invoice items. Invoice Items are returned sorted by creation date, with the most recently created invoice items appearing first.

stripe.SetKey("vtUQeOtUnYr7PGCLQ96Ul4zqpDUO4sOE")

items, err := stripe.InvoiceItems.List()

Returns Invoice Items for the specified range:

// get a list of 10 invoice items, starting at position 40 in the list of invoice items
items, err := stripe.InvoiceItems.ListN(10, 40)

Returns Invoice Items for the specified customer:

items, err := stripe.InvoiceItems.CustomerList("cus_Lt6VFhU30fptWh")

Returns Invoice Items for the specified customer and range:

items, err := stripe.InvoiceItems.CustomerList("cus_Lt6VFhU30fptWh", 10, 40)

Official Stripe Documentation:
https://stripe.com/docs/api#list_invoiceitems

Clone this wiki locally