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

     1  //
     2  //
     3  // File generated from our OpenAPI spec
     4  //
     5  //
     6  
     7  package stripe
     8  
     9  import (
    10  	"encoding/json"
    11  	"github.com/stripe/stripe-go/v76/form"
    12  )
    13  
    14  // Type of the account referenced.
    15  type InvoiceAutomaticTaxLiabilityType string
    16  
    17  // List of values that InvoiceAutomaticTaxLiabilityType can take
    18  const (
    19  	InvoiceAutomaticTaxLiabilityTypeAccount InvoiceAutomaticTaxLiabilityType = "account"
    20  	InvoiceAutomaticTaxLiabilityTypeSelf    InvoiceAutomaticTaxLiabilityType = "self"
    21  )
    22  
    23  // The status of the most recent automated tax calculation for this invoice.
    24  type InvoiceAutomaticTaxStatus string
    25  
    26  // List of values that InvoiceAutomaticTaxStatus can take
    27  const (
    28  	InvoiceAutomaticTaxStatusComplete               InvoiceAutomaticTaxStatus = "complete"
    29  	InvoiceAutomaticTaxStatusFailed                 InvoiceAutomaticTaxStatus = "failed"
    30  	InvoiceAutomaticTaxStatusRequiresLocationInputs InvoiceAutomaticTaxStatus = "requires_location_inputs"
    31  )
    32  
    33  // Indicates the reason why the invoice was created.
    34  //
    35  // * `manual`: Unrelated to a subscription, for example, created via the invoice editor.
    36  // * `subscription`: No longer in use. Applies to subscriptions from before May 2018 where no distinction was made between updates, cycles, and thresholds.
    37  // * `subscription_create`: A new subscription was created.
    38  // * `subscription_cycle`: A subscription advanced into a new period.
    39  // * `subscription_threshold`: A subscription reached a billing threshold.
    40  // * `subscription_update`: A subscription was updated.
    41  // * `upcoming`: Reserved for simulated invoices, per the upcoming invoice endpoint.
    42  type InvoiceBillingReason string
    43  
    44  // List of values that InvoiceBillingReason can take
    45  const (
    46  	InvoiceBillingReasonAutomaticPendingInvoiceItemInvoice InvoiceBillingReason = "automatic_pending_invoice_item_invoice"
    47  	InvoiceBillingReasonManual                             InvoiceBillingReason = "manual"
    48  	InvoiceBillingReasonQuoteAccept                        InvoiceBillingReason = "quote_accept"
    49  	InvoiceBillingReasonSubscription                       InvoiceBillingReason = "subscription"
    50  	InvoiceBillingReasonSubscriptionCreate                 InvoiceBillingReason = "subscription_create"
    51  	InvoiceBillingReasonSubscriptionCycle                  InvoiceBillingReason = "subscription_cycle"
    52  	InvoiceBillingReasonSubscriptionThreshold              InvoiceBillingReason = "subscription_threshold"
    53  	InvoiceBillingReasonSubscriptionUpdate                 InvoiceBillingReason = "subscription_update"
    54  	InvoiceBillingReasonUpcoming                           InvoiceBillingReason = "upcoming"
    55  )
    56  
    57  // Either `charge_automatically`, or `send_invoice`. When charging automatically, Stripe will attempt to pay this invoice using the default source attached to the customer. When sending an invoice, Stripe will email this invoice to the customer with payment instructions.
    58  type InvoiceCollectionMethod string
    59  
    60  // List of values that InvoiceCollectionMethod can take
    61  const (
    62  	InvoiceCollectionMethodChargeAutomatically InvoiceCollectionMethod = "charge_automatically"
    63  	InvoiceCollectionMethodSendInvoice         InvoiceCollectionMethod = "send_invoice"
    64  )
    65  
    66  // Type of the account referenced.
    67  type InvoiceIssuerType string
    68  
    69  // List of values that InvoiceIssuerType can take
    70  const (
    71  	InvoiceIssuerTypeAccount InvoiceIssuerType = "account"
    72  	InvoiceIssuerTypeSelf    InvoiceIssuerType = "self"
    73  )
    74  
    75  // Transaction type of the mandate.
    76  type InvoicePaymentSettingsPaymentMethodOptionsACSSDebitMandateOptionsTransactionType string
    77  
    78  // List of values that InvoicePaymentSettingsPaymentMethodOptionsACSSDebitMandateOptionsTransactionType can take
    79  const (
    80  	InvoicePaymentSettingsPaymentMethodOptionsACSSDebitMandateOptionsTransactionTypeBusiness InvoicePaymentSettingsPaymentMethodOptionsACSSDebitMandateOptionsTransactionType = "business"
    81  	InvoicePaymentSettingsPaymentMethodOptionsACSSDebitMandateOptionsTransactionTypePersonal InvoicePaymentSettingsPaymentMethodOptionsACSSDebitMandateOptionsTransactionType = "personal"
    82  )
    83  
    84  // Bank account verification method.
    85  type InvoicePaymentSettingsPaymentMethodOptionsACSSDebitVerificationMethod string
    86  
    87  // List of values that InvoicePaymentSettingsPaymentMethodOptionsACSSDebitVerificationMethod can take
    88  const (
    89  	InvoicePaymentSettingsPaymentMethodOptionsACSSDebitVerificationMethodAutomatic     InvoicePaymentSettingsPaymentMethodOptionsACSSDebitVerificationMethod = "automatic"
    90  	InvoicePaymentSettingsPaymentMethodOptionsACSSDebitVerificationMethodInstant       InvoicePaymentSettingsPaymentMethodOptionsACSSDebitVerificationMethod = "instant"
    91  	InvoicePaymentSettingsPaymentMethodOptionsACSSDebitVerificationMethodMicrodeposits InvoicePaymentSettingsPaymentMethodOptionsACSSDebitVerificationMethod = "microdeposits"
    92  )
    93  
    94  // We strongly recommend that you rely on our SCA Engine to automatically prompt your customers for authentication based on risk level and [other requirements](https://stripe.com/docs/strong-customer-authentication). However, if you wish to request 3D Secure based on logic from your own fraud engine, provide this option. Read our guide on [manually requesting 3D Secure](https://stripe.com/docs/payments/3d-secure/authentication-flow#manual-three-ds) for more information on how this configuration interacts with Radar and our SCA Engine.
    95  type InvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure string
    96  
    97  // List of values that InvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure can take
    98  const (
    99  	InvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecureAny       InvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure = "any"
   100  	InvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecureAutomatic InvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure = "automatic"
   101  	InvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecureChallenge InvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure = "challenge"
   102  )
   103  
   104  // The funding method type to be used when there are not enough funds in the customer balance. Permitted values include: `bank_transfer`.
   105  type InvoicePaymentSettingsPaymentMethodOptionsCustomerBalanceFundingType string
   106  
   107  // List of values that InvoicePaymentSettingsPaymentMethodOptionsCustomerBalanceFundingType can take
   108  const (
   109  	InvoicePaymentSettingsPaymentMethodOptionsCustomerBalanceFundingTypeBankTransfer InvoicePaymentSettingsPaymentMethodOptionsCustomerBalanceFundingType = "bank_transfer"
   110  )
   111  
   112  // The list of permissions to request. The `payment_method` permission must be included.
   113  type InvoicePaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPermission string
   114  
   115  // List of values that InvoicePaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPermission can take
   116  const (
   117  	InvoicePaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPermissionBalances      InvoicePaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPermission = "balances"
   118  	InvoicePaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPermissionPaymentMethod InvoicePaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPermission = "payment_method"
   119  	InvoicePaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPermissionTransactions  InvoicePaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPermission = "transactions"
   120  )
   121  
   122  // Data features requested to be retrieved upon account creation.
   123  type InvoicePaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPrefetch string
   124  
   125  // List of values that InvoicePaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPrefetch can take
   126  const (
   127  	InvoicePaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPrefetchBalances     InvoicePaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPrefetch = "balances"
   128  	InvoicePaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPrefetchTransactions InvoicePaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPrefetch = "transactions"
   129  )
   130  
   131  // Bank account verification method.
   132  type InvoicePaymentSettingsPaymentMethodOptionsUSBankAccountVerificationMethod string
   133  
   134  // List of values that InvoicePaymentSettingsPaymentMethodOptionsUSBankAccountVerificationMethod can take
   135  const (
   136  	InvoicePaymentSettingsPaymentMethodOptionsUSBankAccountVerificationMethodAutomatic     InvoicePaymentSettingsPaymentMethodOptionsUSBankAccountVerificationMethod = "automatic"
   137  	InvoicePaymentSettingsPaymentMethodOptionsUSBankAccountVerificationMethodInstant       InvoicePaymentSettingsPaymentMethodOptionsUSBankAccountVerificationMethod = "instant"
   138  	InvoicePaymentSettingsPaymentMethodOptionsUSBankAccountVerificationMethodMicrodeposits InvoicePaymentSettingsPaymentMethodOptionsUSBankAccountVerificationMethod = "microdeposits"
   139  )
   140  
   141  // The list of payment method types (e.g. card) to provide to the invoice's PaymentIntent. If not set, Stripe attempts to automatically determine the types to use by looking at the invoice's default payment method, the subscription's default payment method, the customer's default payment method, and your [invoice template settings](https://dashboard.stripe.com/settings/billing/invoice).
   142  type InvoicePaymentSettingsPaymentMethodType string
   143  
   144  // List of values that InvoicePaymentSettingsPaymentMethodType can take
   145  const (
   146  	InvoicePaymentSettingsPaymentMethodTypeACHCreditTransfer  InvoicePaymentSettingsPaymentMethodType = "ach_credit_transfer"
   147  	InvoicePaymentSettingsPaymentMethodTypeACHDebit           InvoicePaymentSettingsPaymentMethodType = "ach_debit"
   148  	InvoicePaymentSettingsPaymentMethodTypeACSSDebit          InvoicePaymentSettingsPaymentMethodType = "acss_debit"
   149  	InvoicePaymentSettingsPaymentMethodTypeAUBECSDebit        InvoicePaymentSettingsPaymentMethodType = "au_becs_debit"
   150  	InvoicePaymentSettingsPaymentMethodTypeBACSDebit          InvoicePaymentSettingsPaymentMethodType = "bacs_debit"
   151  	InvoicePaymentSettingsPaymentMethodTypeBancontact         InvoicePaymentSettingsPaymentMethodType = "bancontact"
   152  	InvoicePaymentSettingsPaymentMethodTypeBoleto             InvoicePaymentSettingsPaymentMethodType = "boleto"
   153  	InvoicePaymentSettingsPaymentMethodTypeCard               InvoicePaymentSettingsPaymentMethodType = "card"
   154  	InvoicePaymentSettingsPaymentMethodTypeCashApp            InvoicePaymentSettingsPaymentMethodType = "cashapp"
   155  	InvoicePaymentSettingsPaymentMethodTypeCustomerBalance    InvoicePaymentSettingsPaymentMethodType = "customer_balance"
   156  	InvoicePaymentSettingsPaymentMethodTypeEPS                InvoicePaymentSettingsPaymentMethodType = "eps"
   157  	InvoicePaymentSettingsPaymentMethodTypeFPX                InvoicePaymentSettingsPaymentMethodType = "fpx"
   158  	InvoicePaymentSettingsPaymentMethodTypeGiropay            InvoicePaymentSettingsPaymentMethodType = "giropay"
   159  	InvoicePaymentSettingsPaymentMethodTypeGrabpay            InvoicePaymentSettingsPaymentMethodType = "grabpay"
   160  	InvoicePaymentSettingsPaymentMethodTypeIDEAL              InvoicePaymentSettingsPaymentMethodType = "ideal"
   161  	InvoicePaymentSettingsPaymentMethodTypeKonbini            InvoicePaymentSettingsPaymentMethodType = "konbini"
   162  	InvoicePaymentSettingsPaymentMethodTypeLink               InvoicePaymentSettingsPaymentMethodType = "link"
   163  	InvoicePaymentSettingsPaymentMethodTypeP24                InvoicePaymentSettingsPaymentMethodType = "p24"
   164  	InvoicePaymentSettingsPaymentMethodTypePayNow             InvoicePaymentSettingsPaymentMethodType = "paynow"
   165  	InvoicePaymentSettingsPaymentMethodTypePaypal             InvoicePaymentSettingsPaymentMethodType = "paypal"
   166  	InvoicePaymentSettingsPaymentMethodTypePromptPay          InvoicePaymentSettingsPaymentMethodType = "promptpay"
   167  	InvoicePaymentSettingsPaymentMethodTypeSEPACreditTransfer InvoicePaymentSettingsPaymentMethodType = "sepa_credit_transfer"
   168  	InvoicePaymentSettingsPaymentMethodTypeSEPADebit          InvoicePaymentSettingsPaymentMethodType = "sepa_debit"
   169  	InvoicePaymentSettingsPaymentMethodTypeSofort             InvoicePaymentSettingsPaymentMethodType = "sofort"
   170  	InvoicePaymentSettingsPaymentMethodTypeUSBankAccount      InvoicePaymentSettingsPaymentMethodType = "us_bank_account"
   171  	InvoicePaymentSettingsPaymentMethodTypeWeChatPay          InvoicePaymentSettingsPaymentMethodType = "wechat_pay"
   172  )
   173  
   174  // Page size of invoice pdf. Options include a4, letter, and auto. If set to auto, page size will be switched to a4 or letter based on customer locale.
   175  type InvoiceRenderingPDFPageSize string
   176  
   177  // List of values that InvoiceRenderingPDFPageSize can take
   178  const (
   179  	InvoiceRenderingPDFPageSizeA4     InvoiceRenderingPDFPageSize = "a4"
   180  	InvoiceRenderingPDFPageSizeAuto   InvoiceRenderingPDFPageSize = "auto"
   181  	InvoiceRenderingPDFPageSizeLetter InvoiceRenderingPDFPageSize = "letter"
   182  )
   183  
   184  // The reasoning behind this tax, for example, if the product is tax exempt. The possible values for this field may be extended as new tax rules are supported.
   185  type InvoiceShippingCostTaxTaxabilityReason string
   186  
   187  // List of values that InvoiceShippingCostTaxTaxabilityReason can take
   188  const (
   189  	InvoiceShippingCostTaxTaxabilityReasonCustomerExempt       InvoiceShippingCostTaxTaxabilityReason = "customer_exempt"
   190  	InvoiceShippingCostTaxTaxabilityReasonNotCollecting        InvoiceShippingCostTaxTaxabilityReason = "not_collecting"
   191  	InvoiceShippingCostTaxTaxabilityReasonNotSubjectToTax      InvoiceShippingCostTaxTaxabilityReason = "not_subject_to_tax"
   192  	InvoiceShippingCostTaxTaxabilityReasonNotSupported         InvoiceShippingCostTaxTaxabilityReason = "not_supported"
   193  	InvoiceShippingCostTaxTaxabilityReasonPortionProductExempt InvoiceShippingCostTaxTaxabilityReason = "portion_product_exempt"
   194  	InvoiceShippingCostTaxTaxabilityReasonPortionReducedRated  InvoiceShippingCostTaxTaxabilityReason = "portion_reduced_rated"
   195  	InvoiceShippingCostTaxTaxabilityReasonPortionStandardRated InvoiceShippingCostTaxTaxabilityReason = "portion_standard_rated"
   196  	InvoiceShippingCostTaxTaxabilityReasonProductExempt        InvoiceShippingCostTaxTaxabilityReason = "product_exempt"
   197  	InvoiceShippingCostTaxTaxabilityReasonProductExemptHoliday InvoiceShippingCostTaxTaxabilityReason = "product_exempt_holiday"
   198  	InvoiceShippingCostTaxTaxabilityReasonProportionallyRated  InvoiceShippingCostTaxTaxabilityReason = "proportionally_rated"
   199  	InvoiceShippingCostTaxTaxabilityReasonReducedRated         InvoiceShippingCostTaxTaxabilityReason = "reduced_rated"
   200  	InvoiceShippingCostTaxTaxabilityReasonReverseCharge        InvoiceShippingCostTaxTaxabilityReason = "reverse_charge"
   201  	InvoiceShippingCostTaxTaxabilityReasonStandardRated        InvoiceShippingCostTaxTaxabilityReason = "standard_rated"
   202  	InvoiceShippingCostTaxTaxabilityReasonTaxableBasisReduced  InvoiceShippingCostTaxTaxabilityReason = "taxable_basis_reduced"
   203  	InvoiceShippingCostTaxTaxabilityReasonZeroRated            InvoiceShippingCostTaxTaxabilityReason = "zero_rated"
   204  )
   205  
   206  // The status of the invoice, one of `draft`, `open`, `paid`, `uncollectible`, or `void`. [Learn more](https://stripe.com/docs/billing/invoices/workflow#workflow-overview)
   207  type InvoiceStatus string
   208  
   209  // List of values that InvoiceStatus can take
   210  const (
   211  	InvoiceStatusDraft         InvoiceStatus = "draft"
   212  	InvoiceStatusOpen          InvoiceStatus = "open"
   213  	InvoiceStatusPaid          InvoiceStatus = "paid"
   214  	InvoiceStatusUncollectible InvoiceStatus = "uncollectible"
   215  	InvoiceStatusVoid          InvoiceStatus = "void"
   216  )
   217  
   218  // The reasoning behind this tax, for example, if the product is tax exempt. The possible values for this field may be extended as new tax rules are supported.
   219  type InvoiceTotalTaxAmountTaxabilityReason string
   220  
   221  // List of values that InvoiceTotalTaxAmountTaxabilityReason can take
   222  const (
   223  	InvoiceTotalTaxAmountTaxabilityReasonCustomerExempt       InvoiceTotalTaxAmountTaxabilityReason = "customer_exempt"
   224  	InvoiceTotalTaxAmountTaxabilityReasonNotCollecting        InvoiceTotalTaxAmountTaxabilityReason = "not_collecting"
   225  	InvoiceTotalTaxAmountTaxabilityReasonNotSubjectToTax      InvoiceTotalTaxAmountTaxabilityReason = "not_subject_to_tax"
   226  	InvoiceTotalTaxAmountTaxabilityReasonNotSupported         InvoiceTotalTaxAmountTaxabilityReason = "not_supported"
   227  	InvoiceTotalTaxAmountTaxabilityReasonPortionProductExempt InvoiceTotalTaxAmountTaxabilityReason = "portion_product_exempt"
   228  	InvoiceTotalTaxAmountTaxabilityReasonPortionReducedRated  InvoiceTotalTaxAmountTaxabilityReason = "portion_reduced_rated"
   229  	InvoiceTotalTaxAmountTaxabilityReasonPortionStandardRated InvoiceTotalTaxAmountTaxabilityReason = "portion_standard_rated"
   230  	InvoiceTotalTaxAmountTaxabilityReasonProductExempt        InvoiceTotalTaxAmountTaxabilityReason = "product_exempt"
   231  	InvoiceTotalTaxAmountTaxabilityReasonProductExemptHoliday InvoiceTotalTaxAmountTaxabilityReason = "product_exempt_holiday"
   232  	InvoiceTotalTaxAmountTaxabilityReasonProportionallyRated  InvoiceTotalTaxAmountTaxabilityReason = "proportionally_rated"
   233  	InvoiceTotalTaxAmountTaxabilityReasonReducedRated         InvoiceTotalTaxAmountTaxabilityReason = "reduced_rated"
   234  	InvoiceTotalTaxAmountTaxabilityReasonReverseCharge        InvoiceTotalTaxAmountTaxabilityReason = "reverse_charge"
   235  	InvoiceTotalTaxAmountTaxabilityReasonStandardRated        InvoiceTotalTaxAmountTaxabilityReason = "standard_rated"
   236  	InvoiceTotalTaxAmountTaxabilityReasonTaxableBasisReduced  InvoiceTotalTaxAmountTaxabilityReason = "taxable_basis_reduced"
   237  	InvoiceTotalTaxAmountTaxabilityReasonZeroRated            InvoiceTotalTaxAmountTaxabilityReason = "zero_rated"
   238  )
   239  
   240  // 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).
   241  type InvoiceParams struct {
   242  	Params `form:"*"`
   243  	// The account tax IDs associated with the invoice. Only editable when the invoice is a draft.
   244  	AccountTaxIDs []*string `form:"account_tax_ids"`
   245  	// A fee in cents (or local equivalent) that will be applied to the invoice and transferred to the application owner's Stripe account. The request must be made with an OAuth key or the Stripe-Account header in order to take an application fee. For more information, see the application fees [documentation](https://stripe.com/docs/billing/invoices/connect#collecting-fees).
   246  	ApplicationFeeAmount *int64 `form:"application_fee_amount"`
   247  	// Controls whether Stripe performs [automatic collection](https://stripe.com/docs/invoicing/integration/automatic-advancement-collection) of the invoice. If `false`, the invoice's state doesn't automatically advance without an explicit action.
   248  	AutoAdvance *bool `form:"auto_advance"`
   249  	// Settings for automatic tax lookup for this invoice.
   250  	AutomaticTax *InvoiceAutomaticTaxParams `form:"automatic_tax"`
   251  	// Either `charge_automatically`, or `send_invoice`. When charging automatically, Stripe will attempt to pay this invoice using the default source attached to the customer. When sending an invoice, Stripe will email this invoice to the customer with payment instructions. Defaults to `charge_automatically`.
   252  	CollectionMethod *string `form:"collection_method"`
   253  	// The currency to create this invoice in. Defaults to that of `customer` if not specified.
   254  	Currency *string `form:"currency"`
   255  	// The ID of the customer who will be billed.
   256  	Customer *string `form:"customer"`
   257  	// A list of up to 4 custom fields to be displayed on the invoice. If a value for `custom_fields` is specified, the list specified will replace the existing custom field list on this invoice. Pass an empty string to remove previously-defined fields.
   258  	CustomFields []*InvoiceCustomFieldParams `form:"custom_fields"`
   259  	// The number of days from which the invoice is created until it is due. Only valid for invoices where `collection_method=send_invoice`. This field can only be updated on `draft` invoices.
   260  	DaysUntilDue *int64 `form:"days_until_due"`
   261  	// ID of the default payment method for the invoice. It must belong to the customer associated with the invoice. If not set, defaults to the subscription's default payment method, if any, or to the default payment method in the customer's invoice settings.
   262  	DefaultPaymentMethod *string `form:"default_payment_method"`
   263  	// ID of the default payment source for the invoice. It must belong to the customer associated with the invoice and be in a chargeable state. If not set, defaults to the subscription's default source, if any, or to the customer's default source.
   264  	DefaultSource *string `form:"default_source"`
   265  	// The tax rates that will apply to any line item that does not have `tax_rates` set. Pass an empty string to remove previously-defined tax rates.
   266  	DefaultTaxRates []*string `form:"default_tax_rates"`
   267  	// An arbitrary string attached to the object. Often useful for displaying to users. Referenced as 'memo' in the Dashboard.
   268  	Description *string `form:"description"`
   269  	// The coupons and promotion codes to redeem into discounts for the invoice. If not specified, inherits the discount from the invoice's customer. Pass an empty string to avoid inheriting any discounts.
   270  	Discounts []*InvoiceDiscountParams `form:"discounts"`
   271  	// The date on which payment for this invoice is due. Only valid for invoices where `collection_method=send_invoice`. This field can only be updated on `draft` invoices.
   272  	DueDate *int64 `form:"due_date"`
   273  	// The date when this invoice is in effect. Same as `finalized_at` unless overwritten. When defined, this value replaces the system-generated 'Date of issue' printed on the invoice PDF and receipt.
   274  	EffectiveAt *int64 `form:"effective_at"`
   275  	// Specifies which fields in the response should be expanded.
   276  	Expand []*string `form:"expand"`
   277  	// Footer to be displayed on the invoice.
   278  	Footer *string `form:"footer"`
   279  	// Revise an existing invoice. The new invoice will be created in `status=draft`. See the [revision documentation](https://stripe.com/docs/invoicing/invoice-revisions) for more details.
   280  	FromInvoice *InvoiceFromInvoiceParams `form:"from_invoice"`
   281  	// The connected account that issues the invoice. The invoice is presented with the branding and support information of the specified account.
   282  	Issuer *InvoiceIssuerParams `form:"issuer"`
   283  	// 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`.
   284  	Metadata map[string]string `form:"metadata"`
   285  	// Set the number for this invoice. If no number is present then a number will be assigned automatically when the invoice is finalized. In many markets, regulations require invoices to be unique, sequential and / or gapless. You are responsible for ensuring this is true across all your different invoicing systems in the event that you edit the invoice number using our API. If you use only Stripe for your invoices and do not change invoice numbers, Stripe handles this aspect of compliance for you automatically.
   286  	Number *string `form:"number"`
   287  	// The account (if any) for which the funds of the invoice payment are intended. If set, the invoice will be presented with the branding and support information of the specified account. See the [Invoices with Connect](https://stripe.com/docs/billing/invoices/connect) documentation for details.
   288  	OnBehalfOf *string `form:"on_behalf_of"`
   289  	// Configuration settings for the PaymentIntent that is generated when the invoice is finalized.
   290  	PaymentSettings *InvoicePaymentSettingsParams `form:"payment_settings"`
   291  	// How to handle pending invoice items on invoice creation. Defaults to `exclude` if the parameter is omitted.
   292  	PendingInvoiceItemsBehavior *string `form:"pending_invoice_items_behavior"`
   293  	// The rendering-related settings that control how the invoice is displayed on customer-facing surfaces such as PDF and Hosted Invoice Page.
   294  	Rendering *InvoiceRenderingParams `form:"rendering"`
   295  	// This is a legacy field that will be removed soon. For details about `rendering_options`, refer to `rendering` instead. Options for invoice PDF rendering.
   296  	RenderingOptions *InvoiceRenderingOptionsParams `form:"rendering_options"`
   297  	// Settings for the cost of shipping for this invoice.
   298  	ShippingCost *InvoiceShippingCostParams `form:"shipping_cost"`
   299  	// Shipping details for the invoice. The Invoice PDF will use the `shipping_details` value if it is set, otherwise the PDF will render the shipping address from the customer.
   300  	ShippingDetails *InvoiceShippingDetailsParams `form:"shipping_details"`
   301  	// Extra information about a charge for the customer's credit card statement. It must contain at least one letter. If not specified and this invoice is part of a subscription, the default `statement_descriptor` will be set to the first subscription item's product's `statement_descriptor`.
   302  	StatementDescriptor *string `form:"statement_descriptor"`
   303  	// The ID of the subscription to invoice, if any. If set, the created invoice will only include pending invoice items for that subscription. The subscription's billing cycle and regular subscription events won't be affected.
   304  	Subscription *string `form:"subscription"`
   305  	// If specified, the funds from the invoice will be transferred to the destination and the ID of the resulting transfer will be found on the invoice's charge. This will be unset if you POST an empty value.
   306  	TransferData *InvoiceTransferDataParams `form:"transfer_data"`
   307  }
   308  
   309  // AddExpand appends a new field to expand.
   310  func (p *InvoiceParams) AddExpand(f string) {
   311  	p.Expand = append(p.Expand, &f)
   312  }
   313  
   314  // AddMetadata adds a new key-value pair to the Metadata.
   315  func (p *InvoiceParams) AddMetadata(key string, value string) {
   316  	if p.Metadata == nil {
   317  		p.Metadata = make(map[string]string)
   318  	}
   319  
   320  	p.Metadata[key] = value
   321  }
   322  
   323  // The account that's liable for tax. If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. The tax transaction is returned in the report of the connected account.
   324  type InvoiceAutomaticTaxLiabilityParams struct {
   325  	// The connected account being referenced when `type` is `account`.
   326  	Account *string `form:"account"`
   327  	// Type of the account referenced in the request.
   328  	Type *string `form:"type"`
   329  }
   330  
   331  // Settings for automatic tax lookup for this invoice.
   332  type InvoiceAutomaticTaxParams struct {
   333  	// Whether Stripe automatically computes tax on this invoice. Note that incompatible invoice items (invoice items with manually specified [tax rates](https://stripe.com/docs/api/tax_rates), negative amounts, or `tax_behavior=unspecified`) cannot be added to automatic tax invoices.
   334  	Enabled *bool `form:"enabled"`
   335  	// The account that's liable for tax. If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. The tax transaction is returned in the report of the connected account.
   336  	Liability *InvoiceAutomaticTaxLiabilityParams `form:"liability"`
   337  }
   338  
   339  // A list of up to 4 custom fields to be displayed on the invoice. If a value for `custom_fields` is specified, the list specified will replace the existing custom field list on this invoice. Pass an empty string to remove previously-defined fields.
   340  type InvoiceCustomFieldParams struct {
   341  	// The name of the custom field. This may be up to 40 characters.
   342  	Name *string `form:"name"`
   343  	// The value of the custom field. This may be up to 140 characters.
   344  	Value *string `form:"value"`
   345  }
   346  
   347  // The discounts that will apply to the invoice. Pass an empty string to remove previously-defined discounts.
   348  type InvoiceDiscountParams struct {
   349  	// ID of the coupon to create a new discount for.
   350  	Coupon *string `form:"coupon"`
   351  	// ID of an existing discount on the object (or one of its ancestors) to reuse.
   352  	Discount *string `form:"discount"`
   353  	// ID of the promotion code to create a new discount for.
   354  	PromotionCode *string `form:"promotion_code"`
   355  }
   356  
   357  // The connected account that issues the invoice. The invoice is presented with the branding and support information of the specified account.
   358  type InvoiceIssuerParams struct {
   359  	// The connected account being referenced when `type` is `account`.
   360  	Account *string `form:"account"`
   361  	// Type of the account referenced in the request.
   362  	Type *string `form:"type"`
   363  }
   364  
   365  // Additional fields for Mandate creation
   366  type InvoicePaymentSettingsPaymentMethodOptionsACSSDebitMandateOptionsParams struct {
   367  	// Transaction type of the mandate.
   368  	TransactionType *string `form:"transaction_type"`
   369  }
   370  
   371  // If paying by `acss_debit`, this sub-hash contains details about the Canadian pre-authorized debit payment method options to pass to the invoice's PaymentIntent.
   372  type InvoicePaymentSettingsPaymentMethodOptionsACSSDebitParams struct {
   373  	// Additional fields for Mandate creation
   374  	MandateOptions *InvoicePaymentSettingsPaymentMethodOptionsACSSDebitMandateOptionsParams `form:"mandate_options"`
   375  	// Verification method for the intent
   376  	VerificationMethod *string `form:"verification_method"`
   377  }
   378  
   379  // If paying by `bancontact`, this sub-hash contains details about the Bancontact payment method options to pass to the invoice's PaymentIntent.
   380  type InvoicePaymentSettingsPaymentMethodOptionsBancontactParams struct {
   381  	// Preferred language of the Bancontact authorization page that the customer is redirected to.
   382  	PreferredLanguage *string `form:"preferred_language"`
   383  }
   384  
   385  // The selected installment plan to use for this invoice.
   386  type InvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanParams struct {
   387  	// For `fixed_count` installment plans, this is the number of installment payments your customer will make to their credit card.
   388  	Count *int64 `form:"count"`
   389  	// For `fixed_count` installment plans, this is the interval between installment payments your customer will make to their credit card.
   390  	// One of `month`.
   391  	Interval *string `form:"interval"`
   392  	// Type of installment plan, one of `fixed_count`.
   393  	Type *string `form:"type"`
   394  }
   395  
   396  // Installment configuration for payments attempted on this invoice (Mexico Only).
   397  //
   398  // For more information, see the [installments integration guide](https://stripe.com/docs/payments/installments).
   399  type InvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsParams struct {
   400  	// Setting to true enables installments for this invoice.
   401  	// Setting to false will prevent any selected plan from applying to a payment.
   402  	Enabled *bool `form:"enabled"`
   403  	// The selected installment plan to use for this invoice.
   404  	Plan *InvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanParams `form:"plan"`
   405  }
   406  
   407  // If paying by `card`, this sub-hash contains details about the Card payment method options to pass to the invoice's PaymentIntent.
   408  type InvoicePaymentSettingsPaymentMethodOptionsCardParams struct {
   409  	// Installment configuration for payments attempted on this invoice (Mexico Only).
   410  	//
   411  	// For more information, see the [installments integration guide](https://stripe.com/docs/payments/installments).
   412  	Installments *InvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsParams `form:"installments"`
   413  	// We strongly recommend that you rely on our SCA Engine to automatically prompt your customers for authentication based on risk level and [other requirements](https://stripe.com/docs/strong-customer-authentication). However, if you wish to request 3D Secure based on logic from your own fraud engine, provide this option. Read our guide on [manually requesting 3D Secure](https://stripe.com/docs/payments/3d-secure/authentication-flow#manual-three-ds) for more information on how this configuration interacts with Radar and our SCA Engine.
   414  	RequestThreeDSecure *string `form:"request_three_d_secure"`
   415  }
   416  
   417  // Configuration for eu_bank_transfer funding type.
   418  type InvoicePaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferEUBankTransferParams struct {
   419  	// The desired country code of the bank account information. Permitted values include: `BE`, `DE`, `ES`, `FR`, `IE`, or `NL`.
   420  	Country *string `form:"country"`
   421  }
   422  
   423  // Configuration for the bank transfer funding type, if the `funding_type` is set to `bank_transfer`.
   424  type InvoicePaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferParams struct {
   425  	// Configuration for eu_bank_transfer funding type.
   426  	EUBankTransfer *InvoicePaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferEUBankTransferParams `form:"eu_bank_transfer"`
   427  	// The bank transfer type that can be used for funding. Permitted values include: `eu_bank_transfer`, `gb_bank_transfer`, `jp_bank_transfer`, `mx_bank_transfer`, or `us_bank_transfer`.
   428  	Type *string `form:"type"`
   429  }
   430  
   431  // If paying by `customer_balance`, this sub-hash contains details about the Bank transfer payment method options to pass to the invoice's PaymentIntent.
   432  type InvoicePaymentSettingsPaymentMethodOptionsCustomerBalanceParams struct {
   433  	// Configuration for the bank transfer funding type, if the `funding_type` is set to `bank_transfer`.
   434  	BankTransfer *InvoicePaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferParams `form:"bank_transfer"`
   435  	// The funding method type to be used when there are not enough funds in the customer balance. Permitted values include: `bank_transfer`.
   436  	FundingType *string `form:"funding_type"`
   437  }
   438  
   439  // If paying by `konbini`, this sub-hash contains details about the Konbini payment method options to pass to the invoice's PaymentIntent.
   440  type InvoicePaymentSettingsPaymentMethodOptionsKonbiniParams struct{}
   441  
   442  // If paying by `sepa_debit`, this sub-hash contains details about the SEPA Direct Debit payment method options to pass to the invoice's PaymentIntent.
   443  type InvoicePaymentSettingsPaymentMethodOptionsSEPADebitParams struct{}
   444  
   445  // Additional fields for Financial Connections Session creation
   446  type InvoicePaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsParams struct {
   447  	// The list of permissions to request. If this parameter is passed, the `payment_method` permission must be included. Valid permissions include: `balances`, `ownership`, `payment_method`, and `transactions`.
   448  	Permissions []*string `form:"permissions"`
   449  	// List of data features that you would like to retrieve upon account creation.
   450  	Prefetch []*string `form:"prefetch"`
   451  }
   452  
   453  // If paying by `us_bank_account`, this sub-hash contains details about the ACH direct debit payment method options to pass to the invoice's PaymentIntent.
   454  type InvoicePaymentSettingsPaymentMethodOptionsUSBankAccountParams struct {
   455  	// Additional fields for Financial Connections Session creation
   456  	FinancialConnections *InvoicePaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsParams `form:"financial_connections"`
   457  	// Verification method for the intent
   458  	VerificationMethod *string `form:"verification_method"`
   459  }
   460  
   461  // Payment-method-specific configuration to provide to the invoice's PaymentIntent.
   462  type InvoicePaymentSettingsPaymentMethodOptionsParams struct {
   463  	// If paying by `acss_debit`, this sub-hash contains details about the Canadian pre-authorized debit payment method options to pass to the invoice's PaymentIntent.
   464  	ACSSDebit *InvoicePaymentSettingsPaymentMethodOptionsACSSDebitParams `form:"acss_debit"`
   465  	// If paying by `bancontact`, this sub-hash contains details about the Bancontact payment method options to pass to the invoice's PaymentIntent.
   466  	Bancontact *InvoicePaymentSettingsPaymentMethodOptionsBancontactParams `form:"bancontact"`
   467  	// If paying by `card`, this sub-hash contains details about the Card payment method options to pass to the invoice's PaymentIntent.
   468  	Card *InvoicePaymentSettingsPaymentMethodOptionsCardParams `form:"card"`
   469  	// If paying by `customer_balance`, this sub-hash contains details about the Bank transfer payment method options to pass to the invoice's PaymentIntent.
   470  	CustomerBalance *InvoicePaymentSettingsPaymentMethodOptionsCustomerBalanceParams `form:"customer_balance"`
   471  	// If paying by `konbini`, this sub-hash contains details about the Konbini payment method options to pass to the invoice's PaymentIntent.
   472  	Konbini *InvoicePaymentSettingsPaymentMethodOptionsKonbiniParams `form:"konbini"`
   473  	// If paying by `sepa_debit`, this sub-hash contains details about the SEPA Direct Debit payment method options to pass to the invoice's PaymentIntent.
   474  	SEPADebit *InvoicePaymentSettingsPaymentMethodOptionsSEPADebitParams `form:"sepa_debit"`
   475  	// If paying by `us_bank_account`, this sub-hash contains details about the ACH direct debit payment method options to pass to the invoice's PaymentIntent.
   476  	USBankAccount *InvoicePaymentSettingsPaymentMethodOptionsUSBankAccountParams `form:"us_bank_account"`
   477  }
   478  
   479  // Configuration settings for the PaymentIntent that is generated when the invoice is finalized.
   480  type InvoicePaymentSettingsParams struct {
   481  	// ID of the mandate to be used for this invoice. It must correspond to the payment method used to pay the invoice, including the invoice's default_payment_method or default_source, if set.
   482  	DefaultMandate *string `form:"default_mandate"`
   483  	// Payment-method-specific configuration to provide to the invoice's PaymentIntent.
   484  	PaymentMethodOptions *InvoicePaymentSettingsPaymentMethodOptionsParams `form:"payment_method_options"`
   485  	// The list of payment method types (e.g. card) to provide to the invoice's PaymentIntent. If not set, Stripe attempts to automatically determine the types to use by looking at the invoice's default payment method, the subscription's default payment method, the customer's default payment method, and your [invoice template settings](https://dashboard.stripe.com/settings/billing/invoice).
   486  	PaymentMethodTypes []*string `form:"payment_method_types"`
   487  }
   488  
   489  // Invoice pdf rendering options
   490  type InvoiceRenderingPDFParams struct {
   491  	// Page size for invoice PDF. Can be set to `a4`, `letter`, or `auto`.
   492  	//  If set to `auto`, invoice PDF page size defaults to `a4` for customers with
   493  	//  Japanese locale and `letter` for customers with other locales.
   494  	PageSize *string `form:"page_size"`
   495  }
   496  
   497  // The rendering-related settings that control how the invoice is displayed on customer-facing surfaces such as PDF and Hosted Invoice Page.
   498  type InvoiceRenderingParams struct {
   499  	// How line-item prices and amounts will be displayed with respect to tax on invoice PDFs. One of `exclude_tax` or `include_inclusive_tax`. `include_inclusive_tax` will include inclusive tax (and exclude exclusive tax) in invoice PDF amounts. `exclude_tax` will exclude all tax (inclusive and exclusive alike) from invoice PDF amounts.
   500  	AmountTaxDisplay *string `form:"amount_tax_display"`
   501  	// Invoice pdf rendering options
   502  	PDF *InvoiceRenderingPDFParams `form:"pdf"`
   503  }
   504  
   505  // This is a legacy field that will be removed soon. For details about `rendering_options`, refer to `rendering` instead. Options for invoice PDF rendering.
   506  type InvoiceRenderingOptionsParams struct {
   507  	// How line-item prices and amounts will be displayed with respect to tax on invoice PDFs. One of `exclude_tax` or `include_inclusive_tax`. `include_inclusive_tax` will include inclusive tax (and exclude exclusive tax) in invoice PDF amounts. `exclude_tax` will exclude all tax (inclusive and exclusive alike) from invoice PDF amounts.
   508  	AmountTaxDisplay *string `form:"amount_tax_display"`
   509  }
   510  
   511  // The upper bound of the estimated range. If empty, represents no upper bound i.e., infinite.
   512  type InvoiceShippingCostShippingRateDataDeliveryEstimateMaximumParams struct {
   513  	// A unit of time.
   514  	Unit *string `form:"unit"`
   515  	// Must be greater than 0.
   516  	Value *int64 `form:"value"`
   517  }
   518  
   519  // The lower bound of the estimated range. If empty, represents no lower bound.
   520  type InvoiceShippingCostShippingRateDataDeliveryEstimateMinimumParams struct {
   521  	// A unit of time.
   522  	Unit *string `form:"unit"`
   523  	// Must be greater than 0.
   524  	Value *int64 `form:"value"`
   525  }
   526  
   527  // The estimated range for how long shipping will take, meant to be displayable to the customer. This will appear on CheckoutSessions.
   528  type InvoiceShippingCostShippingRateDataDeliveryEstimateParams struct {
   529  	// The upper bound of the estimated range. If empty, represents no upper bound i.e., infinite.
   530  	Maximum *InvoiceShippingCostShippingRateDataDeliveryEstimateMaximumParams `form:"maximum"`
   531  	// The lower bound of the estimated range. If empty, represents no lower bound.
   532  	Minimum *InvoiceShippingCostShippingRateDataDeliveryEstimateMinimumParams `form:"minimum"`
   533  }
   534  
   535  // Shipping rates defined in each available currency option. Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies).
   536  type InvoiceShippingCostShippingRateDataFixedAmountCurrencyOptionsParams struct {
   537  	// A non-negative integer in cents representing how much to charge.
   538  	Amount *int64 `form:"amount"`
   539  	// Specifies whether the rate is considered inclusive of taxes or exclusive of taxes. One of `inclusive`, `exclusive`, or `unspecified`.
   540  	TaxBehavior *string `form:"tax_behavior"`
   541  }
   542  
   543  // Describes a fixed amount to charge for shipping. Must be present if type is `fixed_amount`.
   544  type InvoiceShippingCostShippingRateDataFixedAmountParams struct {
   545  	// A non-negative integer in cents representing how much to charge.
   546  	Amount *int64 `form:"amount"`
   547  	// 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).
   548  	Currency *string `form:"currency"`
   549  	// Shipping rates defined in each available currency option. Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies).
   550  	CurrencyOptions map[string]*InvoiceShippingCostShippingRateDataFixedAmountCurrencyOptionsParams `form:"currency_options"`
   551  }
   552  
   553  // Parameters to create a new ad-hoc shipping rate for this order.
   554  type InvoiceShippingCostShippingRateDataParams struct {
   555  	// The estimated range for how long shipping will take, meant to be displayable to the customer. This will appear on CheckoutSessions.
   556  	DeliveryEstimate *InvoiceShippingCostShippingRateDataDeliveryEstimateParams `form:"delivery_estimate"`
   557  	// The name of the shipping rate, meant to be displayable to the customer. This will appear on CheckoutSessions.
   558  	DisplayName *string `form:"display_name"`
   559  	// Describes a fixed amount to charge for shipping. Must be present if type is `fixed_amount`.
   560  	FixedAmount *InvoiceShippingCostShippingRateDataFixedAmountParams `form:"fixed_amount"`
   561  	// 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`.
   562  	Metadata map[string]string `form:"metadata"`
   563  	// Specifies whether the rate is considered inclusive of taxes or exclusive of taxes. One of `inclusive`, `exclusive`, or `unspecified`.
   564  	TaxBehavior *string `form:"tax_behavior"`
   565  	// A [tax code](https://stripe.com/docs/tax/tax-categories) ID. The Shipping tax code is `txcd_92010001`.
   566  	TaxCode *string `form:"tax_code"`
   567  	// The type of calculation to use on the shipping rate. Can only be `fixed_amount` for now.
   568  	Type *string `form:"type"`
   569  }
   570  
   571  // AddMetadata adds a new key-value pair to the Metadata.
   572  func (p *InvoiceShippingCostShippingRateDataParams) AddMetadata(key string, value string) {
   573  	if p.Metadata == nil {
   574  		p.Metadata = make(map[string]string)
   575  	}
   576  
   577  	p.Metadata[key] = value
   578  }
   579  
   580  // Settings for the cost of shipping for this invoice.
   581  type InvoiceShippingCostParams struct {
   582  	// The ID of the shipping rate to use for this order.
   583  	ShippingRate *string `form:"shipping_rate"`
   584  	// Parameters to create a new ad-hoc shipping rate for this order.
   585  	ShippingRateData *InvoiceShippingCostShippingRateDataParams `form:"shipping_rate_data"`
   586  }
   587  
   588  // Shipping details for the invoice. The Invoice PDF will use the `shipping_details` value if it is set, otherwise the PDF will render the shipping address from the customer.
   589  type InvoiceShippingDetailsParams struct {
   590  	// Shipping address
   591  	Address *AddressParams `form:"address"`
   592  	// Recipient name.
   593  	Name *string `form:"name"`
   594  	// Recipient phone (including extension)
   595  	Phone *string `form:"phone"`
   596  }
   597  
   598  // If specified, the funds from the invoice will be transferred to the destination and the ID of the resulting transfer will be found on the invoice's charge. This will be unset if you POST an empty value.
   599  type InvoiceTransferDataParams struct {
   600  	// The amount that will be transferred automatically when the invoice is paid. If no amount is set, the full amount is transferred.
   601  	Amount *int64 `form:"amount"`
   602  	// ID of an existing, connected Stripe account.
   603  	Destination *string `form:"destination"`
   604  }
   605  
   606  // 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.
   607  type InvoiceListParams struct {
   608  	ListParams `form:"*"`
   609  	// The collection method of the invoice to retrieve. Either `charge_automatically` or `send_invoice`.
   610  	CollectionMethod *string `form:"collection_method"`
   611  	// Only return invoices that were created during the given date interval.
   612  	Created *int64 `form:"created"`
   613  	// Only return invoices that were created during the given date interval.
   614  	CreatedRange *RangeQueryParams `form:"created"`
   615  	// Only return invoices for the customer specified by this customer ID.
   616  	Customer     *string           `form:"customer"`
   617  	DueDate      *int64            `form:"due_date"`
   618  	DueDateRange *RangeQueryParams `form:"due_date"`
   619  	// Specifies which fields in the response should be expanded.
   620  	Expand []*string `form:"expand"`
   621  	// The status of the invoice, one of `draft`, `open`, `paid`, `uncollectible`, or `void`. [Learn more](https://stripe.com/docs/billing/invoices/workflow#workflow-overview)
   622  	Status *string `form:"status"`
   623  	// Only return invoices for the subscription specified by this subscription ID.
   624  	Subscription *string `form:"subscription"`
   625  }
   626  
   627  // AddExpand appends a new field to expand.
   628  func (p *InvoiceListParams) AddExpand(f string) {
   629  	p.Expand = append(p.Expand, &f)
   630  }
   631  
   632  // Revise an existing invoice. The new invoice will be created in `status=draft`. See the [revision documentation](https://stripe.com/docs/invoicing/invoice-revisions) for more details.
   633  type InvoiceFromInvoiceParams struct {
   634  	// The relation between the new invoice and the original invoice. Currently, only 'revision' is permitted
   635  	Action *string `form:"action"`
   636  	// The `id` of the invoice that will be cloned.
   637  	Invoice *string `form:"invoice"`
   638  }
   639  
   640  // Search for invoices you've previously created using Stripe's [Search Query Language](https://stripe.com/docs/search#search-query-language).
   641  // Don't use search in read-after-write flows where strict consistency is necessary. Under normal operating
   642  // conditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up
   643  // to an hour behind during outages. Search functionality is not available to merchants in India.
   644  type InvoiceSearchParams struct {
   645  	SearchParams `form:"*"`
   646  	// Specifies which fields in the response should be expanded.
   647  	Expand []*string `form:"expand"`
   648  	// A cursor for pagination across multiple pages of results. Don't include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results.
   649  	Page *string `form:"page"`
   650  }
   651  
   652  // AddExpand appends a new field to expand.
   653  func (p *InvoiceSearchParams) AddExpand(f string) {
   654  	p.Expand = append(p.Expand, &f)
   655  }
   656  
   657  type InvoiceUpcomingAutomaticTaxParams struct {
   658  	Enabled *bool `form:"enabled"`
   659  }
   660  
   661  // The customer's shipping information. Appears on invoices emailed to this customer.
   662  type InvoiceUpcomingCustomerDetailsShippingParams struct {
   663  	// Customer shipping address.
   664  	Address *AddressParams `form:"address"`
   665  	// Customer name.
   666  	Name *string `form:"name"`
   667  	// Customer phone (including extension).
   668  	Phone *string `form:"phone"`
   669  }
   670  
   671  // Tax details about the customer.
   672  type InvoiceUpcomingCustomerDetailsTaxParams struct {
   673  	// A recent IP address of the customer used for tax reporting and tax location inference. Stripe recommends updating the IP address when a new PaymentMethod is attached or the address field on the customer is updated. We recommend against updating this field more frequently since it could result in unexpected tax location/reporting outcomes.
   674  	IPAddress *string `form:"ip_address"`
   675  }
   676  
   677  // The customer's tax IDs.
   678  type InvoiceUpcomingCustomerDetailsTaxIDParams struct {
   679  	// Type of the tax ID, one of `ad_nrt`, `ae_trn`, `ar_cuit`, `au_abn`, `au_arn`, `bg_uic`, `bo_tin`, `br_cnpj`, `br_cpf`, `ca_bn`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `ca_qst`, `ch_vat`, `cl_tin`, `cn_tin`, `co_nit`, `cr_tin`, `do_rcn`, `ec_ruc`, `eg_tin`, `es_cif`, `eu_oss_vat`, `eu_vat`, `gb_vat`, `ge_vat`, `hk_br`, `hu_tin`, `id_npwp`, `il_vat`, `in_gst`, `is_vat`, `jp_cn`, `jp_rn`, `jp_trn`, `ke_pin`, `kr_brn`, `li_uid`, `mx_rfc`, `my_frp`, `my_itn`, `my_sst`, `no_vat`, `no_voec`, `nz_gst`, `pe_ruc`, `ph_tin`, `ro_tin`, `rs_pib`, `ru_inn`, `ru_kpp`, `sa_vat`, `sg_gst`, `sg_uen`, `si_tin`, `sv_nit`, `th_vat`, `tr_tin`, `tw_vat`, `ua_vat`, `us_ein`, `uy_ruc`, `ve_rif`, `vn_tin`, or `za_vat`
   680  	Type *string `form:"type"`
   681  	// Value of the tax ID.
   682  	Value *string `form:"value"`
   683  }
   684  
   685  // Details about the customer you want to invoice or overrides for an existing customer. If `automatic_tax` is enabled then one of `customer`, `customer_details`, `subscription`, or `schedule` must be set.
   686  type InvoiceUpcomingCustomerDetailsParams struct {
   687  	// The customer's address.
   688  	Address *AddressParams `form:"address"`
   689  	// The customer's shipping information. Appears on invoices emailed to this customer.
   690  	Shipping *InvoiceUpcomingCustomerDetailsShippingParams `form:"shipping"`
   691  	// Tax details about the customer.
   692  	Tax *InvoiceUpcomingCustomerDetailsTaxParams `form:"tax"`
   693  	// The customer's tax exemption. One of `none`, `exempt`, or `reverse`.
   694  	TaxExempt *string `form:"tax_exempt"`
   695  	// The customer's tax IDs.
   696  	TaxIDs []*InvoiceUpcomingCustomerDetailsTaxIDParams `form:"tax_ids"`
   697  }
   698  
   699  // 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.
   700  type InvoiceUpcomingInvoiceItemPeriodParams struct {
   701  	// The end of the period, which must be greater than or equal to the start. This value is inclusive.
   702  	End *int64 `form:"end"`
   703  	// The start of the period. This value is inclusive.
   704  	Start *int64 `form:"start"`
   705  }
   706  
   707  // List of invoice items to add or update in the upcoming invoice preview.
   708  type InvoiceUpcomingInvoiceItemParams struct {
   709  	// The integer amount in cents (or local equivalent) of previewed invoice item.
   710  	Amount *int64 `form:"amount"`
   711  	// 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). Only applicable to new invoice items.
   712  	Currency *string `form:"currency"`
   713  	// An arbitrary string which you can attach to the invoice item. The description is displayed in the invoice for easy tracking.
   714  	Description *string `form:"description"`
   715  	// Explicitly controls whether discounts apply to this invoice item. Defaults to true, except for negative invoice items.
   716  	Discountable *bool `form:"discountable"`
   717  	// The coupons to redeem into discounts for the invoice item in the preview.
   718  	Discounts []*InvoiceItemDiscountParams `form:"discounts"`
   719  	// The ID of the invoice item to update in preview. If not specified, a new invoice item will be added to the preview of the upcoming invoice.
   720  	InvoiceItem *string `form:"invoiceitem"`
   721  	// 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`.
   722  	Metadata map[string]string `form:"metadata"`
   723  	// 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.
   724  	Period *InvoiceUpcomingInvoiceItemPeriodParams `form:"period"`
   725  	// The ID of the price object.
   726  	Price *string `form:"price"`
   727  	// Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline.
   728  	PriceData *InvoiceItemPriceDataParams `form:"price_data"`
   729  	// Non-negative integer. The quantity of units for the invoice item.
   730  	Quantity *int64 `form:"quantity"`
   731  	// 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.
   732  	TaxBehavior *string `form:"tax_behavior"`
   733  	// A [tax code](https://stripe.com/docs/tax/tax-categories) ID.
   734  	TaxCode *string `form:"tax_code"`
   735  	// The tax rates that apply to the item. When set, any `default_tax_rates` do not apply to this item.
   736  	TaxRates []*string `form:"tax_rates"`
   737  	// The integer unit amount in cents (or local equivalent) of the charge to be applied to the upcoming invoice. This unit_amount will be multiplied by the quantity to get the full amount. If you want to apply a credit to the customer's account, pass a negative unit_amount.
   738  	UnitAmount *int64 `form:"unit_amount"`
   739  	// 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.
   740  	UnitAmountDecimal *float64 `form:"unit_amount_decimal,high_precision"`
   741  }
   742  
   743  // AddMetadata adds a new key-value pair to the Metadata.
   744  func (p *InvoiceUpcomingInvoiceItemParams) AddMetadata(key string, value string) {
   745  	if p.Metadata == nil {
   746  		p.Metadata = make(map[string]string)
   747  	}
   748  
   749  	p.Metadata[key] = value
   750  }
   751  
   752  // The connected account that issues the invoice. The invoice is presented with the branding and support information of the specified account.
   753  type InvoiceUpcomingIssuerParams struct {
   754  	// The connected account being referenced when `type` is `account`.
   755  	Account *string `form:"account"`
   756  	// Type of the account referenced in the request.
   757  	Type *string `form:"type"`
   758  }
   759  
   760  // 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.
   761  //
   762  // 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.
   763  //
   764  // 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_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_proration_date value passed in the request.
   765  type InvoiceUpcomingParams struct {
   766  	Params `form:"*"`
   767  	// Settings for automatic tax lookup for this invoice preview.
   768  	AutomaticTax *InvoiceAutomaticTaxParams `form:"automatic_tax"`
   769  	// The ID of the coupon to apply to this phase of the subscription schedule. This field has been deprecated and will be removed in a future API version. Use `discounts` instead.
   770  	Coupon *string `form:"coupon"`
   771  	// The currency to preview this invoice in. Defaults to that of `customer` if not specified.
   772  	Currency *string `form:"currency"`
   773  	// The identifier of the customer whose upcoming invoice you'd like to retrieve. If `automatic_tax` is enabled then one of `customer`, `customer_details`, `subscription`, or `schedule` must be set.
   774  	Customer *string `form:"customer"`
   775  	// Details about the customer you want to invoice or overrides for an existing customer. If `automatic_tax` is enabled then one of `customer`, `customer_details`, `subscription`, or `schedule` must be set.
   776  	CustomerDetails *InvoiceUpcomingCustomerDetailsParams `form:"customer_details"`
   777  	// The coupons to redeem into discounts for the invoice preview. If not specified, inherits the discount from the subscription or customer. This works for both coupons directly applied to an invoice and coupons applied to a subscription. Pass an empty string to avoid inheriting any discounts.
   778  	Discounts []*InvoiceDiscountParams `form:"discounts"`
   779  	// Specifies which fields in the response should be expanded.
   780  	Expand []*string `form:"expand"`
   781  	// List of invoice items to add or update in the upcoming invoice preview.
   782  	InvoiceItems []*InvoiceUpcomingInvoiceItemParams `form:"invoice_items"`
   783  	// The connected account that issues the invoice. The invoice is presented with the branding and support information of the specified account.
   784  	Issuer *InvoiceUpcomingIssuerParams `form:"issuer"`
   785  	// The account (if any) for which the funds of the invoice payment are intended. If set, the invoice will be presented with the branding and support information of the specified account. See the [Invoices with Connect](https://stripe.com/docs/billing/invoices/connect) documentation for details.
   786  	OnBehalfOf *string `form:"on_behalf_of"`
   787  	// The identifier of the schedule whose upcoming invoice you'd like to retrieve. Cannot be used with subscription or subscription fields.
   788  	Schedule *string `form:"schedule"`
   789  	// The identifier of the subscription for which you'd like to retrieve the upcoming invoice. If not provided, but a `subscription_items` is provided, you will preview creating a subscription with those items. If neither `subscription` nor `subscription_items` is provided, you will retrieve the next upcoming invoice from among the customer's subscriptions.
   790  	Subscription *string `form:"subscription"`
   791  	// For new subscriptions, a future timestamp to anchor the subscription's [billing cycle](https://stripe.com/docs/subscriptions/billing-cycle). This is used to determine the date of the first full invoice, and, for plans with `month` or `year` intervals, the day of the month for subsequent invoices. For existing subscriptions, the value can only be set to `now` or `unchanged`.
   792  	SubscriptionBillingCycleAnchor          *int64 `form:"subscription_billing_cycle_anchor"`
   793  	SubscriptionBillingCycleAnchorNow       *bool  `form:"-"` // See custom AppendTo
   794  	SubscriptionBillingCycleAnchorUnchanged *bool  `form:"-"` // See custom AppendTo
   795  	// A timestamp at which the subscription should cancel. If set to a date before the current period ends, this will cause a proration if prorations have been enabled using `proration_behavior`. If set during a future period, this will always cause a proration for that period.
   796  	SubscriptionCancelAt *int64 `form:"subscription_cancel_at"`
   797  	// Boolean indicating whether this subscription should cancel at the end of the current period.
   798  	SubscriptionCancelAtPeriodEnd *bool `form:"subscription_cancel_at_period_end"`
   799  	// This simulates the subscription being canceled or expired immediately.
   800  	SubscriptionCancelNow *bool `form:"subscription_cancel_now"`
   801  	// If provided, the invoice returned will preview updating or creating a subscription with these default tax rates. The default tax rates will apply to any line item that does not have `tax_rates` set.
   802  	SubscriptionDefaultTaxRates []*string `form:"subscription_default_tax_rates"`
   803  	// A list of up to 20 subscription items, each with an attached price.
   804  	SubscriptionItems []*SubscriptionItemsParams `form:"subscription_items"`
   805  	// Determines how to handle [prorations](https://stripe.com/docs/billing/subscriptions/prorations) when the billing cycle changes (e.g., when switching plans, resetting `billing_cycle_anchor=now`, or starting a trial), or if an item's `quantity` changes. The default value is `create_prorations`.
   806  	SubscriptionProrationBehavior *string `form:"subscription_proration_behavior"`
   807  	// If previewing an update to a subscription, and doing proration, `subscription_proration_date` forces the proration to be calculated as though the update was done at the specified time. The time given must be within the current subscription period and within the current phase of the schedule backing this subscription, if the schedule exists. If set, `subscription`, and one of `subscription_items`, or `subscription_trial_end` are required. Also, `subscription_proration_behavior` cannot be set to 'none'.
   808  	SubscriptionProrationDate *int64 `form:"subscription_proration_date"`
   809  	// For paused subscriptions, setting `subscription_resume_at` to `now` will preview the invoice that will be generated if the subscription is resumed.
   810  	SubscriptionResumeAt *string `form:"subscription_resume_at"`
   811  	// Date a subscription is intended to start (can be future or past).
   812  	SubscriptionStartDate *int64 `form:"subscription_start_date"`
   813  	// If provided, the invoice returned will preview updating or creating a subscription with that trial end. If set, one of `subscription_items` or `subscription` is required.
   814  	SubscriptionTrialEnd    *int64 `form:"subscription_trial_end"`
   815  	SubscriptionTrialEndNow *bool  `form:"-"` // See custom AppendTo
   816  	// Indicates if a plan's `trial_period_days` should be applied to the subscription. Setting `subscription_trial_end` per subscription is preferred, and this defaults to `false`. Setting this flag to `true` together with `subscription_trial_end` is not allowed. See [Using trial periods on subscriptions](https://stripe.com/docs/billing/subscriptions/trials) to learn more.
   817  	SubscriptionTrialFromPlan *bool `form:"subscription_trial_from_plan"`
   818  }
   819  
   820  // AddExpand appends a new field to expand.
   821  func (p *InvoiceUpcomingParams) AddExpand(f string) {
   822  	p.Expand = append(p.Expand, &f)
   823  }
   824  
   825  // AppendTo implements custom encoding logic for InvoiceUpcomingParams.
   826  func (p *InvoiceUpcomingParams) AppendTo(body *form.Values, keyParts []string) {
   827  	if BoolValue(p.SubscriptionBillingCycleAnchorNow) {
   828  		body.Add(form.FormatKey(append(keyParts, "subscription_billing_cycle_anchor")), "now")
   829  	}
   830  	if BoolValue(p.SubscriptionBillingCycleAnchorUnchanged) {
   831  		body.Add(form.FormatKey(append(keyParts, "subscription_billing_cycle_anchor")), "unchanged")
   832  	}
   833  	if BoolValue(p.SubscriptionTrialEndNow) {
   834  		body.Add(form.FormatKey(append(keyParts, "subscription_trial_end")), "now")
   835  	}
   836  }
   837  
   838  // The account that's liable for tax. If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. The tax transaction is returned in the report of the connected account.
   839  type InvoiceUpcomingLinesAutomaticTaxLiabilityParams struct {
   840  	// The connected account being referenced when `type` is `account`.
   841  	Account *string `form:"account"`
   842  	// Type of the account referenced in the request.
   843  	Type *string `form:"type"`
   844  }
   845  
   846  // Settings for automatic tax lookup for this invoice preview.
   847  type InvoiceUpcomingLinesAutomaticTaxParams struct {
   848  	// Whether Stripe automatically computes tax on this invoice. Note that incompatible invoice items (invoice items with manually specified [tax rates](https://stripe.com/docs/api/tax_rates), negative amounts, or `tax_behavior=unspecified`) cannot be added to automatic tax invoices.
   849  	Enabled *bool `form:"enabled"`
   850  	// The account that's liable for tax. If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. The tax transaction is returned in the report of the connected account.
   851  	Liability *InvoiceUpcomingLinesAutomaticTaxLiabilityParams `form:"liability"`
   852  }
   853  
   854  // The customer's shipping information. Appears on invoices emailed to this customer.
   855  type InvoiceUpcomingLinesCustomerDetailsShippingParams struct {
   856  	// Customer shipping address.
   857  	Address *AddressParams `form:"address"`
   858  	// Customer name.
   859  	Name *string `form:"name"`
   860  	// Customer phone (including extension).
   861  	Phone *string `form:"phone"`
   862  }
   863  
   864  // Tax details about the customer.
   865  type InvoiceUpcomingLinesCustomerDetailsTaxParams struct {
   866  	// A recent IP address of the customer used for tax reporting and tax location inference. Stripe recommends updating the IP address when a new PaymentMethod is attached or the address field on the customer is updated. We recommend against updating this field more frequently since it could result in unexpected tax location/reporting outcomes.
   867  	IPAddress *string `form:"ip_address"`
   868  }
   869  
   870  // The customer's tax IDs.
   871  type InvoiceUpcomingLinesCustomerDetailsTaxIDParams struct {
   872  	// Type of the tax ID, one of `ad_nrt`, `ae_trn`, `ar_cuit`, `au_abn`, `au_arn`, `bg_uic`, `bo_tin`, `br_cnpj`, `br_cpf`, `ca_bn`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `ca_qst`, `ch_vat`, `cl_tin`, `cn_tin`, `co_nit`, `cr_tin`, `do_rcn`, `ec_ruc`, `eg_tin`, `es_cif`, `eu_oss_vat`, `eu_vat`, `gb_vat`, `ge_vat`, `hk_br`, `hu_tin`, `id_npwp`, `il_vat`, `in_gst`, `is_vat`, `jp_cn`, `jp_rn`, `jp_trn`, `ke_pin`, `kr_brn`, `li_uid`, `mx_rfc`, `my_frp`, `my_itn`, `my_sst`, `no_vat`, `no_voec`, `nz_gst`, `pe_ruc`, `ph_tin`, `ro_tin`, `rs_pib`, `ru_inn`, `ru_kpp`, `sa_vat`, `sg_gst`, `sg_uen`, `si_tin`, `sv_nit`, `th_vat`, `tr_tin`, `tw_vat`, `ua_vat`, `us_ein`, `uy_ruc`, `ve_rif`, `vn_tin`, or `za_vat`
   873  	Type *string `form:"type"`
   874  	// Value of the tax ID.
   875  	Value *string `form:"value"`
   876  }
   877  
   878  // Details about the customer you want to invoice or overrides for an existing customer. If `automatic_tax` is enabled then one of `customer`, `customer_details`, `subscription`, or `schedule` must be set.
   879  type InvoiceUpcomingLinesCustomerDetailsParams struct {
   880  	// The customer's address.
   881  	Address *AddressParams `form:"address"`
   882  	// The customer's shipping information. Appears on invoices emailed to this customer.
   883  	Shipping *InvoiceUpcomingLinesCustomerDetailsShippingParams `form:"shipping"`
   884  	// Tax details about the customer.
   885  	Tax *InvoiceUpcomingLinesCustomerDetailsTaxParams `form:"tax"`
   886  	// The customer's tax exemption. One of `none`, `exempt`, or `reverse`.
   887  	TaxExempt *string `form:"tax_exempt"`
   888  	// The customer's tax IDs.
   889  	TaxIDs []*InvoiceUpcomingLinesCustomerDetailsTaxIDParams `form:"tax_ids"`
   890  }
   891  
   892  // The coupons to redeem into discounts for the invoice preview. If not specified, inherits the discount from the subscription or customer. This works for both coupons directly applied to an invoice and coupons applied to a subscription. Pass an empty string to avoid inheriting any discounts.
   893  type InvoiceUpcomingLinesDiscountParams struct {
   894  	// ID of the coupon to create a new discount for.
   895  	Coupon *string `form:"coupon"`
   896  	// ID of an existing discount on the object (or one of its ancestors) to reuse.
   897  	Discount *string `form:"discount"`
   898  	// ID of the promotion code to create a new discount for.
   899  	PromotionCode *string `form:"promotion_code"`
   900  }
   901  
   902  // The coupons to redeem into discounts for the invoice item in the preview.
   903  type InvoiceUpcomingLinesInvoiceItemDiscountParams struct {
   904  	// ID of the coupon to create a new discount for.
   905  	Coupon *string `form:"coupon"`
   906  	// ID of an existing discount on the object (or one of its ancestors) to reuse.
   907  	Discount *string `form:"discount"`
   908  	// ID of the promotion code to create a new discount for.
   909  	PromotionCode *string `form:"promotion_code"`
   910  }
   911  
   912  // 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.
   913  type InvoiceUpcomingLinesInvoiceItemPeriodParams struct {
   914  	// The end of the period, which must be greater than or equal to the start. This value is inclusive.
   915  	End *int64 `form:"end"`
   916  	// The start of the period. This value is inclusive.
   917  	Start *int64 `form:"start"`
   918  }
   919  
   920  // Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline.
   921  type InvoiceUpcomingLinesInvoiceItemPriceDataParams struct {
   922  	// 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).
   923  	Currency *string `form:"currency"`
   924  	// The ID of the product that this price will belong to.
   925  	Product *string `form:"product"`
   926  	// 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.
   927  	TaxBehavior *string `form:"tax_behavior"`
   928  	// A positive integer in cents (or local equivalent) (or 0 for a free price) representing how much to charge.
   929  	UnitAmount *int64 `form:"unit_amount"`
   930  	// 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.
   931  	UnitAmountDecimal *float64 `form:"unit_amount_decimal,high_precision"`
   932  }
   933  
   934  // List of invoice items to add or update in the upcoming invoice preview.
   935  type InvoiceUpcomingLinesInvoiceItemParams struct {
   936  	// The integer amount in cents (or local equivalent) of previewed invoice item.
   937  	Amount *int64 `form:"amount"`
   938  	// 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). Only applicable to new invoice items.
   939  	Currency *string `form:"currency"`
   940  	// An arbitrary string which you can attach to the invoice item. The description is displayed in the invoice for easy tracking.
   941  	Description *string `form:"description"`
   942  	// Explicitly controls whether discounts apply to this invoice item. Defaults to true, except for negative invoice items.
   943  	Discountable *bool `form:"discountable"`
   944  	// The coupons to redeem into discounts for the invoice item in the preview.
   945  	Discounts []*InvoiceUpcomingLinesInvoiceItemDiscountParams `form:"discounts"`
   946  	// The ID of the invoice item to update in preview. If not specified, a new invoice item will be added to the preview of the upcoming invoice.
   947  	InvoiceItem *string `form:"invoiceitem"`
   948  	// 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`.
   949  	Metadata map[string]string `form:"metadata"`
   950  	// 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.
   951  	Period *InvoiceUpcomingLinesInvoiceItemPeriodParams `form:"period"`
   952  	// The ID of the price object.
   953  	Price *string `form:"price"`
   954  	// Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline.
   955  	PriceData *InvoiceUpcomingLinesInvoiceItemPriceDataParams `form:"price_data"`
   956  	// Non-negative integer. The quantity of units for the invoice item.
   957  	Quantity *int64 `form:"quantity"`
   958  	// 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.
   959  	TaxBehavior *string `form:"tax_behavior"`
   960  	// A [tax code](https://stripe.com/docs/tax/tax-categories) ID.
   961  	TaxCode *string `form:"tax_code"`
   962  	// The tax rates that apply to the item. When set, any `default_tax_rates` do not apply to this item.
   963  	TaxRates []*string `form:"tax_rates"`
   964  	// The integer unit amount in cents (or local equivalent) of the charge to be applied to the upcoming invoice. This unit_amount will be multiplied by the quantity to get the full amount. If you want to apply a credit to the customer's account, pass a negative unit_amount.
   965  	UnitAmount *int64 `form:"unit_amount"`
   966  	// 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.
   967  	UnitAmountDecimal *float64 `form:"unit_amount_decimal,high_precision"`
   968  }
   969  
   970  // AddMetadata adds a new key-value pair to the Metadata.
   971  func (p *InvoiceUpcomingLinesInvoiceItemParams) AddMetadata(key string, value string) {
   972  	if p.Metadata == nil {
   973  		p.Metadata = make(map[string]string)
   974  	}
   975  
   976  	p.Metadata[key] = value
   977  }
   978  
   979  // The connected account that issues the invoice. The invoice is presented with the branding and support information of the specified account.
   980  type InvoiceUpcomingLinesIssuerParams struct {
   981  	// The connected account being referenced when `type` is `account`.
   982  	Account *string `form:"account"`
   983  	// Type of the account referenced in the request.
   984  	Type *string `form:"type"`
   985  }
   986  
   987  // Define thresholds at which an invoice will be sent, and the subscription advanced to a new billing period. When updating, pass an empty string to remove previously-defined thresholds.
   988  type InvoiceUpcomingLinesSubscriptionItemBillingThresholdsParams struct {
   989  	// Number of units that meets the billing threshold to advance the subscription to a new billing period (e.g., it takes 10 $5 units to meet a $50 [monetary threshold](https://stripe.com/docs/api/subscriptions/update#update_subscription-billing_thresholds-amount_gte))
   990  	UsageGTE *int64 `form:"usage_gte"`
   991  }
   992  
   993  // The coupons to redeem into discounts for the subscription item.
   994  type InvoiceUpcomingLinesSubscriptionItemDiscountParams struct {
   995  	// ID of the coupon to create a new discount for.
   996  	Coupon *string `form:"coupon"`
   997  	// ID of an existing discount on the object (or one of its ancestors) to reuse.
   998  	Discount *string `form:"discount"`
   999  	// ID of the promotion code to create a new discount for.
  1000  	PromotionCode *string `form:"promotion_code"`
  1001  }
  1002  
  1003  // The recurring components of a price such as `interval` and `interval_count`.
  1004  type InvoiceUpcomingLinesSubscriptionItemPriceDataRecurringParams struct {
  1005  	// Specifies billing frequency. Either `day`, `week`, `month` or `year`.
  1006  	Interval *string `form:"interval"`
  1007  	// The number of intervals between subscription billings. For example, `interval=month` and `interval_count=3` bills every 3 months. Maximum of three years interval allowed (3 years, 36 months, or 156 weeks).
  1008  	IntervalCount *int64 `form:"interval_count"`
  1009  }
  1010  
  1011  // Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline.
  1012  type InvoiceUpcomingLinesSubscriptionItemPriceDataParams struct {
  1013  	// 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).
  1014  	Currency *string `form:"currency"`
  1015  	// The ID of the product that this price will belong to.
  1016  	Product *string `form:"product"`
  1017  	// The recurring components of a price such as `interval` and `interval_count`.
  1018  	Recurring *InvoiceUpcomingLinesSubscriptionItemPriceDataRecurringParams `form:"recurring"`
  1019  	// 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.
  1020  	TaxBehavior *string `form:"tax_behavior"`
  1021  	// A positive integer in cents (or local equivalent) (or 0 for a free price) representing how much to charge.
  1022  	UnitAmount *int64 `form:"unit_amount"`
  1023  	// 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.
  1024  	UnitAmountDecimal *float64 `form:"unit_amount_decimal,high_precision"`
  1025  }
  1026  
  1027  // A list of up to 20 subscription items, each with an attached price.
  1028  type InvoiceUpcomingLinesSubscriptionItemParams struct {
  1029  	// Define thresholds at which an invoice will be sent, and the subscription advanced to a new billing period. When updating, pass an empty string to remove previously-defined thresholds.
  1030  	BillingThresholds *InvoiceUpcomingLinesSubscriptionItemBillingThresholdsParams `form:"billing_thresholds"`
  1031  	// Delete all usage for a given subscription item. Allowed only when `deleted` is set to `true` and the current plan's `usage_type` is `metered`.
  1032  	ClearUsage *bool `form:"clear_usage"`
  1033  	// A flag that, if set to `true`, will delete the specified item.
  1034  	Deleted *bool `form:"deleted"`
  1035  	// The coupons to redeem into discounts for the subscription item.
  1036  	Discounts []*InvoiceUpcomingLinesSubscriptionItemDiscountParams `form:"discounts"`
  1037  	// Subscription item to update.
  1038  	ID *string `form:"id"`
  1039  	// 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`.
  1040  	Metadata map[string]string `form:"metadata"`
  1041  	// Plan ID for this item, as a string.
  1042  	Plan *string `form:"plan"`
  1043  	// The ID of the price object. When changing a subscription item's price, `quantity` is set to 1 unless a `quantity` parameter is provided.
  1044  	Price *string `form:"price"`
  1045  	// Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline.
  1046  	PriceData *InvoiceUpcomingLinesSubscriptionItemPriceDataParams `form:"price_data"`
  1047  	// Quantity for this item.
  1048  	Quantity *int64 `form:"quantity"`
  1049  	// A list of [Tax Rate](https://stripe.com/docs/api/tax_rates) ids. These Tax Rates will override the [`default_tax_rates`](https://stripe.com/docs/api/subscriptions/create#create_subscription-default_tax_rates) on the Subscription. When updating, pass an empty string to remove previously-defined tax rates.
  1050  	TaxRates []*string `form:"tax_rates"`
  1051  }
  1052  
  1053  // AddMetadata adds a new key-value pair to the Metadata.
  1054  func (p *InvoiceUpcomingLinesSubscriptionItemParams) AddMetadata(key string, value string) {
  1055  	if p.Metadata == nil {
  1056  		p.Metadata = make(map[string]string)
  1057  	}
  1058  
  1059  	p.Metadata[key] = value
  1060  }
  1061  
  1062  // 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.
  1063  type InvoiceUpcomingLinesParams struct {
  1064  	ListParams `form:"*"`
  1065  	// Settings for automatic tax lookup for this invoice preview.
  1066  	AutomaticTax *InvoiceUpcomingLinesAutomaticTaxParams `form:"automatic_tax"`
  1067  	// The ID of the coupon to apply to this phase of the subscription schedule. This field has been deprecated and will be removed in a future API version. Use `discounts` instead.
  1068  	Coupon *string `form:"coupon"`
  1069  	// The currency to preview this invoice in. Defaults to that of `customer` if not specified.
  1070  	Currency *string `form:"currency"`
  1071  	// The identifier of the customer whose upcoming invoice you'd like to retrieve. If `automatic_tax` is enabled then one of `customer`, `customer_details`, `subscription`, or `schedule` must be set.
  1072  	Customer *string `form:"customer"`
  1073  	// Details about the customer you want to invoice or overrides for an existing customer. If `automatic_tax` is enabled then one of `customer`, `customer_details`, `subscription`, or `schedule` must be set.
  1074  	CustomerDetails *InvoiceUpcomingLinesCustomerDetailsParams `form:"customer_details"`
  1075  	// The coupons to redeem into discounts for the invoice preview. If not specified, inherits the discount from the subscription or customer. This works for both coupons directly applied to an invoice and coupons applied to a subscription. Pass an empty string to avoid inheriting any discounts.
  1076  	Discounts []*InvoiceUpcomingLinesDiscountParams `form:"discounts"`
  1077  	// Specifies which fields in the response should be expanded.
  1078  	Expand []*string `form:"expand"`
  1079  	// List of invoice items to add or update in the upcoming invoice preview.
  1080  	InvoiceItems []*InvoiceUpcomingLinesInvoiceItemParams `form:"invoice_items"`
  1081  	// The connected account that issues the invoice. The invoice is presented with the branding and support information of the specified account.
  1082  	Issuer *InvoiceUpcomingLinesIssuerParams `form:"issuer"`
  1083  	// The account (if any) for which the funds of the invoice payment are intended. If set, the invoice will be presented with the branding and support information of the specified account. See the [Invoices with Connect](https://stripe.com/docs/billing/invoices/connect) documentation for details.
  1084  	OnBehalfOf *string `form:"on_behalf_of"`
  1085  	// The identifier of the schedule whose upcoming invoice you'd like to retrieve. Cannot be used with subscription or subscription fields.
  1086  	Schedule *string `form:"schedule"`
  1087  	// The identifier of the subscription for which you'd like to retrieve the upcoming invoice. If not provided, but a `subscription_items` is provided, you will preview creating a subscription with those items. If neither `subscription` nor `subscription_items` is provided, you will retrieve the next upcoming invoice from among the customer's subscriptions.
  1088  	Subscription *string `form:"subscription"`
  1089  	// For new subscriptions, a future timestamp to anchor the subscription's [billing cycle](https://stripe.com/docs/subscriptions/billing-cycle). This is used to determine the date of the first full invoice, and, for plans with `month` or `year` intervals, the day of the month for subsequent invoices. For existing subscriptions, the value can only be set to `now` or `unchanged`.
  1090  	SubscriptionBillingCycleAnchor          *int64 `form:"subscription_billing_cycle_anchor"`
  1091  	SubscriptionBillingCycleAnchorNow       *bool  `form:"-"` // See custom AppendTo
  1092  	SubscriptionBillingCycleAnchorUnchanged *bool  `form:"-"` // See custom AppendTo
  1093  	// A timestamp at which the subscription should cancel. If set to a date before the current period ends, this will cause a proration if prorations have been enabled using `proration_behavior`. If set during a future period, this will always cause a proration for that period.
  1094  	SubscriptionCancelAt *int64 `form:"subscription_cancel_at"`
  1095  	// Boolean indicating whether this subscription should cancel at the end of the current period.
  1096  	SubscriptionCancelAtPeriodEnd *bool `form:"subscription_cancel_at_period_end"`
  1097  	// This simulates the subscription being canceled or expired immediately.
  1098  	SubscriptionCancelNow *bool `form:"subscription_cancel_now"`
  1099  	// If provided, the invoice returned will preview updating or creating a subscription with these default tax rates. The default tax rates will apply to any line item that does not have `tax_rates` set.
  1100  	SubscriptionDefaultTaxRates []*string `form:"subscription_default_tax_rates"`
  1101  	// A list of up to 20 subscription items, each with an attached price.
  1102  	SubscriptionItems []*InvoiceUpcomingLinesSubscriptionItemParams `form:"subscription_items"`
  1103  	// Determines how to handle [prorations](https://stripe.com/docs/billing/subscriptions/prorations) when the billing cycle changes (e.g., when switching plans, resetting `billing_cycle_anchor=now`, or starting a trial), or if an item's `quantity` changes. The default value is `create_prorations`.
  1104  	SubscriptionProrationBehavior *string `form:"subscription_proration_behavior"`
  1105  	// If previewing an update to a subscription, and doing proration, `subscription_proration_date` forces the proration to be calculated as though the update was done at the specified time. The time given must be within the current subscription period and within the current phase of the schedule backing this subscription, if the schedule exists. If set, `subscription`, and one of `subscription_items`, or `subscription_trial_end` are required. Also, `subscription_proration_behavior` cannot be set to 'none'.
  1106  	SubscriptionProrationDate *int64 `form:"subscription_proration_date"`
  1107  	// For paused subscriptions, setting `subscription_resume_at` to `now` will preview the invoice that will be generated if the subscription is resumed.
  1108  	SubscriptionResumeAt *string `form:"subscription_resume_at"`
  1109  	// Date a subscription is intended to start (can be future or past).
  1110  	SubscriptionStartDate *int64 `form:"subscription_start_date"`
  1111  	// If provided, the invoice returned will preview updating or creating a subscription with that trial end. If set, one of `subscription_items` or `subscription` is required.
  1112  	SubscriptionTrialEnd    *int64 `form:"subscription_trial_end"`
  1113  	SubscriptionTrialEndNow *bool  `form:"-"` // See custom AppendTo
  1114  	// Indicates if a plan's `trial_period_days` should be applied to the subscription. Setting `subscription_trial_end` per subscription is preferred, and this defaults to `false`. Setting this flag to `true` together with `subscription_trial_end` is not allowed. See [Using trial periods on subscriptions](https://stripe.com/docs/billing/subscriptions/trials) to learn more.
  1115  	SubscriptionTrialFromPlan *bool `form:"subscription_trial_from_plan"`
  1116  }
  1117  
  1118  // AddExpand appends a new field to expand.
  1119  func (p *InvoiceUpcomingLinesParams) AddExpand(f string) {
  1120  	p.Expand = append(p.Expand, &f)
  1121  }
  1122  
  1123  // AppendTo implements custom encoding logic for InvoiceUpcomingLinesParams.
  1124  func (p *InvoiceUpcomingLinesParams) AppendTo(body *form.Values, keyParts []string) {
  1125  	if BoolValue(p.SubscriptionBillingCycleAnchorNow) {
  1126  		body.Add(form.FormatKey(append(keyParts, "subscription_billing_cycle_anchor")), "now")
  1127  	}
  1128  	if BoolValue(p.SubscriptionBillingCycleAnchorUnchanged) {
  1129  		body.Add(form.FormatKey(append(keyParts, "subscription_billing_cycle_anchor")), "unchanged")
  1130  	}
  1131  	if BoolValue(p.SubscriptionTrialEndNow) {
  1132  		body.Add(form.FormatKey(append(keyParts, "subscription_trial_end")), "now")
  1133  	}
  1134  }
  1135  
  1136  // 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.
  1137  type InvoiceFinalizeInvoiceParams struct {
  1138  	Params `form:"*"`
  1139  	// Controls whether Stripe performs [automatic collection](https://stripe.com/docs/invoicing/integration/automatic-advancement-collection) of the invoice. If `false`, the invoice's state doesn't automatically advance without an explicit action.
  1140  	AutoAdvance *bool `form:"auto_advance"`
  1141  	// Specifies which fields in the response should be expanded.
  1142  	Expand []*string `form:"expand"`
  1143  }
  1144  
  1145  // AddExpand appends a new field to expand.
  1146  func (p *InvoiceFinalizeInvoiceParams) AddExpand(f string) {
  1147  	p.Expand = append(p.Expand, &f)
  1148  }
  1149  
  1150  // Marking an invoice as uncollectible is useful for keeping track of bad debts that can be written off for accounting purposes.
  1151  type InvoiceMarkUncollectibleParams struct {
  1152  	Params `form:"*"`
  1153  	// Specifies which fields in the response should be expanded.
  1154  	Expand []*string `form:"expand"`
  1155  }
  1156  
  1157  // AddExpand appends a new field to expand.
  1158  func (p *InvoiceMarkUncollectibleParams) AddExpand(f string) {
  1159  	p.Expand = append(p.Expand, &f)
  1160  }
  1161  
  1162  // 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.
  1163  type InvoicePayParams struct {
  1164  	Params `form:"*"`
  1165  	// Specifies which fields in the response should be expanded.
  1166  	Expand []*string `form:"expand"`
  1167  	// In cases where the source used to pay the invoice has insufficient funds, passing `forgive=true` controls whether a charge should be attempted for the full amount available on the source, up to the amount to fully pay the invoice. This effectively forgives the difference between the amount available on the source and the amount due.
  1168  	//
  1169  	// Passing `forgive=false` will fail the charge if the source hasn't been pre-funded with the right amount. An example for this case is with ACH Credit Transfers and wires: if the amount wired is less than the amount due by a small amount, you might want to forgive the difference. Defaults to `false`.
  1170  	Forgive *bool `form:"forgive"`
  1171  	// ID of the mandate to be used for this invoice. It must correspond to the payment method used to pay the invoice, including the payment_method param or the invoice's default_payment_method or default_source, if set.
  1172  	Mandate *string `form:"mandate"`
  1173  	// Indicates if a customer is on or off-session while an invoice payment is attempted. Defaults to `true` (off-session).
  1174  	OffSession *bool `form:"off_session"`
  1175  	// Boolean representing whether an invoice is paid outside of Stripe. This will result in no charge being made. Defaults to `false`.
  1176  	PaidOutOfBand *bool `form:"paid_out_of_band"`
  1177  	// A PaymentMethod to be charged. The PaymentMethod must be the ID of a PaymentMethod belonging to the customer associated with the invoice being paid.
  1178  	PaymentMethod *string `form:"payment_method"`
  1179  	// A payment source to be charged. The source must be the ID of a source belonging to the customer associated with the invoice being paid.
  1180  	Source *string `form:"source"`
  1181  }
  1182  
  1183  // AddExpand appends a new field to expand.
  1184  func (p *InvoicePayParams) AddExpand(f string) {
  1185  	p.Expand = append(p.Expand, &f)
  1186  }
  1187  
  1188  // 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.
  1189  //
  1190  // Requests made in test-mode result in no emails being sent, despite sending an invoice.sent event.
  1191  type InvoiceSendInvoiceParams struct {
  1192  	Params `form:"*"`
  1193  	// Specifies which fields in the response should be expanded.
  1194  	Expand []*string `form:"expand"`
  1195  }
  1196  
  1197  // AddExpand appends a new field to expand.
  1198  func (p *InvoiceSendInvoiceParams) AddExpand(f string) {
  1199  	p.Expand = append(p.Expand, &f)
  1200  }
  1201  
  1202  // 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.
  1203  //
  1204  // 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.
  1205  type InvoiceVoidInvoiceParams struct {
  1206  	Params `form:"*"`
  1207  	// Specifies which fields in the response should be expanded.
  1208  	Expand []*string `form:"expand"`
  1209  }
  1210  
  1211  // AddExpand appends a new field to expand.
  1212  func (p *InvoiceVoidInvoiceParams) AddExpand(f string) {
  1213  	p.Expand = append(p.Expand, &f)
  1214  }
  1215  
  1216  // 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.
  1217  type InvoiceListLinesParams struct {
  1218  	ListParams `form:"*"`
  1219  	Invoice    *string `form:"-"` // Included in URL
  1220  	// Specifies which fields in the response should be expanded.
  1221  	Expand []*string `form:"expand"`
  1222  }
  1223  
  1224  // AddExpand appends a new field to expand.
  1225  func (p *InvoiceListLinesParams) AddExpand(f string) {
  1226  	p.Expand = append(p.Expand, &f)
  1227  }
  1228  
  1229  // The account that's liable for tax. If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. The tax transaction is returned in the report of the connected account.
  1230  type InvoiceAutomaticTaxLiability struct {
  1231  	// The connected account being referenced when `type` is `account`.
  1232  	Account *Account `json:"account"`
  1233  	// Type of the account referenced.
  1234  	Type InvoiceAutomaticTaxLiabilityType `json:"type"`
  1235  }
  1236  type InvoiceAutomaticTax struct {
  1237  	// Whether Stripe automatically computes tax on this invoice. Note that incompatible invoice items (invoice items with manually specified [tax rates](https://stripe.com/docs/api/tax_rates), negative amounts, or `tax_behavior=unspecified`) cannot be added to automatic tax invoices.
  1238  	Enabled bool `json:"enabled"`
  1239  	// The account that's liable for tax. If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. The tax transaction is returned in the report of the connected account.
  1240  	Liability *InvoiceAutomaticTaxLiability `json:"liability"`
  1241  	// The status of the most recent automated tax calculation for this invoice.
  1242  	Status InvoiceAutomaticTaxStatus `json:"status"`
  1243  }
  1244  
  1245  // Custom fields displayed on the invoice.
  1246  type InvoiceCustomField struct {
  1247  	// The name of the custom field.
  1248  	Name string `json:"name"`
  1249  	// The value of the custom field.
  1250  	Value string `json:"value"`
  1251  }
  1252  
  1253  // The customer's tax IDs. Until the invoice is finalized, this field will contain the same tax IDs as `customer.tax_ids`. Once the invoice is finalized, this field will no longer be updated.
  1254  type InvoiceCustomerTaxID struct {
  1255  	// The type of the tax ID, one of `ad_nrt`, `ar_cuit`, `eu_vat`, `bo_tin`, `br_cnpj`, `br_cpf`, `cn_tin`, `co_nit`, `cr_tin`, `do_rcn`, `ec_ruc`, `eu_oss_vat`, `pe_ruc`, `ro_tin`, `rs_pib`, `sv_nit`, `uy_ruc`, `ve_rif`, `vn_tin`, `gb_vat`, `nz_gst`, `au_abn`, `au_arn`, `in_gst`, `no_vat`, `no_voec`, `za_vat`, `ch_vat`, `mx_rfc`, `sg_uen`, `ru_inn`, `ru_kpp`, `ca_bn`, `hk_br`, `es_cif`, `tw_vat`, `th_vat`, `jp_cn`, `jp_rn`, `jp_trn`, `li_uid`, `my_itn`, `us_ein`, `kr_brn`, `ca_qst`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `my_sst`, `sg_gst`, `ae_trn`, `cl_tin`, `sa_vat`, `id_npwp`, `my_frp`, `il_vat`, `ge_vat`, `ua_vat`, `is_vat`, `bg_uic`, `hu_tin`, `si_tin`, `ke_pin`, `tr_tin`, `eg_tin`, `ph_tin`, or `unknown`
  1256  	Type *TaxIDType `json:"type"`
  1257  	// The value of the tax ID.
  1258  	Value string `json:"value"`
  1259  }
  1260  
  1261  // Details of the invoice that was cloned. See the [revision documentation](https://stripe.com/docs/invoicing/invoice-revisions) for more details.
  1262  type InvoiceFromInvoice struct {
  1263  	// The relation between this invoice and the cloned invoice
  1264  	Action string `json:"action"`
  1265  	// The invoice that was cloned.
  1266  	Invoice *Invoice `json:"invoice"`
  1267  }
  1268  type InvoiceIssuer struct {
  1269  	// The connected account being referenced when `type` is `account`.
  1270  	Account *Account `json:"account"`
  1271  	// Type of the account referenced.
  1272  	Type InvoiceIssuerType `json:"type"`
  1273  }
  1274  type InvoicePaymentSettingsPaymentMethodOptionsACSSDebitMandateOptions struct {
  1275  	// Transaction type of the mandate.
  1276  	TransactionType InvoicePaymentSettingsPaymentMethodOptionsACSSDebitMandateOptionsTransactionType `json:"transaction_type"`
  1277  }
  1278  
  1279  // If paying by `acss_debit`, this sub-hash contains details about the Canadian pre-authorized debit payment method options to pass to the invoice's PaymentIntent.
  1280  type InvoicePaymentSettingsPaymentMethodOptionsACSSDebit struct {
  1281  	MandateOptions *InvoicePaymentSettingsPaymentMethodOptionsACSSDebitMandateOptions `json:"mandate_options"`
  1282  	// Bank account verification method.
  1283  	VerificationMethod InvoicePaymentSettingsPaymentMethodOptionsACSSDebitVerificationMethod `json:"verification_method"`
  1284  }
  1285  
  1286  // If paying by `bancontact`, this sub-hash contains details about the Bancontact payment method options to pass to the invoice's PaymentIntent.
  1287  type InvoicePaymentSettingsPaymentMethodOptionsBancontact struct {
  1288  	// Preferred language of the Bancontact authorization page that the customer is redirected to.
  1289  	PreferredLanguage string `json:"preferred_language"`
  1290  }
  1291  type InvoicePaymentSettingsPaymentMethodOptionsCardInstallments struct {
  1292  	// Whether Installments are enabled for this Invoice.
  1293  	Enabled bool `json:"enabled"`
  1294  }
  1295  
  1296  // If paying by `card`, this sub-hash contains details about the Card payment method options to pass to the invoice's PaymentIntent.
  1297  type InvoicePaymentSettingsPaymentMethodOptionsCard struct {
  1298  	Installments *InvoicePaymentSettingsPaymentMethodOptionsCardInstallments `json:"installments"`
  1299  	// We strongly recommend that you rely on our SCA Engine to automatically prompt your customers for authentication based on risk level and [other requirements](https://stripe.com/docs/strong-customer-authentication). However, if you wish to request 3D Secure based on logic from your own fraud engine, provide this option. Read our guide on [manually requesting 3D Secure](https://stripe.com/docs/payments/3d-secure/authentication-flow#manual-three-ds) for more information on how this configuration interacts with Radar and our SCA Engine.
  1300  	RequestThreeDSecure InvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure `json:"request_three_d_secure"`
  1301  }
  1302  type InvoicePaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferEUBankTransfer struct {
  1303  	// The desired country code of the bank account information. Permitted values include: `BE`, `DE`, `ES`, `FR`, `IE`, or `NL`.
  1304  	Country string `json:"country"`
  1305  }
  1306  type InvoicePaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransfer struct {
  1307  	EUBankTransfer *InvoicePaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferEUBankTransfer `json:"eu_bank_transfer"`
  1308  	// The bank transfer type that can be used for funding. Permitted values include: `eu_bank_transfer`, `gb_bank_transfer`, `jp_bank_transfer`, `mx_bank_transfer`, or `us_bank_transfer`.
  1309  	Type string `json:"type"`
  1310  }
  1311  
  1312  // If paying by `customer_balance`, this sub-hash contains details about the Bank transfer payment method options to pass to the invoice's PaymentIntent.
  1313  type InvoicePaymentSettingsPaymentMethodOptionsCustomerBalance struct {
  1314  	BankTransfer *InvoicePaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransfer `json:"bank_transfer"`
  1315  	// The funding method type to be used when there are not enough funds in the customer balance. Permitted values include: `bank_transfer`.
  1316  	FundingType InvoicePaymentSettingsPaymentMethodOptionsCustomerBalanceFundingType `json:"funding_type"`
  1317  }
  1318  
  1319  // If paying by `konbini`, this sub-hash contains details about the Konbini payment method options to pass to the invoice's PaymentIntent.
  1320  type InvoicePaymentSettingsPaymentMethodOptionsKonbini struct{}
  1321  
  1322  // If paying by `sepa_debit`, this sub-hash contains details about the SEPA Direct Debit payment method options to pass to the invoice's PaymentIntent.
  1323  type InvoicePaymentSettingsPaymentMethodOptionsSEPADebit struct{}
  1324  type InvoicePaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnections struct {
  1325  	// The list of permissions to request. The `payment_method` permission must be included.
  1326  	Permissions []InvoicePaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPermission `json:"permissions"`
  1327  	// Data features requested to be retrieved upon account creation.
  1328  	Prefetch []InvoicePaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPrefetch `json:"prefetch"`
  1329  }
  1330  
  1331  // If paying by `us_bank_account`, this sub-hash contains details about the ACH direct debit payment method options to pass to the invoice's PaymentIntent.
  1332  type InvoicePaymentSettingsPaymentMethodOptionsUSBankAccount struct {
  1333  	FinancialConnections *InvoicePaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnections `json:"financial_connections"`
  1334  	// Bank account verification method.
  1335  	VerificationMethod InvoicePaymentSettingsPaymentMethodOptionsUSBankAccountVerificationMethod `json:"verification_method"`
  1336  }
  1337  
  1338  // Payment-method-specific configuration to provide to the invoice's PaymentIntent.
  1339  type InvoicePaymentSettingsPaymentMethodOptions struct {
  1340  	// If paying by `acss_debit`, this sub-hash contains details about the Canadian pre-authorized debit payment method options to pass to the invoice's PaymentIntent.
  1341  	ACSSDebit *InvoicePaymentSettingsPaymentMethodOptionsACSSDebit `json:"acss_debit"`
  1342  	// If paying by `bancontact`, this sub-hash contains details about the Bancontact payment method options to pass to the invoice's PaymentIntent.
  1343  	Bancontact *InvoicePaymentSettingsPaymentMethodOptionsBancontact `json:"bancontact"`
  1344  	// If paying by `card`, this sub-hash contains details about the Card payment method options to pass to the invoice's PaymentIntent.
  1345  	Card *InvoicePaymentSettingsPaymentMethodOptionsCard `json:"card"`
  1346  	// If paying by `customer_balance`, this sub-hash contains details about the Bank transfer payment method options to pass to the invoice's PaymentIntent.
  1347  	CustomerBalance *InvoicePaymentSettingsPaymentMethodOptionsCustomerBalance `json:"customer_balance"`
  1348  	// If paying by `konbini`, this sub-hash contains details about the Konbini payment method options to pass to the invoice's PaymentIntent.
  1349  	Konbini *InvoicePaymentSettingsPaymentMethodOptionsKonbini `json:"konbini"`
  1350  	// If paying by `sepa_debit`, this sub-hash contains details about the SEPA Direct Debit payment method options to pass to the invoice's PaymentIntent.
  1351  	SEPADebit *InvoicePaymentSettingsPaymentMethodOptionsSEPADebit `json:"sepa_debit"`
  1352  	// If paying by `us_bank_account`, this sub-hash contains details about the ACH direct debit payment method options to pass to the invoice's PaymentIntent.
  1353  	USBankAccount *InvoicePaymentSettingsPaymentMethodOptionsUSBankAccount `json:"us_bank_account"`
  1354  }
  1355  type InvoicePaymentSettings struct {
  1356  	// ID of the mandate to be used for this invoice. It must correspond to the payment method used to pay the invoice, including the invoice's default_payment_method or default_source, if set.
  1357  	DefaultMandate string `json:"default_mandate"`
  1358  	// Payment-method-specific configuration to provide to the invoice's PaymentIntent.
  1359  	PaymentMethodOptions *InvoicePaymentSettingsPaymentMethodOptions `json:"payment_method_options"`
  1360  	// The list of payment method types (e.g. card) to provide to the invoice's PaymentIntent. If not set, Stripe attempts to automatically determine the types to use by looking at the invoice's default payment method, the subscription's default payment method, the customer's default payment method, and your [invoice template settings](https://dashboard.stripe.com/settings/billing/invoice).
  1361  	PaymentMethodTypes []InvoicePaymentSettingsPaymentMethodType `json:"payment_method_types"`
  1362  }
  1363  
  1364  // Invoice pdf rendering options
  1365  type InvoiceRenderingPDF struct {
  1366  	// Page size of invoice pdf. Options include a4, letter, and auto. If set to auto, page size will be switched to a4 or letter based on customer locale.
  1367  	PageSize InvoiceRenderingPDFPageSize `json:"page_size"`
  1368  }
  1369  
  1370  // The rendering-related settings that control how the invoice is displayed on customer-facing surfaces such as PDF and Hosted Invoice Page.
  1371  type InvoiceRendering struct {
  1372  	// How line-item prices and amounts will be displayed with respect to tax on invoice PDFs.
  1373  	AmountTaxDisplay string `json:"amount_tax_display"`
  1374  	// Invoice pdf rendering options
  1375  	PDF *InvoiceRenderingPDF `json:"pdf"`
  1376  }
  1377  
  1378  // This is a legacy field that will be removed soon. For details about `rendering_options`, refer to `rendering` instead. Options for invoice PDF rendering.
  1379  type InvoiceRenderingOptions struct {
  1380  	// How line-item prices and amounts will be displayed with respect to tax on invoice PDFs.
  1381  	AmountTaxDisplay string `json:"amount_tax_display"`
  1382  }
  1383  
  1384  // The taxes applied to the shipping rate.
  1385  type InvoiceShippingCostTax struct {
  1386  	// Amount of tax applied for this rate.
  1387  	Amount int64 `json:"amount"`
  1388  	// Tax rates can be applied to [invoices](https://stripe.com/docs/billing/invoices/tax-rates), [subscriptions](https://stripe.com/docs/billing/subscriptions/taxes) and [Checkout Sessions](https://stripe.com/docs/payments/checkout/set-up-a-subscription#tax-rates) to collect tax.
  1389  	//
  1390  	// Related guide: [Tax rates](https://stripe.com/docs/billing/taxes/tax-rates)
  1391  	Rate *TaxRate `json:"rate"`
  1392  	// The reasoning behind this tax, for example, if the product is tax exempt. The possible values for this field may be extended as new tax rules are supported.
  1393  	TaxabilityReason InvoiceShippingCostTaxTaxabilityReason `json:"taxability_reason"`
  1394  	// The amount on which tax is calculated, in cents (or local equivalent).
  1395  	TaxableAmount int64 `json:"taxable_amount"`
  1396  }
  1397  
  1398  // The details of the cost of shipping, including the ShippingRate applied on the invoice.
  1399  type InvoiceShippingCost struct {
  1400  	// Total shipping cost before any taxes are applied.
  1401  	AmountSubtotal int64 `json:"amount_subtotal"`
  1402  	// Total tax amount applied due to shipping costs. If no tax was applied, defaults to 0.
  1403  	AmountTax int64 `json:"amount_tax"`
  1404  	// Total shipping cost after taxes are applied.
  1405  	AmountTotal int64 `json:"amount_total"`
  1406  	// The ID of the ShippingRate for this invoice.
  1407  	ShippingRate *ShippingRate `json:"shipping_rate"`
  1408  	// The taxes applied to the shipping rate.
  1409  	Taxes []*InvoiceShippingCostTax `json:"taxes"`
  1410  }
  1411  type InvoiceStatusTransitions struct {
  1412  	// The time that the invoice draft was finalized.
  1413  	FinalizedAt int64 `json:"finalized_at"`
  1414  	// The time that the invoice was marked uncollectible.
  1415  	MarkedUncollectibleAt int64 `json:"marked_uncollectible_at"`
  1416  	// The time that the invoice was paid.
  1417  	PaidAt int64 `json:"paid_at"`
  1418  	// The time that the invoice was voided.
  1419  	VoidedAt int64 `json:"voided_at"`
  1420  }
  1421  
  1422  // Details about the subscription that created this invoice.
  1423  type InvoiceSubscriptionDetails struct {
  1424  	// Set of [key-value pairs](https://stripe.com/docs/api/metadata) defined as subscription metadata when an invoice is created. Becomes an immutable snapshot of the subscription metadata at the time of invoice finalization.
  1425  	//  *Note: This attribute is populated only for invoices created on or after June 29, 2023.*
  1426  	Metadata map[string]string `json:"metadata"`
  1427  }
  1428  
  1429  // Indicates which line items triggered a threshold invoice.
  1430  type InvoiceThresholdReasonItemReason struct {
  1431  	// The IDs of the line items that triggered the threshold invoice.
  1432  	LineItemIDs []string `json:"line_item_ids"`
  1433  	// The quantity threshold boundary that applied to the given line item.
  1434  	UsageGTE int64 `json:"usage_gte"`
  1435  }
  1436  type InvoiceThresholdReason struct {
  1437  	// The total invoice amount threshold boundary if it triggered the threshold invoice.
  1438  	AmountGTE int64 `json:"amount_gte"`
  1439  	// Indicates which line items triggered a threshold invoice.
  1440  	ItemReasons []*InvoiceThresholdReasonItemReason `json:"item_reasons"`
  1441  }
  1442  
  1443  // The aggregate amounts calculated per discount across all line items.
  1444  type InvoiceTotalDiscountAmount struct {
  1445  	// The amount, in cents (or local equivalent), of the discount.
  1446  	Amount int64 `json:"amount"`
  1447  	// The discount that was applied to get this discount amount.
  1448  	Discount *Discount `json:"discount"`
  1449  }
  1450  
  1451  // The aggregate amounts calculated per tax rate for all line items.
  1452  type InvoiceTotalTaxAmount struct {
  1453  	// The amount, in cents (or local equivalent), of the tax.
  1454  	Amount int64 `json:"amount"`
  1455  	// Whether this tax amount is inclusive or exclusive.
  1456  	Inclusive bool `json:"inclusive"`
  1457  	// The reasoning behind this tax, for example, if the product is tax exempt. The possible values for this field may be extended as new tax rules are supported.
  1458  	TaxabilityReason InvoiceTotalTaxAmountTaxabilityReason `json:"taxability_reason"`
  1459  	// The amount on which tax is calculated, in cents (or local equivalent).
  1460  	TaxableAmount int64 `json:"taxable_amount"`
  1461  	// The tax rate that was applied to get this tax amount.
  1462  	TaxRate *TaxRate `json:"tax_rate"`
  1463  }
  1464  
  1465  // The account (if any) the payment will be attributed to for tax reporting, and where funds from the payment will be transferred to for the invoice.
  1466  type InvoiceTransferData struct {
  1467  	// The amount in cents (or local equivalent) that will be transferred to the destination account when the invoice is paid. By default, the entire amount is transferred to the destination.
  1468  	Amount int64 `json:"amount"`
  1469  	// The account where funds from the payment will be transferred to upon payment success.
  1470  	Destination *Account `json:"destination"`
  1471  }
  1472  
  1473  // Invoices are statements of amounts owed by a customer, and are either
  1474  // generated one-off, or generated periodically from a subscription.
  1475  //
  1476  // They contain [invoice items](https://stripe.com/docs/api#invoiceitems), and proration adjustments
  1477  // that may be caused by subscription upgrades/downgrades (if necessary).
  1478  //
  1479  // If your invoice is configured to be billed through automatic charges,
  1480  // Stripe automatically finalizes your invoice and attempts payment. Note
  1481  // that finalizing the invoice,
  1482  // [when automatic](https://stripe.com/docs/invoicing/integration/automatic-advancement-collection), does
  1483  // not happen immediately as the invoice is created. Stripe waits
  1484  // until one hour after the last webhook was successfully sent (or the last
  1485  // webhook timed out after failing). If you (and the platforms you may have
  1486  // connected to) have no webhooks configured, Stripe waits one hour after
  1487  // creation to finalize the invoice.
  1488  //
  1489  // If your invoice is configured to be billed by sending an email, then based on your
  1490  // [email settings](https://dashboard.stripe.com/account/billing/automatic),
  1491  // Stripe will email the invoice to your customer and await payment. These
  1492  // emails can contain a link to a hosted page to pay the invoice.
  1493  //
  1494  // Stripe applies any customer credit on the account before determining the
  1495  // amount due for the invoice (i.e., the amount that will be actually
  1496  // charged). If the amount due for the invoice is less than Stripe's [minimum allowed charge
  1497  // per currency](https://stripe.com/docs/currencies#minimum-and-maximum-charge-amounts), the
  1498  // invoice is automatically marked paid, and we add the amount due to the
  1499  // customer's credit balance which is applied to the next invoice.
  1500  //
  1501  // More details on the customer's credit balance are
  1502  // [here](https://stripe.com/docs/billing/customer/balance).
  1503  //
  1504  // Related guide: [Send invoices to customers](https://stripe.com/docs/billing/invoices/sending)
  1505  type Invoice struct {
  1506  	APIResource
  1507  	// The country of the business associated with this invoice, most often the business creating the invoice.
  1508  	AccountCountry string `json:"account_country"`
  1509  	// The public name of the business associated with this invoice, most often the business creating the invoice.
  1510  	AccountName string `json:"account_name"`
  1511  	// The account tax IDs associated with the invoice. Only editable when the invoice is a draft.
  1512  	AccountTaxIDs []*TaxID `json:"account_tax_ids"`
  1513  	// Final amount due at this time for this invoice. If the invoice's total is smaller than the minimum charge amount, for example, or if there is account credit that can be applied to the invoice, the `amount_due` may be 0. If there is a positive `starting_balance` for the invoice (the customer owes money), the `amount_due` will also take that into account. The charge that gets generated for the invoice will be for the amount specified in `amount_due`.
  1514  	AmountDue int64 `json:"amount_due"`
  1515  	// The amount, in cents (or local equivalent), that was paid.
  1516  	AmountPaid int64 `json:"amount_paid"`
  1517  	// The difference between amount_due and amount_paid, in cents (or local equivalent).
  1518  	AmountRemaining int64 `json:"amount_remaining"`
  1519  	// This is the sum of all the shipping amounts.
  1520  	AmountShipping int64 `json:"amount_shipping"`
  1521  	// ID of the Connect Application that created the invoice.
  1522  	Application *Application `json:"application"`
  1523  	// The fee in cents (or local equivalent) that will be applied to the invoice and transferred to the application owner's Stripe account when the invoice is paid.
  1524  	ApplicationFeeAmount int64 `json:"application_fee_amount"`
  1525  	// Number of payment attempts made for this invoice, from the perspective of the payment retry schedule. Any payment attempt counts as the first attempt, and subsequently only automatic retries increment the attempt count. In other words, manual payment attempts after the first attempt do not affect the retry schedule.
  1526  	AttemptCount int64 `json:"attempt_count"`
  1527  	// Whether an attempt has been made to pay the invoice. An invoice is not attempted until 1 hour after the `invoice.created` webhook, for example, so you might not want to display that invoice as unpaid to your users.
  1528  	Attempted bool `json:"attempted"`
  1529  	// Controls whether Stripe performs [automatic collection](https://stripe.com/docs/invoicing/integration/automatic-advancement-collection) of the invoice. If `false`, the invoice's state doesn't automatically advance without an explicit action.
  1530  	AutoAdvance  bool                 `json:"auto_advance"`
  1531  	AutomaticTax *InvoiceAutomaticTax `json:"automatic_tax"`
  1532  	// Indicates the reason why the invoice was created.
  1533  	//
  1534  	// * `manual`: Unrelated to a subscription, for example, created via the invoice editor.
  1535  	// * `subscription`: No longer in use. Applies to subscriptions from before May 2018 where no distinction was made between updates, cycles, and thresholds.
  1536  	// * `subscription_create`: A new subscription was created.
  1537  	// * `subscription_cycle`: A subscription advanced into a new period.
  1538  	// * `subscription_threshold`: A subscription reached a billing threshold.
  1539  	// * `subscription_update`: A subscription was updated.
  1540  	// * `upcoming`: Reserved for simulated invoices, per the upcoming invoice endpoint.
  1541  	BillingReason InvoiceBillingReason `json:"billing_reason"`
  1542  	// ID of the latest charge generated for this invoice, if any.
  1543  	Charge *Charge `json:"charge"`
  1544  	// Either `charge_automatically`, or `send_invoice`. When charging automatically, Stripe will attempt to pay this invoice using the default source attached to the customer. When sending an invoice, Stripe will email this invoice to the customer with payment instructions.
  1545  	CollectionMethod InvoiceCollectionMethod `json:"collection_method"`
  1546  	// Time at which the object was created. Measured in seconds since the Unix epoch.
  1547  	Created int64 `json:"created"`
  1548  	// 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).
  1549  	Currency Currency `json:"currency"`
  1550  	// The ID of the customer who will be billed.
  1551  	Customer *Customer `json:"customer"`
  1552  	// The customer's address. Until the invoice is finalized, this field will equal `customer.address`. Once the invoice is finalized, this field will no longer be updated.
  1553  	CustomerAddress *Address `json:"customer_address"`
  1554  	// The customer's email. Until the invoice is finalized, this field will equal `customer.email`. Once the invoice is finalized, this field will no longer be updated.
  1555  	CustomerEmail string `json:"customer_email"`
  1556  	// The customer's name. Until the invoice is finalized, this field will equal `customer.name`. Once the invoice is finalized, this field will no longer be updated.
  1557  	CustomerName string `json:"customer_name"`
  1558  	// The customer's phone number. Until the invoice is finalized, this field will equal `customer.phone`. Once the invoice is finalized, this field will no longer be updated.
  1559  	CustomerPhone string `json:"customer_phone"`
  1560  	// The customer's shipping information. Until the invoice is finalized, this field will equal `customer.shipping`. Once the invoice is finalized, this field will no longer be updated.
  1561  	CustomerShipping *ShippingDetails `json:"customer_shipping"`
  1562  	// The customer's tax exempt status. Until the invoice is finalized, this field will equal `customer.tax_exempt`. Once the invoice is finalized, this field will no longer be updated.
  1563  	CustomerTaxExempt *CustomerTaxExempt `json:"customer_tax_exempt"`
  1564  	// The customer's tax IDs. Until the invoice is finalized, this field will contain the same tax IDs as `customer.tax_ids`. Once the invoice is finalized, this field will no longer be updated.
  1565  	CustomerTaxIDs []*InvoiceCustomerTaxID `json:"customer_tax_ids"`
  1566  	// Custom fields displayed on the invoice.
  1567  	CustomFields []*InvoiceCustomField `json:"custom_fields"`
  1568  	// ID of the default payment method for the invoice. It must belong to the customer associated with the invoice. If not set, defaults to the subscription's default payment method, if any, or to the default payment method in the customer's invoice settings.
  1569  	DefaultPaymentMethod *PaymentMethod `json:"default_payment_method"`
  1570  	// ID of the default payment source for the invoice. It must belong to the customer associated with the invoice and be in a chargeable state. If not set, defaults to the subscription's default source, if any, or to the customer's default source.
  1571  	DefaultSource *PaymentSource `json:"default_source"`
  1572  	// The tax rates applied to this invoice, if any.
  1573  	DefaultTaxRates []*TaxRate `json:"default_tax_rates"`
  1574  	Deleted         bool       `json:"deleted"`
  1575  	// An arbitrary string attached to the object. Often useful for displaying to users. Referenced as 'memo' in the Dashboard.
  1576  	Description string `json:"description"`
  1577  	// Describes the current discount applied to this invoice, if there is one. Not populated if there are multiple discounts.
  1578  	Discount *Discount `json:"discount"`
  1579  	// The discounts applied to the invoice. Line item discounts are applied before invoice discounts. Use `expand[]=discounts` to expand each discount.
  1580  	Discounts []*Discount `json:"discounts"`
  1581  	// The date on which payment for this invoice is due. This value will be `null` for invoices where `collection_method=charge_automatically`.
  1582  	DueDate int64 `json:"due_date"`
  1583  	// The date when this invoice is in effect. Same as `finalized_at` unless overwritten. When defined, this value replaces the system-generated 'Date of issue' printed on the invoice PDF and receipt.
  1584  	EffectiveAt int64 `json:"effective_at"`
  1585  	// Ending customer balance after the invoice is finalized. Invoices are finalized approximately an hour after successful webhook delivery or when payment collection is attempted for the invoice. If the invoice has not been finalized yet, this will be null.
  1586  	EndingBalance int64 `json:"ending_balance"`
  1587  	// Footer displayed on the invoice.
  1588  	Footer string `json:"footer"`
  1589  	// Details of the invoice that was cloned. See the [revision documentation](https://stripe.com/docs/invoicing/invoice-revisions) for more details.
  1590  	FromInvoice *InvoiceFromInvoice `json:"from_invoice"`
  1591  	// The URL for the hosted invoice page, which allows customers to view and pay an invoice. If the invoice has not been finalized yet, this will be null.
  1592  	HostedInvoiceURL string `json:"hosted_invoice_url"`
  1593  	// Unique identifier for the object. This property is always present unless the invoice is an upcoming invoice. See [Retrieve an upcoming invoice](https://stripe.com/docs/api/invoices/upcoming) for more details.
  1594  	ID string `json:"id"`
  1595  	// The link to download the PDF for the invoice. If the invoice has not been finalized yet, this will be null.
  1596  	InvoicePDF string         `json:"invoice_pdf"`
  1597  	Issuer     *InvoiceIssuer `json:"issuer"`
  1598  	// The error encountered during the previous attempt to finalize the invoice. This field is cleared when the invoice is successfully finalized.
  1599  	LastFinalizationError *Error `json:"last_finalization_error"`
  1600  	// The ID of the most recent non-draft revision of this invoice
  1601  	LatestRevision *Invoice `json:"latest_revision"`
  1602  	// The individual line items that make up the invoice. `lines` is sorted as follows: (1) pending invoice items (including prorations) in reverse chronological order, (2) subscription items in reverse chronological order, and (3) invoice items added after invoice creation in chronological order.
  1603  	Lines *InvoiceLineItemList `json:"lines"`
  1604  	// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
  1605  	Livemode bool `json:"livemode"`
  1606  	// 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.
  1607  	Metadata map[string]string `json:"metadata"`
  1608  	// The time at which payment will next be attempted. This value will be `null` for invoices where `collection_method=send_invoice`.
  1609  	NextPaymentAttempt int64 `json:"next_payment_attempt"`
  1610  	// A unique, identifying string that appears on emails sent to the customer for this invoice. This starts with the customer's unique invoice_prefix if it is specified.
  1611  	Number string `json:"number"`
  1612  	// String representing the object's type. Objects of the same type share the same value.
  1613  	Object string `json:"object"`
  1614  	// The account (if any) for which the funds of the invoice payment are intended. If set, the invoice will be presented with the branding and support information of the specified account. See the [Invoices with Connect](https://stripe.com/docs/billing/invoices/connect) documentation for details.
  1615  	OnBehalfOf *Account `json:"on_behalf_of"`
  1616  	// Whether payment was successfully collected for this invoice. An invoice can be paid (most commonly) with a charge or with credit from the customer's account balance.
  1617  	Paid bool `json:"paid"`
  1618  	// Returns true if the invoice was manually marked paid, returns false if the invoice hasn't been paid yet or was paid on Stripe.
  1619  	PaidOutOfBand bool `json:"paid_out_of_band"`
  1620  	// The PaymentIntent associated with this invoice. The PaymentIntent is generated when the invoice is finalized, and can then be used to pay the invoice. Note that voiding an invoice will cancel the PaymentIntent.
  1621  	PaymentIntent   *PaymentIntent          `json:"payment_intent"`
  1622  	PaymentSettings *InvoicePaymentSettings `json:"payment_settings"`
  1623  	// End of the usage period during which invoice items were added to this invoice.
  1624  	PeriodEnd int64 `json:"period_end"`
  1625  	// Start of the usage period during which invoice items were added to this invoice.
  1626  	PeriodStart int64 `json:"period_start"`
  1627  	// Total amount of all post-payment credit notes issued for this invoice.
  1628  	PostPaymentCreditNotesAmount int64 `json:"post_payment_credit_notes_amount"`
  1629  	// Total amount of all pre-payment credit notes issued for this invoice.
  1630  	PrePaymentCreditNotesAmount int64 `json:"pre_payment_credit_notes_amount"`
  1631  	// The quote this invoice was generated from.
  1632  	Quote *Quote `json:"quote"`
  1633  	// This is the transaction number that appears on email receipts sent for this invoice.
  1634  	ReceiptNumber string `json:"receipt_number"`
  1635  	// The rendering-related settings that control how the invoice is displayed on customer-facing surfaces such as PDF and Hosted Invoice Page.
  1636  	Rendering *InvoiceRendering `json:"rendering"`
  1637  	// This is a legacy field that will be removed soon. For details about `rendering_options`, refer to `rendering` instead. Options for invoice PDF rendering.
  1638  	RenderingOptions *InvoiceRenderingOptions `json:"rendering_options"`
  1639  	// The details of the cost of shipping, including the ShippingRate applied on the invoice.
  1640  	ShippingCost *InvoiceShippingCost `json:"shipping_cost"`
  1641  	// Shipping details for the invoice. The Invoice PDF will use the `shipping_details` value if it is set, otherwise the PDF will render the shipping address from the customer.
  1642  	ShippingDetails *ShippingDetails `json:"shipping_details"`
  1643  	// Starting customer balance before the invoice is finalized. If the invoice has not been finalized yet, this will be the current customer balance. For revision invoices, this also includes any customer balance that was applied to the original invoice.
  1644  	StartingBalance int64 `json:"starting_balance"`
  1645  	// Extra information about an invoice for the customer's credit card statement.
  1646  	StatementDescriptor string `json:"statement_descriptor"`
  1647  	// The status of the invoice, one of `draft`, `open`, `paid`, `uncollectible`, or `void`. [Learn more](https://stripe.com/docs/billing/invoices/workflow#workflow-overview)
  1648  	Status            InvoiceStatus             `json:"status"`
  1649  	StatusTransitions *InvoiceStatusTransitions `json:"status_transitions"`
  1650  	// The subscription that this invoice was prepared for, if any.
  1651  	Subscription *Subscription `json:"subscription"`
  1652  	// Details about the subscription that created this invoice.
  1653  	SubscriptionDetails *InvoiceSubscriptionDetails `json:"subscription_details"`
  1654  	// Only set for upcoming invoices that preview prorations. The time used to calculate prorations.
  1655  	SubscriptionProrationDate int64 `json:"subscription_proration_date"`
  1656  	// Total of all subscriptions, invoice items, and prorations on the invoice before any invoice level discount or exclusive tax is applied. Item discounts are already incorporated
  1657  	Subtotal int64 `json:"subtotal"`
  1658  	// The integer amount in cents (or local equivalent) representing the subtotal of the invoice before any invoice level discount or tax is applied. Item discounts are already incorporated
  1659  	SubtotalExcludingTax int64 `json:"subtotal_excluding_tax"`
  1660  	// The amount of tax on this invoice. This is the sum of all the tax amounts on this invoice.
  1661  	Tax int64 `json:"tax"`
  1662  	// ID of the test clock this invoice belongs to.
  1663  	TestClock       *TestHelpersTestClock   `json:"test_clock"`
  1664  	ThresholdReason *InvoiceThresholdReason `json:"threshold_reason"`
  1665  	// Total after discounts and taxes.
  1666  	Total int64 `json:"total"`
  1667  	// The aggregate amounts calculated per discount across all line items.
  1668  	TotalDiscountAmounts []*InvoiceTotalDiscountAmount `json:"total_discount_amounts"`
  1669  	// The integer amount in cents (or local equivalent) representing the total amount of the invoice including all discounts but excluding all tax.
  1670  	TotalExcludingTax int64 `json:"total_excluding_tax"`
  1671  	// The aggregate amounts calculated per tax rate for all line items.
  1672  	TotalTaxAmounts []*InvoiceTotalTaxAmount `json:"total_tax_amounts"`
  1673  	// The account (if any) the payment will be attributed to for tax reporting, and where funds from the payment will be transferred to for the invoice.
  1674  	TransferData *InvoiceTransferData `json:"transfer_data"`
  1675  	// Invoices are automatically paid or sent 1 hour after webhooks are delivered, or until all webhook delivery attempts have [been exhausted](https://stripe.com/docs/billing/webhooks#understand). This field tracks the time when webhooks for this invoice were successfully delivered. If the invoice had no webhooks to deliver, this will be set while the invoice is being created.
  1676  	WebhooksDeliveredAt int64 `json:"webhooks_delivered_at"`
  1677  }
  1678  
  1679  // InvoiceList is a list of Invoices as retrieved from a list endpoint.
  1680  type InvoiceList struct {
  1681  	APIResource
  1682  	ListMeta
  1683  	Data []*Invoice `json:"data"`
  1684  }
  1685  
  1686  // InvoiceSearchResult is a list of Invoice search results as retrieved from a search endpoint.
  1687  type InvoiceSearchResult struct {
  1688  	APIResource
  1689  	SearchMeta
  1690  	Data []*Invoice `json:"data"`
  1691  }
  1692  
  1693  // UnmarshalJSON handles deserialization of an Invoice.
  1694  // This custom unmarshaling is needed because the resulting
  1695  // property may be an id or the full struct if it was expanded.
  1696  func (i *Invoice) UnmarshalJSON(data []byte) error {
  1697  	if id, ok := ParseID(data); ok {
  1698  		i.ID = id
  1699  		return nil
  1700  	}
  1701  
  1702  	type invoice Invoice
  1703  	var v invoice
  1704  	if err := json.Unmarshal(data, &v); err != nil {
  1705  		return err
  1706  	}
  1707  
  1708  	*i = Invoice(v)
  1709  	return nil
  1710  }