• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

stripe / stripe-go / 11295426688

11 Oct 2024 03:52PM UTC coverage: 62.991% (-0.02%) from 63.015%
11295426688

Pull #1934

github

stripe-openapi[bot]
Merge upstream and update generated code for v1290
Pull Request #1934: Update generated code for beta

0 of 8 new or added lines in 2 files covered. (0.0%)

472 existing lines in 21 files now uncovered.

6209 of 9857 relevant lines covered (62.99%)

15.67 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

42.55
/subscription.go
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/v80/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
// Type of the account referenced.
58
type SubscriptionInvoiceSettingsIssuerType string
59

60
// List of values that SubscriptionInvoiceSettingsIssuerType can take
61
const (
62
        SubscriptionInvoiceSettingsIssuerTypeAccount SubscriptionInvoiceSettingsIssuerType = "account"
63
        SubscriptionInvoiceSettingsIssuerTypeSelf    SubscriptionInvoiceSettingsIssuerType = "self"
64
)
65

66
// The type of error encountered by the price migration.
67
type SubscriptionLastPriceMigrationErrorType string
68

69
// List of values that SubscriptionLastPriceMigrationErrorType can take
70
const (
71
        SubscriptionLastPriceMigrationErrorTypePriceUniquenessViolation SubscriptionLastPriceMigrationErrorType = "price_uniqueness_violation"
72
)
73

74
// The payment collection behavior for this subscription while paused. One of `keep_as_draft`, `mark_uncollectible`, or `void`.
75
type SubscriptionPauseCollectionBehavior string
76

77
// List of values that SubscriptionPauseCollectionBehavior can take
78
const (
79
        SubscriptionPauseCollectionBehaviorKeepAsDraft       SubscriptionPauseCollectionBehavior = "keep_as_draft"
80
        SubscriptionPauseCollectionBehaviorMarkUncollectible SubscriptionPauseCollectionBehavior = "mark_uncollectible"
81
        SubscriptionPauseCollectionBehaviorVoid              SubscriptionPauseCollectionBehavior = "void"
82
)
83

84
// Transaction type of the mandate.
85
type SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebitMandateOptionsTransactionType string
86

87
// List of values that SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebitMandateOptionsTransactionType can take
88
const (
89
        SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebitMandateOptionsTransactionTypeBusiness SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebitMandateOptionsTransactionType = "business"
90
        SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebitMandateOptionsTransactionTypePersonal SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebitMandateOptionsTransactionType = "personal"
91
)
92

93
// Bank account verification method.
94
type SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebitVerificationMethod string
95

96
// List of values that SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebitVerificationMethod can take
97
const (
98
        SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebitVerificationMethodAutomatic     SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebitVerificationMethod = "automatic"
99
        SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebitVerificationMethodInstant       SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebitVerificationMethod = "instant"
100
        SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebitVerificationMethodMicrodeposits SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebitVerificationMethod = "microdeposits"
101
)
102

103
// 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.
104
type SubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptionsAmountType string
105

106
// List of values that SubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptionsAmountType can take
107
const (
108
        SubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptionsAmountTypeFixed   SubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptionsAmountType = "fixed"
109
        SubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptionsAmountTypeMaximum SubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptionsAmountType = "maximum"
110
)
111

112
// 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.
113
type SubscriptionPaymentSettingsPaymentMethodOptionsCardNetwork string
114

115
// List of values that SubscriptionPaymentSettingsPaymentMethodOptionsCardNetwork can take
116
const (
117
        SubscriptionPaymentSettingsPaymentMethodOptionsCardNetworkAmex            SubscriptionPaymentSettingsPaymentMethodOptionsCardNetwork = "amex"
118
        SubscriptionPaymentSettingsPaymentMethodOptionsCardNetworkCartesBancaires SubscriptionPaymentSettingsPaymentMethodOptionsCardNetwork = "cartes_bancaires"
119
        SubscriptionPaymentSettingsPaymentMethodOptionsCardNetworkDiners          SubscriptionPaymentSettingsPaymentMethodOptionsCardNetwork = "diners"
120
        SubscriptionPaymentSettingsPaymentMethodOptionsCardNetworkDiscover        SubscriptionPaymentSettingsPaymentMethodOptionsCardNetwork = "discover"
121
        SubscriptionPaymentSettingsPaymentMethodOptionsCardNetworkEFTPOSAU        SubscriptionPaymentSettingsPaymentMethodOptionsCardNetwork = "eftpos_au"
122
        SubscriptionPaymentSettingsPaymentMethodOptionsCardNetworkGirocard        SubscriptionPaymentSettingsPaymentMethodOptionsCardNetwork = "girocard"
123
        SubscriptionPaymentSettingsPaymentMethodOptionsCardNetworkInterac         SubscriptionPaymentSettingsPaymentMethodOptionsCardNetwork = "interac"
124
        SubscriptionPaymentSettingsPaymentMethodOptionsCardNetworkJCB             SubscriptionPaymentSettingsPaymentMethodOptionsCardNetwork = "jcb"
125
        SubscriptionPaymentSettingsPaymentMethodOptionsCardNetworkMastercard      SubscriptionPaymentSettingsPaymentMethodOptionsCardNetwork = "mastercard"
126
        SubscriptionPaymentSettingsPaymentMethodOptionsCardNetworkUnionpay        SubscriptionPaymentSettingsPaymentMethodOptionsCardNetwork = "unionpay"
127
        SubscriptionPaymentSettingsPaymentMethodOptionsCardNetworkUnknown         SubscriptionPaymentSettingsPaymentMethodOptionsCardNetwork = "unknown"
128
        SubscriptionPaymentSettingsPaymentMethodOptionsCardNetworkVisa            SubscriptionPaymentSettingsPaymentMethodOptionsCardNetwork = "visa"
129
)
130

131
// 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.
132
type SubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure string
133

134
// List of values that SubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure can take
135
const (
136
        SubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecureAny       SubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure = "any"
137
        SubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecureAutomatic SubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure = "automatic"
138
        SubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecureChallenge SubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure = "challenge"
139
)
140

141
// The funding method type to be used when there are not enough funds in the customer balance. Permitted values include: `bank_transfer`.
142
type SubscriptionPaymentSettingsPaymentMethodOptionsCustomerBalanceFundingType string
143

144
// List of values that SubscriptionPaymentSettingsPaymentMethodOptionsCustomerBalanceFundingType can take
145
const (
146
        SubscriptionPaymentSettingsPaymentMethodOptionsCustomerBalanceFundingTypeBankTransfer SubscriptionPaymentSettingsPaymentMethodOptionsCustomerBalanceFundingType = "bank_transfer"
147
)
148

149
// The account subcategories to use to filter for possible accounts to link. Valid subcategories are `checking` and `savings`.
150
type SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsFiltersAccountSubcategory string
151

152
// List of values that SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsFiltersAccountSubcategory can take
153
const (
154
        SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsFiltersAccountSubcategoryChecking SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsFiltersAccountSubcategory = "checking"
155
        SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsFiltersAccountSubcategorySavings  SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsFiltersAccountSubcategory = "savings"
156
)
157

158
// The list of permissions to request. The `payment_method` permission must be included.
159
type SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPermission string
160

161
// List of values that SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPermission can take
162
const (
163
        SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPermissionBalances      SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPermission = "balances"
164
        SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPermissionOwnership     SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPermission = "ownership"
165
        SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPermissionPaymentMethod SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPermission = "payment_method"
166
        SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPermissionTransactions  SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPermission = "transactions"
167
)
168

169
// Data features requested to be retrieved upon account creation.
170
type SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPrefetch string
171

172
// List of values that SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPrefetch can take
173
const (
174
        SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPrefetchBalances         SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPrefetch = "balances"
175
        SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPrefetchInferredBalances SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPrefetch = "inferred_balances"
176
        SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPrefetchOwnership        SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPrefetch = "ownership"
177
        SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPrefetchTransactions     SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPrefetch = "transactions"
178
)
179

180
// Bank account verification method.
181
type SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountVerificationMethod string
182

183
// List of values that SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountVerificationMethod can take
184
const (
185
        SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountVerificationMethodAutomatic     SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountVerificationMethod = "automatic"
186
        SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountVerificationMethodInstant       SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountVerificationMethod = "instant"
187
        SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountVerificationMethodMicrodeposits SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountVerificationMethod = "microdeposits"
188
)
189

190
// 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).
191
type SubscriptionPaymentSettingsPaymentMethodType string
192

