• 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

0.0
/billingportal_configuration.go
1
//
2
//
3
// File generated from our OpenAPI spec
4
//
5
//
6

7
package stripe
8

9
import "encoding/json"
10

11
// The types of customer updates that are supported. When empty, customers are not updateable.
12
type BillingPortalConfigurationFeaturesCustomerUpdateAllowedUpdate string
13

14
// List of values that BillingPortalConfigurationFeaturesCustomerUpdateAllowedUpdate can take
15
const (
16
        BillingPortalConfigurationFeaturesCustomerUpdateAllowedUpdateAddress  BillingPortalConfigurationFeaturesCustomerUpdateAllowedUpdate = "address"
17
        BillingPortalConfigurationFeaturesCustomerUpdateAllowedUpdateEmail    BillingPortalConfigurationFeaturesCustomerUpdateAllowedUpdate = "email"
18
        BillingPortalConfigurationFeaturesCustomerUpdateAllowedUpdateName     BillingPortalConfigurationFeaturesCustomerUpdateAllowedUpdate = "name"
19
        BillingPortalConfigurationFeaturesCustomerUpdateAllowedUpdatePhone    BillingPortalConfigurationFeaturesCustomerUpdateAllowedUpdate = "phone"
20
        BillingPortalConfigurationFeaturesCustomerUpdateAllowedUpdateShipping BillingPortalConfigurationFeaturesCustomerUpdateAllowedUpdate = "shipping"
21
        BillingPortalConfigurationFeaturesCustomerUpdateAllowedUpdateTaxID    BillingPortalConfigurationFeaturesCustomerUpdateAllowedUpdate = "tax_id"
22
)
23

24
// Which cancellation reasons will be given as options to the customer.
25
type BillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOption string
26

27
// List of values that BillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOption can take
28
const (
29
        BillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOptionCustomerService BillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOption = "customer_service"
30
        BillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOptionLowQuality      BillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOption = "low_quality"
31
        BillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOptionMissingFeatures BillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOption = "missing_features"
32
        BillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOptionOther           BillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOption = "other"
33
        BillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOptionSwitchedService BillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOption = "switched_service"
34
        BillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOptionTooComplex      BillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOption = "too_complex"
35
        BillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOptionTooExpensive    BillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOption = "too_expensive"
36
        BillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOptionUnused          BillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOption = "unused"
37
)
38

39
// Whether to cancel subscriptions immediately or at the end of the billing period.
40
type BillingPortalConfigurationFeaturesSubscriptionCancelMode string
41

42
// List of values that BillingPortalConfigurationFeaturesSubscriptionCancelMode can take
43
const (
44
        BillingPortalConfigurationFeaturesSubscriptionCancelModeAtPeriodEnd BillingPortalConfigurationFeaturesSubscriptionCancelMode = "at_period_end"
45
        BillingPortalConfigurationFeaturesSubscriptionCancelModeImmediately BillingPortalConfigurationFeaturesSubscriptionCancelMode = "immediately"
46
)
47

48
// Whether to create prorations when canceling subscriptions. Possible values are `none` and `create_prorations`.
49
type BillingPortalConfigurationFeaturesSubscriptionCancelProrationBehavior string
50

51
// List of values that BillingPortalConfigurationFeaturesSubscriptionCancelProrationBehavior can take
52
const (
53
        BillingPortalConfigurationFeaturesSubscriptionCancelProrationBehaviorAlwaysInvoice    BillingPortalConfigurationFeaturesSubscriptionCancelProrationBehavior = "always_invoice"
54
        BillingPortalConfigurationFeaturesSubscriptionCancelProrationBehaviorCreateProrations BillingPortalConfigurationFeaturesSubscriptionCancelProrationBehavior = "create_prorations"
55
        BillingPortalConfigurationFeaturesSubscriptionCancelProrationBehaviorNone             BillingPortalConfigurationFeaturesSubscriptionCancelProrationBehavior = "none"
56
)
57

58
// The types of subscription updates that are supported for items listed in the `products` attribute. When empty, subscriptions are not updateable.
59
type BillingPortalConfigurationFeaturesSubscriptionUpdateDefaultAllowedUpdate string
60

