Retrieve an invoice's line items 

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.

Parameters

No parameters.

More parameters

  • ending_beforestring

  • limitinteger

  • starting_afterstring

Returns

Returns a list of line_item objects.

GET /v1/invoices/:id/lines
Stripe.apiKey = "sk_test_BQokikJ...2HlWgH4olfQ2sk_test_BQokikJOvBiI2HlWgH4olfQ2";
Invoice invoice = Invoice.retrieve("in_1NpHok2eZvKYlo2CyeiBref0");
InvoiceLineItemCollectionListParams params =
InvoiceLineItemCollectionListParams.builder().build();
InvoiceLineItemCollection invoiceLineItems = invoice.getLines().list(params);
Response
{
"object": "list",
"url": "/v1/invoices/in_1NpHiG2eZvKYlo2CZV0ZkEBT/lines",
"has_more": false,
"data": [
{
"id": "il_tmp_1NpHiK2eZvKYlo2C9NdV8VrI",
"object": "line_item",
"amount": 129999,
"currency": "usd",
"description": "My First Invoice Item (created for API docs)",
"discount_amounts": [],
"discountable": true,
"discounts": [],
"livemode": false,
"metadata": {},
"parent": {
"type": "invoice_item_details",
"invoice_item_details": {
"invoice_item": "ii_1NpHiK2eZvKYlo2C9NdV8VrI",
"proration": false,
"proration_details": {
"credited_items": null
},
"subscription": null
}
},
"period": {
"end": 1694467932,
"start": 1694467932
},
"pricing": {
"price_details": {
"price": "price_1NpEIa2eZvKYlo2CXcy5DRPA",
"product": "prod_OcTFTbV7qh48bd"
},
"type": "price_details",
"unit_amount_decimal": "129999"
},
"quantity": 1,
"taxes": []
}
]
}

Bulk add invoice line items 

Adds multiple line items to an invoice. This is only possible when an invoice is still a draft.

Parameters

  • linesarray of MapsRequired

    The line items to add.

  • invoice_metadataMap

    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. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to metadata.

Returns

The updated invoice with newly added line items is returned upon success. Otherwise, this call throws an error.