193
// List of values that SubscriptionPaymentSettingsPaymentMethodType can take
194
const (
195
        SubscriptionPaymentSettingsPaymentMethodTypeACHCreditTransfer  SubscriptionPaymentSettingsPaymentMethodType = "ach_credit_transfer"
196
        SubscriptionPaymentSettingsPaymentMethodTypeACHDebit           SubscriptionPaymentSettingsPaymentMethodType = "ach_debit"
197
        SubscriptionPaymentSettingsPaymentMethodTypeACSSDebit          SubscriptionPaymentSettingsPaymentMethodType = "acss_debit"
198
        SubscriptionPaymentSettingsPaymentMethodTypeAmazonPay          SubscriptionPaymentSettingsPaymentMethodType = "amazon_pay"
199
        SubscriptionPaymentSettingsPaymentMethodTypeAUBECSDebit        SubscriptionPaymentSettingsPaymentMethodType = "au_becs_debit"
200
        SubscriptionPaymentSettingsPaymentMethodTypeBACSDebit          SubscriptionPaymentSettingsPaymentMethodType = "bacs_debit"
201
        SubscriptionPaymentSettingsPaymentMethodTypeBancontact         SubscriptionPaymentSettingsPaymentMethodType = "bancontact"
202
        SubscriptionPaymentSettingsPaymentMethodTypeBoleto             SubscriptionPaymentSettingsPaymentMethodType = "boleto"
203
        SubscriptionPaymentSettingsPaymentMethodTypeCard               SubscriptionPaymentSettingsPaymentMethodType = "card"
204
        SubscriptionPaymentSettingsPaymentMethodTypeCashApp            SubscriptionPaymentSettingsPaymentMethodType = "cashapp"
205
        SubscriptionPaymentSettingsPaymentMethodTypeCustomerBalance    SubscriptionPaymentSettingsPaymentMethodType = "customer_balance"
206
        SubscriptionPaymentSettingsPaymentMethodTypeEPS                SubscriptionPaymentSettingsPaymentMethodType = "eps"
207
        SubscriptionPaymentSettingsPaymentMethodTypeFPX                SubscriptionPaymentSettingsPaymentMethodType = "fpx"
208
        SubscriptionPaymentSettingsPaymentMethodTypeGiropay            SubscriptionPaymentSettingsPaymentMethodType = "giropay"
209
        SubscriptionPaymentSettingsPaymentMethodTypeGrabpay            SubscriptionPaymentSettingsPaymentMethodType = "grabpay"
210
        SubscriptionPaymentSettingsPaymentMethodTypeIDEAL              SubscriptionPaymentSettingsPaymentMethodType = "ideal"
211
        SubscriptionPaymentSettingsPaymentMethodTypeKonbini            SubscriptionPaymentSettingsPaymentMethodType = "konbini"
212
        SubscriptionPaymentSettingsPaymentMethodTypeLink               SubscriptionPaymentSettingsPaymentMethodType = "link"
213
        SubscriptionPaymentSettingsPaymentMethodTypeMultibanco         SubscriptionPaymentSettingsPaymentMethodType = "multibanco"
214
        SubscriptionPaymentSettingsPaymentMethodTypeP24                SubscriptionPaymentSettingsPaymentMethodType = "p24"
215
        SubscriptionPaymentSettingsPaymentMethodTypePayNow             SubscriptionPaymentSettingsPaymentMethodType = "paynow"
216
        SubscriptionPaymentSettingsPaymentMethodTypePaypal             SubscriptionPaymentSettingsPaymentMethodType = "paypal"
217
        SubscriptionPaymentSettingsPaymentMethodTypePromptPay          SubscriptionPaymentSettingsPaymentMethodType = "promptpay"
218
        SubscriptionPaymentSettingsPaymentMethodTypeRevolutPay         SubscriptionPaymentSettingsPaymentMethodType = "revolut_pay"
219
        SubscriptionPaymentSettingsPaymentMethodTypeSEPACreditTransfer SubscriptionPaymentSettingsPaymentMethodType = "sepa_credit_transfer"
220
        SubscriptionPaymentSettingsPaymentMethodTypeSEPADebit          SubscriptionPaymentSettingsPaymentMethodType = "sepa_debit"
221
        SubscriptionPaymentSettingsPaymentMethodTypeSofort             SubscriptionPaymentSettingsPaymentMethodType = "sofort"
222
        SubscriptionPaymentSettingsPaymentMethodTypeSwish              SubscriptionPaymentSettingsPaymentMethodType = "swish"
223
        SubscriptionPaymentSettingsPaymentMethodTypeUSBankAccount      SubscriptionPaymentSettingsPaymentMethodType = "us_bank_account"
224
        SubscriptionPaymentSettingsPaymentMethodTypeWeChatPay          SubscriptionPaymentSettingsPaymentMethodType = "wechat_pay"
225
)
226

227
// Configure whether Stripe updates `subscription.default_payment_method` when payment succeeds. Defaults to `off`.
228
type SubscriptionPaymentSettingsSaveDefaultPaymentMethod string
229

230
// List of values that SubscriptionPaymentSettingsSaveDefaultPaymentMethod can take
231
const (
232
        SubscriptionPaymentSettingsSaveDefaultPaymentMethodOff            SubscriptionPaymentSettingsSaveDefaultPaymentMethod = "off"
233
        SubscriptionPaymentSettingsSaveDefaultPaymentMethodOnSubscription SubscriptionPaymentSettingsSaveDefaultPaymentMethod = "on_subscription"
234
)
235

236
// Specifies invoicing frequency. Either `day`, `week`, `month` or `year`.
237
type SubscriptionPendingInvoiceItemIntervalInterval string
238

239
// List of values that SubscriptionPendingInvoiceItemIntervalInterval can take
240
const (
241
        SubscriptionPendingInvoiceItemIntervalIntervalDay   SubscriptionPendingInvoiceItemIntervalInterval = "day"
242
        SubscriptionPendingInvoiceItemIntervalIntervalMonth SubscriptionPendingInvoiceItemIntervalInterval = "month"
243
        SubscriptionPendingInvoiceItemIntervalIntervalWeek  SubscriptionPendingInvoiceItemIntervalInterval = "week"
244
        SubscriptionPendingInvoiceItemIntervalIntervalYear  SubscriptionPendingInvoiceItemIntervalInterval = "year"
245
)
246

247
// Whether to cancel or preserve `prebilling` if the subscription is updated during the prebilled period.
248
type SubscriptionPrebillingUpdateBehavior string
249

250
// List of values that SubscriptionPrebillingUpdateBehavior can take
251
const (
252
        SubscriptionPrebillingUpdateBehaviorPrebill SubscriptionPrebillingUpdateBehavior = "prebill"
253
        SubscriptionPrebillingUpdateBehaviorReset   SubscriptionPrebillingUpdateBehavior = "reset"
254
)
255

256
// Possible values are `incomplete`, `incomplete_expired`, `trialing`, `active`, `past_due`, `canceled`, `unpaid`, or `paused`.
257
//
258
// 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.
259
//
260
// A subscription that is currently in a trial period is `trialing` and moves to `active` when the trial period is over.
261
//
262
// 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.
263
//
264
// 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).
265
//
266
// 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.
267
type SubscriptionStatus string
268

269
// List of values that SubscriptionStatus can take
270
const (
271
        SubscriptionStatusActive            SubscriptionStatus = "active"
272
        SubscriptionStatusCanceled          SubscriptionStatus = "canceled"
273
        SubscriptionStatusIncomplete        SubscriptionStatus = "incomplete"
274
        SubscriptionStatusIncompleteExpired SubscriptionStatus = "incomplete_expired"
275
        SubscriptionStatusPastDue           SubscriptionStatus = "past_due"
276
        SubscriptionStatusPaused            SubscriptionStatus = "paused"
277
        SubscriptionStatusTrialing          SubscriptionStatus = "trialing"
278
        SubscriptionStatusUnpaid            SubscriptionStatus = "unpaid"
279
)
280

281
// Indicates how the subscription should change when the trial ends if the user did not provide a payment method.
282
type SubscriptionTrialSettingsEndBehaviorMissingPaymentMethod string
283

284
// List of values that SubscriptionTrialSettingsEndBehaviorMissingPaymentMethod can take
285
const (
286
        SubscriptionTrialSettingsEndBehaviorMissingPaymentMethodCancel        SubscriptionTrialSettingsEndBehaviorMissingPaymentMethod = "cancel"
287
        SubscriptionTrialSettingsEndBehaviorMissingPaymentMethodCreateInvoice SubscriptionTrialSettingsEndBehaviorMissingPaymentMethod = "create_invoice"
288
        SubscriptionTrialSettingsEndBehaviorMissingPaymentMethodPause         SubscriptionTrialSettingsEndBehaviorMissingPaymentMethod = "pause"
289
)
290