61
// List of values that BillingPortalConfigurationFeaturesSubscriptionUpdateDefaultAllowedUpdate can take
62
const (
63
        BillingPortalConfigurationFeaturesSubscriptionUpdateDefaultAllowedUpdatePrice         BillingPortalConfigurationFeaturesSubscriptionUpdateDefaultAllowedUpdate = "price"
64
        BillingPortalConfigurationFeaturesSubscriptionUpdateDefaultAllowedUpdatePromotionCode BillingPortalConfigurationFeaturesSubscriptionUpdateDefaultAllowedUpdate = "promotion_code"
65
        BillingPortalConfigurationFeaturesSubscriptionUpdateDefaultAllowedUpdateQuantity      BillingPortalConfigurationFeaturesSubscriptionUpdateDefaultAllowedUpdate = "quantity"
66
)
67

68
// Determines how to handle prorations resulting from subscription updates. Valid values are `none`, `create_prorations`, and `always_invoice`. Defaults to a value of `none` if you don't set it during creation.
69
type BillingPortalConfigurationFeaturesSubscriptionUpdateProrationBehavior string
70

71
// List of values that BillingPortalConfigurationFeaturesSubscriptionUpdateProrationBehavior can take
72
const (
73
        BillingPortalConfigurationFeaturesSubscriptionUpdateProrationBehaviorAlwaysInvoice    BillingPortalConfigurationFeaturesSubscriptionUpdateProrationBehavior = "always_invoice"
74
        BillingPortalConfigurationFeaturesSubscriptionUpdateProrationBehaviorCreateProrations BillingPortalConfigurationFeaturesSubscriptionUpdateProrationBehavior = "create_prorations"
75
        BillingPortalConfigurationFeaturesSubscriptionUpdateProrationBehaviorNone             BillingPortalConfigurationFeaturesSubscriptionUpdateProrationBehavior = "none"
76
)
77

78
// Returns a list of configurations that describe the functionality of the customer portal.
79
type BillingPortalConfigurationListParams struct {
80
        ListParams `form:"*"`
81
        // Only return configurations that are active or inactive (e.g., pass `true` to only list active configurations).
82
        Active *bool `form:"active"`
83
        // Specifies which fields in the response should be expanded.
84
        Expand []*string `form:"expand"`
85
        // Only return the default or non-default configurations (e.g., pass `true` to only list the default configuration).
86
        IsDefault *bool `form:"is_default"`
87
}
88

89
// AddExpand appends a new field to expand.
UNCOV
90
func (p *BillingPortalConfigurationListParams) AddExpand(f string) {
×
UNCOV
91
        p.Expand = append(p.Expand, &f)
×
UNCOV
92
}
×
93

94
// The business information shown to customers in the portal.
95
type BillingPortalConfigurationBusinessProfileParams struct {
96
        // The messaging shown to customers in the portal.
97
        Headline *string `form:"headline"`
98
        // A link to the business's publicly available privacy policy.
99
        PrivacyPolicyURL *string `form:"privacy_policy_url"`
100
        // A link to the business's publicly available terms of service.
101
        TermsOfServiceURL *string `form:"terms_of_service_url"`
102
}
103

104
// Information about updating the customer details in the portal.
105
type BillingPortalConfigurationFeaturesCustomerUpdateParams struct {
106
        // The types of customer updates that are supported. When empty, customers are not updateable.
107
        AllowedUpdates []*string `form:"allowed_updates"`
108
        // Whether the feature is enabled.
109
        Enabled *bool `form:"enabled"`
110
}
111

112
// Information about showing the billing history in the portal.
113
type BillingPortalConfigurationFeaturesInvoiceHistoryParams struct {
114
        // Whether the feature is enabled.
115
        Enabled *bool `form:"enabled"`
116
}
117

118
// Information about updating payment methods in the portal.
119
type BillingPortalConfigurationFeaturesPaymentMethodUpdateParams struct {
120
        // Whether the feature is enabled.
121
        Enabled *bool `form:"enabled"`
122
}
123

124
// Whether the cancellation reasons will be collected in the portal and which options are exposed to the customer
125
type BillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonParams struct {
126
        // Whether the feature is enabled.
127
        Enabled *bool `form:"enabled"`
128
        // Which cancellation reasons will be given as options to the customer.
129
        Options []*string `form:"options"`
130
}
131