POST /v1/invoices/:id/add_lines
Stripe.apiKey = "sk_test_BQokikJ...2HlWgH4olfQ2sk_test_BQokikJOvBiI2HlWgH4olfQ2";
Invoice resource = Invoice.retrieve("in_1NuhUa2eZvKYlo2CWYVhyvD9");
InvoiceAddLinesParams params =
InvoiceAddLinesParams.builder()
.addLine(
InvoiceAddLinesParams.Line.builder()
.setDescription("test description")
.setAmount(799L)
.build()
)
.addLine(
InvoiceAddLinesParams.Line.builder()
.setInvoiceItem("ii_1NuLVd2eZvKYlo2CRWY0Hqgi")
.build()
)
.build();
Invoice invoice = resource.addLines(params);
Response
{
"id": "in_1NuhUa2eZvKYlo2CWYVhyvD9",
"object": "invoice",
"account_country": "US",
"account_name": "Stripe.com",
"account_tax_ids": null,
"amount_due": 998,
"amount_paid": 0,
"amount_overpaid": 0,
"amount_remaining": 998,
"amount_shipping": 0,
"application": null,
"attempt_count": 0,
"attempted": false,
"auto_advance": false,
"automatic_tax": {
"enabled": false,
"liability": null,
"status": null
},
"billing_reason": "manual",
"collection_method": "charge_automatically",
"created": 1695758664,
"currency": "usd",
"custom_fields": null,
"customer": "cus_9s6XKzkNRiz8i3",
"customer_address": null,
"customer_email": "test@test.com",
"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,
"discounts": [],
"due_date": null,
"effective_at": null,
"ending_balance": null,
"footer": null,
"from_invoice": null,
"hosted_invoice_url": null,
"invoice_pdf": null,
"issuer": {
"type": "self"
},
"last_finalization_error": null,
"latest_revision": null,
"lines": {
"object": "list",
"data": [
{
"id": "il_1NuhUa2eZvKYlo2CC98Fg3Bo",
"object": "line_item",
"amount": 799,
"currency": "usd",
"description": "test description",
"discount_amounts": [],
"discountable": true,
"discounts": [],
"livemode": false,
"metadata": {},
"parent": {
"type": "invoice_item_details",
"invoice_item_details": {
"invoice_item": "ii_1NuhUa2eZvKYlo2CGeF7Qgx0",
"proration": false,
"proration_details": {
"credited_items": null
},
"subscription": null
}
},
"period": {
"end": 1695758664,
"start": 1695758664
},
"pricing": {
"price_details": {
"price": "price_1NuhLA2eZvKYlo2Cq1tIGEBp",
"product": "prod_Oi7aO1GPi1dWX7"
},
"type": "price_details",
"unit_amount_decimal": "799"
},
"quantity": 1,
"taxes": []
},
{
"id": "il_1NuLVe2eZvKYlo2Canh35EfU",
"object": "line_item",
"amount": 199,
"currency": "usd",
"description": "Canned Coffee",
"discount_amounts": [],
"discountable": true,
"discounts": [],
"livemode": false,
"metadata": {},
"parent": {
"type": "invoice_item_details",
"invoice_item_details": {
"invoice_item": "ii_1NuLVd2eZvKYlo2CRWY0Hqgi",
"proration": false,
"proration_details": {
"credited_items": null
},
"subscription": null
}
},
"period": {
"end": 1695674161,
"start": 1695674161
},
"pricing": {
"price_details": {
"price": "price_1NuI212eZvKYlo2CWgdD8kET",
"product": "prod_OhhQNWDYdIbXYv"
},
"type": "price_details",
"unit_amount_decimal": "199"
},
"quantity": 1,
"taxes": []
}
],
"has_more": false,
"url": "/v1/invoices/upcoming/lines?customer=cus_9s6XKzkNRiz8i3"
},
"livemode": false,
"metadata": {},
"next_payment_attempt": null,
"number": null,
"on_behalf_of": null,
"parent": null,
"payment_settings": {
"default_mandate": null,
"payment_method_options": null,
"payment_method_types": null
},
"period_end": 1688482163,
"period_start": 1688395763,
"post_payment_credit_notes_amount": 0,
"pre_payment_credit_notes_amount": 0,
"receipt_number": null,
"redaction": null,
"rendering": null,
"shipping_cost": null,
"shipping_details": null,
"starting_balance": 0,
"statement_descriptor": null,
"status": "draft",
"status_transitions": {
"finalized_at": null,
"marked_uncollectible_at": null,
"paid_at": null,
"voided_at": null
},
"subtotal": 998,
"subtotal_excluding_tax": 998,
"test_clock": null,
"total": 998,
"total_discount_amounts": [],
"total_excluding_tax": 998,
"total_taxes": [],
"webhooks_delivered_at": null
}

Bulk remove invoice line items 

Removes multiple line items from an invoice. This is only possible when an invoice is still a draft.

Parameters

  • linesarray of MapsRequired

    The line items to remove.

  • invoice_metadataMap

    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. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to metadata.

Returns

The updated invoice without the removed line items is returned upon success. Otherwise, this call throws an error.

