github.com/stripe/stripe-go/v76@v76.25.0/invoicelineitem.go (about)

     1  //
     2  //
     3  // File generated from our OpenAPI spec
     4  //
     5  //
     6  
     7  package stripe
     8  
     9  // A string identifying the type of the source of this line item, either an `invoiceitem` or a `subscription`.
    10  type InvoiceLineItemType string
    11  
    12  // List of values that InvoiceLineItemType can take
    13  const (
    14  	InvoiceLineItemTypeInvoiceItem  InvoiceLineItemType = "invoiceitem"
    15  	InvoiceLineItemTypeSubscription InvoiceLineItemType = "subscription"
    16  )
    17  
    18  // The coupons, promotion codes & existing discounts which apply to the line item. Item discounts are applied before invoice discounts. Pass an empty string to remove previously-defined discounts.
    19  type InvoiceLineItemDiscountParams struct {
    20  	// ID of the coupon to create a new discount for.
    21  	Coupon *string `form:"coupon"`
    22  	// ID of an existing discount on the object (or one of its ancestors) to reuse.
    23  	Discount *string `form:"discount"`
    24  	// ID of the promotion code to create a new discount for.
    25  	PromotionCode *string `form:"promotion_code"`
    26  }
    27  
    28  // The period associated with this invoice item. When set to different values, the period will be rendered on the invoice. If you have [Stripe Revenue Recognition](https://stripe.com/docs/revenue-recognition) enabled, the period will be used to recognize and defer revenue. See the [Revenue Recognition documentation](https://stripe.com/docs/revenue-recognition/methodology/subscriptions-and-invoicing) for details.
    29  type InvoiceLineItemPeriodParams struct {
    30  	// The end of the period, which must be greater than or equal to the start. This value is inclusive.
    31  	End *int64 `form:"end"`
    32  	// The start of the period. This value is inclusive.
    33  	Start *int64 `form:"start"`
    34  }
    35  
    36  // Data used to generate a new product object inline. One of `product` or `product_data` is required.
    37  type InvoiceLineItemPriceDataProductDataParams struct {
    38  	// The product's description, meant to be displayable to the customer. Use this field to optionally store a long form explanation of the product being sold for your own rendering purposes.
    39  	Description *string `form:"description"`
    40  	// A list of up to 8 URLs of images for this product, meant to be displayable to the customer.
    41  	Images []*string `form:"images"`
    42  	// Set of [key-value pairs](https://stripe.com/docs/api/metadata) 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`.
    43  	Metadata map[string]string `form:"metadata"`
    44  	// The product's name, meant to be displayable to the customer.
    45  	Name *string `form:"name"`
    46  	// A [tax code](https://stripe.com/docs/tax/tax-categories) ID.
    47  	TaxCode *string `form:"tax_code"`
    48  }
    49  
    50  // AddMetadata adds a new key-value pair to the Metadata.
    51  func (p *InvoiceLineItemPriceDataProductDataParams) AddMetadata(key string, value string) {
    52  	if p.Metadata == nil {
    53  		p.Metadata = make(map[string]string)
    54  	}
    55  
    56  	p.Metadata[key] = value
    57  }
    58  
    59  // Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline.
    60  type InvoiceLineItemPriceDataParams struct {
    61  	// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
    62  	Currency *string `form:"currency"`
    63  	// The ID of the product that this price will belong to. One of `product` or `product_data` is required.
    64  	Product *string `form:"product"`
    65  	// Data used to generate a new product object inline. One of `product` or `product_data` is required.
    66  	ProductData *InvoiceLineItemPriceDataProductDataParams `form:"product_data"`
    67  	// Only required if a [default tax behavior](https://stripe.com/docs/tax/products-prices-tax-categories-tax-behavior#setting-a-default-tax-behavior-(recommended)) was not provided in the Stripe Tax settings. Specifies whether the price is considered inclusive of taxes or exclusive of taxes. One of `inclusive`, `exclusive`, or `unspecified`. Once specified as either `inclusive` or `exclusive`, it cannot be changed.
    68  	TaxBehavior *string `form:"tax_behavior"`
    69  	// A non-negative integer in cents (or local equivalent) representing how much to charge. One of `unit_amount` or `unit_amount_decimal` is required.
    70  	UnitAmount *int64 `form:"unit_amount"`
    71  	// Same as `unit_amount`, but accepts a decimal value in cents (or local equivalent) with at most 12 decimal places. Only one of `unit_amount` and `unit_amount_decimal` can be set.
    72  	UnitAmountDecimal *float64 `form:"unit_amount_decimal,high_precision"`
    73  }
    74  
    75  // Data to find or create a TaxRate object.
    76  //
    77  // Stripe automatically creates or reuses a TaxRate object for each tax amount. If the `tax_rate_data` exactly matches a previous value, Stripe will reuse the TaxRate object. TaxRate objects created automatically by Stripe are immediately archived, do not appear in the line item's `tax_rates`, and cannot be directly added to invoices, payments, or line items.
    78  type InvoiceLineItemTaxAmountTaxRateDataParams struct {
    79  	// Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)).
    80  	Country *string `form:"country"`
    81  	// An arbitrary string attached to the tax rate for your internal use only. It will not be visible to your customers.
    82  	Description *string `form:"description"`
    83  	// The display name of the tax rate, which will be shown to users.
    84  	DisplayName *string `form:"display_name"`
    85  	// This specifies if the tax rate is inclusive or exclusive.
    86  	Inclusive *bool `form:"inclusive"`
    87  	// The jurisdiction for the tax rate. You can use this label field for tax reporting purposes. It also appears on your customer's invoice.
    88  	Jurisdiction *string `form:"jurisdiction"`
    89  	// The statutory tax rate percent. This field accepts decimal values between 0 and 100 inclusive with at most 4 decimal places. To accommodate fixed-amount taxes, set the percentage to zero. Stripe will not display zero percentages on the invoice unless the `amount` of the tax is also zero.
    90  	Percentage *float64 `form:"percentage"`
    91  	// [ISO 3166-2 subdivision code](https://en.wikipedia.org/wiki/ISO_3166-2:US), without country prefix. For example, "NY" for New York, United States.
    92  	State *string `form:"state"`
    93  	// The high-level tax type, such as `vat` or `sales_tax`.
    94  	TaxType *string `form:"tax_type"`
    95  }
    96  
    97  // A list of up to 10 tax amounts for this line item. This can be useful if you calculate taxes on your own or use a third-party to calculate them. You cannot set tax amounts if any line item has [tax_rates](https://stripe.com/docs/api/invoices/line_item#invoice_line_item_object-tax_rates) or if the invoice has [default_tax_rates](https://stripe.com/docs/api/invoices/object#invoice_object-default_tax_rates) or uses [automatic tax](https://stripe.com/docs/tax/invoicing). Pass an empty string to remove previously defined tax amounts.
    98  type InvoiceLineItemTaxAmountParams struct {
    99  	// The amount, in cents (or local equivalent), of the tax.
   100  	Amount *int64 `form:"amount"`
   101  	// The amount on which tax is calculated, in cents (or local equivalent).
   102  	TaxableAmount *int64 `form:"taxable_amount"`
   103  	// Data to find or create a TaxRate object.
   104  	//
   105  	// Stripe automatically creates or reuses a TaxRate object for each tax amount. If the `tax_rate_data` exactly matches a previous value, Stripe will reuse the TaxRate object. TaxRate objects created automatically by Stripe are immediately archived, do not appear in the line item's `tax_rates`, and cannot be directly added to invoices, payments, or line items.
   106  	TaxRateData *InvoiceLineItemTaxAmountTaxRateDataParams `form:"tax_rate_data"`
   107  }
   108  
   109  // Updates an invoice's line item. Some fields, such as tax_amounts, only live on the invoice line item,
   110  // so they can only be updated through this endpoint. Other fields, such as amount, live on both the invoice
   111  // item and the invoice line item, so updates on this endpoint will propagate to the invoice item as well.
   112  // Updating an invoice's line item is only possible before the invoice is finalized.
   113  type InvoiceLineItemParams struct {
   114  	Params  `form:"*"`
   115  	Invoice *string `form:"-"` // Included in URL
   116  	// The integer amount in cents (or local equivalent) of the charge to be applied to the upcoming invoice. If you want to apply a credit to the customer's account, pass a negative amount.
   117  	Amount *int64 `form:"amount"`
   118  	// An arbitrary string which you can attach to the invoice item. The description is displayed in the invoice for easy tracking.
   119  	Description *string `form:"description"`
   120  	// Controls whether discounts apply to this line item. Defaults to false for prorations or negative line items, and true for all other line items. Cannot be set to true for prorations.
   121  	Discountable *bool `form:"discountable"`
   122  	// The coupons, promotion codes & existing discounts which apply to the line item. Item discounts are applied before invoice discounts. Pass an empty string to remove previously-defined discounts.
   123  	Discounts []*InvoiceLineItemDiscountParams `form:"discounts"`
   124  	// Specifies which fields in the response should be expanded.
   125  	Expand []*string `form:"expand"`
   126  	// Set of [key-value pairs](https://stripe.com/docs/api/metadata) 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`.
   127  	Metadata map[string]string `form:"metadata"`
   128  	// The period associated with this invoice item. When set to different values, the period will be rendered on the invoice. If you have [Stripe Revenue Recognition](https://stripe.com/docs/revenue-recognition) enabled, the period will be used to recognize and defer revenue. See the [Revenue Recognition documentation](https://stripe.com/docs/revenue-recognition/methodology/subscriptions-and-invoicing) for details.
   129  	Period *InvoiceLineItemPeriodParams `form:"period"`
   130  	// The ID of the price object.
   131  	Price *string `form:"price"`
   132  	// Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline.
   133  	PriceData *InvoiceLineItemPriceDataParams `form:"price_data"`
   134  	// Non-negative integer. The quantity of units for the line item.
   135  	Quantity *int64 `form:"quantity"`
   136  	// A list of up to 10 tax amounts for this line item. This can be useful if you calculate taxes on your own or use a third-party to calculate them. You cannot set tax amounts if any line item has [tax_rates](https://stripe.com/docs/api/invoices/line_item#invoice_line_item_object-tax_rates) or if the invoice has [default_tax_rates](https://stripe.com/docs/api/invoices/object#invoice_object-default_tax_rates) or uses [automatic tax](https://stripe.com/docs/tax/invoicing). Pass an empty string to remove previously defined tax amounts.
   137  	TaxAmounts []*InvoiceLineItemTaxAmountParams `form:"tax_amounts"`
   138  	// The tax rates which apply to the line item. When set, the `default_tax_rates` on the invoice do not apply to this line item. Pass an empty string to remove previously-defined tax rates.
   139  	TaxRates []*string `form:"tax_rates"`
   140  }
   141  
   142  // AddExpand appends a new field to expand.
   143  func (p *InvoiceLineItemParams) AddExpand(f string) {
   144  	p.Expand = append(p.Expand, &f)
   145  }
   146  
   147  // AddMetadata adds a new key-value pair to the Metadata.
   148  func (p *InvoiceLineItemParams) AddMetadata(key string, value string) {
   149  	if p.Metadata == nil {
   150  		p.Metadata = make(map[string]string)
   151  	}
   152  
   153  	p.Metadata[key] = value
   154  }
   155  
   156  // The amount of discount calculated per discount for this line item.
   157  type InvoiceLineItemDiscountAmount struct {
   158  	// The amount, in cents (or local equivalent), of the discount.
   159  	Amount int64 `json:"amount"`
   160  	// The discount that was applied to get this discount amount.
   161  	Discount *Discount `json:"discount"`
   162  }
   163  
   164  // For a credit proration `line_item`, the original debit line_items to which the credit proration applies.
   165  type InvoiceLineItemProrationDetailsCreditedItems struct {
   166  	// Invoice containing the credited invoice line items
   167  	Invoice string `json:"invoice"`
   168  	// Credited invoice line items
   169  	InvoiceLineItems []string `json:"invoice_line_items"`
   170  }
   171  
   172  // Additional details for proration line items
   173  type InvoiceLineItemProrationDetails struct {
   174  	// For a credit proration `line_item`, the original debit line_items to which the credit proration applies.
   175  	CreditedItems *InvoiceLineItemProrationDetailsCreditedItems `json:"credited_items"`
   176  }
   177  type InvoiceLineItem struct {
   178  	APIResource
   179  	// The amount, in cents (or local equivalent).
   180  	Amount int64 `json:"amount"`
   181  	// The integer amount in cents (or local equivalent) representing the amount for this line item, excluding all tax and discounts.
   182  	AmountExcludingTax int64 `json:"amount_excluding_tax"`
   183  	// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
   184  	Currency Currency `json:"currency"`
   185  	// An arbitrary string attached to the object. Often useful for displaying to users.
   186  	Description string `json:"description"`
   187  	// If true, discounts will apply to this line item. Always false for prorations.
   188  	Discountable bool `json:"discountable"`
   189  	// The amount of discount calculated per discount for this line item.
   190  	DiscountAmounts []*InvoiceLineItemDiscountAmount `json:"discount_amounts"`
   191  	// The discounts applied to the invoice line item. Line item discounts are applied before invoice discounts. Use `expand[]=discounts` to expand each discount.
   192  	Discounts []*Discount `json:"discounts"`
   193  	// Unique identifier for the object.
   194  	ID string `json:"id"`
   195  	// The ID of the invoice that contains this line item.
   196  	Invoice string `json:"invoice"`
   197  	// The ID of the [invoice item](https://stripe.com/docs/api/invoiceitems) associated with this line item if any.
   198  	InvoiceItem *InvoiceItem `json:"invoice_item"`
   199  	// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
   200  	Livemode bool `json:"livemode"`
   201  	// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Note that for line items with `type=subscription` this will reflect the metadata of the subscription that caused the line item to be created.
   202  	Metadata map[string]string `json:"metadata"`
   203  	// String representing the object's type. Objects of the same type share the same value.
   204  	Object string  `json:"object"`
   205  	Period *Period `json:"period"`
   206  	// The plan of the subscription, if the line item is a subscription or a proration.
   207  	Plan *Plan `json:"plan"`
   208  	// The price of the line item.
   209  	Price *Price `json:"price"`
   210  	// Whether this is a proration.
   211  	Proration bool `json:"proration"`
   212  	// Additional details for proration line items
   213  	ProrationDetails *InvoiceLineItemProrationDetails `json:"proration_details"`
   214  	// The quantity of the subscription, if the line item is a subscription or a proration.
   215  	Quantity int64 `json:"quantity"`
   216  	// The subscription that the invoice item pertains to, if any.
   217  	Subscription *Subscription `json:"subscription"`
   218  	// The subscription item that generated this line item. Left empty if the line item is not an explicit result of a subscription.
   219  	SubscriptionItem *SubscriptionItem `json:"subscription_item"`
   220  	// The amount of tax calculated per tax rate for this line item
   221  	TaxAmounts []*InvoiceTotalTaxAmount `json:"tax_amounts"`
   222  	// The tax rates which apply to the line item.
   223  	TaxRates []*TaxRate `json:"tax_rates"`
   224  	// A string identifying the type of the source of this line item, either an `invoiceitem` or a `subscription`.
   225  	Type InvoiceLineItemType `json:"type"`
   226  	// The amount in cents (or local equivalent) representing the unit amount for this line item, excluding all tax and discounts.
   227  	UnitAmountExcludingTax float64 `json:"unit_amount_excluding_tax,string"`
   228  }
   229  
   230  // Period is a structure representing a start and end dates.
   231  type Period struct {
   232  	End   int64 `json:"end"`
   233  	Start int64 `json:"start"`
   234  }
   235  
   236  // InvoiceLineItemList is a list of InvoiceLineItems as retrieved from a list endpoint.
   237  type InvoiceLineItemList struct {
   238  	APIResource
   239  	ListMeta
   240  	Data []*InvoiceLineItem `json:"data"`
   241  }