291
// Details about why this subscription was cancelled
292
type SubscriptionCancelCancellationDetailsParams struct {
293
        // Additional comments about why the user canceled the subscription, if the subscription was canceled explicitly by the user.
294
        Comment *string `form:"comment"`
295
        // The customer submitted reason for why they canceled, if the subscription was canceled explicitly by the user.
296
        Feedback *string `form:"feedback"`
297
}
298

299
// Cancels a customer's subscription immediately. The customer won't be charged again for the subscription. After it's canceled, you can no longer update the subscription or its [metadata](https://stripe.com/metadata).
300
//
301
// Any pending invoice items that you've created are still charged 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 are also left in place and collected at the end of the period. But if the subscription is set to cancel immediately, pending prorations are removed.
302
//
303
// By default, upon subscription cancellation, Stripe stops 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.
304
type SubscriptionCancelParams struct {
305
        Params `form:"*"`
306
        // Details about why this subscription was cancelled
307
        CancellationDetails *SubscriptionCancelCancellationDetailsParams `form:"cancellation_details"`
308
        // Specifies which fields in the response should be expanded.
309
        Expand []*string `form:"expand"`
310
        // Will generate a final invoice that invoices for any un-invoiced metered usage and new/pending proration invoice items. Defaults to `false`.
311
        InvoiceNow *bool `form:"invoice_now"`
312
        // Will generate a proration invoice item that credits remaining unused time until the subscription period end. Defaults to `false`.
313
        Prorate *bool `form:"prorate"`
314
}
315

316
// AddExpand appends a new field to expand.
UNCOV
317
func (p *SubscriptionCancelParams) AddExpand(f string) {
×
UNCOV
318
        p.Expand = append(p.Expand, &f)
×
UNCOV
319
}
×
320

321
// Retrieves the subscription with the given ID.
322
type SubscriptionParams struct {
323
        Params `form:"*"`
324
        // 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.
325
        AddInvoiceItems []*SubscriptionAddInvoiceItemParams `form:"add_invoice_items"`
326
        // 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).
327
        ApplicationFeePercent *float64 `form:"application_fee_percent"`
328
        // Automatic tax settings for this subscription. We recommend you only include this parameter when the existing value is being changed.
329
        AutomaticTax *SubscriptionAutomaticTaxParams `form:"automatic_tax"`
330
        // 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.
331
        BackdateStartDate *int64 `form:"backdate_start_date"`
332
        // 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.
333
        BillingCycleAnchor *int64 `form:"billing_cycle_anchor"`
334
        // 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.
335
        BillingCycleAnchorConfig    *SubscriptionBillingCycleAnchorConfigParams `form:"billing_cycle_anchor_config"`
336
        BillingCycleAnchorNow       *bool                                       `form:"-"` // See custom AppendTo
337
        BillingCycleAnchorUnchanged *bool                                       `form:"-"` // See custom AppendTo
338
        // 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.
339
        BillingThresholds *SubscriptionBillingThresholdsParams `form:"billing_thresholds"`
340
        // 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.
341
        CancelAt *int64 `form:"cancel_at"`
342
        // Indicate whether this subscription should cancel at the end of the current period (`current_period_end`). Defaults to `false`.
343
        CancelAtPeriodEnd *bool `form:"cancel_at_period_end"`
344
        // Details about why this subscription was cancelled
345
        CancellationDetails *SubscriptionCancellationDetailsParams `form:"cancellation_details"`
346
        // 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`.
347
        CollectionMethod *string `form:"collection_method"`
348
        // 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.
349
        Coupon *string `form:"coupon"`
350
        // 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).
351
        Currency *string `form:"currency"`
352
        // The identifier of the customer to subscribe.
353
        Customer *string `form:"customer"`
354
        // 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`.
355
        DaysUntilDue *int64 `form:"days_until_due"`
356
        // 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).
357
        DefaultPaymentMethod *string `form:"default_payment_method"`
358
        // 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).
359
        DefaultSource *string `form:"default_source"`
360
        // 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.
361
        DefaultTaxRates []*string `form:"default_tax_rates"`
362
        // 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.
363
        Description *string `form:"description"`
364
        // The coupons to redeem into discounts for the subscription. If not specified or empty, inherits the discount from the subscription's customer.
365
        Discounts []*SubscriptionDiscountParams `form:"discounts"`
366
        // Specifies which fields in the response should be expanded.
367
        Expand []*string `form:"expand"`
368
        // All invoices will be billed using the specified settings.
369
        InvoiceSettings *SubscriptionInvoiceSettingsParams `form:"invoice_settings"`
370
        // A list of up to 20 subscription items, each with an attached price.
371
        Items []*SubscriptionItemsParams `form:"items"`
372
        // 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`.
373
        Metadata map[string]string `form:"metadata"`
374
        // Indicates if a customer is on or off-session while an invoice payment is attempted. Defaults to `false` (on-session).
375
        OffSession *bool `form:"off_session"`
376
        // The account on behalf of which to charge, for each of the subscription's invoices.
377
        OnBehalfOf *string `form:"on_behalf_of"`
378
        // 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).
379
        PauseCollection *SubscriptionPauseCollectionParams `form:"pause_collection"`
380
        // Only applies to subscriptions with `collection_method=charge_automatically`.
381
        //
382
        // 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.
383
        //
384
        // 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.
385
        //
386
        // 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.
387
        //
388
        // `pending_if_incomplete` is only used with updates and cannot be passed when creating a Subscription.
389
        //
390
        // Subscriptions with `collection_method=send_invoice` are automatically activated regardless of the first Invoice status.
391
        PaymentBehavior *string `form:"payment_behavior"`
392
        // Payment settings to pass to invoices created by the subscription.
393
        PaymentSettings *SubscriptionPaymentSettingsParams `form:"payment_settings"`
394
        // 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.
395
        PendingInvoiceItemInterval *SubscriptionPendingInvoiceItemIntervalParams `form:"pending_invoice_item_interval"`
396
        // If specified, the invoicing for the given billing cycle iterations will be processed now.
397
        Prebilling *SubscriptionPrebillingParams `form:"prebilling"`
398
        // The 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.
399
        PromotionCode *string `form:"promotion_code"`
400
        // 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`.
401
        ProrationBehavior *string `form:"proration_behavior"`
402
        // 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.
403
        ProrationDate *int64 `form:"proration_date"`
404
        // 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.
405
        TransferData *SubscriptionTransferDataParams `form:"transfer_data"`
406
        // 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.
407
        TrialEnd    *int64 `form:"trial_end"`
408
        TrialEndNow *bool  `form:"-"` // See custom AppendTo
409
        // 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.
410
        TrialFromPlan *bool `form:"trial_from_plan"`
411
        // 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.
412
        TrialPeriodDays *int64 `form:"trial_period_days"`
413
        // Settings related to subscription trials.
414
        TrialSettings *SubscriptionTrialSettingsParams `form:"trial_settings"`
415
}
416

417
// AddExpand appends a new field to expand.
UNCOV
418
func (p *SubscriptionParams) AddExpand(f string) {
×
UNCOV
419
        p.Expand = append(p.Expand, &f)
×
UNCOV
420
}
×
421

422
// AddMetadata adds a new key-value pair to the Metadata.
423
func (p *SubscriptionParams) AddMetadata(key string, value string) {
×
424
        if p.Metadata == nil {
×
425
                p.Metadata = make(map[string]string)
×
UNCOV
426
        }
×
427

428
        p.Metadata[key] = value
×
429
}
430

431
// AppendTo implements custom encoding logic for SubscriptionParams.
432
func (p *SubscriptionParams) AppendTo(body *form.Values, keyParts []string) {
3✔
433
        if BoolValue(p.BillingCycleAnchorNow) {
4✔
434
                body.Add(form.FormatKey(append(keyParts, "billing_cycle_anchor")), "now")
1✔
435
        }
1✔
436
        if BoolValue(p.BillingCycleAnchorUnchanged) {
4✔
437
                body.Add(form.FormatKey(append(keyParts, "billing_cycle_anchor")), "unchanged")
1✔
438
        }
1✔
439
        if BoolValue(p.TrialEndNow) {
4✔
440
                body.Add(form.FormatKey(append(keyParts, "trial_end")), "now")
1✔
441
        }
1✔
442
}
443