POST /v1/invoices/:id/remove_lines
Stripe.apiKey = "sk_test_BQokikJ...2HlWgH4olfQ2sk_test_BQokikJOvBiI2HlWgH4olfQ2";
Invoice resource = Invoice.retrieve("in_1NuhUa2eZvKYlo2CWYVhyvD9");
InvoiceRemoveLinesParams params =
InvoiceRemoveLinesParams.builder()
.addLine(
InvoiceRemoveLinesParams.Line.builder()
.setId("il_1NuhUa2eZvKYlo2CC98Fg3Bo")
.setBehavior(InvoiceRemoveLinesParams.Line.Behavior.DELETE)
.build()
)
.addLine(
InvoiceRemoveLinesParams.Line.builder()
.setId("il_1NuLVe2eZvKYlo2Canh35EfU")
.setBehavior(InvoiceRemoveLinesParams.Line.Behavior.UNASSIGN)
.build()
)
.build();
Invoice invoice = resource.removeLines(params);
Response
{
"id": "in_1NuhUa2eZvKYlo2CWYVhyvD9",
"object": "invoice",
"account_country": "US",
"account_name": "Stripe.com",
"account_tax_ids": null,
"amount_due": 998,
"amount_paid": 0,
"amount_overpaid": 0,
"amount_remaining": 998,
"amount_shipping": 0,
"application": null,
"attempt_count": 0,
"attempted": false,
"auto_advance": false,
"automatic_tax": {
"enabled": false,
"liability": null,
"status": null
},
"billing_reason": "manual",
"collection_method": "charge_automatically",
"created": 1695758664,
"currency": "usd",
"custom_fields": null,
"customer": "cus_9s6XKzkNRiz8i3",
"customer_address": null,
"customer_email": "test@test.com",
"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,
"discounts": [],
"due_date": null,
"effective_at": null,
"ending_balance": null,
"footer": null,
"from_invoice": null,
"hosted_invoice_url": null,
"invoice_pdf": null,
"issuer": {
"type": "self"
},
"last_finalization_error": null,
"latest_revision": null,
"lines": {
"object": "list",
"data": [
{
"id": "il_1NuhUa2eZvKYlo2CC98Fg3Bo",
"object": "line_item",
"amount": 799,
"currency": "usd",
"description": "test description",
"discount_amounts": [],
"discountable": true,
"discounts": [],
"livemode": false,
"metadata": {},
"parent": {
"type": "invoice_item_details",
"invoice_item_details": {
"invoice_item": "ii_1NuhUa2eZvKYlo2CGeF7Qgx0",
"proration": false,
"proration_details": {
"credited_items": null
},
"subscription": null
}
},
"period": {
"end": 1695758664,
"start": 1695758664
},
"pricing": {
"price_details": {
"price": "price_1NuhLA2eZvKYlo2Cq1tIGEBp",
"product": "prod_Oi7aO1GPi1dWX7"
},
"type": "price_details",
"unit_amount_decimal": "799"
},
"quantity": 1,
"taxes": []
},
{
"id": "il_1NuLVe2eZvKYlo2Canh35EfU",
"object": "line_item",
"amount": 199,
"currency": "usd",
"description": "Canned Coffee",
"discount_amounts": [],
"discountable": true,
"discounts": [],
"livemode": false,
"metadata": {},
"parent": {
"type": "invoice_item_details",
"invoice_item_details": {
"invoice_item": "ii_1NuLVd2eZvKYlo2CRWY0Hqgi",
"proration": false,
"proration_details": {
"credited_items": null
},
"subscription": null
}
},
"period": {
"end": 1695674161,
"start": 1695674161
},
"pricing": {
"price_details": {
"price": "price_1NuI212eZvKYlo2CWgdD8kET",
"product": "prod_OhhQNWDYdIbXYv"
},
"type": "price_details",
"unit_amount_decimal": "199"
},
"quantity": 1,
"taxes": []
}
],
"has_more": false,
"url": "/v1/invoices/upcoming/lines?customer=cus_9s6XKzkNRiz8i3"
},
"livemode": false,
"metadata": {},
"next_payment_attempt": null,
"number": null,
"on_behalf_of": null,
"parent": null,
"payment_settings": {
"default_mandate": null,
"payment_method_options": null,
"payment_method_types": null
},
"period_end": 1688482163,
"period_start": 1688395763,
"post_payment_credit_notes_amount": 0,
"pre_payment_credit_notes_amount": 0,
"receipt_number": null,
"redaction": null,
"rendering": null,
"shipping_cost": null,
"shipping_details": null,
"starting_balance": 0,
"statement_descriptor": null,
"status": "draft",
"status_transitions": {
"finalized_at": null,
"marked_uncollectible_at": null,
"paid_at": null,
"voided_at": null
},
"subtotal": 998,
"subtotal_excluding_tax": 998,
"test_clock": null,
"total": 998,
"total_discount_amounts": [],
"total_excluding_tax": 998,
"total_taxes": [],
"webhooks_delivered_at": null
}

Bulk update invoice line items 

Updates multiple line items on an invoice. This is only possible when an invoice is still a draft.

Parameters

  • linesarray of MapsRequired

    The line items to update.

  • invoice_metadataMap

    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. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to metadata. For type=subscription line items, the incoming metadata specified on the request is directly used to set this value, in contrast to type=invoiceitem line items, where any existing metadata on the invoice line is merged with the incoming data.

Returns

The updated invoice is returned upon success. Otherwise, this call throws an error.

