github.com/stripe/stripe-go/v76@v76.25.0/billingportal_session.go (about) 1 // 2 // 3 // File generated from our OpenAPI spec 4 // 5 // 6 7 package stripe 8 9 // The specified type of behavior after the flow is completed. 10 type BillingPortalSessionFlowAfterCompletionType string 11 12 // List of values that BillingPortalSessionFlowAfterCompletionType can take 13 const ( 14 BillingPortalSessionFlowAfterCompletionTypeHostedConfirmation BillingPortalSessionFlowAfterCompletionType = "hosted_confirmation" 15 BillingPortalSessionFlowAfterCompletionTypePortalHomepage BillingPortalSessionFlowAfterCompletionType = "portal_homepage" 16 BillingPortalSessionFlowAfterCompletionTypeRedirect BillingPortalSessionFlowAfterCompletionType = "redirect" 17 ) 18 19 // Type of retention strategy that will be used. 20 type BillingPortalSessionFlowSubscriptionCancelRetentionType string 21 22 // List of values that BillingPortalSessionFlowSubscriptionCancelRetentionType can take 23 const ( 24 BillingPortalSessionFlowSubscriptionCancelRetentionTypeCouponOffer BillingPortalSessionFlowSubscriptionCancelRetentionType = "coupon_offer" 25 ) 26 27 // Type of flow that the customer will go through. 28 type BillingPortalSessionFlowType string 29 30 // List of values that BillingPortalSessionFlowType can take 31 const ( 32 BillingPortalSessionFlowTypePaymentMethodUpdate BillingPortalSessionFlowType = "payment_method_update" 33 BillingPortalSessionFlowTypeSubscriptionCancel BillingPortalSessionFlowType = "subscription_cancel" 34 BillingPortalSessionFlowTypeSubscriptionUpdate BillingPortalSessionFlowType = "subscription_update" 35 BillingPortalSessionFlowTypeSubscriptionUpdateConfirm BillingPortalSessionFlowType = "subscription_update_confirm" 36 ) 37 38 // Configuration when `after_completion.type=hosted_confirmation`. 39 type BillingPortalSessionFlowDataAfterCompletionHostedConfirmationParams struct { 40 // A custom message to display to the customer after the flow is completed. 41 CustomMessage *string `form:"custom_message"` 42 } 43 44 // Configuration when `after_completion.type=redirect`. 45 type BillingPortalSessionFlowDataAfterCompletionRedirectParams struct { 46 // The URL the customer will be redirected to after the flow is completed. 47 ReturnURL *string `form:"return_url"` 48 } 49 50 // Behavior after the flow is completed. 51 type BillingPortalSessionFlowDataAfterCompletionParams struct { 52 // Configuration when `after_completion.type=hosted_confirmation`. 53 HostedConfirmation *BillingPortalSessionFlowDataAfterCompletionHostedConfirmationParams `form:"hosted_confirmation"` 54 // Configuration when `after_completion.type=redirect`. 55 Redirect *BillingPortalSessionFlowDataAfterCompletionRedirectParams `form:"redirect"` 56 // The specified behavior after the flow is completed. 57 Type *string `form:"type"` 58 } 59 60 // Configuration when `retention.type=coupon_offer`. 61 type BillingPortalSessionFlowDataSubscriptionCancelRetentionCouponOfferParams struct { 62 // The ID of the coupon to be offered. 63 Coupon *string `form:"coupon"` 64 } 65 66 // Specify a retention strategy to be used in the cancellation flow. 67 type BillingPortalSessionFlowDataSubscriptionCancelRetentionParams struct { 68 // Configuration when `retention.type=coupon_offer`. 69 CouponOffer *BillingPortalSessionFlowDataSubscriptionCancelRetentionCouponOfferParams `form:"coupon_offer"` 70 // Type of retention strategy to use with the customer. 71 Type *string `form:"type"` 72 } 73 74 // Configuration when `flow_data.type=subscription_cancel`. 75 type BillingPortalSessionFlowDataSubscriptionCancelParams struct { 76 // Specify a retention strategy to be used in the cancellation flow. 77 Retention *BillingPortalSessionFlowDataSubscriptionCancelRetentionParams `form:"retention"` 78 // The ID of the subscription to be canceled. 79 Subscription *string `form:"subscription"` 80 } 81 82 // Configuration when `flow_data.type=subscription_update`. 83 type BillingPortalSessionFlowDataSubscriptionUpdateParams struct { 84 // The ID of the subscription to be updated. 85 Subscription *string `form:"subscription"` 86 } 87 88 // The coupon or promotion code to apply to this subscription update. Currently, only up to one may be specified. 89 type BillingPortalSessionFlowDataSubscriptionUpdateConfirmDiscountParams struct { 90 // The ID of the coupon to apply to this subscription update. 91 Coupon *string `form:"coupon"` 92 // The ID of a promotion code to apply to this subscription update. 93 PromotionCode *string `form:"promotion_code"` 94 } 95 96 // The [subscription item](https://stripe.com/docs/api/subscription_items) to be updated through this flow. Currently, only up to one may be specified and subscriptions with multiple items are not updatable. 97 type BillingPortalSessionFlowDataSubscriptionUpdateConfirmItemParams struct { 98 // The ID of the [subscription item](https://stripe.com/docs/api/subscriptions/object#subscription_object-items-data-id) to be updated. 99 ID *string `form:"id"` 100 // The price the customer should subscribe to through this flow. The price must also be included in the configuration's [`features.subscription_update.products`](https://stripe.com/docs/api/customer_portal/configuration#portal_configuration_object-features-subscription_update-products). 101 Price *string `form:"price"` 102 // [Quantity](https://stripe.com/docs/subscriptions/quantities) for this item that the customer should subscribe to through this flow. 103 Quantity *int64 `form:"quantity"` 104 } 105 106 // Configuration when `flow_data.type=subscription_update_confirm`. 107 type BillingPortalSessionFlowDataSubscriptionUpdateConfirmParams struct { 108 // The coupon or promotion code to apply to this subscription update. Currently, only up to one may be specified. 109 Discounts []*BillingPortalSessionFlowDataSubscriptionUpdateConfirmDiscountParams `form:"discounts"` 110 // The [subscription item](https://stripe.com/docs/api/subscription_items) to be updated through this flow. Currently, only up to one may be specified and subscriptions with multiple items are not updatable. 111 Items []*BillingPortalSessionFlowDataSubscriptionUpdateConfirmItemParams `form:"items"` 112 // The ID of the subscription to be updated. 113 Subscription *string `form:"subscription"` 114 } 115 116 // Information about a specific flow for the customer to go through. See the [docs](https://stripe.com/docs/customer-management/portal-deep-links) to learn more about using customer portal deep links and flows. 117 type BillingPortalSessionFlowDataParams struct { 118 // Behavior after the flow is completed. 119 AfterCompletion *BillingPortalSessionFlowDataAfterCompletionParams `form:"after_completion"` 120 // Configuration when `flow_data.type=subscription_cancel`. 121 SubscriptionCancel *BillingPortalSessionFlowDataSubscriptionCancelParams `form:"subscription_cancel"` 122 // Configuration when `flow_data.type=subscription_update`. 123 SubscriptionUpdate *BillingPortalSessionFlowDataSubscriptionUpdateParams `form:"subscription_update"` 124 // Configuration when `flow_data.type=subscription_update_confirm`. 125 SubscriptionUpdateConfirm *BillingPortalSessionFlowDataSubscriptionUpdateConfirmParams `form:"subscription_update_confirm"` 126 // Type of flow that the customer will go through. 127 Type *string `form:"type"` 128 } 129 130 // Creates a session of the customer portal. 131 type BillingPortalSessionParams struct { 132 Params `form:"*"` 133 // The ID of an existing [configuration](https://stripe.com/docs/api/customer_portal/configuration) to use for this session, describing its functionality and features. If not specified, the session uses the default configuration. 134 Configuration *string `form:"configuration"` 135 // The ID of an existing customer. 136 Customer *string `form:"customer"` 137 // Specifies which fields in the response should be expanded. 138 Expand []*string `form:"expand"` 139 // Information about a specific flow for the customer to go through. See the [docs](https://stripe.com/docs/customer-management/portal-deep-links) to learn more about using customer portal deep links and flows. 140 FlowData *BillingPortalSessionFlowDataParams `form:"flow_data"` 141 // The IETF language tag of the locale customer portal is displayed in. If blank or auto, the customer's `preferred_locales` or browser's locale is used. 142 Locale *string `form:"locale"` 143 // The `on_behalf_of` account to use for this session. When specified, only subscriptions and invoices with this `on_behalf_of` account appear in the portal. For more information, see the [docs](https://stripe.com/docs/connect/separate-charges-and-transfers#on-behalf-of). Use the [Accounts API](https://stripe.com/docs/api/accounts/object#account_object-settings-branding) to modify the `on_behalf_of` account's branding settings, which the portal displays. 144 OnBehalfOf *string `form:"on_behalf_of"` 145 // The default URL to redirect customers to when they click on the portal's link to return to your website. 146 ReturnURL *string `form:"return_url"` 147 } 148 149 // AddExpand appends a new field to expand. 150 func (p *BillingPortalSessionParams) AddExpand(f string) { 151 p.Expand = append(p.Expand, &f) 152 } 153 154 // Configuration when `after_completion.type=hosted_confirmation`. 155 type BillingPortalSessionFlowAfterCompletionHostedConfirmation struct { 156 // A custom message to display to the customer after the flow is completed. 157 CustomMessage string `json:"custom_message"` 158 } 159 160 // Configuration when `after_completion.type=redirect`. 161 type BillingPortalSessionFlowAfterCompletionRedirect struct { 162 // The URL the customer will be redirected to after the flow is completed. 163 ReturnURL string `json:"return_url"` 164 } 165 type BillingPortalSessionFlowAfterCompletion struct { 166 // Configuration when `after_completion.type=hosted_confirmation`. 167 HostedConfirmation *BillingPortalSessionFlowAfterCompletionHostedConfirmation `json:"hosted_confirmation"` 168 // Configuration when `after_completion.type=redirect`. 169 Redirect *BillingPortalSessionFlowAfterCompletionRedirect `json:"redirect"` 170 // The specified type of behavior after the flow is completed. 171 Type BillingPortalSessionFlowAfterCompletionType `json:"type"` 172 } 173 174 // Configuration when `retention.type=coupon_offer`. 175 type BillingPortalSessionFlowSubscriptionCancelRetentionCouponOffer struct { 176 // The ID of the coupon to be offered. 177 Coupon string `json:"coupon"` 178 } 179 180 // Specify a retention strategy to be used in the cancellation flow. 181 type BillingPortalSessionFlowSubscriptionCancelRetention struct { 182 // Configuration when `retention.type=coupon_offer`. 183 CouponOffer *BillingPortalSessionFlowSubscriptionCancelRetentionCouponOffer `json:"coupon_offer"` 184 // Type of retention strategy that will be used. 185 Type BillingPortalSessionFlowSubscriptionCancelRetentionType `json:"type"` 186 } 187 188 // Configuration when `flow.type=subscription_cancel`. 189 type BillingPortalSessionFlowSubscriptionCancel struct { 190 // Specify a retention strategy to be used in the cancellation flow. 191 Retention *BillingPortalSessionFlowSubscriptionCancelRetention `json:"retention"` 192 // The ID of the subscription to be canceled. 193 Subscription string `json:"subscription"` 194 } 195 196 // Configuration when `flow.type=subscription_update`. 197 type BillingPortalSessionFlowSubscriptionUpdate struct { 198 // The ID of the subscription to be updated. 199 Subscription string `json:"subscription"` 200 } 201 202 // The coupon or promotion code to apply to this subscription update. Currently, only up to one may be specified. 203 type BillingPortalSessionFlowSubscriptionUpdateConfirmDiscount struct { 204 // The ID of the coupon to apply to this subscription update. 205 Coupon string `json:"coupon"` 206 // The ID of a promotion code to apply to this subscription update. 207 PromotionCode string `json:"promotion_code"` 208 } 209 210 // The [subscription item](https://stripe.com/docs/api/subscription_items) to be updated through this flow. Currently, only up to one may be specified and subscriptions with multiple items are not updatable. 211 type BillingPortalSessionFlowSubscriptionUpdateConfirmItem struct { 212 // The ID of the [subscription item](https://stripe.com/docs/api/subscriptions/object#subscription_object-items-data-id) to be updated. 213 ID string `json:"id"` 214 // The price the customer should subscribe to through this flow. The price must also be included in the configuration's [`features.subscription_update.products`](https://stripe.com/docs/api/customer_portal/configuration#portal_configuration_object-features-subscription_update-products). 215 Price string `json:"price"` 216 // [Quantity](https://stripe.com/docs/subscriptions/quantities) for this item that the customer should subscribe to through this flow. 217 Quantity int64 `json:"quantity"` 218 } 219 220 // Configuration when `flow.type=subscription_update_confirm`. 221 type BillingPortalSessionFlowSubscriptionUpdateConfirm struct { 222 // The coupon or promotion code to apply to this subscription update. Currently, only up to one may be specified. 223 Discounts []*BillingPortalSessionFlowSubscriptionUpdateConfirmDiscount `json:"discounts"` 224 // The [subscription item](https://stripe.com/docs/api/subscription_items) to be updated through this flow. Currently, only up to one may be specified and subscriptions with multiple items are not updatable. 225 Items []*BillingPortalSessionFlowSubscriptionUpdateConfirmItem `json:"items"` 226 // The ID of the subscription to be updated. 227 Subscription string `json:"subscription"` 228 } 229 230 // Information about a specific flow for the customer to go through. See the [docs](https://stripe.com/docs/customer-management/portal-deep-links) to learn more about using customer portal deep links and flows. 231 type BillingPortalSessionFlow struct { 232 AfterCompletion *BillingPortalSessionFlowAfterCompletion `json:"after_completion"` 233 // Configuration when `flow.type=subscription_cancel`. 234 SubscriptionCancel *BillingPortalSessionFlowSubscriptionCancel `json:"subscription_cancel"` 235 // Configuration when `flow.type=subscription_update`. 236 SubscriptionUpdate *BillingPortalSessionFlowSubscriptionUpdate `json:"subscription_update"` 237 // Configuration when `flow.type=subscription_update_confirm`. 238 SubscriptionUpdateConfirm *BillingPortalSessionFlowSubscriptionUpdateConfirm `json:"subscription_update_confirm"` 239 // Type of flow that the customer will go through. 240 Type BillingPortalSessionFlowType `json:"type"` 241 } 242 243 // The Billing customer portal is a Stripe-hosted UI for subscription and 244 // billing management. 245 // 246 // A portal configuration describes the functionality and features that you 247 // want to provide to your customers through the portal. 248 // 249 // A portal session describes the instantiation of the customer portal for 250 // a particular customer. By visiting the session's URL, the customer 251 // can manage their subscriptions and billing details. For security reasons, 252 // sessions are short-lived and will expire if the customer does not visit the URL. 253 // Create sessions on-demand when customers intend to manage their subscriptions 254 // and billing details. 255 // 256 // Learn more in the [integration guide](https://stripe.com/docs/billing/subscriptions/integrating-customer-portal). 257 type BillingPortalSession struct { 258 APIResource 259 // The configuration used by this session, describing the features available. 260 Configuration *BillingPortalConfiguration `json:"configuration"` 261 // Time at which the object was created. Measured in seconds since the Unix epoch. 262 Created int64 `json:"created"` 263 // The ID of the customer for this session. 264 Customer string `json:"customer"` 265 // Information about a specific flow for the customer to go through. See the [docs](https://stripe.com/docs/customer-management/portal-deep-links) to learn more about using customer portal deep links and flows. 266 Flow *BillingPortalSessionFlow `json:"flow"` 267 // Unique identifier for the object. 268 ID string `json:"id"` 269 // Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. 270 Livemode bool `json:"livemode"` 271 // The IETF language tag of the locale Customer Portal is displayed in. If blank or auto, the customer's `preferred_locales` or browser's locale is used. 272 Locale string `json:"locale"` 273 // String representing the object's type. Objects of the same type share the same value. 274 Object string `json:"object"` 275 // The account for which the session was created on behalf of. When specified, only subscriptions and invoices with this `on_behalf_of` account appear in the portal. For more information, see the [docs](https://stripe.com/docs/connect/separate-charges-and-transfers#on-behalf-of). Use the [Accounts API](https://stripe.com/docs/api/accounts/object#account_object-settings-branding) to modify the `on_behalf_of` account's branding settings, which the portal displays. 276 OnBehalfOf string `json:"on_behalf_of"` 277 // The URL to redirect customers to when they click on the portal's link to return to your website. 278 ReturnURL string `json:"return_url"` 279 // The short-lived URL of the session that gives customers access to the customer portal. 280 URL string `json:"url"` 281 }