444
// Time span for the redeemed discount.
445
type SubscriptionAddInvoiceItemDiscountDiscountEndDurationParams struct {
446
        // Specifies a type of interval unit. Either `day`, `week`, `month` or `year`.
447
        Interval *string `form:"interval"`
448
        // The number of intervals, as an whole number greater than 0. Stripe multiplies this by the interval type to get the overall duration.
449
        IntervalCount *int64 `form:"interval_count"`
450
}
451

452
// Details to determine how long the discount should be applied for.
453
type SubscriptionAddInvoiceItemDiscountDiscountEndParams struct {
454
        // Time span for the redeemed discount.
455
        Duration *SubscriptionAddInvoiceItemDiscountDiscountEndDurationParams `form:"duration"`
456
        // A precise Unix timestamp for the discount to end. Must be in the future.
457
        Timestamp *int64 `form:"timestamp"`
458
        // The type of calculation made to determine when the discount ends.
459
        Type *string `form:"type"`
460
}
461

462
// The coupons to redeem into discounts for the item.
463
type SubscriptionAddInvoiceItemDiscountParams struct {
464
        // ID of the coupon to create a new discount for.
465
        Coupon *string `form:"coupon"`
466
        // ID of an existing discount on the object (or one of its ancestors) to reuse.
467
        Discount *string `form:"discount"`
468
        // Details to determine how long the discount should be applied for.
469
        DiscountEnd *SubscriptionAddInvoiceItemDiscountDiscountEndParams `form:"discount_end"`
470
        // ID of the promotion code to create a new discount for.
471
        PromotionCode *string `form:"promotion_code"`
472
}
473

474
// 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.
475
type SubscriptionAddInvoiceItemParams struct {
476
        // The coupons to redeem into discounts for the item.
477
        Discounts []*SubscriptionAddInvoiceItemDiscountParams `form:"discounts"`
478
        // The ID of the price object. One of `price` or `price_data` is required.
479
        Price *string `form:"price"`
480
        // Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline. One of `price` or `price_data` is required.
481
        PriceData *InvoiceItemPriceDataParams `form:"price_data"`
482
        // Quantity for this item. Defaults to 1.
483
        Quantity *int64 `form:"quantity"`
484
        // The tax rates which apply to the item. When set, the `default_tax_rates` do not apply to this item.
485
        TaxRates []*string `form:"tax_rates"`
486
}
487

488
// 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.
489
type SubscriptionAutomaticTaxLiabilityParams struct {
490
        // The connected account being referenced when `type` is `account`.
491
        Account *string `form:"account"`
492
        // Type of the account referenced in the request.
493
        Type *string `form:"type"`
494
}
495

496
// Automatic tax settings for this subscription. We recommend you only include this parameter when the existing value is being changed.
497
type SubscriptionAutomaticTaxParams struct {
498
        // Enabled automatic tax calculation which will automatically compute tax rates on all invoices generated by the subscription.
499
        Enabled *bool `form:"enabled"`
500
        // 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.
501
        Liability *SubscriptionAutomaticTaxLiabilityParams `form:"liability"`
502
}
503

504
// 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.
505
type SubscriptionBillingThresholdsParams struct {
506
        // Monetary threshold that triggers the subscription to advance to a new billing period
507
        AmountGTE *int64 `form:"amount_gte"`
508
        // 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.
509
        ResetBillingCycleAnchor *bool `form:"reset_billing_cycle_anchor"`
510
}
511

512
// Details about why this subscription was cancelled
513
type SubscriptionCancellationDetailsParams struct {
514
        // Additional comments about why the user canceled the subscription, if the subscription was canceled explicitly by the user.
515
        Comment *string `form:"comment"`
516
        // The customer submitted reason for why they canceled, if the subscription was canceled explicitly by the user.
517
        Feedback *string `form:"feedback"`
518
}
519

520
// Time span for the redeemed discount.
521
type SubscriptionDiscountDiscountEndDurationParams struct {
522
        // Specifies a type of interval unit. Either `day`, `week`, `month` or `year`.
523
        Interval *string `form:"interval"`
524
        // The number of intervals, as an whole number greater than 0. Stripe multiplies this by the interval type to get the overall duration.
525
        IntervalCount *int64 `form:"interval_count"`
526
}
527

528
// Details to determine how long the discount should be applied for.
529
type SubscriptionDiscountDiscountEndParams struct {
530
        // Time span for the redeemed discount.
531
        Duration *SubscriptionDiscountDiscountEndDurationParams `form:"duration"`
532
        // A precise Unix timestamp for the discount to end. Must be in the future.
533
        Timestamp *int64 `form:"timestamp"`
534
        // The type of calculation made to determine when the discount ends.
535
        Type *string `form:"type"`
536
}
537

538
// The coupons to redeem into discounts for the subscription. If not specified or empty, inherits the discount from the subscription's customer.
539
type SubscriptionDiscountParams struct {
540
        // ID of the coupon to create a new discount for.
541
        Coupon *string `form:"coupon"`
542
        // ID of an existing discount on the object (or one of its ancestors) to reuse.
543
        Discount *string `form:"discount"`
544
        // Details to determine how long the discount should be applied for.
545
        DiscountEnd *SubscriptionDiscountDiscountEndParams `form:"discount_end"`
546
        // ID of the promotion code to create a new discount for.
547
        PromotionCode *string `form:"promotion_code"`
548
}
549

550
// The connected account that issues the invoice. The invoice is presented with the branding and support information of the specified account.
551
type SubscriptionInvoiceSettingsIssuerParams struct {
552
        // The connected account being referenced when `type` is `account`.
553
        Account *string `form:"account"`
554
        // Type of the account referenced in the request.
555
        Type *string `form:"type"`
556
}
557

558
// All invoices will be billed using the specified settings.
559
type SubscriptionInvoiceSettingsParams struct {
560
        // The account tax IDs associated with the subscription. Will be set on invoices generated by the subscription.
561
        AccountTaxIDs []*string `form:"account_tax_ids"`
562
        // The connected account that issues the invoice. The invoice is presented with the branding and support information of the specified account.
563
        Issuer *SubscriptionInvoiceSettingsIssuerParams `form:"issuer"`
564
}
565

566
// A list of up to 20 subscription items, each with an attached price.
567
type SubscriptionItemsParams struct {
568
        Params `form:"*"`
569
        // 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.
570
        BillingThresholds *SubscriptionItemBillingThresholdsParams `form:"billing_thresholds"`
571
        // 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`.
572
        ClearUsage *bool `form:"clear_usage"`
573
        // A flag that, if set to `true`, will delete the specified item.
574
        Deleted *bool `form:"deleted"`
575
        // The coupons to redeem into discounts for the subscription item.
576
        Discounts []*SubscriptionItemDiscountParams `form:"discounts"`
577
        // Subscription item to update.
578
        ID *string `form:"id"`
579
        // 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`.
580
        Metadata map[string]string `form:"metadata"`
581
        // Plan ID for this item, as a string.
582
        Plan *string `form:"plan"`
583
        // The ID of the price object. One of `price` or `price_data` is required. When changing a subscription item's price, `quantity` is set to 1 unless a `quantity` parameter is provided.
584
        Price *string `form:"price"`
585
        // Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline. One of `price` or `price_data` is required.
586
        PriceData *SubscriptionItemPriceDataParams `form:"price_data"`
587
        // Quantity for this item.
588
        Quantity *int64 `form:"quantity"`
589
        // 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.
590
        TaxRates []*string `form:"tax_rates"`
591
        // Define options to configure the trial on the subscription item.
592
        Trial *SubscriptionItemTrialParams `form:"trial"`
593
}
594

595
// AddMetadata adds a new key-value pair to the Metadata.
UNCOV
596
func (p *SubscriptionItemsParams) AddMetadata(key string, value string) {
×
UNCOV
597
        if p.Metadata == nil {
×
UNCOV
598
                p.Metadata = make(map[string]string)
×
UNCOV
599
        }
×
600

601
        p.Metadata[key] = value
×
602
}
603

604
// 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).
605
type SubscriptionPauseCollectionParams struct {
606
        // The payment collection behavior for this subscription while paused. One of `keep_as_draft`, `mark_uncollectible`, or `void`.
607
        Behavior *string `form:"behavior"`
608
        // The time after which the subscription will resume collecting payments.
609
        ResumesAt *int64 `form:"resumes_at"`
610
}
611

612
// Additional fields for Mandate creation
613
type SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebitMandateOptionsParams struct {
614
        // Transaction type of the mandate.
615
        TransactionType *string `form:"transaction_type"`
616
}
617

