Class InvoiceItem

All Implemented Interfaces:
HasId, MetadataStore<InvoiceItem>, StripeActiveObject, StripeObjectInterface

public class InvoiceItem extends ApiResource implements HasId, MetadataStore<InvoiceItem>
Invoice Items represent the component lines of an invoice. An invoice item is added to an invoice by creating or updating it with an invoice field, at which point it will be included as an invoice line item within invoice.lines.

Invoice Items can be created before you are ready to actually send the invoice. This can be particularly useful when combined with a subscription. Sometimes you want to add a charge or credit to a customer, but actually charge or credit the customer’s card only at the end of a regular billing cycle. This is useful for combining several charges (to minimize per-transaction fees), or for having Stripe tabulate your usage-based billing totals.

Related guides: Integrate with the Invoicing API, Subscription Invoices.

  • Constructor Details

    • InvoiceItem

      public InvoiceItem()
  • Method Details

    • getCustomer

      public String getCustomer()
      Get ID of expandable customer object.
    • setCustomer

      public void setCustomer(String id)
    • getCustomerObject

      public Customer getCustomerObject()
      Get expanded customer.
    • setCustomerObject

      public void setCustomerObject(Customer expandableObject)
    • getInvoice

      public String getInvoice()
      Get ID of expandable invoice object.
    • setInvoice

      public void setInvoice(String id)
    • getInvoiceObject

      public Invoice getInvoiceObject()
      Get expanded invoice.
    • setInvoiceObject

      public void setInvoiceObject(Invoice expandableObject)
    • getSubscription

      public String getSubscription()
      Get ID of expandable subscription object.
    • setSubscription

      public void setSubscription(String id)
    • getSubscriptionObject

      public Subscription getSubscriptionObject()
      Get expanded subscription.
    • setSubscriptionObject

      public void setSubscriptionObject(Subscription expandableObject)
    • getTestClock

      public String getTestClock()
      Get ID of expandable testClock object.
    • setTestClock

      public void setTestClock(String id)
    • getTestClockObject

      public TestClock getTestClockObject()
      Get expanded testClock.
    • setTestClockObject

      public void setTestClockObject(TestClock expandableObject)
    • getDiscounts

      public List<String> getDiscounts()
      Get IDs of expandable discounts object list.
    • setDiscounts

      public void setDiscounts(List<String> ids)
    • getDiscountObjects

      public List<Discount> getDiscountObjects()
      Get expanded discounts.
    • setDiscountObjects

      public void setDiscountObjects(List<Discount> objs)
    • create

      public static InvoiceItem create(Map<String,Object> params) throws StripeException
      Creates an item to be added to a draft invoice (up to 250 items per invoice). If no invoice is specified, the item will be on the next invoice created for the customer specified.
      Throws:
      StripeException
    • create

      public static InvoiceItem create(Map<String,Object> params, RequestOptions options) throws StripeException
      Creates an item to be added to a draft invoice (up to 250 items per invoice). If no invoice is specified, the item will be on the next invoice created for the customer specified.
      Throws:
      StripeException
    • create

      public static InvoiceItem create(InvoiceItemCreateParams params) throws StripeException
      Creates an item to be added to a draft invoice (up to 250 items per invoice). If no invoice is specified, the item will be on the next invoice created for the customer specified.
      Throws:
      StripeException
    • create

      public static InvoiceItem create(InvoiceItemCreateParams params, RequestOptions options) throws StripeException
      Creates an item to be added to a draft invoice (up to 250 items per invoice). If no invoice is specified, the item will be on the next invoice created for the customer specified.
      Throws:
      StripeException
    • delete

      public InvoiceItem delete() throws StripeException
      Deletes an invoice item, removing it from an invoice. Deleting invoice items is only possible when they’re not attached to invoices, or if it’s attached to a draft invoice.
      Throws:
      StripeException
    • delete

      public InvoiceItem delete(RequestOptions options) throws StripeException
      Deletes an invoice item, removing it from an invoice. Deleting invoice items is only possible when they’re not attached to invoices, or if it’s attached to a draft invoice.
      Throws:
      StripeException
    • delete

      public InvoiceItem delete(Map<String,Object> params) throws StripeException
      Deletes an invoice item, removing it from an invoice. Deleting invoice items is only possible when they’re not attached to invoices, or if it’s attached to a draft invoice.
      Throws:
      StripeException
    • delete

      public InvoiceItem delete(Map<String,Object> params, RequestOptions options) throws StripeException
      Deletes an invoice item, removing it from an invoice. Deleting invoice items is only possible when they’re not attached to invoices, or if it’s attached to a draft invoice.
      Throws:
      StripeException
    • list

      public static InvoiceItemCollection list(Map<String,Object> params) throws StripeException
      Returns a list of your invoice items. Invoice items are returned sorted by creation date, with the most recently created invoice items appearing first.
      Throws:
      StripeException
    • list

      public static InvoiceItemCollection list(Map<String,Object> params, RequestOptions options) throws StripeException
      Returns a list of your invoice items. Invoice items are returned sorted by creation date, with the most recently created invoice items appearing first.
      Throws:
      StripeException
    • list

      public static InvoiceItemCollection list(InvoiceItemListParams params) throws StripeException
      Returns a list of your invoice items. Invoice items are returned sorted by creation date, with the most recently created invoice items appearing first.
      Throws:
      StripeException
    • list

      public static InvoiceItemCollection list(InvoiceItemListParams params, RequestOptions options) throws StripeException
      Returns a list of your invoice items. Invoice items are returned sorted by creation date, with the most recently created invoice items appearing first.
      Throws:
      StripeException
    • retrieve

      public static InvoiceItem retrieve(String invoiceitem) throws StripeException
      Retrieves the invoice item with the given ID.
      Throws:
      StripeException
    • retrieve

      public static InvoiceItem retrieve(String invoiceitem, RequestOptions options) throws StripeException
      Retrieves the invoice item with the given ID.
      Throws:
      StripeException
    • retrieve

      public static InvoiceItem retrieve(String invoiceitem, Map<String,Object> params, RequestOptions options) throws StripeException
      Retrieves the invoice item with the given ID.
      Throws:
      StripeException
    • retrieve

      public static InvoiceItem retrieve(String invoiceitem, InvoiceItemRetrieveParams params, RequestOptions options) throws StripeException
      Retrieves the invoice item with the given ID.
      Throws:
      StripeException
    • update

      public InvoiceItem update(Map<String,Object> params) throws StripeException
      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.
      Specified by:
      update in interface MetadataStore<InvoiceItem>
      Throws:
      StripeException
    • update

      public InvoiceItem update(Map<String,Object> params, RequestOptions options) throws StripeException
      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.
      Specified by:
      update in interface MetadataStore<InvoiceItem>
      Throws:
      StripeException
    • update

      public InvoiceItem update(InvoiceItemUpdateParams params) throws StripeException
      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.
      Throws:
      StripeException
    • update

      public InvoiceItem update(InvoiceItemUpdateParams params, RequestOptions options) throws StripeException
      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.
      Throws:
      StripeException
    • setResponseGetter

      public void setResponseGetter(StripeResponseGetter responseGetter)
      Description copied from interface: StripeActiveObject
      Method is used by the containing object or StripeResponseGetter implementations to set the StripeResponseGetter instance used to make further requests.
      Specified by:
      setResponseGetter in interface StripeActiveObject
      Overrides:
      setResponseGetter in class ApiResource
      Parameters:
      responseGetter - the StripeResponseGetter instance to use for making further requests.
    • getAmount

      public Long getAmount()
      Amount (in the currency specified) of the invoice item. This should always be equal to unit_amount * quantity.
    • getCurrency

      public String getCurrency()
      Three-letter ISO currency code, in lowercase. Must be a supported currency.
    • getDate

      public Long getDate()
      Time at which the object was created. Measured in seconds since the Unix epoch.
    • getDeleted

      public Boolean getDeleted()
      Always true for a deleted object.
    • getDescription

      public String getDescription()
      An arbitrary string attached to the object. Often useful for displaying to users.
    • getDiscountable

      public Boolean getDiscountable()
      If true, discounts will apply to this invoice item. Always false for prorations.
    • getLivemode

      public Boolean getLivemode()
      Has the value true if the object exists in live mode or the value false if the object exists in test mode.
    • getObject

      public String getObject()
      String representing the object's type. Objects of the same type share the same value.

      Equal to invoiceitem.

    • getPeriod

      public InvoiceItem.Period getPeriod()
    • getPlan

      public Plan getPlan()
      If the invoice item is a proration, the plan of the subscription that the proration was computed for.
    • getPrice

      public Price getPrice()
      The price of the invoice item.
    • getProration

      public Boolean getProration()
      Whether the invoice item was created automatically as a proration adjustment when the customer switched plans.
    • getQuantity

      public Long getQuantity()
      Quantity of units for the invoice item. If the invoice item is a proration, the quantity of the subscription that the proration was computed for.
    • getSubscriptionItem

      public String getSubscriptionItem()
      The subscription item that this invoice item has been created for, if any.
    • getTaxRates

      public List<TaxRate> getTaxRates()
      The tax rates which apply to the invoice item. When set, the default_tax_rates on the invoice do not apply to this invoice item.
    • getUnitAmount

      public Long getUnitAmount()
      Unit amount (in the currency specified) of the invoice item.
    • getUnitAmountDecimal

      public BigDecimal getUnitAmountDecimal()
      Same as unit_amount, but contains a decimal value with at most 12 decimal places.
    • setAmount

      public void setAmount(Long amount)
      Amount (in the currency specified) of the invoice item. This should always be equal to unit_amount * quantity.
    • setCurrency

      public void setCurrency(String currency)
      Three-letter ISO currency code, in lowercase. Must be a supported currency.
    • setDate

      public void setDate(Long date)
      Time at which the object was created. Measured in seconds since the Unix epoch.
    • setDeleted

      public void setDeleted(Boolean deleted)
      Always true for a deleted object.
    • setDescription

      public void setDescription(String description)
      An arbitrary string attached to the object. Often useful for displaying to users.
    • setDiscountable

      public void setDiscountable(Boolean discountable)
      If true, discounts will apply to this invoice item. Always false for prorations.
    • setId

      public void setId(String id)
      Unique identifier for the object.
    • setLivemode

      public void setLivemode(Boolean livemode)
      Has the value true if the object exists in live mode or the value false if the object exists in test mode.
    • setMetadata

      public void setMetadata(Map<String,String> metadata)
      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.
    • setObject

      public void setObject(String object)
      String representing the object's type. Objects of the same type share the same value.

      Equal to invoiceitem.

    • setPeriod

      public void setPeriod(InvoiceItem.Period period)
    • setPlan

      public void setPlan(Plan plan)
      If the invoice item is a proration, the plan of the subscription that the proration was computed for.
    • setPrice

      public void setPrice(Price price)
      The price of the invoice item.
    • setProration

      public void setProration(Boolean proration)
      Whether the invoice item was created automatically as a proration adjustment when the customer switched plans.
    • setQuantity

      public void setQuantity(Long quantity)
      Quantity of units for the invoice item. If the invoice item is a proration, the quantity of the subscription that the proration was computed for.
    • setSubscriptionItem

      public void setSubscriptionItem(String subscriptionItem)
      The subscription item that this invoice item has been created for, if any.
    • setTaxRates

      public void setTaxRates(List<TaxRate> taxRates)
      The tax rates which apply to the invoice item. When set, the default_tax_rates on the invoice do not apply to this invoice item.
    • setUnitAmount

      public void setUnitAmount(Long unitAmount)
      Unit amount (in the currency specified) of the invoice item.
    • setUnitAmountDecimal

      public void setUnitAmountDecimal(BigDecimal unitAmountDecimal)
      Same as unit_amount, but contains a decimal value with at most 12 decimal places.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getId

      public String getId()
      Unique identifier for the object.
      Specified by:
      getId in interface HasId
    • getMetadata

      public Map<String,String> getMetadata()
      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.
      Specified by:
      getMetadata in interface MetadataStore<InvoiceItem>