github.com/stripe/stripe-go/v76@v76.25.0/subscription.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 SubscriptionAutomaticTaxLiabilityType string
    16  
    17  // List of values that SubscriptionAutomaticTaxLiabilityType can take
    18  const (
    19  	SubscriptionAutomaticTaxLiabilityTypeAccount SubscriptionAutomaticTaxLiabilityType = "account"
    20  	SubscriptionAutomaticTaxLiabilityTypeSelf    SubscriptionAutomaticTaxLiabilityType = "self"
    21  )
    22  
    23  // The customer submitted reason for why they canceled, if the subscription was canceled explicitly by the user.
    24  type SubscriptionCancellationDetailsFeedback string
    25  
    26  // List of values that SubscriptionCancellationDetailsFeedback can take
    27  const (
    28  	SubscriptionCancellationDetailsFeedbackCustomerService SubscriptionCancellationDetailsFeedback = "customer_service"
    29  	SubscriptionCancellationDetailsFeedbackLowQuality      SubscriptionCancellationDetailsFeedback = "low_quality"
    30  	SubscriptionCancellationDetailsFeedbackMissingFeatures SubscriptionCancellationDetailsFeedback = "missing_features"
    31  	SubscriptionCancellationDetailsFeedbackOther           SubscriptionCancellationDetailsFeedback = "other"
    32  	SubscriptionCancellationDetailsFeedbackSwitchedService SubscriptionCancellationDetailsFeedback = "switched_service"
    33  	SubscriptionCancellationDetailsFeedbackTooComplex      SubscriptionCancellationDetailsFeedback = "too_complex"
    34  	SubscriptionCancellationDetailsFeedbackTooExpensive    SubscriptionCancellationDetailsFeedback = "too_expensive"
    35  	SubscriptionCancellationDetailsFeedbackUnused          SubscriptionCancellationDetailsFeedback = "unused"
    36  )
    37  
    38  // Why this subscription was canceled.
    39  type SubscriptionCancellationDetailsReason string
    40  
    41  // List of values that SubscriptionCancellationDetailsReason can take
    42  const (
    43  	SubscriptionCancellationDetailsReasonCancellationRequested SubscriptionCancellationDetailsReason = "cancellation_requested"
    44  	SubscriptionCancellationDetailsReasonPaymentDisputed       SubscriptionCancellationDetailsReason = "payment_disputed"
    45  	SubscriptionCancellationDetailsReasonPaymentFailed         SubscriptionCancellationDetailsReason = "payment_failed"
    46  )
    47  
    48  // Either `charge_automatically`, or `send_invoice`. When charging automatically, Stripe will attempt to pay this subscription at the end of the cycle using the default source attached to the customer. When sending an invoice, Stripe will email your customer an invoice with payment instructions and mark the subscription as `active`.
    49  type SubscriptionCollectionMethod string
    50  
    51  // List of values that SubscriptionCollectionMethod can take
    52  const (
    53  	SubscriptionCollectionMethodChargeAutomatically SubscriptionCollectionMethod = "charge_automatically"
    54  	SubscriptionCollectionMethodSendInvoice         SubscriptionCollectionMethod = "send_invoice"
    55  )
    56  
    57  // The payment collection behavior for this subscription while paused. One of `keep_as_draft`, `mark_uncollectible`, or `void`.
    58  type SubscriptionPauseCollectionBehavior string
    59  
    60  // List of values that SubscriptionPauseCollectionBehavior can take
    61  const (
    62  	SubscriptionPauseCollectionBehaviorKeepAsDraft       SubscriptionPauseCollectionBehavior = "keep_as_draft"
    63  	SubscriptionPauseCollectionBehaviorMarkUncollectible SubscriptionPauseCollectionBehavior = "mark_uncollectible"
    64  	SubscriptionPauseCollectionBehaviorVoid              SubscriptionPauseCollectionBehavior = "void"
    65  )
    66  
    67  // Transaction type of the mandate.
    68  type SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebitMandateOptionsTransactionType string
    69  
    70  // List of values that SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebitMandateOptionsTransactionType can take
    71  const (
    72  	SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebitMandateOptionsTransactionTypeBusiness SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebitMandateOptionsTransactionType = "business"
    73  	SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebitMandateOptionsTransactionTypePersonal SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebitMandateOptionsTransactionType = "personal"
    74  )
    75  
    76  // Bank account verification method.
    77  type SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebitVerificationMethod string
    78  
    79  // List of values that SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebitVerificationMethod can take
    80  const (
    81  	SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebitVerificationMethodAutomatic     SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebitVerificationMethod = "automatic"
    82  	SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebitVerificationMethodInstant       SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebitVerificationMethod = "instant"
    83  	SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebitVerificationMethodMicrodeposits SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebitVerificationMethod = "microdeposits"
    84  )
    85  
    86  // One of `fixed` or `maximum`. If `fixed`, the `amount` param refers to the exact amount to be charged in future payments. If `maximum`, the amount charged can be up to the value passed for the `amount` param.
    87  type SubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptionsAmountType string
    88  
    89  // List of values that SubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptionsAmountType can take
    90  const (
    91  	SubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptionsAmountTypeFixed   SubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptionsAmountType = "fixed"
    92  	SubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptionsAmountTypeMaximum SubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptionsAmountType = "maximum"
    93  )
    94  
    95  // Selected network to process this Subscription on. Depends on the available networks of the card attached to the Subscription. Can be only set confirm-time.
    96  type SubscriptionPaymentSettingsPaymentMethodOptionsCardNetwork string
    97  
    98  // List of values that SubscriptionPaymentSettingsPaymentMethodOptionsCardNetwork can take
    99  const (
   100  	SubscriptionPaymentSettingsPaymentMethodOptionsCardNetworkAmex            SubscriptionPaymentSettingsPaymentMethodOptionsCardNetwork = "amex"
   101  	SubscriptionPaymentSettingsPaymentMethodOptionsCardNetworkCartesBancaires SubscriptionPaymentSettingsPaymentMethodOptionsCardNetwork = "cartes_bancaires"
   102  	SubscriptionPaymentSettingsPaymentMethodOptionsCardNetworkDiners          SubscriptionPaymentSettingsPaymentMethodOptionsCardNetwork = "diners"
   103  	SubscriptionPaymentSettingsPaymentMethodOptionsCardNetworkDiscover        SubscriptionPaymentSettingsPaymentMethodOptionsCardNetwork = "discover"
   104  	SubscriptionPaymentSettingsPaymentMethodOptionsCardNetworkEFTPOSAU        SubscriptionPaymentSettingsPaymentMethodOptionsCardNetwork = "eftpos_au"
   105  	SubscriptionPaymentSettingsPaymentMethodOptionsCardNetworkInterac         SubscriptionPaymentSettingsPaymentMethodOptionsCardNetwork = "interac"
   106  	SubscriptionPaymentSettingsPaymentMethodOptionsCardNetworkJCB             SubscriptionPaymentSettingsPaymentMethodOptionsCardNetwork = "jcb"
   107  	SubscriptionPaymentSettingsPaymentMethodOptionsCardNetworkMastercard      SubscriptionPaymentSettingsPaymentMethodOptionsCardNetwork = "mastercard"
   108  	SubscriptionPaymentSettingsPaymentMethodOptionsCardNetworkUnionpay        SubscriptionPaymentSettingsPaymentMethodOptionsCardNetwork = "unionpay"
   109  	SubscriptionPaymentSettingsPaymentMethodOptionsCardNetworkUnknown         SubscriptionPaymentSettingsPaymentMethodOptionsCardNetwork = "unknown"
   110  	SubscriptionPaymentSettingsPaymentMethodOptionsCardNetworkVisa            SubscriptionPaymentSettingsPaymentMethodOptionsCardNetwork = "visa"
   111  )
   112  
   113  // 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.
   114  type SubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure string
   115  
   116  // List of values that SubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure can take
   117  const (
   118  	SubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecureAny       SubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure = "any"
   119  	SubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecureAutomatic SubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure = "automatic"
   120  	SubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecureChallenge SubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure = "challenge"
   121  )
   122  
   123  // The funding method type to be used when there are not enough funds in the customer balance. Permitted values include: `bank_transfer`.
   124  type SubscriptionPaymentSettingsPaymentMethodOptionsCustomerBalanceFundingType string
   125  
   126  // List of values that SubscriptionPaymentSettingsPaymentMethodOptionsCustomerBalanceFundingType can take
   127  const (
   128  	SubscriptionPaymentSettingsPaymentMethodOptionsCustomerBalanceFundingTypeBankTransfer SubscriptionPaymentSettingsPaymentMethodOptionsCustomerBalanceFundingType = "bank_transfer"
   129  )
   130  
   131  // The list of permissions to request. The `payment_method` permission must be included.
   132  type SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPermission string
   133  
   134  // List of values that SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPermission can take
   135  const (
   136  	SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPermissionBalances      SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPermission = "balances"
   137  	SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPermissionPaymentMethod SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPermission = "payment_method"
   138  	SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPermissionTransactions  SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPermission = "transactions"
   139  )
   140  
   141  // Data features requested to be retrieved upon account creation.
   142  type SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPrefetch string
   143  
   144  // List of values that SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPrefetch can take
   145  const (
   146  	SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPrefetchBalances     SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPrefetch = "balances"
   147  	SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPrefetchTransactions SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPrefetch = "transactions"
   148  )
   149  
   150  // Bank account verification method.
   151  type SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountVerificationMethod string
   152  
   153  // List of values that SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountVerificationMethod can take
   154  const (
   155  	SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountVerificationMethodAutomatic     SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountVerificationMethod = "automatic"
   156  	SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountVerificationMethodInstant       SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountVerificationMethod = "instant"
   157  	SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountVerificationMethodMicrodeposits SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountVerificationMethod = "microdeposits"
   158  )
   159  
   160  // The list of payment method types to provide to every invoice created by the subscription. 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).
   161  type SubscriptionPaymentSettingsPaymentMethodType string
   162  
   163  // List of values that SubscriptionPaymentSettingsPaymentMethodType can take
   164  const (
   165  	SubscriptionPaymentSettingsPaymentMethodTypeACHCreditTransfer  SubscriptionPaymentSettingsPaymentMethodType = "ach_credit_transfer"
   166  	SubscriptionPaymentSettingsPaymentMethodTypeACHDebit           SubscriptionPaymentSettingsPaymentMethodType = "ach_debit"
   167  	SubscriptionPaymentSettingsPaymentMethodTypeACSSDebit          SubscriptionPaymentSettingsPaymentMethodType = "acss_debit"
   168  	SubscriptionPaymentSettingsPaymentMethodTypeAUBECSDebit        SubscriptionPaymentSettingsPaymentMethodType = "au_becs_debit"
   169  	SubscriptionPaymentSettingsPaymentMethodTypeBACSDebit          SubscriptionPaymentSettingsPaymentMethodType = "bacs_debit"
   170  	SubscriptionPaymentSettingsPaymentMethodTypeBancontact         SubscriptionPaymentSettingsPaymentMethodType = "bancontact"
   171  	SubscriptionPaymentSettingsPaymentMethodTypeBoleto             SubscriptionPaymentSettingsPaymentMethodType = "boleto"
   172  	SubscriptionPaymentSettingsPaymentMethodTypeCard               SubscriptionPaymentSettingsPaymentMethodType = "card"
   173  	SubscriptionPaymentSettingsPaymentMethodTypeCashApp            SubscriptionPaymentSettingsPaymentMethodType = "cashapp"
   174  	SubscriptionPaymentSettingsPaymentMethodTypeCustomerBalance    SubscriptionPaymentSettingsPaymentMethodType = "customer_balance"
   175  	SubscriptionPaymentSettingsPaymentMethodTypeEPS                SubscriptionPaymentSettingsPaymentMethodType = "eps"
   176  	SubscriptionPaymentSettingsPaymentMethodTypeFPX                SubscriptionPaymentSettingsPaymentMethodType = "fpx"
   177  	SubscriptionPaymentSettingsPaymentMethodTypeGiropay            SubscriptionPaymentSettingsPaymentMethodType = "giropay"
   178  	SubscriptionPaymentSettingsPaymentMethodTypeGrabpay            SubscriptionPaymentSettingsPaymentMethodType = "grabpay"
   179  	SubscriptionPaymentSettingsPaymentMethodTypeIDEAL              SubscriptionPaymentSettingsPaymentMethodType = "ideal"
   180  	SubscriptionPaymentSettingsPaymentMethodTypeKonbini            SubscriptionPaymentSettingsPaymentMethodType = "konbini"
   181  	SubscriptionPaymentSettingsPaymentMethodTypeLink               SubscriptionPaymentSettingsPaymentMethodType = "link"
   182  	SubscriptionPaymentSettingsPaymentMethodTypeP24                SubscriptionPaymentSettingsPaymentMethodType = "p24"
   183  	SubscriptionPaymentSettingsPaymentMethodTypePayNow             SubscriptionPaymentSettingsPaymentMethodType = "paynow"
   184  	SubscriptionPaymentSettingsPaymentMethodTypePaypal             SubscriptionPaymentSettingsPaymentMethodType = "paypal"
   185  	SubscriptionPaymentSettingsPaymentMethodTypePromptPay          SubscriptionPaymentSettingsPaymentMethodType = "promptpay"
   186  	SubscriptionPaymentSettingsPaymentMethodTypeSEPACreditTransfer SubscriptionPaymentSettingsPaymentMethodType = "sepa_credit_transfer"
   187  	SubscriptionPaymentSettingsPaymentMethodTypeSEPADebit          SubscriptionPaymentSettingsPaymentMethodType = "sepa_debit"
   188  	SubscriptionPaymentSettingsPaymentMethodTypeSofort             SubscriptionPaymentSettingsPaymentMethodType = "sofort"
   189  	SubscriptionPaymentSettingsPaymentMethodTypeUSBankAccount      SubscriptionPaymentSettingsPaymentMethodType = "us_bank_account"
   190  	SubscriptionPaymentSettingsPaymentMethodTypeWeChatPay          SubscriptionPaymentSettingsPaymentMethodType = "wechat_pay"
   191  )
   192  
   193  // Either `off`, or `on_subscription`. With `on_subscription` Stripe updates `subscription.default_payment_method` when a subscription payment succeeds.
   194  type SubscriptionPaymentSettingsSaveDefaultPaymentMethod string
   195  
   196  // List of values that SubscriptionPaymentSettingsSaveDefaultPaymentMethod can take
   197  const (
   198  	SubscriptionPaymentSettingsSaveDefaultPaymentMethodOff            SubscriptionPaymentSettingsSaveDefaultPaymentMethod = "off"
   199  	SubscriptionPaymentSettingsSaveDefaultPaymentMethodOnSubscription SubscriptionPaymentSettingsSaveDefaultPaymentMethod = "on_subscription"
   200  )
   201  
   202  // Specifies invoicing frequency. Either `day`, `week`, `month` or `year`.
   203  type SubscriptionPendingInvoiceItemIntervalInterval string
   204  
   205  // List of values that SubscriptionPendingInvoiceItemIntervalInterval can take
   206  const (
   207  	SubscriptionPendingInvoiceItemIntervalIntervalDay   SubscriptionPendingInvoiceItemIntervalInterval = "day"
   208  	SubscriptionPendingInvoiceItemIntervalIntervalMonth SubscriptionPendingInvoiceItemIntervalInterval = "month"
   209  	SubscriptionPendingInvoiceItemIntervalIntervalWeek  SubscriptionPendingInvoiceItemIntervalInterval = "week"
   210  	SubscriptionPendingInvoiceItemIntervalIntervalYear  SubscriptionPendingInvoiceItemIntervalInterval = "year"
   211  )
   212  
   213  // Possible values are `incomplete`, `incomplete_expired`, `trialing`, `active`, `past_due`, `canceled`, `unpaid`, or `paused`.
   214  //
   215  // For `collection_method=charge_automatically` a subscription moves into `incomplete` if the initial payment attempt fails. A subscription in this status can only have metadata and default_source updated. Once the first invoice is paid, the subscription moves into an `active` status. If the first invoice is not paid within 23 hours, the subscription transitions to `incomplete_expired`. This is a terminal status, the open invoice will be voided and no further invoices will be generated.
   216  //
   217  // A subscription that is currently in a trial period is `trialing` and moves to `active` when the trial period is over.
   218  //
   219  // A subscription can only enter a `paused` status [when a trial ends without a payment method](https://stripe.com/billing/subscriptions/trials#create-free-trials-without-payment). A `paused` subscription doesn't generate invoices and can be resumed after your customer adds their payment method. The `paused` status is different from [pausing collection](https://stripe.com/billing/subscriptions/pause-payment), which still generates invoices and leaves the subscription's status unchanged.
   220  //
   221  // If subscription `collection_method=charge_automatically`, it becomes `past_due` when payment is required but cannot be paid (due to failed payment or awaiting additional user actions). Once Stripe has exhausted all payment retry attempts, the subscription will become `canceled` or `unpaid` (depending on your subscriptions settings).
   222  //
   223  // If subscription `collection_method=send_invoice` it becomes `past_due` when its invoice is not paid by the due date, and `canceled` or `unpaid` if it is still not paid by an additional deadline after that. Note that when a subscription has a status of `unpaid`, no subsequent invoices will be attempted (invoices will be created, but then immediately automatically closed). After receiving updated payment information from a customer, you may choose to reopen and pay their closed invoices.
   224  type SubscriptionStatus string
   225  
   226  // List of values that SubscriptionStatus can take
   227  const (
   228  	SubscriptionStatusActive            SubscriptionStatus = "active"
   229  	SubscriptionStatusCanceled          SubscriptionStatus = "canceled"
   230  	SubscriptionStatusIncomplete        SubscriptionStatus = "incomplete"
   231  	SubscriptionStatusIncompleteExpired SubscriptionStatus = "incomplete_expired"
   232  	SubscriptionStatusPastDue           SubscriptionStatus = "past_due"
   233  	SubscriptionStatusPaused            SubscriptionStatus = "paused"
   234  	SubscriptionStatusTrialing          SubscriptionStatus = "trialing"
   235  	SubscriptionStatusUnpaid            SubscriptionStatus = "unpaid"
   236  )
   237  
   238  // Indicates how the subscription should change when the trial ends if the user did not provide a payment method.
   239  type SubscriptionTrialSettingsEndBehaviorMissingPaymentMethod string
   240  
   241  // List of values that SubscriptionTrialSettingsEndBehaviorMissingPaymentMethod can take
   242  const (
   243  	SubscriptionTrialSettingsEndBehaviorMissingPaymentMethodCancel        SubscriptionTrialSettingsEndBehaviorMissingPaymentMethod = "cancel"
   244  	SubscriptionTrialSettingsEndBehaviorMissingPaymentMethodCreateInvoice SubscriptionTrialSettingsEndBehaviorMissingPaymentMethod = "create_invoice"
   245  	SubscriptionTrialSettingsEndBehaviorMissingPaymentMethodPause         SubscriptionTrialSettingsEndBehaviorMissingPaymentMethod = "pause"
   246  )
   247  
   248  // Details about why this subscription was cancelled
   249  type SubscriptionCancelCancellationDetailsParams struct {
   250  	// Additional comments about why the user canceled the subscription, if the subscription was canceled explicitly by the user.
   251  	Comment *string `form:"comment"`
   252  	// The customer submitted reason for why they canceled, if the subscription was canceled explicitly by the user.
   253  	Feedback *string `form:"feedback"`
   254  }
   255  
   256  // Cancels a customer's subscription immediately. The customer will not be charged again for the subscription.
   257  //
   258  // Note, however, that any pending invoice items that you've created will still be charged for at the end of the period, unless manually [deleted](https://stripe.com/docs/api#delete_invoiceitem). If you've set the subscription to cancel at the end of the period, any pending prorations will also be left in place and collected at the end of the period. But if the subscription is set to cancel immediately, pending prorations will be removed.
   259  //
   260  // By default, upon subscription cancellation, Stripe will stop automatic collection of all finalized invoices for the customer. This is intended to prevent unexpected payment attempts after the customer has canceled a subscription. However, you can resume automatic collection of the invoices manually after subscription cancellation to have us proceed. Or, you could check for unpaid invoices before allowing the customer to cancel the subscription at all.
   261  type SubscriptionCancelParams struct {
   262  	Params `form:"*"`
   263  	// Details about why this subscription was cancelled
   264  	CancellationDetails *SubscriptionCancelCancellationDetailsParams `form:"cancellation_details"`
   265  	// Specifies which fields in the response should be expanded.
   266  	Expand []*string `form:"expand"`
   267  	// Will generate a final invoice that invoices for any un-invoiced metered usage and new/pending proration invoice items.
   268  	InvoiceNow *bool `form:"invoice_now"`
   269  	// Will generate a proration invoice item that credits remaining unused time until the subscription period end.
   270  	Prorate *bool `form:"prorate"`
   271  }
   272  
   273  // AddExpand appends a new field to expand.
   274  func (p *SubscriptionCancelParams) AddExpand(f string) {
   275  	p.Expand = append(p.Expand, &f)
   276  }
   277  
   278  // Retrieves the subscription with the given ID.
   279  type SubscriptionParams struct {
   280  	Params `form:"*"`
   281  	// A list of prices and quantities that will generate invoice items appended to the next invoice for this subscription. You may pass up to 20 items.
   282  	AddInvoiceItems []*SubscriptionAddInvoiceItemParams `form:"add_invoice_items"`
   283  	// A non-negative decimal between 0 and 100, with at most two decimal places. This represents the percentage of the subscription invoice total that will be transferred to the application owner's Stripe account. The request must be made by a platform account on a connected account in order to set an application fee percentage. For more information, see the application fees [documentation](https://stripe.com/docs/connect/subscriptions#collecting-fees-on-subscriptions).
   284  	ApplicationFeePercent *float64 `form:"application_fee_percent"`
   285  	// Automatic tax settings for this subscription. We recommend you only include this parameter when the existing value is being changed.
   286  	AutomaticTax *SubscriptionAutomaticTaxParams `form:"automatic_tax"`
   287  	// For new subscriptions, a past timestamp to backdate the subscription's start date to. If set, the first invoice will contain a proration for the timespan between the start date and the current time. Can be combined with trials and the billing cycle anchor.
   288  	BackdateStartDate *int64 `form:"backdate_start_date"`
   289  	// A future timestamp in UTC format to anchor the subscription's [billing cycle](https://stripe.com/docs/subscriptions/billing-cycle). The anchor is the reference point that aligns future billing cycle dates. It sets the day of week for `week` intervals, the day of month for `month` and `year` intervals, and the month of year for `year` intervals.
   290  	BillingCycleAnchor *int64 `form:"billing_cycle_anchor"`
   291  	// Mutually exclusive with billing_cycle_anchor and only valid with monthly and yearly price intervals. When provided, the billing_cycle_anchor is set to the next occurence of the day_of_month at the hour, minute, and second UTC.
   292  	BillingCycleAnchorConfig    *SubscriptionBillingCycleAnchorConfigParams `form:"billing_cycle_anchor_config"`
   293  	BillingCycleAnchorNow       *bool                                       `form:"-"` // See custom AppendTo
   294  	BillingCycleAnchorUnchanged *bool                                       `form:"-"` // See custom AppendTo
   295  	// Define thresholds at which an invoice will be sent, and the subscription advanced to a new billing period. Pass an empty string to remove previously-defined thresholds.
   296  	BillingThresholds *SubscriptionBillingThresholdsParams `form:"billing_thresholds"`
   297  	// 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.
   298  	CancelAt *int64 `form:"cancel_at"`
   299  	// Boolean indicating whether this subscription should cancel at the end of the current period.
   300  	CancelAtPeriodEnd *bool `form:"cancel_at_period_end"`
   301  	// Details about why this subscription was cancelled
   302  	CancellationDetails *SubscriptionCancellationDetailsParams `form:"cancellation_details"`
   303  	// Either `charge_automatically`, or `send_invoice`. When charging automatically, Stripe will attempt to pay this subscription at the end of the cycle using the default source attached to the customer. When sending an invoice, Stripe will email your customer an invoice with payment instructions and mark the subscription as `active`. Defaults to `charge_automatically`.
   304  	CollectionMethod *string `form:"collection_method"`
   305  	// The ID of the coupon to apply to this subscription. A coupon applied to a subscription will only affect invoices created for that particular subscription. This field has been deprecated and will be removed in a future API version. Use `discounts` instead.
   306  	Coupon *string `form:"coupon"`
   307  	// 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).
   308  	Currency *string `form:"currency"`
   309  	// The identifier of the customer to subscribe.
   310  	Customer *string `form:"customer"`
   311  	// Number of days a customer has to pay invoices generated by this subscription. Valid only for subscriptions where `collection_method` is set to `send_invoice`.
   312  	DaysUntilDue *int64 `form:"days_until_due"`
   313  	// ID of the default payment method for the subscription. It must belong to the customer associated with the subscription. This takes precedence over `default_source`. If neither are set, invoices will use the customer's [invoice_settings.default_payment_method](https://stripe.com/docs/api/customers/object#customer_object-invoice_settings-default_payment_method) or [default_source](https://stripe.com/docs/api/customers/object#customer_object-default_source).
   314  	DefaultPaymentMethod *string `form:"default_payment_method"`
   315  	// ID of the default payment source for the subscription. It must belong to the customer associated with the subscription and be in a chargeable state. If `default_payment_method` is also set, `default_payment_method` will take precedence. If neither are set, invoices will use the customer's [invoice_settings.default_payment_method](https://stripe.com/docs/api/customers/object#customer_object-invoice_settings-default_payment_method) or [default_source](https://stripe.com/docs/api/customers/object#customer_object-default_source).
   316  	DefaultSource *string `form:"default_source"`
   317  	// The tax rates that will apply to any subscription item that does not have `tax_rates` set. Invoices created will have their `default_tax_rates` populated from the subscription. Pass an empty string to remove previously-defined tax rates.
   318  	DefaultTaxRates []*string `form:"default_tax_rates"`
   319  	// The subscription's description, meant to be displayable to the customer. Use this field to optionally store an explanation of the subscription for rendering in Stripe surfaces and certain local payment methods UIs.
   320  	Description *string `form:"description"`
   321  	// The coupons to redeem into discounts for the subscription. If not specified or empty, inherits the discount from the subscription's customer.
   322  	Discounts []*SubscriptionDiscountParams `form:"discounts"`
   323  	// Specifies which fields in the response should be expanded.
   324  	Expand []*string `form:"expand"`
   325  	// All invoices will be billed using the specified settings.
   326  	InvoiceSettings *SubscriptionInvoiceSettingsParams `form:"invoice_settings"`
   327  	// A list of up to 20 subscription items, each with an attached price.
   328  	Items []*SubscriptionItemsParams `form:"items"`
   329  	// 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`.
   330  	Metadata map[string]string `form:"metadata"`
   331  	// Indicates if a customer is on or off-session while an invoice payment is attempted.
   332  	OffSession *bool `form:"off_session"`
   333  	// The account on behalf of which to charge, for each of the subscription's invoices.
   334  	OnBehalfOf *string `form:"on_behalf_of"`
   335  	// If specified, payment collection for this subscription will be paused. Note that the subscription status will be unchanged and will not be updated to `paused`. Learn more about [pausing collection](https://stripe.com/billing/subscriptions/pause-payment).
   336  	PauseCollection *SubscriptionPauseCollectionParams `form:"pause_collection"`
   337  	// Only applies to subscriptions with `collection_method=charge_automatically`.
   338  	//
   339  	// Use `allow_incomplete` to create Subscriptions with `status=incomplete` if the first invoice can't be paid. Creating Subscriptions with this status allows you to manage scenarios where additional customer actions are needed to pay a subscription's invoice. For example, SCA regulation may require 3DS authentication to complete payment. See the [SCA Migration Guide](https://stripe.com/docs/billing/migration/strong-customer-authentication) for Billing to learn more. This is the default behavior.
   340  	//
   341  	// Use `default_incomplete` to create Subscriptions with `status=incomplete` when the first invoice requires payment, otherwise start as active. Subscriptions transition to `status=active` when successfully confirming the PaymentIntent on the first invoice. This allows simpler management of scenarios where additional customer actions are needed to pay a subscription's invoice, such as failed payments, [SCA regulation](https://stripe.com/docs/billing/migration/strong-customer-authentication), or collecting a mandate for a bank debit payment method. If the PaymentIntent is not confirmed within 23 hours Subscriptions transition to `status=incomplete_expired`, which is a terminal state.
   342  	//
   343  	// Use `error_if_incomplete` if you want Stripe to return an HTTP 402 status code if a subscription's first invoice can't be paid. For example, if a payment method requires 3DS authentication due to SCA regulation and further customer action is needed, this parameter doesn't create a Subscription and returns an error instead. This was the default behavior for API versions prior to 2019-03-14. See the [changelog](https://stripe.com/docs/upgrades#2019-03-14) to learn more.
   344  	//
   345  	// `pending_if_incomplete` is only used with updates and cannot be passed when creating a Subscription.
   346  	//
   347  	// Subscriptions with `collection_method=send_invoice` are automatically activated regardless of the first Invoice status.
   348  	PaymentBehavior *string `form:"payment_behavior"`
   349  	// Payment settings to pass to invoices created by the subscription.
   350  	PaymentSettings *SubscriptionPaymentSettingsParams `form:"payment_settings"`
   351  	// Specifies an interval for how often to bill for any pending invoice items. It is analogous to calling [Create an invoice](https://stripe.com/docs/api#create_invoice) for the given subscription at the specified interval.
   352  	PendingInvoiceItemInterval *SubscriptionPendingInvoiceItemIntervalParams `form:"pending_invoice_item_interval"`
   353  	// The ID of a promotion code to apply to this subscription. A promotion code applied to a subscription will only affect invoices created for that particular subscription. This field has been deprecated and will be removed in a future API version. Use `discounts` instead.
   354  	PromotionCode *string `form:"promotion_code"`
   355  	// 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`.
   356  	ProrationBehavior *string `form:"proration_behavior"`
   357  	// If set, the proration will be calculated as though the subscription was updated at the given time. This can be used to apply exactly the same proration that was previewed with [upcoming invoice](https://stripe.com/docs/api#upcoming_invoice) endpoint. It can also be used to implement custom proration logic, such as prorating by day instead of by second, by providing the time that you wish to use for proration calculations.
   358  	ProrationDate *int64 `form:"proration_date"`
   359  	// If specified, the funds from the subscription's invoices will be transferred to the destination and the ID of the resulting transfers will be found on the resulting charges. This will be unset if you POST an empty value.
   360  	TransferData *SubscriptionTransferDataParams `form:"transfer_data"`
   361  	// Unix timestamp representing the end of the trial period the customer will get before being charged for the first time. If set, trial_end will override the default trial period of the plan the customer is being subscribed to. The special value `now` can be provided to end the customer's trial immediately. Can be at most two years from `billing_cycle_anchor`. See [Using trial periods on subscriptions](https://stripe.com/docs/billing/subscriptions/trials) to learn more.
   362  	TrialEnd    *int64 `form:"trial_end"`
   363  	TrialEndNow *bool  `form:"-"` // See custom AppendTo
   364  	// Indicates if a plan's `trial_period_days` should be applied to the subscription. Setting `trial_end` per subscription is preferred, and this defaults to `false`. Setting this flag to `true` together with `trial_end` is not allowed. See [Using trial periods on subscriptions](https://stripe.com/docs/billing/subscriptions/trials) to learn more.
   365  	TrialFromPlan *bool `form:"trial_from_plan"`
   366  	// Integer representing the number of trial period days before the customer is charged for the first time. This will always overwrite any trials that might apply via a subscribed plan. See [Using trial periods on subscriptions](https://stripe.com/docs/billing/subscriptions/trials) to learn more.
   367  	TrialPeriodDays *int64 `form:"trial_period_days"`
   368  	// Settings related to subscription trials.
   369  	TrialSettings *SubscriptionTrialSettingsParams `form:"trial_settings"`
   370  }
   371  
   372  // AddExpand appends a new field to expand.
   373  func (p *SubscriptionParams) AddExpand(f string) {
   374  	p.Expand = append(p.Expand, &f)
   375  }
   376  
   377  // AddMetadata adds a new key-value pair to the Metadata.
   378  func (p *SubscriptionParams) AddMetadata(key string, value string) {
   379  	if p.Metadata == nil {
   380  		p.Metadata = make(map[string]string)
   381  	}
   382  
   383  	p.Metadata[key] = value
   384  }
   385  
   386  // AppendTo implements custom encoding logic for SubscriptionParams.
   387  func (p *SubscriptionParams) AppendTo(body *form.Values, keyParts []string) {
   388  	if BoolValue(p.BillingCycleAnchorNow) {
   389  		body.Add(form.FormatKey(append(keyParts, "billing_cycle_anchor")), "now")
   390  	}
   391  	if BoolValue(p.BillingCycleAnchorUnchanged) {
   392  		body.Add(form.FormatKey(append(keyParts, "billing_cycle_anchor")), "unchanged")
   393  	}
   394  	if BoolValue(p.TrialEndNow) {
   395  		body.Add(form.FormatKey(append(keyParts, "trial_end")), "now")
   396  	}
   397  }
   398  
   399  // The coupons to redeem into discounts for the item.
   400  type SubscriptionAddInvoiceItemDiscountParams struct {
   401  	// ID of the coupon to create a new discount for.
   402  	Coupon *string `form:"coupon"`
   403  	// ID of an existing discount on the object (or one of its ancestors) to reuse.
   404  	Discount *string `form:"discount"`
   405  	// ID of the promotion code to create a new discount for.
   406  	PromotionCode *string `form:"promotion_code"`
   407  }
   408  
   409  // A list of prices and quantities that will generate invoice items appended to the next invoice for this subscription. You may pass up to 20 items.
   410  type SubscriptionAddInvoiceItemParams struct {
   411  	// The coupons to redeem into discounts for the item.
   412  	Discounts []*SubscriptionAddInvoiceItemDiscountParams `form:"discounts"`
   413  	// The ID of the price object.
   414  	Price *string `form:"price"`
   415  	// Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline.
   416  	PriceData *InvoiceItemPriceDataParams `form:"price_data"`
   417  	// Quantity for this item. Defaults to 1.
   418  	Quantity *int64 `form:"quantity"`
   419  	// The tax rates which apply to the item. When set, the `default_tax_rates` do not apply to this item.
   420  	TaxRates []*string `form:"tax_rates"`
   421  }
   422  
   423  // 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.
   424  type SubscriptionAutomaticTaxLiabilityParams struct {
   425  	// The connected account being referenced when `type` is `account`.
   426  	Account *string `form:"account"`
   427  	// Type of the account referenced in the request.
   428  	Type *string `form:"type"`
   429  }
   430  
   431  // Automatic tax settings for this subscription. We recommend you only include this parameter when the existing value is being changed.
   432  type SubscriptionAutomaticTaxParams struct {
   433  	// Enabled automatic tax calculation which will automatically compute tax rates on all invoices generated by the subscription.
   434  	Enabled *bool `form:"enabled"`
   435  	// 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.
   436  	Liability *SubscriptionAutomaticTaxLiabilityParams `form:"liability"`
   437  }
   438  
   439  // Define thresholds at which an invoice will be sent, and the subscription advanced to a new billing period. Pass an empty string to remove previously-defined thresholds.
   440  type SubscriptionBillingThresholdsParams struct {
   441  	// Monetary threshold that triggers the subscription to advance to a new billing period
   442  	AmountGTE *int64 `form:"amount_gte"`
   443  	// Indicates if the `billing_cycle_anchor` should be reset when a threshold is reached. If true, `billing_cycle_anchor` will be updated to the date/time the threshold was last reached; otherwise, the value will remain unchanged.
   444  	ResetBillingCycleAnchor *bool `form:"reset_billing_cycle_anchor"`
   445  }
   446  
   447  // Details about why this subscription was cancelled
   448  type SubscriptionCancellationDetailsParams struct {
   449  	// Additional comments about why the user canceled the subscription, if the subscription was canceled explicitly by the user.
   450  	Comment *string `form:"comment"`
   451  	// The customer submitted reason for why they canceled, if the subscription was canceled explicitly by the user.
   452  	Feedback *string `form:"feedback"`
   453  }
   454  
   455  // The coupons to redeem into discounts for the subscription. If not specified or empty, inherits the discount from the subscription's customer.
   456  type SubscriptionDiscountParams struct {
   457  	// ID of the coupon to create a new discount for.
   458  	Coupon *string `form:"coupon"`
   459  	// ID of an existing discount on the object (or one of its ancestors) to reuse.
   460  	Discount *string `form:"discount"`
   461  	// ID of the promotion code to create a new discount for.
   462  	PromotionCode *string `form:"promotion_code"`
   463  }
   464  
   465  // The connected account that issues the invoice. The invoice is presented with the branding and support information of the specified account.
   466  type SubscriptionInvoiceSettingsIssuerParams struct {
   467  	// The connected account being referenced when `type` is `account`.
   468  	Account *string `form:"account"`
   469  	// Type of the account referenced in the request.
   470  	Type *string `form:"type"`
   471  }
   472  
   473  // All invoices will be billed using the specified settings.
   474  type SubscriptionInvoiceSettingsParams struct {
   475  	// The account tax IDs associated with the subscription. Will be set on invoices generated by the subscription.
   476  	AccountTaxIDs []*string `form:"account_tax_ids"`
   477  	// The connected account that issues the invoice. The invoice is presented with the branding and support information of the specified account.
   478  	Issuer *SubscriptionInvoiceSettingsIssuerParams `form:"issuer"`
   479  }
   480  
   481  // A list of up to 20 subscription items, each with an attached price.
   482  type SubscriptionItemsParams struct {
   483  	Params `form:"*"`
   484  	// 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.
   485  	BillingThresholds *SubscriptionItemBillingThresholdsParams `form:"billing_thresholds"`
   486  	// 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`.
   487  	ClearUsage *bool `form:"clear_usage"`
   488  	// A flag that, if set to `true`, will delete the specified item.
   489  	Deleted *bool `form:"deleted"`
   490  	// The coupons to redeem into discounts for the subscription item.
   491  	Discounts []*SubscriptionItemDiscountParams `form:"discounts"`
   492  	// Subscription item to update.
   493  	ID *string `form:"id"`
   494  	// 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`.
   495  	Metadata map[string]string `form:"metadata"`
   496  	// Plan ID for this item, as a string.
   497  	Plan *string `form:"plan"`
   498  	// The ID of the price object. When changing a subscription item's price, `quantity` is set to 1 unless a `quantity` parameter is provided.
   499  	Price *string `form:"price"`
   500  	// Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline.
   501  	PriceData *SubscriptionItemPriceDataParams `form:"price_data"`
   502  	// Quantity for this item.
   503  	Quantity *int64 `form:"quantity"`
   504  	// 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.
   505  	TaxRates []*string `form:"tax_rates"`
   506  }
   507  
   508  // AddMetadata adds a new key-value pair to the Metadata.
   509  func (p *SubscriptionItemsParams) AddMetadata(key string, value string) {
   510  	if p.Metadata == nil {
   511  		p.Metadata = make(map[string]string)
   512  	}
   513  
   514  	p.Metadata[key] = value
   515  }
   516  
   517  // If specified, payment collection for this subscription will be paused. Note that the subscription status will be unchanged and will not be updated to `paused`. Learn more about [pausing collection](https://stripe.com/billing/subscriptions/pause-payment).
   518  type SubscriptionPauseCollectionParams struct {
   519  	// The payment collection behavior for this subscription while paused. One of `keep_as_draft`, `mark_uncollectible`, or `void`.
   520  	Behavior *string `form:"behavior"`
   521  	// The time after which the subscription will resume collecting payments.
   522  	ResumesAt *int64 `form:"resumes_at"`
   523  }
   524  
   525  // Additional fields for Mandate creation
   526  type SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebitMandateOptionsParams struct {
   527  	// Transaction type of the mandate.
   528  	TransactionType *string `form:"transaction_type"`
   529  }
   530  
   531  // This sub-hash contains details about the Canadian pre-authorized debit payment method options to pass to the invoice's PaymentIntent.
   532  type SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebitParams struct {
   533  	// Additional fields for Mandate creation
   534  	MandateOptions *SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebitMandateOptionsParams `form:"mandate_options"`
   535  	// Verification method for the intent
   536  	VerificationMethod *string `form:"verification_method"`
   537  }
   538  
   539  // This sub-hash contains details about the Bancontact payment method options to pass to the invoice's PaymentIntent.
   540  type SubscriptionPaymentSettingsPaymentMethodOptionsBancontactParams struct {
   541  	// Preferred language of the Bancontact authorization page that the customer is redirected to.
   542  	PreferredLanguage *string `form:"preferred_language"`
   543  }
   544  
   545  // Configuration options for setting up an eMandate for cards issued in India.
   546  type SubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptionsParams struct {
   547  	// Amount to be charged for future payments.
   548  	Amount *int64 `form:"amount"`
   549  	// One of `fixed` or `maximum`. If `fixed`, the `amount` param refers to the exact amount to be charged in future payments. If `maximum`, the amount charged can be up to the value passed for the `amount` param.
   550  	AmountType *string `form:"amount_type"`
   551  	// A description of the mandate or subscription that is meant to be displayed to the customer.
   552  	Description *string `form:"description"`
   553  }
   554  
   555  // This sub-hash contains details about the Card payment method options to pass to the invoice's PaymentIntent.
   556  type SubscriptionPaymentSettingsPaymentMethodOptionsCardParams struct {
   557  	// Configuration options for setting up an eMandate for cards issued in India.
   558  	MandateOptions *SubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptionsParams `form:"mandate_options"`
   559  	// Selected network to process this Subscription on. Depends on the available networks of the card attached to the Subscription. Can be only set confirm-time.
   560  	Network *string `form:"network"`
   561  	// 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.
   562  	RequestThreeDSecure *string `form:"request_three_d_secure"`
   563  }
   564  
   565  // Configuration for eu_bank_transfer funding type.
   566  type SubscriptionPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferEUBankTransferParams struct {
   567  	// The desired country code of the bank account information. Permitted values include: `BE`, `DE`, `ES`, `FR`, `IE`, or `NL`.
   568  	Country *string `form:"country"`
   569  }
   570  
   571  // Configuration for the bank transfer funding type, if the `funding_type` is set to `bank_transfer`.
   572  type SubscriptionPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferParams struct {
   573  	// Configuration for eu_bank_transfer funding type.
   574  	EUBankTransfer *SubscriptionPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferEUBankTransferParams `form:"eu_bank_transfer"`
   575  	// 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`.
   576  	Type *string `form:"type"`
   577  }
   578  
   579  // This sub-hash contains details about the Bank transfer payment method options to pass to the invoice's PaymentIntent.
   580  type SubscriptionPaymentSettingsPaymentMethodOptionsCustomerBalanceParams struct {
   581  	// Configuration for the bank transfer funding type, if the `funding_type` is set to `bank_transfer`.
   582  	BankTransfer *SubscriptionPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferParams `form:"bank_transfer"`
   583  	// The funding method type to be used when there are not enough funds in the customer balance. Permitted values include: `bank_transfer`.
   584  	FundingType *string `form:"funding_type"`
   585  }
   586  
   587  // This sub-hash contains details about the Konbini payment method options to pass to the invoice's PaymentIntent.
   588  type SubscriptionPaymentSettingsPaymentMethodOptionsKonbiniParams struct{}
   589  
   590  // This sub-hash contains details about the SEPA Direct Debit payment method options to pass to the invoice's PaymentIntent.
   591  type SubscriptionPaymentSettingsPaymentMethodOptionsSEPADebitParams struct{}
   592  
   593  // Additional fields for Financial Connections Session creation
   594  type SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsParams struct {
   595  	// 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`.
   596  	Permissions []*string `form:"permissions"`
   597  	// List of data features that you would like to retrieve upon account creation.
   598  	Prefetch []*string `form:"prefetch"`
   599  }
   600  
   601  // This sub-hash contains details about the ACH direct debit payment method options to pass to the invoice's PaymentIntent.
   602  type SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountParams struct {
   603  	// Additional fields for Financial Connections Session creation
   604  	FinancialConnections *SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsParams `form:"financial_connections"`
   605  	// Verification method for the intent
   606  	VerificationMethod *string `form:"verification_method"`
   607  }
   608  
   609  // Payment-method-specific configuration to provide to invoices created by the subscription.
   610  type SubscriptionPaymentSettingsPaymentMethodOptionsParams struct {
   611  	// This sub-hash contains details about the Canadian pre-authorized debit payment method options to pass to the invoice's PaymentIntent.
   612  	ACSSDebit *SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebitParams `form:"acss_debit"`
   613  	// This sub-hash contains details about the Bancontact payment method options to pass to the invoice's PaymentIntent.
   614  	Bancontact *SubscriptionPaymentSettingsPaymentMethodOptionsBancontactParams `form:"bancontact"`
   615  	// This sub-hash contains details about the Card payment method options to pass to the invoice's PaymentIntent.
   616  	Card *SubscriptionPaymentSettingsPaymentMethodOptionsCardParams `form:"card"`
   617  	// This sub-hash contains details about the Bank transfer payment method options to pass to the invoice's PaymentIntent.
   618  	CustomerBalance *SubscriptionPaymentSettingsPaymentMethodOptionsCustomerBalanceParams `form:"customer_balance"`
   619  	// This sub-hash contains details about the Konbini payment method options to pass to the invoice's PaymentIntent.
   620  	Konbini *SubscriptionPaymentSettingsPaymentMethodOptionsKonbiniParams `form:"konbini"`
   621  	// This sub-hash contains details about the SEPA Direct Debit payment method options to pass to the invoice's PaymentIntent.
   622  	SEPADebit *SubscriptionPaymentSettingsPaymentMethodOptionsSEPADebitParams `form:"sepa_debit"`
   623  	// This sub-hash contains details about the ACH direct debit payment method options to pass to the invoice's PaymentIntent.
   624  	USBankAccount *SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountParams `form:"us_bank_account"`
   625  }
   626  
   627  // Payment settings to pass to invoices created by the subscription.
   628  type SubscriptionPaymentSettingsParams struct {
   629  	// Payment-method-specific configuration to provide to invoices created by the subscription.
   630  	PaymentMethodOptions *SubscriptionPaymentSettingsPaymentMethodOptionsParams `form:"payment_method_options"`
   631  	// 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).
   632  	PaymentMethodTypes []*string `form:"payment_method_types"`
   633  	// Either `off`, or `on_subscription`. With `on_subscription` Stripe updates `subscription.default_payment_method` when a subscription payment succeeds.
   634  	SaveDefaultPaymentMethod *string `form:"save_default_payment_method"`
   635  }
   636  
   637  // Specifies an interval for how often to bill for any pending invoice items. It is analogous to calling [Create an invoice](https://stripe.com/docs/api#create_invoice) for the given subscription at the specified interval.
   638  type SubscriptionPendingInvoiceItemIntervalParams struct {
   639  	// Specifies invoicing frequency. Either `day`, `week`, `month` or `year`.
   640  	Interval *string `form:"interval"`
   641  	// The number of intervals between invoices. For example, `interval=month` and `interval_count=3` bills every 3 months. Maximum of one year interval allowed (1 year, 12 months, or 52 weeks).
   642  	IntervalCount *int64 `form:"interval_count"`
   643  }
   644  
   645  // If specified, the funds from the subscription's invoices will be transferred to the destination and the ID of the resulting transfers will be found on the resulting charges. This will be unset if you POST an empty value.
   646  type SubscriptionTransferDataParams struct {
   647  	// A non-negative decimal between 0 and 100, with at most two decimal places. This represents the percentage of the subscription invoice total that will be transferred to the destination account. By default, the entire amount is transferred to the destination.
   648  	AmountPercent *float64 `form:"amount_percent"`
   649  	// ID of an existing, connected Stripe account.
   650  	Destination *string `form:"destination"`
   651  }
   652  
   653  // Defines how the subscription should behave when the user's free trial ends.
   654  type SubscriptionTrialSettingsEndBehaviorParams struct {
   655  	// Indicates how the subscription should change when the trial ends if the user did not provide a payment method.
   656  	MissingPaymentMethod *string `form:"missing_payment_method"`
   657  }
   658  
   659  // Settings related to subscription trials.
   660  type SubscriptionTrialSettingsParams struct {
   661  	// Defines how the subscription should behave when the user's free trial ends.
   662  	EndBehavior *SubscriptionTrialSettingsEndBehaviorParams `form:"end_behavior"`
   663  }
   664  
   665  // Removes the currently applied discount on a subscription.
   666  type SubscriptionDeleteDiscountParams struct {
   667  	Params `form:"*"`
   668  }
   669  
   670  // Filter subscriptions by their automatic tax settings.
   671  type SubscriptionListAutomaticTaxParams struct {
   672  	// Enabled automatic tax calculation which will automatically compute tax rates on all invoices generated by the subscription.
   673  	Enabled *bool `form:"enabled"`
   674  }
   675  
   676  // By default, returns a list of subscriptions that have not been canceled. In order to list canceled subscriptions, specify status=canceled.
   677  type SubscriptionListParams struct {
   678  	ListParams `form:"*"`
   679  	// Filter subscriptions by their automatic tax settings.
   680  	AutomaticTax *SubscriptionListAutomaticTaxParams `form:"automatic_tax"`
   681  	// The collection method of the subscriptions to retrieve. Either `charge_automatically` or `send_invoice`.
   682  	CollectionMethod *string `form:"collection_method"`
   683  	// Only return subscriptions that were created during the given date interval.
   684  	Created *int64 `form:"created"`
   685  	// Only return subscriptions that were created during the given date interval.
   686  	CreatedRange            *RangeQueryParams `form:"created"`
   687  	CurrentPeriodEnd        *int64            `form:"current_period_end"`
   688  	CurrentPeriodEndRange   *RangeQueryParams `form:"current_period_end"`
   689  	CurrentPeriodStart      *int64            `form:"current_period_start"`
   690  	CurrentPeriodStartRange *RangeQueryParams `form:"current_period_start"`
   691  	// The ID of the customer whose subscriptions will be retrieved.
   692  	Customer *string `form:"customer"`
   693  	// Specifies which fields in the response should be expanded.
   694  	Expand []*string `form:"expand"`
   695  	// The ID of the plan whose subscriptions will be retrieved.
   696  	Plan *string `form:"plan"`
   697  	// Filter for subscriptions that contain this recurring price ID.
   698  	Price *string `form:"price"`
   699  	// The status of the subscriptions to retrieve. Passing in a value of `canceled` will return all canceled subscriptions, including those belonging to deleted customers. Pass `ended` to find subscriptions that are canceled and subscriptions that are expired due to [incomplete payment](https://stripe.com/docs/billing/subscriptions/overview#subscription-statuses). Passing in a value of `all` will return subscriptions of all statuses. If no value is supplied, all subscriptions that have not been canceled are returned.
   700  	Status *string `form:"status"`
   701  	// Filter for subscriptions that are associated with the specified test clock. The response will not include subscriptions with test clocks if this and the customer parameter is not set.
   702  	TestClock *string `form:"test_clock"`
   703  }
   704  
   705  // AddExpand appends a new field to expand.
   706  func (p *SubscriptionListParams) AddExpand(f string) {
   707  	p.Expand = append(p.Expand, &f)
   708  }
   709  
   710  // Mutually exclusive with billing_cycle_anchor and only valid with monthly and yearly price intervals. When provided, the billing_cycle_anchor is set to the next occurence of the day_of_month at the hour, minute, and second UTC.
   711  type SubscriptionBillingCycleAnchorConfigParams struct {
   712  	// The day of the month the billing_cycle_anchor should be. Ranges from 1 to 31.
   713  	DayOfMonth *int64 `form:"day_of_month"`
   714  	// The hour of the day the billing_cycle_anchor should be. Ranges from 0 to 23.
   715  	Hour *int64 `form:"hour"`
   716  	// The minute of the hour the billing_cycle_anchor should be. Ranges from 0 to 59.
   717  	Minute *int64 `form:"minute"`
   718  	// The month to start full cycle billing periods. Ranges from 1 to 12.
   719  	Month *int64 `form:"month"`
   720  	// The second of the minute the billing_cycle_anchor should be. Ranges from 0 to 59.
   721  	Second *int64 `form:"second"`
   722  }
   723  
   724  // Search for subscriptions you've previously created using Stripe's [Search Query Language](https://stripe.com/docs/search#search-query-language).
   725  // Don't use search in read-after-write flows where strict consistency is necessary. Under normal operating
   726  // conditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up
   727  // to an hour behind during outages. Search functionality is not available to merchants in India.
   728  type SubscriptionSearchParams struct {
   729  	SearchParams `form:"*"`
   730  	// Specifies which fields in the response should be expanded.
   731  	Expand []*string `form:"expand"`
   732  	// 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.
   733  	Page *string `form:"page"`
   734  }
   735  
   736  // AddExpand appends a new field to expand.
   737  func (p *SubscriptionSearchParams) AddExpand(f string) {
   738  	p.Expand = append(p.Expand, &f)
   739  }
   740  
   741  // Initiates resumption of a paused subscription, optionally resetting the billing cycle anchor and creating prorations. If a resumption invoice is generated, it must be paid or marked uncollectible before the subscription will be unpaused. If payment succeeds the subscription will become active, and if payment fails the subscription will be past_due. The resumption invoice will void automatically if not paid by the expiration date.
   742  type SubscriptionResumeParams struct {
   743  	Params `form:"*"`
   744  	// Either `now` or `unchanged`. Setting the value to `now` resets the subscription's billing cycle anchor to the current time (in UTC). Setting the value to `unchanged` advances the subscription's billing cycle anchor to the period that surrounds the current time. For more information, see the billing cycle [documentation](https://stripe.com/docs/billing/subscriptions/billing-cycle).
   745  	BillingCycleAnchor *string `form:"billing_cycle_anchor"`
   746  	// Specifies which fields in the response should be expanded.
   747  	Expand []*string `form:"expand"`
   748  	// 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`.
   749  	ProrationBehavior *string `form:"proration_behavior"`
   750  	// If set, the proration will be calculated as though the subscription was resumed at the given time. This can be used to apply exactly the same proration that was previewed with [upcoming invoice](https://stripe.com/docs/api#retrieve_customer_invoice) endpoint.
   751  	ProrationDate *int64 `form:"proration_date"`
   752  }
   753  
   754  // AddExpand appends a new field to expand.
   755  func (p *SubscriptionResumeParams) AddExpand(f string) {
   756  	p.Expand = append(p.Expand, &f)
   757  }
   758  
   759  // 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.
   760  type SubscriptionAutomaticTaxLiability struct {
   761  	// The connected account being referenced when `type` is `account`.
   762  	Account *Account `json:"account"`
   763  	// Type of the account referenced.
   764  	Type SubscriptionAutomaticTaxLiabilityType `json:"type"`
   765  }
   766  type SubscriptionAutomaticTax struct {
   767  	// Whether Stripe automatically computes tax on this subscription.
   768  	Enabled bool `json:"enabled"`
   769  	// 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.
   770  	Liability *SubscriptionAutomaticTaxLiability `json:"liability"`
   771  }
   772  
   773  // The fixed values used to calculate the `billing_cycle_anchor`.
   774  type SubscriptionBillingCycleAnchorConfig struct {
   775  	// The day of the month of the billing_cycle_anchor.
   776  	DayOfMonth int64 `json:"day_of_month"`
   777  	// The hour of the day of the billing_cycle_anchor.
   778  	Hour int64 `json:"hour"`
   779  	// The minute of the hour of the billing_cycle_anchor.
   780  	Minute int64 `json:"minute"`
   781  	// The month to start full cycle billing periods.
   782  	Month int64 `json:"month"`
   783  	// The second of the minute of the billing_cycle_anchor.
   784  	Second int64 `json:"second"`
   785  }
   786  
   787  // Define thresholds at which an invoice will be sent, and the subscription advanced to a new billing period
   788  type SubscriptionBillingThresholds struct {
   789  	// Monetary threshold that triggers the subscription to create an invoice
   790  	AmountGTE int64 `json:"amount_gte"`
   791  	// Indicates if the `billing_cycle_anchor` should be reset when a threshold is reached. If true, `billing_cycle_anchor` will be updated to the date/time the threshold was last reached; otherwise, the value will remain unchanged. This value may not be `true` if the subscription contains items with plans that have `aggregate_usage=last_ever`.
   792  	ResetBillingCycleAnchor bool `json:"reset_billing_cycle_anchor"`
   793  }
   794  
   795  // Details about why this subscription was cancelled
   796  type SubscriptionCancellationDetails struct {
   797  	// Additional comments about why the user canceled the subscription, if the subscription was canceled explicitly by the user.
   798  	Comment string `json:"comment"`
   799  	// The customer submitted reason for why they canceled, if the subscription was canceled explicitly by the user.
   800  	Feedback SubscriptionCancellationDetailsFeedback `json:"feedback"`
   801  	// Why this subscription was canceled.
   802  	Reason SubscriptionCancellationDetailsReason `json:"reason"`
   803  }
   804  
   805  // If specified, payment collection for this subscription will be paused. Note that the subscription status will be unchanged and will not be updated to `paused`. Learn more about [pausing collection](https://stripe.com/billing/subscriptions/pause-payment).
   806  type SubscriptionPauseCollection struct {
   807  	// The payment collection behavior for this subscription while paused. One of `keep_as_draft`, `mark_uncollectible`, or `void`.
   808  	Behavior SubscriptionPauseCollectionBehavior `json:"behavior"`
   809  	// The time after which the subscription will resume collecting payments.
   810  	ResumesAt int64 `json:"resumes_at"`
   811  }
   812  type SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebitMandateOptions struct {
   813  	// Transaction type of the mandate.
   814  	TransactionType SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebitMandateOptionsTransactionType `json:"transaction_type"`
   815  }
   816  
   817  // This sub-hash contains details about the Canadian pre-authorized debit payment method options to pass to invoices created by the subscription.
   818  type SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebit struct {
   819  	MandateOptions *SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebitMandateOptions `json:"mandate_options"`
   820  	// Bank account verification method.
   821  	VerificationMethod SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebitVerificationMethod `json:"verification_method"`
   822  }
   823  
   824  // This sub-hash contains details about the Bancontact payment method options to pass to invoices created by the subscription.
   825  type SubscriptionPaymentSettingsPaymentMethodOptionsBancontact struct {
   826  	// Preferred language of the Bancontact authorization page that the customer is redirected to.
   827  	PreferredLanguage string `json:"preferred_language"`
   828  }
   829  type SubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptions struct {
   830  	// Amount to be charged for future payments.
   831  	Amount int64 `json:"amount"`
   832  	// One of `fixed` or `maximum`. If `fixed`, the `amount` param refers to the exact amount to be charged in future payments. If `maximum`, the amount charged can be up to the value passed for the `amount` param.
   833  	AmountType SubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptionsAmountType `json:"amount_type"`
   834  	// A description of the mandate or subscription that is meant to be displayed to the customer.
   835  	Description string `json:"description"`
   836  }
   837  
   838  // This sub-hash contains details about the Card payment method options to pass to invoices created by the subscription.
   839  type SubscriptionPaymentSettingsPaymentMethodOptionsCard struct {
   840  	MandateOptions *SubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptions `json:"mandate_options"`
   841  	// Selected network to process this Subscription on. Depends on the available networks of the card attached to the Subscription. Can be only set confirm-time.
   842  	Network SubscriptionPaymentSettingsPaymentMethodOptionsCardNetwork `json:"network"`
   843  	// 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.
   844  	RequestThreeDSecure SubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure `json:"request_three_d_secure"`
   845  }
   846  type SubscriptionPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferEUBankTransfer struct {
   847  	// The desired country code of the bank account information. Permitted values include: `BE`, `DE`, `ES`, `FR`, `IE`, or `NL`.
   848  	Country string `json:"country"`
   849  }
   850  type SubscriptionPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransfer struct {
   851  	EUBankTransfer *SubscriptionPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferEUBankTransfer `json:"eu_bank_transfer"`
   852  	// 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`.
   853  	Type string `json:"type"`
   854  }
   855  
   856  // This sub-hash contains details about the Bank transfer payment method options to pass to invoices created by the subscription.
   857  type SubscriptionPaymentSettingsPaymentMethodOptionsCustomerBalance struct {
   858  	BankTransfer *SubscriptionPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransfer `json:"bank_transfer"`
   859  	// The funding method type to be used when there are not enough funds in the customer balance. Permitted values include: `bank_transfer`.
   860  	FundingType SubscriptionPaymentSettingsPaymentMethodOptionsCustomerBalanceFundingType `json:"funding_type"`
   861  }
   862  
   863  // This sub-hash contains details about the Konbini payment method options to pass to invoices created by the subscription.
   864  type SubscriptionPaymentSettingsPaymentMethodOptionsKonbini struct{}
   865  
   866  // This sub-hash contains details about the SEPA Direct Debit payment method options to pass to invoices created by the subscription.
   867  type SubscriptionPaymentSettingsPaymentMethodOptionsSEPADebit struct{}
   868  type SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnections struct {
   869  	// The list of permissions to request. The `payment_method` permission must be included.
   870  	Permissions []SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPermission `json:"permissions"`
   871  	// Data features requested to be retrieved upon account creation.
   872  	Prefetch []SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPrefetch `json:"prefetch"`
   873  }
   874  
   875  // This sub-hash contains details about the ACH direct debit payment method options to pass to invoices created by the subscription.
   876  type SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccount struct {
   877  	FinancialConnections *SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnections `json:"financial_connections"`
   878  	// Bank account verification method.
   879  	VerificationMethod SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountVerificationMethod `json:"verification_method"`
   880  }
   881  
   882  // Payment-method-specific configuration to provide to invoices created by the subscription.
   883  type SubscriptionPaymentSettingsPaymentMethodOptions struct {
   884  	// This sub-hash contains details about the Canadian pre-authorized debit payment method options to pass to invoices created by the subscription.
   885  	ACSSDebit *SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebit `json:"acss_debit"`
   886  	// This sub-hash contains details about the Bancontact payment method options to pass to invoices created by the subscription.
   887  	Bancontact *SubscriptionPaymentSettingsPaymentMethodOptionsBancontact `json:"bancontact"`
   888  	// This sub-hash contains details about the Card payment method options to pass to invoices created by the subscription.
   889  	Card *SubscriptionPaymentSettingsPaymentMethodOptionsCard `json:"card"`
   890  	// This sub-hash contains details about the Bank transfer payment method options to pass to invoices created by the subscription.
   891  	CustomerBalance *SubscriptionPaymentSettingsPaymentMethodOptionsCustomerBalance `json:"customer_balance"`
   892  	// This sub-hash contains details about the Konbini payment method options to pass to invoices created by the subscription.
   893  	Konbini *SubscriptionPaymentSettingsPaymentMethodOptionsKonbini `json:"konbini"`
   894  	// This sub-hash contains details about the SEPA Direct Debit payment method options to pass to invoices created by the subscription.
   895  	SEPADebit *SubscriptionPaymentSettingsPaymentMethodOptionsSEPADebit `json:"sepa_debit"`
   896  	// This sub-hash contains details about the ACH direct debit payment method options to pass to invoices created by the subscription.
   897  	USBankAccount *SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccount `json:"us_bank_account"`
   898  }
   899  
   900  // Payment settings passed on to invoices created by the subscription.
   901  type SubscriptionPaymentSettings struct {
   902  	// Payment-method-specific configuration to provide to invoices created by the subscription.
   903  	PaymentMethodOptions *SubscriptionPaymentSettingsPaymentMethodOptions `json:"payment_method_options"`
   904  	// The list of payment method types to provide to every invoice created by the subscription. 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).
   905  	PaymentMethodTypes []SubscriptionPaymentSettingsPaymentMethodType `json:"payment_method_types"`
   906  	// Either `off`, or `on_subscription`. With `on_subscription` Stripe updates `subscription.default_payment_method` when a subscription payment succeeds.
   907  	SaveDefaultPaymentMethod SubscriptionPaymentSettingsSaveDefaultPaymentMethod `json:"save_default_payment_method"`
   908  }
   909  
   910  // Specifies an interval for how often to bill for any pending invoice items. It is analogous to calling [Create an invoice](https://stripe.com/docs/api#create_invoice) for the given subscription at the specified interval.
   911  type SubscriptionPendingInvoiceItemInterval struct {
   912  	// Specifies invoicing frequency. Either `day`, `week`, `month` or `year`.
   913  	Interval SubscriptionPendingInvoiceItemIntervalInterval `json:"interval"`
   914  	// The number of intervals between invoices. For example, `interval=month` and `interval_count=3` bills every 3 months. Maximum of one year interval allowed (1 year, 12 months, or 52 weeks).
   915  	IntervalCount int64 `json:"interval_count"`
   916  }
   917  
   918  // If specified, [pending updates](https://stripe.com/docs/billing/subscriptions/pending-updates) that will be applied to the subscription once the `latest_invoice` has been paid.
   919  type SubscriptionPendingUpdate struct {
   920  	// If the update is applied, determines the date of the first full invoice, and, for plans with `month` or `year` intervals, the day of the month for subsequent invoices. The timestamp is in UTC format.
   921  	BillingCycleAnchor int64 `json:"billing_cycle_anchor"`
   922  	// The point after which the changes reflected by this update will be discarded and no longer applied.
   923  	ExpiresAt int64 `json:"expires_at"`
   924  	// List of subscription items, each with an attached plan, that will be set if the update is applied.
   925  	SubscriptionItems []*SubscriptionItem `json:"subscription_items"`
   926  	// Unix timestamp representing the end of the trial period the customer will get before being charged for the first time, if the update is applied.
   927  	TrialEnd int64 `json:"trial_end"`
   928  	// Indicates if a plan's `trial_period_days` should be applied to the subscription. Setting `trial_end` per subscription is preferred, and this defaults to `false`. Setting this flag to `true` together with `trial_end` is not allowed. See [Using trial periods on subscriptions](https://stripe.com/docs/billing/subscriptions/trials) to learn more.
   929  	TrialFromPlan bool `json:"trial_from_plan"`
   930  }
   931  
   932  // The account (if any) the subscription's payments will be attributed to for tax reporting, and where funds from each payment will be transferred to for each of the subscription's invoices.
   933  type SubscriptionTransferData struct {
   934  	// A non-negative decimal between 0 and 100, with at most two decimal places. This represents the percentage of the subscription invoice total that will be transferred to the destination account. By default, the entire amount is transferred to the destination.
   935  	AmountPercent float64 `json:"amount_percent"`
   936  	// The account where funds from the payment will be transferred to upon payment success.
   937  	Destination *Account `json:"destination"`
   938  }
   939  
   940  // Defines how a subscription behaves when a free trial ends.
   941  type SubscriptionTrialSettingsEndBehavior struct {
   942  	// Indicates how the subscription should change when the trial ends if the user did not provide a payment method.
   943  	MissingPaymentMethod SubscriptionTrialSettingsEndBehaviorMissingPaymentMethod `json:"missing_payment_method"`
   944  }
   945  
   946  // Settings related to subscription trials.
   947  type SubscriptionTrialSettings struct {
   948  	// Defines how a subscription behaves when a free trial ends.
   949  	EndBehavior *SubscriptionTrialSettingsEndBehavior `json:"end_behavior"`
   950  }
   951  
   952  // Subscriptions allow you to charge a customer on a recurring basis.
   953  //
   954  // Related guide: [Creating subscriptions](https://stripe.com/docs/billing/subscriptions/creating)
   955  type Subscription struct {
   956  	APIResource
   957  	// ID of the Connect Application that created the subscription.
   958  	Application *Application `json:"application"`
   959  	// A non-negative decimal between 0 and 100, with at most two decimal places. This represents the percentage of the subscription invoice total that will be transferred to the application owner's Stripe account.
   960  	ApplicationFeePercent float64                   `json:"application_fee_percent"`
   961  	AutomaticTax          *SubscriptionAutomaticTax `json:"automatic_tax"`
   962  	// The reference point that aligns future [billing cycle](https://stripe.com/docs/subscriptions/billing-cycle) dates. It sets the day of week for `week` intervals, the day of month for `month` and `year` intervals, and the month of year for `year` intervals. The timestamp is in UTC format.
   963  	BillingCycleAnchor int64 `json:"billing_cycle_anchor"`
   964  	// The fixed values used to calculate the `billing_cycle_anchor`.
   965  	BillingCycleAnchorConfig *SubscriptionBillingCycleAnchorConfig `json:"billing_cycle_anchor_config"`
   966  	// Define thresholds at which an invoice will be sent, and the subscription advanced to a new billing period
   967  	BillingThresholds *SubscriptionBillingThresholds `json:"billing_thresholds"`
   968  	// A date in the future at which the subscription will automatically get canceled
   969  	CancelAt int64 `json:"cancel_at"`
   970  	// If the subscription has been canceled with the `at_period_end` flag set to `true`, `cancel_at_period_end` on the subscription will be true. You can use this attribute to determine whether a subscription that has a status of active is scheduled to be canceled at the end of the current period.
   971  	CancelAtPeriodEnd bool `json:"cancel_at_period_end"`
   972  	// If the subscription has been canceled, the date of that cancellation. If the subscription was canceled with `cancel_at_period_end`, `canceled_at` will reflect the time of the most recent update request, not the end of the subscription period when the subscription is automatically moved to a canceled state.
   973  	CanceledAt int64 `json:"canceled_at"`
   974  	// Details about why this subscription was cancelled
   975  	CancellationDetails *SubscriptionCancellationDetails `json:"cancellation_details"`
   976  	// Either `charge_automatically`, or `send_invoice`. When charging automatically, Stripe will attempt to pay this subscription at the end of the cycle using the default source attached to the customer. When sending an invoice, Stripe will email your customer an invoice with payment instructions and mark the subscription as `active`.
   977  	CollectionMethod SubscriptionCollectionMethod `json:"collection_method"`
   978  	// Time at which the object was created. Measured in seconds since the Unix epoch.
   979  	Created int64 `json:"created"`
   980  	// 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).
   981  	Currency Currency `json:"currency"`
   982  	// End of the current period that the subscription has been invoiced for. At the end of this period, a new invoice will be created.
   983  	CurrentPeriodEnd int64 `json:"current_period_end"`
   984  	// Start of the current period that the subscription has been invoiced for.
   985  	CurrentPeriodStart int64 `json:"current_period_start"`
   986  	// ID of the customer who owns the subscription.
   987  	Customer *Customer `json:"customer"`
   988  	// Number of days a customer has to pay invoices generated by this subscription. This value will be `null` for subscriptions where `collection_method=charge_automatically`.
   989  	DaysUntilDue int64 `json:"days_until_due"`
   990  	// ID of the default payment method for the subscription. It must belong to the customer associated with the subscription. This takes precedence over `default_source`. If neither are set, invoices will use the customer's [invoice_settings.default_payment_method](https://stripe.com/docs/api/customers/object#customer_object-invoice_settings-default_payment_method) or [default_source](https://stripe.com/docs/api/customers/object#customer_object-default_source).
   991  	DefaultPaymentMethod *PaymentMethod `json:"default_payment_method"`
   992  	// ID of the default payment source for the subscription. It must belong to the customer associated with the subscription and be in a chargeable state. If `default_payment_method` is also set, `default_payment_method` will take precedence. If neither are set, invoices will use the customer's [invoice_settings.default_payment_method](https://stripe.com/docs/api/customers/object#customer_object-invoice_settings-default_payment_method) or [default_source](https://stripe.com/docs/api/customers/object#customer_object-default_source).
   993  	DefaultSource *PaymentSource `json:"default_source"`
   994  	// The tax rates that will apply to any subscription item that does not have `tax_rates` set. Invoices created will have their `default_tax_rates` populated from the subscription.
   995  	DefaultTaxRates []*TaxRate `json:"default_tax_rates"`
   996  	// The subscription's description, meant to be displayable to the customer. Use this field to optionally store an explanation of the subscription for rendering in Stripe surfaces and certain local payment methods UIs.
   997  	Description string `json:"description"`
   998  	// Describes the current discount applied to this subscription, if there is one. When billing, a discount applied to a subscription overrides a discount applied on a customer-wide basis. This field has been deprecated and will be removed in a future API version. Use `discounts` instead.
   999  	Discount *Discount `json:"discount"`
  1000  	// The discounts applied to the subscription. Subscription item discounts are applied before subscription discounts. Use `expand[]=discounts` to expand each discount.
  1001  	Discounts []*Discount `json:"discounts"`
  1002  	// If the subscription has ended, the date the subscription ended.
  1003  	EndedAt int64 `json:"ended_at"`
  1004  	// Unique identifier for the object.
  1005  	ID string `json:"id"`
  1006  	// List of subscription items, each with an attached price.
  1007  	Items *SubscriptionItemList `json:"items"`
  1008  	// The most recent invoice this subscription has generated.
  1009  	LatestInvoice *Invoice `json:"latest_invoice"`
  1010  	// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
  1011  	Livemode bool `json:"livemode"`
  1012  	// 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.
  1013  	Metadata map[string]string `json:"metadata"`
  1014  	// Specifies the approximate timestamp on which any pending invoice items will be billed according to the schedule provided at `pending_invoice_item_interval`.
  1015  	NextPendingInvoiceItemInvoice int64 `json:"next_pending_invoice_item_invoice"`
  1016  	// String representing the object's type. Objects of the same type share the same value.
  1017  	Object string `json:"object"`
  1018  	// The account (if any) the charge was made on behalf of for charges associated with this subscription. See the Connect documentation for details.
  1019  	OnBehalfOf *Account `json:"on_behalf_of"`
  1020  	// If specified, payment collection for this subscription will be paused. Note that the subscription status will be unchanged and will not be updated to `paused`. Learn more about [pausing collection](https://stripe.com/billing/subscriptions/pause-payment).
  1021  	PauseCollection *SubscriptionPauseCollection `json:"pause_collection"`
  1022  	// Payment settings passed on to invoices created by the subscription.
  1023  	PaymentSettings *SubscriptionPaymentSettings `json:"payment_settings"`
  1024  	// Specifies an interval for how often to bill for any pending invoice items. It is analogous to calling [Create an invoice](https://stripe.com/docs/api#create_invoice) for the given subscription at the specified interval.
  1025  	PendingInvoiceItemInterval *SubscriptionPendingInvoiceItemInterval `json:"pending_invoice_item_interval"`
  1026  	// You can use this [SetupIntent](https://stripe.com/docs/api/setup_intents) to collect user authentication when creating a subscription without immediate payment or updating a subscription's payment method, allowing you to optimize for off-session payments. Learn more in the [SCA Migration Guide](https://stripe.com/docs/billing/migration/strong-customer-authentication#scenario-2).
  1027  	PendingSetupIntent *SetupIntent `json:"pending_setup_intent"`
  1028  	// If specified, [pending updates](https://stripe.com/docs/billing/subscriptions/pending-updates) that will be applied to the subscription once the `latest_invoice` has been paid.
  1029  	PendingUpdate *SubscriptionPendingUpdate `json:"pending_update"`
  1030  	// The schedule attached to the subscription
  1031  	Schedule *SubscriptionSchedule `json:"schedule"`
  1032  	// Date when the subscription was first created. The date might differ from the `created` date due to backdating.
  1033  	StartDate int64 `json:"start_date"`
  1034  	// Possible values are `incomplete`, `incomplete_expired`, `trialing`, `active`, `past_due`, `canceled`, `unpaid`, or `paused`.
  1035  	//
  1036  	// For `collection_method=charge_automatically` a subscription moves into `incomplete` if the initial payment attempt fails. A subscription in this status can only have metadata and default_source updated. Once the first invoice is paid, the subscription moves into an `active` status. If the first invoice is not paid within 23 hours, the subscription transitions to `incomplete_expired`. This is a terminal status, the open invoice will be voided and no further invoices will be generated.
  1037  	//
  1038  	// A subscription that is currently in a trial period is `trialing` and moves to `active` when the trial period is over.
  1039  	//
  1040  	// A subscription can only enter a `paused` status [when a trial ends without a payment method](https://stripe.com/billing/subscriptions/trials#create-free-trials-without-payment). A `paused` subscription doesn't generate invoices and can be resumed after your customer adds their payment method. The `paused` status is different from [pausing collection](https://stripe.com/billing/subscriptions/pause-payment), which still generates invoices and leaves the subscription's status unchanged.
  1041  	//
  1042  	// If subscription `collection_method=charge_automatically`, it becomes `past_due` when payment is required but cannot be paid (due to failed payment or awaiting additional user actions). Once Stripe has exhausted all payment retry attempts, the subscription will become `canceled` or `unpaid` (depending on your subscriptions settings).
  1043  	//
  1044  	// If subscription `collection_method=send_invoice` it becomes `past_due` when its invoice is not paid by the due date, and `canceled` or `unpaid` if it is still not paid by an additional deadline after that. Note that when a subscription has a status of `unpaid`, no subsequent invoices will be attempted (invoices will be created, but then immediately automatically closed). After receiving updated payment information from a customer, you may choose to reopen and pay their closed invoices.
  1045  	Status SubscriptionStatus `json:"status"`
  1046  	// ID of the test clock this subscription belongs to.
  1047  	TestClock *TestHelpersTestClock `json:"test_clock"`
  1048  	// The account (if any) the subscription's payments will be attributed to for tax reporting, and where funds from each payment will be transferred to for each of the subscription's invoices.
  1049  	TransferData *SubscriptionTransferData `json:"transfer_data"`
  1050  	// If the subscription has a trial, the end of that trial.
  1051  	TrialEnd int64 `json:"trial_end"`
  1052  	// Settings related to subscription trials.
  1053  	TrialSettings *SubscriptionTrialSettings `json:"trial_settings"`
  1054  	// If the subscription has a trial, the beginning of that trial.
  1055  	TrialStart int64 `json:"trial_start"`
  1056  }
  1057  
  1058  // SubscriptionList is a list of Subscriptions as retrieved from a list endpoint.
  1059  type SubscriptionList struct {
  1060  	APIResource
  1061  	ListMeta
  1062  	Data []*Subscription `json:"data"`
  1063  }
  1064  
  1065  // SubscriptionSearchResult is a list of Subscription search results as retrieved from a search endpoint.
  1066  type SubscriptionSearchResult struct {
  1067  	APIResource
  1068  	SearchMeta
  1069  	Data []*Subscription `json:"data"`
  1070  }
  1071  
  1072  // UnmarshalJSON handles deserialization of a Subscription.
  1073  // This custom unmarshaling is needed because the resulting
  1074  // property may be an id or the full struct if it was expanded.
  1075  func (s *Subscription) UnmarshalJSON(data []byte) error {
  1076  	if id, ok := ParseID(data); ok {
  1077  		s.ID = id
  1078  		return nil
  1079  	}
  1080  
  1081  	type subscription Subscription
  1082  	var v subscription
  1083  	if err := json.Unmarshal(data, &v); err != nil {
  1084  		return err
  1085  	}
  1086  
  1087  	*s = Subscription(v)
  1088  	return nil
  1089  }