132
// Information about canceling subscriptions in the portal.
133
type BillingPortalConfigurationFeaturesSubscriptionCancelParams struct {
134
        // Whether the cancellation reasons will be collected in the portal and which options are exposed to the customer
135
        CancellationReason *BillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonParams `form:"cancellation_reason"`
136
        // Whether the feature is enabled.
137
        Enabled *bool `form:"enabled"`
138
        // Whether to cancel subscriptions immediately or at the end of the billing period.
139
        Mode *string `form:"mode"`
140
        // Whether to create prorations when canceling subscriptions. Possible values are `none` and `create_prorations`, which is only compatible with `mode=immediately`. No prorations are generated when canceling a subscription at the end of its natural billing period.
141
        ProrationBehavior *string `form:"proration_behavior"`
142
}
143

144
// The list of up to 10 products that support subscription updates.
145
type BillingPortalConfigurationFeaturesSubscriptionUpdateProductParams struct {
146
        // The list of price IDs for the product that a subscription can be updated to.
147
        Prices []*string `form:"prices"`
148
        // The product id.
149
        Product *string `form:"product"`
150
}
151

152
// Information about updating subscriptions in the portal.
153
type BillingPortalConfigurationFeaturesSubscriptionUpdateParams struct {
154
        // The types of subscription updates that are supported. When empty, subscriptions are not updateable.
155
        DefaultAllowedUpdates []*string `form:"default_allowed_updates"`
156
        // Whether the feature is enabled.
157
        Enabled *bool `form:"enabled"`
158
        // The list of up to 10 products that support subscription updates.
159
        Products []*BillingPortalConfigurationFeaturesSubscriptionUpdateProductParams `form:"products"`
160
        // Determines how to handle prorations resulting from subscription updates. Valid values are `none`, `create_prorations`, and `always_invoice`.
161
        ProrationBehavior *string `form:"proration_behavior"`
162
}
163

164
// Information about the features available in the portal.
165
type BillingPortalConfigurationFeaturesParams struct {
166
        // Information about updating the customer details in the portal.
167
        CustomerUpdate *BillingPortalConfigurationFeaturesCustomerUpdateParams `form:"customer_update"`
168
        // Information about showing the billing history in the portal.
169
        InvoiceHistory *BillingPortalConfigurationFeaturesInvoiceHistoryParams `form:"invoice_history"`
170
        // Information about updating payment methods in the portal.
171
        PaymentMethodUpdate *BillingPortalConfigurationFeaturesPaymentMethodUpdateParams `form:"payment_method_update"`
172
        // Information about canceling subscriptions in the portal.
173
        SubscriptionCancel *BillingPortalConfigurationFeaturesSubscriptionCancelParams `form:"subscription_cancel"`
174
        // Information about updating subscriptions in the portal.
175
        SubscriptionUpdate *BillingPortalConfigurationFeaturesSubscriptionUpdateParams `form:"subscription_update"`
176
}
177

178
// The hosted login page for this configuration. Learn more about the portal login page in our [integration docs](https://stripe.com/docs/billing/subscriptions/integrating-customer-portal#share).
179
type BillingPortalConfigurationLoginPageParams struct {
180
        // Set to `true` to generate a shareable URL [`login_page.url`](https://stripe.com/docs/api/customer_portal/configuration#portal_configuration_object-login_page-url) that will take your customers to a hosted login page for the customer portal.
181
        //
182
        // Set to `false` to deactivate the `login_page.url`.
183
        Enabled *bool `form:"enabled"`
184
}
185

186
// Creates a configuration that describes the functionality and behavior of a PortalSession
187
type BillingPortalConfigurationParams struct {
188
        Params `form:"*"`
189
        // Whether the configuration is active and can be used to create portal sessions.
190
        Active *bool `form:"active"`
191
        // The business information shown to customers in the portal.
192
        BusinessProfile *BillingPortalConfigurationBusinessProfileParams `form:"business_profile"`
193
        // The default URL to redirect customers to when they click on the portal's link to return to your website. This can be [overriden](https://stripe.com/docs/api/customer_portal/sessions/create#create_portal_session-return_url) when creating the session.
194
        DefaultReturnURL *string `form:"default_return_url"`
195
        // Specifies which fields in the response should be expanded.
196
        Expand []*string `form:"expand"`
197
        // Information about the features available in the portal.
198
        Features *BillingPortalConfigurationFeaturesParams `form:"features"`
199
        // The hosted login page for this configuration. Learn more about the portal login page in our [integration docs](https://stripe.com/docs/billing/subscriptions/integrating-customer-portal#share).
200
        LoginPage *BillingPortalConfigurationLoginPageParams `form:"login_page"`
201
        // Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to `metadata`.
202
        Metadata map[string]string `form:"metadata"`
203
}
204