618
// This sub-hash contains details about the Canadian pre-authorized debit payment method options to pass to the invoice's PaymentIntent.
619
type SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebitParams struct {
620
        // Additional fields for Mandate creation
621
        MandateOptions *SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebitMandateOptionsParams `form:"mandate_options"`
622
        // Verification method for the intent
623
        VerificationMethod *string `form:"verification_method"`
624
}
625

626
// This sub-hash contains details about the Bancontact payment method options to pass to the invoice's PaymentIntent.
627
type SubscriptionPaymentSettingsPaymentMethodOptionsBancontactParams struct {
628
        // Preferred language of the Bancontact authorization page that the customer is redirected to.
629
        PreferredLanguage *string `form:"preferred_language"`
630
}
631

632
// Configuration options for setting up an eMandate for cards issued in India.
633
type SubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptionsParams struct {
634
        // Amount to be charged for future payments.
635
        Amount *int64 `form:"amount"`
636
        // 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.
637
        AmountType *string `form:"amount_type"`
638
        // A description of the mandate or subscription that is meant to be displayed to the customer.
639
        Description *string `form:"description"`
640
}
641

642
// This sub-hash contains details about the Card payment method options to pass to the invoice's PaymentIntent.
643
type SubscriptionPaymentSettingsPaymentMethodOptionsCardParams struct {
644
        // Configuration options for setting up an eMandate for cards issued in India.
645
        MandateOptions *SubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptionsParams `form:"mandate_options"`
646
        // 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.
647
        Network *string `form:"network"`
648
        // 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.
649
        RequestThreeDSecure *string `form:"request_three_d_secure"`
650
}
651

652
// Configuration for eu_bank_transfer funding type.
653
type SubscriptionPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferEUBankTransferParams struct {
654
        // The desired country code of the bank account information. Permitted values include: `BE`, `DE`, `ES`, `FR`, `IE`, or `NL`.
655
        Country *string `form:"country"`
656
}
657

658
// Configuration for the bank transfer funding type, if the `funding_type` is set to `bank_transfer`.
659
type SubscriptionPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferParams struct {
660
        // Configuration for eu_bank_transfer funding type.
661
        EUBankTransfer *SubscriptionPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferEUBankTransferParams `form:"eu_bank_transfer"`
662
        // 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`.
663
        Type *string `form:"type"`
664
}
665

666
// This sub-hash contains details about the Bank transfer payment method options to pass to the invoice's PaymentIntent.
667
type SubscriptionPaymentSettingsPaymentMethodOptionsCustomerBalanceParams struct {
668
        // Configuration for the bank transfer funding type, if the `funding_type` is set to `bank_transfer`.
669
        BankTransfer *SubscriptionPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferParams `form:"bank_transfer"`
670
        // The funding method type to be used when there are not enough funds in the customer balance. Permitted values include: `bank_transfer`.
671
        FundingType *string `form:"funding_type"`
672
}
673

674
// This sub-hash contains details about the Konbini payment method options to pass to the invoice's PaymentIntent.
675
type SubscriptionPaymentSettingsPaymentMethodOptionsKonbiniParams struct{}
676

677
// This sub-hash contains details about the SEPA Direct Debit payment method options to pass to the invoice's PaymentIntent.
678
type SubscriptionPaymentSettingsPaymentMethodOptionsSEPADebitParams struct{}
679

680
// Provide filters for the linked accounts that the customer can select for the payment method.
681
type SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsFiltersParams struct {
682
        // The account subcategories to use to filter for selectable accounts. Valid subcategories are `checking` and `savings`.
683
        AccountSubcategories []*string `form:"account_subcategories"`
684
        // ID of the institution to use to filter for selectable accounts.
685
        Institution *string `form:"institution"`
686
}
687

688
// Additional fields for Financial Connections Session creation
689
type SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsParams struct {
690
        // Provide filters for the linked accounts that the customer can select for the payment method.
691
        Filters *SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsFiltersParams `form:"filters"`
692
        // 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`.
693
        Permissions []*string `form:"permissions"`
694
        // List of data features that you would like to retrieve upon account creation.
695
        Prefetch []*string `form:"prefetch"`
696
}
697

698
// This sub-hash contains details about the ACH direct debit payment method options to pass to the invoice's PaymentIntent.
699
type SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountParams struct {
700
        // Additional fields for Financial Connections Session creation
701
        FinancialConnections *SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsParams `form:"financial_connections"`
702
        // Verification method for the intent
703
        VerificationMethod *string `form:"verification_method"`
704
}
705

706
// Payment-method-specific configuration to provide to invoices created by the subscription.
707
type SubscriptionPaymentSettingsPaymentMethodOptionsParams struct {
708
        // This sub-hash contains details about the Canadian pre-authorized debit payment method options to pass to the invoice's PaymentIntent.
709
        ACSSDebit *SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebitParams `form:"acss_debit"`
710
        // This sub-hash contains details about the Bancontact payment method options to pass to the invoice's PaymentIntent.
711
        Bancontact *SubscriptionPaymentSettingsPaymentMethodOptionsBancontactParams `form:"bancontact"`
712
        // This sub-hash contains details about the Card payment method options to pass to the invoice's PaymentIntent.
713
        Card *SubscriptionPaymentSettingsPaymentMethodOptionsCardParams `form:"card"`
714
        // This sub-hash contains details about the Bank transfer payment method options to pass to the invoice's PaymentIntent.
715
        CustomerBalance *SubscriptionPaymentSettingsPaymentMethodOptionsCustomerBalanceParams `form:"customer_balance"`
716
        // This sub-hash contains details about the Konbini payment method options to pass to the invoice's PaymentIntent.
717
        Konbini *SubscriptionPaymentSettingsPaymentMethodOptionsKonbiniParams `form:"konbini"`
718
        // This sub-hash contains details about the SEPA Direct Debit payment method options to pass to the invoice's PaymentIntent.
719
        SEPADebit *SubscriptionPaymentSettingsPaymentMethodOptionsSEPADebitParams `form:"sepa_debit"`
720
        // This sub-hash contains details about the ACH direct debit payment method options to pass to the invoice's PaymentIntent.
721
        USBankAccount *SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountParams `form:"us_bank_account"`
722
}
723

724
// Payment settings to pass to invoices created by the subscription.
725
type SubscriptionPaymentSettingsParams struct {
726
        // Payment-method-specific configuration to provide to invoices created by the subscription.
727
        PaymentMethodOptions *SubscriptionPaymentSettingsPaymentMethodOptionsParams `form:"payment_method_options"`
728
        // 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).
729
        PaymentMethodTypes []*string `form:"payment_method_types"`
730
        // Configure whether Stripe updates `subscription.default_payment_method` when payment succeeds. Defaults to `off` if unspecified.
731
        SaveDefaultPaymentMethod *string `form:"save_default_payment_method"`
732
}
733

734
// 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.
735
type SubscriptionPendingInvoiceItemIntervalParams struct {
736
        // Specifies invoicing frequency. Either `day`, `week`, `month` or `year`.
737
        Interval *string `form:"interval"`
738
        // 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).
739
        IntervalCount *int64 `form:"interval_count"`
740
}
741

742
// If specified, the invoicing for the given billing cycle iterations will be processed now.
743
type SubscriptionPrebillingParams struct {
744
        // This is used to determine the number of billing cycles to prebill.
745
        Iterations *int64 `form:"iterations"`
746
        // Whether to cancel or preserve `prebilling` if the subscription is updated during the prebilled period. The default value is `reset`.
747
        UpdateBehavior *string `form:"update_behavior"`
748
}
749

750
// 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.
751
type SubscriptionTransferDataParams struct {
752
        // 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.
753
        AmountPercent *float64 `form:"amount_percent"`
754
        // ID of an existing, connected Stripe account.
755
        Destination *string `form:"destination"`
756
}
757

758
// Defines how the subscription should behave when the user's free trial ends.
759
type SubscriptionTrialSettingsEndBehaviorParams struct {
760
        // Indicates how the subscription should change when the trial ends if the user did not provide a payment method.
761
        MissingPaymentMethod *string `form:"missing_payment_method"`
762
}
763

764
// Settings related to subscription trials.
765
type SubscriptionTrialSettingsParams struct {
766
        // Defines how the subscription should behave when the user's free trial ends.
767
        EndBehavior *SubscriptionTrialSettingsEndBehaviorParams `form:"end_behavior"`
768
}
769

770
// Removes the currently applied discount on a subscription.
771
type SubscriptionDeleteDiscountParams struct {
772
        Params `form:"*"`
773
}
774

775
// Filter subscriptions by their automatic tax settings.
776
type SubscriptionListAutomaticTaxParams struct {
777
        // Enabled automatic tax calculation which will automatically compute tax rates on all invoices generated by the subscription.
778
        Enabled *bool `form:"enabled"`
779
}
780