POST /v1/invoices/:id/update_lines
Stripe.apiKey = "sk_test_BQokikJ...2HlWgH4olfQ2sk_test_BQokikJOvBiI2HlWgH4olfQ2";
Invoice resource = Invoice.retrieve("in_1NuhUa2eZvKYlo2CWYVhyvD9");
InvoiceUpdateLinesParams params =
InvoiceUpdateLinesParams.builder()
.addLine(
InvoiceUpdateLinesParams.Line.builder()
.setId("il_1NuhUa2eZvKYlo2CC98Fg3Bo")
.setDescription("test description")
.build()
)
.build();
Invoice invoice = resource.updateLines(params);
Response
{
"id": "in_1NuhUa2eZvKYlo2CWYVhyvD9",
"object": "invoice",
"account_country": "US",
"account_name": "Stripe.com",
"account_tax_ids": null,
"amount_due": 998,
"amount_paid": 0,
"amount_overpaid": 0,
"amount_remaining": 998,
"amount_shipping": 0,
"application": null,
"application_fee_amount": null,
"attempt_count": 0,
"attempted": false,
"auto_advance": false,
"automatic_tax": {
"enabled": false,
"liability": null,
"status": null
},
"billing_reason": "manual",
"collection_method": "charge_automatically",
"created": 1695758664,
"currency": "usd",
"custom_fields": null,
"customer": "cus_9s6XKzkNRiz8i3",
"customer_address": null,
"customer_email": "test@test.com",
"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,
"discounts": [],
"due_date": null,
"effective_at": null,
"ending_balance": null,
"footer": null,
"from_invoice": null,
"hosted_invoice_url": null,
"invoice_pdf": null,
"issuer": {
"type": "self"
},
"last_finalization_error": null,
"latest_revision": null,
"lines": {
"object": "list",
"data": [
{
"id": "il_1NuhUa2eZvKYlo2CC98Fg3Bo",
"object": "line_item",
"amount": 799,
"currency": "usd",
"description": "test description",
"discount_amounts": [],
"discountable": true,
"discounts": [],
"invoice_item": "ii_1NuhUa2eZvKYlo2CGeF7Qgx0",
"livemode": false,
"metadata": {},
"period": {
"end": 1695758664,
"start": 1695758664
},
"pricing": {
"price_details": {
"price": "price_1NuhLA2eZvKYlo2Cq1tIGEBp",
"product": "prod_Oi7aO1GPi1dWX7"
},
"type": "price_details",
"unit_amount_decimal": "799"
},
"proration": false,
"proration_details": {
"credited_items": null
},
"quantity": 1,
"subscription": null,
"taxes": []
},
{
"id": "il_1NuLVe2eZvKYlo2Canh35EfU",
"object": "line_item",
"amount": 199,
"currency": "usd",
"description": "Canned Coffee",
"discount_amounts": [],
"discountable": true,
"discounts": [],
"invoice_item": "ii_1NuLVd2eZvKYlo2CRWY0Hqgi",
"livemode": false,
"metadata": {},
"period": {
"end": 1695674161,
"start": 1695674161
},
"pricing": {
"price_details": {
"price": "price_1NuI212eZvKYlo2CWgdD8kET",
"product": "prod_OhhQNWDYdIbXYv"
},
"type": "price_details",
"unit_amount_decimal": "199"
},
"proration": false,
"proration_details": {
"credited_items": null
},
"quantity": 1,
"subscription": null,
"taxes": [],
"type": "invoiceitem"
}
],
"has_more": false,
"url": "/v1/invoices/upcoming/lines?customer=cus_9s6XKzkNRiz8i3"
},
"livemode": false,
"metadata": {},
"next_payment_attempt": null,
"number": null,
"on_behalf_of": null,
"parent": null,
"payment_settings": {
"default_mandate": null,
"payment_method_options": null,
"payment_method_types": null
},
"period_end": 1688482163,
"period_start": 1688395763,
"post_payment_credit_notes_amount": 0,
"pre_payment_credit_notes_amount": 0,
"receipt_number": null,
"redaction": null,
"rendering": null,
"shipping_cost": null,
"shipping_details": null,
"starting_balance": 0,
"statement_descriptor": null,
"status": "draft",
"status_transitions": {
"finalized_at": null,
"marked_uncollectible_at": null,
"paid_at": null,
"voided_at": null
},
"subtotal": 998,
"subtotal_excluding_tax": 998,
"test_clock": null,
"total": 998,
"total_discount_amounts": [],
"total_excluding_tax": 998,
"total_taxes": [],
"webhooks_delivered_at": null
}

Invoice Payment 

Invoice Payments represent payments made against invoices. Invoice Payments can be accessed in two ways:

  • By expanding the payments field on the Invoice resource.
  • By using the Invoice Payment retrieve and list endpoints.

Invoice Payments include the mapping between payment objects, such as Payment Intent, and Invoices. This resource and its endpoints allows you to easily track if a payment is associated with a specific invoice and monitor the allocation details of the payments.