205
// AddExpand appends a new field to expand.
UNCOV
206
func (p *BillingPortalConfigurationParams) AddExpand(f string) {
×
UNCOV
207
        p.Expand = append(p.Expand, &f)
×
UNCOV
208
}
×
209

210
// AddMetadata adds a new key-value pair to the Metadata.
UNCOV
211
func (p *BillingPortalConfigurationParams) AddMetadata(key string, value string) {
×
UNCOV
212
        if p.Metadata == nil {
×
UNCOV
213
                p.Metadata = make(map[string]string)
×
UNCOV
214
        }
×
215

UNCOV
216
        p.Metadata[key] = value
×
217
}
218

219
type BillingPortalConfigurationBusinessProfile struct {
220
        // The messaging shown to customers in the portal.
221
        Headline string `json:"headline"`
222
        // A link to the business's publicly available privacy policy.
223
        PrivacyPolicyURL string `json:"privacy_policy_url"`
224
        // A link to the business's publicly available terms of service.
225
        TermsOfServiceURL string `json:"terms_of_service_url"`
226
}
227
type BillingPortalConfigurationFeaturesCustomerUpdate struct {
228
        // The types of customer updates that are supported. When empty, customers are not updateable.
229
        AllowedUpdates []BillingPortalConfigurationFeaturesCustomerUpdateAllowedUpdate `json:"allowed_updates"`
230
        // Whether the feature is enabled.
231
        Enabled bool `json:"enabled"`
232
}
233
type BillingPortalConfigurationFeaturesInvoiceHistory struct {
234
        // Whether the feature is enabled.
235
        Enabled bool `json:"enabled"`
236
}
237
type BillingPortalConfigurationFeaturesPaymentMethodUpdate struct {
238
        // Whether the feature is enabled.
239
        Enabled bool `json:"enabled"`
240
}
241
type BillingPortalConfigurationFeaturesSubscriptionCancelCancellationReason struct {
242
        // Whether the feature is enabled.
243
        Enabled bool `json:"enabled"`
244
        // Which cancellation reasons will be given as options to the customer.
245
        Options []BillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOption `json:"options"`
246
}
247
type BillingPortalConfigurationFeaturesSubscriptionCancel struct {
248
        CancellationReason *BillingPortalConfigurationFeaturesSubscriptionCancelCancellationReason `json:"cancellation_reason"`
249
        // Whether the feature is enabled.
250
        Enabled bool `json:"enabled"`
251
        // Whether to cancel subscriptions immediately or at the end of the billing period.
252
        Mode BillingPortalConfigurationFeaturesSubscriptionCancelMode `json:"mode"`
253
        // Whether to create prorations when canceling subscriptions. Possible values are `none` and `create_prorations`.
254
        ProrationBehavior BillingPortalConfigurationFeaturesSubscriptionCancelProrationBehavior `json:"proration_behavior"`
255
}
256