781
// By default, returns a list of subscriptions that have not been canceled. In order to list canceled subscriptions, specify status=canceled.
782
type SubscriptionListParams struct {
783
        ListParams `form:"*"`
784
        // Filter subscriptions by their automatic tax settings.
785
        AutomaticTax *SubscriptionListAutomaticTaxParams `form:"automatic_tax"`
786
        // The collection method of the subscriptions to retrieve. Either `charge_automatically` or `send_invoice`.
787
        CollectionMethod *string `form:"collection_method"`
788
        // Only return subscriptions that were created during the given date interval.
789
        Created *int64 `form:"created"`
790
        // Only return subscriptions that were created during the given date interval.
791
        CreatedRange *RangeQueryParams `form:"created"`
792
        // Only return subscriptions whose current_period_end falls within the given date interval.
793
        CurrentPeriodEnd *int64 `form:"current_period_end"`
794
        // Only return subscriptions whose current_period_end falls within the given date interval.
795
        CurrentPeriodEndRange *RangeQueryParams `form:"current_period_end"`
796
        // Only return subscriptions whose current_period_start falls within the given date interval.
797
        CurrentPeriodStart *int64 `form:"current_period_start"`
798
        // Only return subscriptions whose current_period_start falls within the given date interval.
799
        CurrentPeriodStartRange *RangeQueryParams `form:"current_period_start"`
800
        // The ID of the customer whose subscriptions will be retrieved.
801
        Customer *string `form:"customer"`
802
        // Specifies which fields in the response should be expanded.
803
        Expand []*string `form:"expand"`
804
        // The ID of the plan whose subscriptions will be retrieved.
805
        Plan *string `form:"plan"`
806
        // Filter for subscriptions that contain this recurring price ID.
807
        Price *string `form:"price"`
808
        // 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.
809
        Status *string `form:"status"`
810
        // 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.
811
        TestClock *string `form:"test_clock"`
812
}
813

814
// AddExpand appends a new field to expand.
UNCOV
815
func (p *SubscriptionListParams) AddExpand(f string) {
×
UNCOV
816
        p.Expand = append(p.Expand, &f)
×
UNCOV
817
}
×
818

819
// 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.
820
type SubscriptionBillingCycleAnchorConfigParams struct {
821
        // The day of the month the billing_cycle_anchor should be. Ranges from 1 to 31.
822
        DayOfMonth *int64 `form:"day_of_month"`
823
        // The hour of the day the billing_cycle_anchor should be. Ranges from 0 to 23.
824
        Hour *int64 `form:"hour"`
825
        // The minute of the hour the billing_cycle_anchor should be. Ranges from 0 to 59.
826
        Minute *int64 `form:"minute"`
827
        // The month to start full cycle billing periods. Ranges from 1 to 12.
828
        Month *int64 `form:"month"`
829
        // The second of the minute the billing_cycle_anchor should be. Ranges from 0 to 59.
830
        Second *int64 `form:"second"`
831
}
832

833
// Search for subscriptions you've previously created using Stripe's [Search Query Language](https://stripe.com/docs/search#search-query-language).
834
// Don't use search in read-after-write flows where strict consistency is necessary. Under normal operating
835
// conditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up
836
// to an hour behind during outages. Search functionality is not available to merchants in India.
837
type SubscriptionSearchParams struct {
838
        SearchParams `form:"*"`
839
        // Specifies which fields in the response should be expanded.
840
        Expand []*string `form:"expand"`
841
        // 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.
842
        Page *string `form:"page"`
843
}
844

845
// AddExpand appends a new field to expand.
UNCOV
846
func (p *SubscriptionSearchParams) AddExpand(f string) {
×
UNCOV
847
        p.Expand = append(p.Expand, &f)
×
UNCOV
848
}
×
849

850
// 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.
851
type SubscriptionResumeParams struct {
852
        Params `form:"*"`
853
        // 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).
854
        BillingCycleAnchor *string `form:"billing_cycle_anchor"`
855
        // Specifies which fields in the response should be expanded.
856
        Expand []*string `form:"expand"`
857
        // 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`.
858
        ProrationBehavior *string `form:"proration_behavior"`
859
        // 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.
860
        ProrationDate *int64 `form:"proration_date"`
861
}
862

863
// AddExpand appends a new field to expand.
UNCOV
864
func (p *SubscriptionResumeParams) AddExpand(f string) {
×
UNCOV
865
        p.Expand = append(p.Expand, &f)
×
UNCOV
866
}
×
867

868
// 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.
869
type SubscriptionAutomaticTaxLiability struct {
870
        // The connected account being referenced when `type` is `account`.
871
        Account *Account `json:"account"`
872
        // Type of the account referenced.
873
        Type SubscriptionAutomaticTaxLiabilityType `json:"type"`
874
}
875
type SubscriptionAutomaticTax struct {
876
        // Whether Stripe automatically computes tax on this subscription.
877
        Enabled bool `json:"enabled"`
878
        // 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.
879
        Liability *SubscriptionAutomaticTaxLiability `json:"liability"`
880
}
881

882
// The fixed values used to calculate the `billing_cycle_anchor`.
883
type SubscriptionBillingCycleAnchorConfig struct {
884
        // The day of the month of the billing_cycle_anchor.
885
        DayOfMonth int64 `json:"day_of_month"`
886
        // The hour of the day of the billing_cycle_anchor.
887
        Hour int64 `json:"hour"`
888
        // The minute of the hour of the billing_cycle_anchor.
889
        Minute int64 `json:"minute"`
890
        // The month to start full cycle billing periods.
891
        Month int64 `json:"month"`
892
        // The second of the minute of the billing_cycle_anchor.
893
        Second int64 `json:"second"`
894
}
895

896
// Define thresholds at which an invoice will be sent, and the subscription advanced to a new billing period
897
type SubscriptionBillingThresholds struct {
898
        // Monetary threshold that triggers the subscription to create an invoice
899
        AmountGTE int64 `json:"amount_gte"`
900
        // 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`.
901
        ResetBillingCycleAnchor bool `json:"reset_billing_cycle_anchor"`
902
}
903

904
// Details about why this subscription was cancelled
905
type SubscriptionCancellationDetails struct {
906
        // Additional comments about why the user canceled the subscription, if the subscription was canceled explicitly by the user.
907
        Comment string `json:"comment"`
908
        // The customer submitted reason for why they canceled, if the subscription was canceled explicitly by the user.
909
        Feedback SubscriptionCancellationDetailsFeedback `json:"feedback"`
910
        // Why this subscription was canceled.
911
        Reason SubscriptionCancellationDetailsReason `json:"reason"`
912
}
913
type SubscriptionInvoiceSettingsIssuer struct {
914
        // The connected account being referenced when `type` is `account`.
915
        Account *Account `json:"account"`
916
        // Type of the account referenced.
917
        Type SubscriptionInvoiceSettingsIssuerType `json:"type"`
918
}
919
type SubscriptionInvoiceSettings struct {
920
        // The account tax IDs associated with the subscription. Will be set on invoices generated by the subscription.
921
        AccountTaxIDs []*TaxID                           `json:"account_tax_ids"`
922
        Issuer        *SubscriptionInvoiceSettingsIssuer `json:"issuer"`
923
}
924

925
// The involved price pairs in each failed transition.
926
type SubscriptionLastPriceMigrationErrorFailedTransition struct {
927
        // The original price to be migrated.
928
        SourcePrice string `json:"source_price"`
929
        // The intended resulting price of the migration.
930
        TargetPrice string `json:"target_price"`
931
}
932

933
// Details of the most recent price migration that failed for the subscription.
934
type SubscriptionLastPriceMigrationError struct {
935
        // The time at which the price migration encountered an error.
936
        ErroredAt int64 `json:"errored_at"`
937
        // The involved price pairs in each failed transition.
938
        FailedTransitions []*SubscriptionLastPriceMigrationErrorFailedTransition `json:"failed_transitions"`
939
        // The type of error encountered by the price migration.
940
        Type SubscriptionLastPriceMigrationErrorType `json:"type"`
941
}
942

943
// 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).
944
type SubscriptionPauseCollection struct {
945
        // The payment collection behavior for this subscription while paused. One of `keep_as_draft`, `mark_uncollectible`, or `void`.
946
        Behavior SubscriptionPauseCollectionBehavior `json:"behavior"`
947
        // The time after which the subscription will resume collecting payments.
948
        ResumesAt int64 `json:"resumes_at"`
949
}
950
type SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebitMandateOptions struct {
951
        // Transaction type of the mandate.
952
        TransactionType SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebitMandateOptionsTransactionType `json:"transaction_type"`
953
}
954

955
// This sub-hash contains details about the Canadian pre-authorized debit payment method options to pass to invoices created by the subscription.
956
type SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebit struct {
957
        MandateOptions *SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebitMandateOptions `json:"mandate_options"`
958
        // Bank account verification method.
959
        VerificationMethod SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebitVerificationMethod `json:"verification_method"`
960
}
961

962
// This sub-hash contains details about the Bancontact payment method options to pass to invoices created by the subscription.
963
type SubscriptionPaymentSettingsPaymentMethodOptionsBancontact struct {
964
        // Preferred language of the Bancontact authorization page that the customer is redirected to.
965
        PreferredLanguage string `json:"preferred_language"`
966
}
967
type SubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptions struct {
968
        // Amount to be charged for future payments.
969
        Amount int64 `json:"amount"`
970
        // 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.
971
        AmountType SubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptionsAmountType `json:"amount_type"`
972
        // A description of the mandate or subscription that is meant to be displayed to the customer.
973
        Description string `json:"description"`
974
}
975

976
// This sub-hash contains details about the Card payment method options to pass to invoices created by the subscription.
977
type SubscriptionPaymentSettingsPaymentMethodOptionsCard struct {
978
        MandateOptions *SubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptions `json:"mandate_options"`
979
        // 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.
980
        Network SubscriptionPaymentSettingsPaymentMethodOptionsCardNetwork `json:"network"`
981
        // 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.
982
        RequestThreeDSecure SubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure `json:"request_three_d_secure"`
983
}
984
type SubscriptionPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferEUBankTransfer struct {
985
        // The desired country code of the bank account information. Permitted values include: `BE`, `DE`, `ES`, `FR`, `IE`, or `NL`.
986
        Country string `json:"country"`
987
}
988
type SubscriptionPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransfer struct {
989
        EUBankTransfer *SubscriptionPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferEUBankTransfer `json:"eu_bank_transfer"`
990
        // 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`.
991
        Type string `json:"type"`
992
}
993

994
// This sub-hash contains details about the Bank transfer payment method options to pass to invoices created by the subscription.
995
type SubscriptionPaymentSettingsPaymentMethodOptionsCustomerBalance struct {
996
        BankTransfer *SubscriptionPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransfer `json:"bank_transfer"`
997
        // The funding method type to be used when there are not enough funds in the customer balance. Permitted values include: `bank_transfer`.
998
        FundingType SubscriptionPaymentSettingsPaymentMethodOptionsCustomerBalanceFundingType `json:"funding_type"`
999
}
1000

1001
// This sub-hash contains details about the Konbini payment method options to pass to invoices created by the subscription.
1002
type SubscriptionPaymentSettingsPaymentMethodOptionsKonbini struct{}
1003

1004
// This sub-hash contains details about the SEPA Direct Debit payment method options to pass to invoices created by the subscription.
1005
type SubscriptionPaymentSettingsPaymentMethodOptionsSEPADebit struct{}
1006
type SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsFilters struct {
1007
        // The account subcategories to use to filter for possible accounts to link. Valid subcategories are `checking` and `savings`.
1008
        AccountSubcategories []SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsFiltersAccountSubcategory `json:"account_subcategories"`
1009
        // The institution to use to filter for possible accounts to link.
1010
        Institution string `json:"institution"`
1011
}
1012
type SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnections struct {
1013
        Filters *SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsFilters `json:"filters"`
1014
        // The list of permissions to request. The `payment_method` permission must be included.
1015
        Permissions []SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPermission `json:"permissions"`
1016
        // Data features requested to be retrieved upon account creation.
1017
        Prefetch []SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnectionsPrefetch `json:"prefetch"`
1018
}
1019

1020
// This sub-hash contains details about the ACH direct debit payment method options to pass to invoices created by the subscription.
1021
type SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccount struct {
1022
        FinancialConnections *SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountFinancialConnections `json:"financial_connections"`
1023
        // Bank account verification method.
1024
        VerificationMethod SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccountVerificationMethod `json:"verification_method"`
1025
}
1026

1027
// Payment-method-specific configuration to provide to invoices created by the subscription.
1028
type SubscriptionPaymentSettingsPaymentMethodOptions struct {
1029
        // This sub-hash contains details about the Canadian pre-authorized debit payment method options to pass to invoices created by the subscription.
1030
        ACSSDebit *SubscriptionPaymentSettingsPaymentMethodOptionsACSSDebit `json:"acss_debit"`
1031
        // This sub-hash contains details about the Bancontact payment method options to pass to invoices created by the subscription.
1032
        Bancontact *SubscriptionPaymentSettingsPaymentMethodOptionsBancontact `json:"bancontact"`
1033
        // This sub-hash contains details about the Card payment method options to pass to invoices created by the subscription.
1034
        Card *SubscriptionPaymentSettingsPaymentMethodOptionsCard `json:"card"`
1035
        // This sub-hash contains details about the Bank transfer payment method options to pass to invoices created by the subscription.
1036
        CustomerBalance *SubscriptionPaymentSettingsPaymentMethodOptionsCustomerBalance `json:"customer_balance"`
1037
        // This sub-hash contains details about the Konbini payment method options to pass to invoices created by the subscription.
1038
        Konbini *SubscriptionPaymentSettingsPaymentMethodOptionsKonbini `json:"konbini"`
1039
        // This sub-hash contains details about the SEPA Direct Debit payment method options to pass to invoices created by the subscription.
1040
        SEPADebit *SubscriptionPaymentSettingsPaymentMethodOptionsSEPADebit `json:"sepa_debit"`
1041
        // This sub-hash contains details about the ACH direct debit payment method options to pass to invoices created by the subscription.
1042
        USBankAccount *SubscriptionPaymentSettingsPaymentMethodOptionsUSBankAccount `json:"us_bank_account"`
1043
}
1044

1045
// Payment settings passed on to invoices created by the subscription.
1046
type SubscriptionPaymentSettings struct {
1047
        // Payment-method-specific configuration to provide to invoices created by the subscription.
1048
        PaymentMethodOptions *SubscriptionPaymentSettingsPaymentMethodOptions `json:"payment_method_options"`
1049
        // 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).
1050
        PaymentMethodTypes []SubscriptionPaymentSettingsPaymentMethodType `json:"payment_method_types"`
1051
        // Configure whether Stripe updates `subscription.default_payment_method` when payment succeeds. Defaults to `off`.
1052
        SaveDefaultPaymentMethod SubscriptionPaymentSettingsSaveDefaultPaymentMethod `json:"save_default_payment_method"`
1053
}
1054

1055
// 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.
1056
type SubscriptionPendingInvoiceItemInterval struct {
1057
        // Specifies invoicing frequency. Either `day`, `week`, `month` or `year`.
1058
        Interval SubscriptionPendingInvoiceItemIntervalInterval `json:"interval"`
1059
        // 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).
1060
        IntervalCount int64 `json:"interval_count"`
1061
}
1062

1063
// 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.
1064
type SubscriptionPendingUpdate struct {
1065
        // 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.
1066
        BillingCycleAnchor int64 `json:"billing_cycle_anchor"`
1067
        // The point after which the changes reflected by this update will be discarded and no longer applied.
1068
        ExpiresAt int64 `json:"expires_at"`
1069
        // The number of iterations of prebilling to apply.
1070
        PrebillingIterations int64 `json:"prebilling_iterations"`
1071
        // List of subscription items, each with an attached plan, that will be set if the update is applied.
1072
        SubscriptionItems []*SubscriptionItem `json:"subscription_items"`
1073
        // 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.
1074
        TrialEnd int64 `json:"trial_end"`
1075
        // 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.
1076
        TrialFromPlan bool `json:"trial_from_plan"`
1077
}
1078

1079
// Time period and invoice for a Subscription billed in advance.
1080
type SubscriptionPrebilling struct {
1081
        // ID of the prebilling invoice.
1082
        Invoice *Invoice `json:"invoice"`
1083
        // The end of the last period for which the invoice pre-bills.
1084
        PeriodEnd int64 `json:"period_end"`
1085
        // The start of the first period for which the invoice pre-bills.
1086
        PeriodStart int64 `json:"period_start"`
1087
        // Whether to cancel or preserve `prebilling` if the subscription is updated during the prebilled period.
1088
        UpdateBehavior SubscriptionPrebillingUpdateBehavior `json:"update_behavior"`
1089
}
1090