257
// The list of up to 10 products that support subscription updates.
258
type BillingPortalConfigurationFeaturesSubscriptionUpdateProduct struct {
259
        // The list of price IDs which, when subscribed to, a subscription can be updated.
260
        Prices []string `json:"prices"`
261
        // The product ID.
262
        Product string `json:"product"`
263
}
264
type BillingPortalConfigurationFeaturesSubscriptionUpdate struct {
265
        // The types of subscription updates that are supported for items listed in the `products` attribute. When empty, subscriptions are not updateable.
266
        DefaultAllowedUpdates []BillingPortalConfigurationFeaturesSubscriptionUpdateDefaultAllowedUpdate `json:"default_allowed_updates"`
267
        // Whether the feature is enabled.
268
        Enabled bool `json:"enabled"`
269
        // The list of up to 10 products that support subscription updates.
270
        Products []*BillingPortalConfigurationFeaturesSubscriptionUpdateProduct `json:"products"`
271
        // Determines how to handle prorations resulting from subscription updates. Valid values are `none`, `create_prorations`, and `always_invoice`. Defaults to a value of `none` if you don't set it during creation.
272
        ProrationBehavior BillingPortalConfigurationFeaturesSubscriptionUpdateProrationBehavior `json:"proration_behavior"`
273
}
274
type BillingPortalConfigurationFeatures struct {
275
        CustomerUpdate      *BillingPortalConfigurationFeaturesCustomerUpdate      `json:"customer_update"`
276
        InvoiceHistory      *BillingPortalConfigurationFeaturesInvoiceHistory      `json:"invoice_history"`
277
        PaymentMethodUpdate *BillingPortalConfigurationFeaturesPaymentMethodUpdate `json:"payment_method_update"`
278
        SubscriptionCancel  *BillingPortalConfigurationFeaturesSubscriptionCancel  `json:"subscription_cancel"`
279
        SubscriptionUpdate  *BillingPortalConfigurationFeaturesSubscriptionUpdate  `json:"subscription_update"`
280
}
281
type BillingPortalConfigurationLoginPage struct {
282
        // If `true`, a shareable `url` will be generated that will take your customers to a hosted login page for the customer portal.
283
        //
284
        // If `false`, the previously generated `url`, if any, will be deactivated.
285
        Enabled bool `json:"enabled"`
286
        // A shareable URL to the hosted portal login page. Your customers will be able to log in with their [email](https://stripe.com/docs/api/customers/object#customer_object-email) and receive a link to their customer portal.
287
        URL string `json:"url"`
288
}
289

290
// A portal configuration describes the functionality and behavior of a portal session.
291
type BillingPortalConfiguration struct {
292
        APIResource
293
        // Whether the configuration is active and can be used to create portal sessions.
294
        Active bool `json:"active"`
295
        // ID of the Connect Application that created the configuration.
296
        Application     *Application                               `json:"application"`
297
        BusinessProfile *BillingPortalConfigurationBusinessProfile `json:"business_profile"`
298
        // Time at which the object was created. Measured in seconds since the Unix epoch.
299
        Created int64 `json:"created"`
300
        // The default URL to redirect customers to when they click on the portal's link to return to your website. This can be [overriden](https://stripe.com/docs/api/customer_portal/sessions/create#create_portal_session-return_url) when creating the session.
301
        DefaultReturnURL string                              `json:"default_return_url"`
302
        Features         *BillingPortalConfigurationFeatures `json:"features"`
303
        // Unique identifier for the object.
304
        ID string `json:"id"`
305
        // Whether the configuration is the default. If `true`, this configuration can be managed in the Dashboard and portal sessions will use this configuration unless it is overriden when creating the session.
306
        IsDefault bool `json:"is_default"`
307
        // Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
308
        Livemode  bool                                 `json:"livemode"`
309
        LoginPage *BillingPortalConfigurationLoginPage `json:"login_page"`
310
        // 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.
311
        Metadata map[string]string `json:"metadata"`
312
        // String representing the object's type. Objects of the same type share the same value.
313
        Object string `json:"object"`
314
        // Time at which the object was last updated. Measured in seconds since the Unix epoch.
315
        Updated int64 `json:"updated"`
316
}
317

318
// BillingPortalConfigurationList is a list of Configurations as retrieved from a list endpoint.
319
type BillingPortalConfigurationList struct {
320
        APIResource
321
        ListMeta
322
        Data []*BillingPortalConfiguration `json:"data"`
323
}
324

325
// UnmarshalJSON handles deserialization of a BillingPortalConfiguration.
326
// This custom unmarshaling is needed because the resulting
327
// property may be an id or the full struct if it was expanded.
UNCOV
328
func (b *BillingPortalConfiguration) UnmarshalJSON(data []byte) error {
×
UNCOV
329
        if id, ok := ParseID(data); ok {
×
UNCOV
330
                b.ID = id
×
UNCOV
331
                return nil
×
UNCOV
332
        }
×
333

UNCOV
334
        type billingPortalConfiguration BillingPortalConfiguration
×
UNCOV
335
        var v billingPortalConfiguration
×
UNCOV
336
        if err := json.Unmarshal(data, &v); err != nil {
×
UNCOV
337
                return err
×
UNCOV
338
        }
×
339

UNCOV
340
        *b = BillingPortalConfiguration(v)
×
UNCOV
341
        return nil
×
342
}
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