1091
// 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.
1092
type SubscriptionTransferData struct {
1093
        // 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.
1094
        AmountPercent float64 `json:"amount_percent"`
1095
        // The account where funds from the payment will be transferred to upon payment success.
1096
        Destination *Account `json:"destination"`
1097
}
1098

1099
// Defines how a subscription behaves when a free trial ends.
1100
type SubscriptionTrialSettingsEndBehavior struct {
1101
        // Indicates how the subscription should change when the trial ends if the user did not provide a payment method.
1102
        MissingPaymentMethod SubscriptionTrialSettingsEndBehaviorMissingPaymentMethod `json:"missing_payment_method"`
1103
}
1104

1105
// Settings related to subscription trials.
1106
type SubscriptionTrialSettings struct {
1107
        // Defines how a subscription behaves when a free trial ends.
1108
        EndBehavior *SubscriptionTrialSettingsEndBehavior `json:"end_behavior"`
1109
}
1110

1111
// Subscriptions allow you to charge a customer on a recurring basis.
1112
//
1113
// Related guide: [Creating subscriptions](https://stripe.com/docs/billing/subscriptions/creating)
1114
type Subscription struct {
1115
        APIResource
1116
        // ID of the Connect Application that created the subscription.
1117
        Application *Application `json:"application"`
1118
        // 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.
1119
        ApplicationFeePercent float64                   `json:"application_fee_percent"`
1120
        AutomaticTax          *SubscriptionAutomaticTax `json:"automatic_tax"`
1121
        // 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.
1122
        BillingCycleAnchor int64 `json:"billing_cycle_anchor"`
1123
        // The fixed values used to calculate the `billing_cycle_anchor`.
1124
        BillingCycleAnchorConfig *SubscriptionBillingCycleAnchorConfig `json:"billing_cycle_anchor_config"`
1125
        // Define thresholds at which an invoice will be sent, and the subscription advanced to a new billing period
1126
        BillingThresholds *SubscriptionBillingThresholds `json:"billing_thresholds"`
1127
        // A date in the future at which the subscription will automatically get canceled
1128
        CancelAt int64 `json:"cancel_at"`
1129
        // Whether this subscription will (if `status=active`) or did (if `status=canceled`) cancel at the end of the current billing period.
1130
        CancelAtPeriodEnd bool `json:"cancel_at_period_end"`
1131
        // 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.
1132
        CanceledAt int64 `json:"canceled_at"`
1133
        // Details about why this subscription was cancelled
1134
        CancellationDetails *SubscriptionCancellationDetails `json:"cancellation_details"`
1135
        // 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`.
1136
        CollectionMethod SubscriptionCollectionMethod `json:"collection_method"`
1137
        // Time at which the object was created. Measured in seconds since the Unix epoch.
1138
        Created int64 `json:"created"`
1139
        // 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).
1140
        Currency Currency `json:"currency"`
1141
        // End of the current period that the subscription has been invoiced for. At the end of this period, a new invoice will be created.
1142
        CurrentPeriodEnd int64 `json:"current_period_end"`
1143
        // Start of the current period that the subscription has been invoiced for.
1144
        CurrentPeriodStart int64 `json:"current_period_start"`
1145
        // ID of the customer who owns the subscription.
1146
        Customer *Customer `json:"customer"`
1147
        // 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`.
1148
        DaysUntilDue int64 `json:"days_until_due"`
1149
        // 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).
1150
        DefaultPaymentMethod *PaymentMethod `json:"default_payment_method"`
1151
        // 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).
1152
        DefaultSource *PaymentSource `json:"default_source"`
1153
        // 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.
1154
        DefaultTaxRates []*TaxRate `json:"default_tax_rates"`
1155
        // 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.
1156
        Description string `json:"description"`
1157
        // 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.
1158
        Discount *Discount `json:"discount"`
1159
        // The discounts applied to the subscription. Subscription item discounts are applied before subscription discounts. Use `expand[]=discounts` to expand each discount.
1160
        Discounts []*Discount `json:"discounts"`
1161
        // If the subscription has ended, the date the subscription ended.
1162
        EndedAt int64 `json:"ended_at"`
1163
        // Unique identifier for the object.
1164
        ID              string                       `json:"id"`
1165
        InvoiceSettings *SubscriptionInvoiceSettings `json:"invoice_settings"`
1166
        // List of subscription items, each with an attached price.
1167
        Items *SubscriptionItemList `json:"items"`
1168
        // Details of the most recent price migration that failed for the subscription.
1169
        LastPriceMigrationError *SubscriptionLastPriceMigrationError `json:"last_price_migration_error"`
1170
        // The most recent invoice this subscription has generated.
1171
        LatestInvoice *Invoice `json:"latest_invoice"`
1172
        // Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
1173
        Livemode bool `json:"livemode"`
1174
        // 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.
1175
        Metadata map[string]string `json:"metadata"`
1176
        // Specifies the approximate timestamp on which any pending invoice items will be billed according to the schedule provided at `pending_invoice_item_interval`.
1177
        NextPendingInvoiceItemInvoice int64 `json:"next_pending_invoice_item_invoice"`
1178
        // String representing the object's type. Objects of the same type share the same value.
1179
        Object string `json:"object"`
1180
        // The account (if any) the charge was made on behalf of for charges associated with this subscription. See the Connect documentation for details.
1181
        OnBehalfOf *Account `json:"on_behalf_of"`
1182
        // 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).
1183
        PauseCollection *SubscriptionPauseCollection `json:"pause_collection"`
1184
        // Payment settings passed on to invoices created by the subscription.
1185
        PaymentSettings *SubscriptionPaymentSettings `json:"payment_settings"`
1186
        // 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.
1187
        PendingInvoiceItemInterval *SubscriptionPendingInvoiceItemInterval `json:"pending_invoice_item_interval"`
1188
        // 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).
1189
        PendingSetupIntent *SetupIntent `json:"pending_setup_intent"`
1190
        // 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.
1191
        PendingUpdate *SubscriptionPendingUpdate `json:"pending_update"`
1192
        // Time period and invoice for a Subscription billed in advance.
1193
        Prebilling *SubscriptionPrebilling `json:"prebilling"`
1194
        // The schedule attached to the subscription
1195
        Schedule *SubscriptionSchedule `json:"schedule"`
1196
        // Date when the subscription was first created. The date might differ from the `created` date due to backdating.
1197
        StartDate int64 `json:"start_date"`
1198
        // Possible values are `incomplete`, `incomplete_expired`, `trialing`, `active`, `past_due`, `canceled`, `unpaid`, or `paused`.
1199
        //
1200
        // 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.
1201
        //
1202
        // A subscription that is currently in a trial period is `trialing` and moves to `active` when the trial period is over.
1203
        //
1204
        // 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.
1205
        //
1206
        // 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).
1207
        //
1208
        // 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.
1209
        Status SubscriptionStatus `json:"status"`
1210
        // ID of the test clock this subscription belongs to.
1211
        TestClock *TestHelpersTestClock `json:"test_clock"`
1212
        // 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.
1213
        TransferData *SubscriptionTransferData `json:"transfer_data"`
1214
        // If the subscription has a trial, the end of that trial.
1215
        TrialEnd int64 `json:"trial_end"`
1216
        // Settings related to subscription trials.
1217
        TrialSettings *SubscriptionTrialSettings `json:"trial_settings"`
1218
        // If the subscription has a trial, the beginning of that trial.
1219
        TrialStart int64 `json:"trial_start"`
1220
}
1221

1222
// SubscriptionList is a list of Subscriptions as retrieved from a list endpoint.
1223
type SubscriptionList struct {
1224
        APIResource
1225
        ListMeta
1226
        Data []*Subscription `json:"data"`
1227
}
1228

1229
// SubscriptionSearchResult is a list of Subscription search results as retrieved from a search endpoint.
1230
type SubscriptionSearchResult struct {
1231
        APIResource
1232
        SearchMeta
1233
        Data []*Subscription `json:"data"`
1234
}
1235

1236
// UnmarshalJSON handles deserialization of a Subscription.
1237
// This custom unmarshaling is needed because the resulting
1238
// property may be an id or the full struct if it was expanded.
1239
func (s *Subscription) UnmarshalJSON(data []byte) error {
2✔
1240
        if id, ok := ParseID(data); ok {
3✔
1241
                s.ID = id
1✔
1242
                return nil
1✔
1243
        }
1✔
1244

1245
        type subscription Subscription
1✔
1246
        var v subscription
1✔
1247
        if err := json.Unmarshal(data, &v); err != nil {
1✔
UNCOV
1248
                return err
×
UNCOV
1249
        }
×
1250

1251
        *s = Subscription(v)
1✔
1252
        return nil
1✔
1253
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc