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

     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.
    90  func (p *BillingPortalConfigurationListParams) AddExpand(f string) {
    91  	p.Expand = append(p.Expand, &f)
    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 pausing subscriptions in the portal.
   165  type BillingPortalConfigurationFeaturesSubscriptionPauseParams struct {
   166  	// Whether the feature is enabled.
   167  	Enabled *bool `form:"enabled"`
   168  }
   169  
   170  // Information about the features available in the portal.
   171  type BillingPortalConfigurationFeaturesParams struct {
   172  	// Information about updating the customer details in the portal.
   173  	CustomerUpdate *BillingPortalConfigurationFeaturesCustomerUpdateParams `form:"customer_update"`
   174  	// Information about showing the billing history in the portal.
   175  	InvoiceHistory *BillingPortalConfigurationFeaturesInvoiceHistoryParams `form:"invoice_history"`
   176  	// Information about updating payment methods in the portal.
   177  	PaymentMethodUpdate *BillingPortalConfigurationFeaturesPaymentMethodUpdateParams `form:"payment_method_update"`
   178  	// Information about canceling subscriptions in the portal.
   179  	SubscriptionCancel *BillingPortalConfigurationFeaturesSubscriptionCancelParams `form:"subscription_cancel"`
   180  	// Information about pausing subscriptions in the portal.
   181  	SubscriptionPause *BillingPortalConfigurationFeaturesSubscriptionPauseParams `form:"subscription_pause"`
   182  	// Information about updating subscriptions in the portal.
   183  	SubscriptionUpdate *BillingPortalConfigurationFeaturesSubscriptionUpdateParams `form:"subscription_update"`
   184  }
   185  
   186  // 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).
   187  type BillingPortalConfigurationLoginPageParams struct {
   188  	// 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.
   189  	//
   190  	// Set to `false` to deactivate the `login_page.url`.
   191  	Enabled *bool `form:"enabled"`
   192  }
   193  
   194  // Creates a configuration that describes the functionality and behavior of a PortalSession
   195  type BillingPortalConfigurationParams struct {
   196  	Params `form:"*"`
   197  	// Whether the configuration is active and can be used to create portal sessions.
   198  	Active *bool `form:"active"`
   199  	// The business information shown to customers in the portal.
   200  	BusinessProfile *BillingPortalConfigurationBusinessProfileParams `form:"business_profile"`
   201  	// 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.
   202  	DefaultReturnURL *string `form:"default_return_url"`
   203  	// Specifies which fields in the response should be expanded.
   204  	Expand []*string `form:"expand"`
   205  	// Information about the features available in the portal.
   206  	Features *BillingPortalConfigurationFeaturesParams `form:"features"`
   207  	// 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).
   208  	LoginPage *BillingPortalConfigurationLoginPageParams `form:"login_page"`
   209  	// 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`.
   210  	Metadata map[string]string `form:"metadata"`
   211  }
   212  
   213  // AddExpand appends a new field to expand.
   214  func (p *BillingPortalConfigurationParams) AddExpand(f string) {
   215  	p.Expand = append(p.Expand, &f)
   216  }
   217  
   218  // AddMetadata adds a new key-value pair to the Metadata.
   219  func (p *BillingPortalConfigurationParams) AddMetadata(key string, value string) {
   220  	if p.Metadata == nil {
   221  		p.Metadata = make(map[string]string)
   222  	}
   223  
   224  	p.Metadata[key] = value
   225  }
   226  
   227  type BillingPortalConfigurationBusinessProfile struct {
   228  	// The messaging shown to customers in the portal.
   229  	Headline string `json:"headline"`
   230  	// A link to the business's publicly available privacy policy.
   231  	PrivacyPolicyURL string `json:"privacy_policy_url"`
   232  	// A link to the business's publicly available terms of service.
   233  	TermsOfServiceURL string `json:"terms_of_service_url"`
   234  }
   235  type BillingPortalConfigurationFeaturesCustomerUpdate struct {
   236  	// The types of customer updates that are supported. When empty, customers are not updateable.
   237  	AllowedUpdates []BillingPortalConfigurationFeaturesCustomerUpdateAllowedUpdate `json:"allowed_updates"`
   238  	// Whether the feature is enabled.
   239  	Enabled bool `json:"enabled"`
   240  }
   241  type BillingPortalConfigurationFeaturesInvoiceHistory struct {
   242  	// Whether the feature is enabled.
   243  	Enabled bool `json:"enabled"`
   244  }
   245  type BillingPortalConfigurationFeaturesPaymentMethodUpdate struct {
   246  	// Whether the feature is enabled.
   247  	Enabled bool `json:"enabled"`
   248  }
   249  type BillingPortalConfigurationFeaturesSubscriptionCancelCancellationReason struct {
   250  	// Whether the feature is enabled.
   251  	Enabled bool `json:"enabled"`
   252  	// Which cancellation reasons will be given as options to the customer.
   253  	Options []BillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOption `json:"options"`
   254  }
   255  type BillingPortalConfigurationFeaturesSubscriptionCancel struct {
   256  	CancellationReason *BillingPortalConfigurationFeaturesSubscriptionCancelCancellationReason `json:"cancellation_reason"`
   257  	// Whether the feature is enabled.
   258  	Enabled bool `json:"enabled"`
   259  	// Whether to cancel subscriptions immediately or at the end of the billing period.
   260  	Mode BillingPortalConfigurationFeaturesSubscriptionCancelMode `json:"mode"`
   261  	// Whether to create prorations when canceling subscriptions. Possible values are `none` and `create_prorations`.
   262  	ProrationBehavior BillingPortalConfigurationFeaturesSubscriptionCancelProrationBehavior `json:"proration_behavior"`
   263  }
   264  
   265  // The list of up to 10 products that support subscription updates.
   266  type BillingPortalConfigurationFeaturesSubscriptionUpdateProduct struct {
   267  	// The list of price IDs which, when subscribed to, a subscription can be updated.
   268  	Prices []string `json:"prices"`
   269  	// The product ID.
   270  	Product string `json:"product"`
   271  }
   272  type BillingPortalConfigurationFeaturesSubscriptionUpdate struct {
   273  	// The types of subscription updates that are supported for items listed in the `products` attribute. When empty, subscriptions are not updateable.
   274  	DefaultAllowedUpdates []BillingPortalConfigurationFeaturesSubscriptionUpdateDefaultAllowedUpdate `json:"default_allowed_updates"`
   275  	// Whether the feature is enabled.
   276  	Enabled bool `json:"enabled"`
   277  	// The list of up to 10 products that support subscription updates.
   278  	Products []*BillingPortalConfigurationFeaturesSubscriptionUpdateProduct `json:"products"`
   279  	// 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.
   280  	ProrationBehavior BillingPortalConfigurationFeaturesSubscriptionUpdateProrationBehavior `json:"proration_behavior"`
   281  }
   282  type BillingPortalConfigurationFeaturesSubscriptionPause struct {
   283  	// Whether the feature is enabled.
   284  	Enabled bool `json:"enabled"`
   285  }
   286  type BillingPortalConfigurationFeatures struct {
   287  	CustomerUpdate      *BillingPortalConfigurationFeaturesCustomerUpdate      `json:"customer_update"`
   288  	InvoiceHistory      *BillingPortalConfigurationFeaturesInvoiceHistory      `json:"invoice_history"`
   289  	PaymentMethodUpdate *BillingPortalConfigurationFeaturesPaymentMethodUpdate `json:"payment_method_update"`
   290  	SubscriptionCancel  *BillingPortalConfigurationFeaturesSubscriptionCancel  `json:"subscription_cancel"`
   291  	SubscriptionPause   *BillingPortalConfigurationFeaturesSubscriptionPause   `json:"subscription_pause"`
   292  	SubscriptionUpdate  *BillingPortalConfigurationFeaturesSubscriptionUpdate  `json:"subscription_update"`
   293  }
   294  type BillingPortalConfigurationLoginPage struct {
   295  	// If `true`, a shareable `url` will be generated that will take your customers to a hosted login page for the customer portal.
   296  	//
   297  	// If `false`, the previously generated `url`, if any, will be deactivated.
   298  	Enabled bool `json:"enabled"`
   299  	// 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.
   300  	URL string `json:"url"`
   301  }
   302  
   303  // A portal configuration describes the functionality and behavior of a portal session.
   304  type BillingPortalConfiguration struct {
   305  	APIResource
   306  	// Whether the configuration is active and can be used to create portal sessions.
   307  	Active bool `json:"active"`
   308  	// ID of the Connect Application that created the configuration.
   309  	Application     *Application                               `json:"application"`
   310  	BusinessProfile *BillingPortalConfigurationBusinessProfile `json:"business_profile"`
   311  	// Time at which the object was created. Measured in seconds since the Unix epoch.
   312  	Created int64 `json:"created"`
   313  	// 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.
   314  	DefaultReturnURL string                              `json:"default_return_url"`
   315  	Features         *BillingPortalConfigurationFeatures `json:"features"`
   316  	// Unique identifier for the object.
   317  	ID string `json:"id"`
   318  	// 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.
   319  	IsDefault bool `json:"is_default"`
   320  	// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
   321  	Livemode  bool                                 `json:"livemode"`
   322  	LoginPage *BillingPortalConfigurationLoginPage `json:"login_page"`
   323  	// 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.
   324  	Metadata map[string]string `json:"metadata"`
   325  	// String representing the object's type. Objects of the same type share the same value.
   326  	Object string `json:"object"`
   327  	// Time at which the object was last updated. Measured in seconds since the Unix epoch.
   328  	Updated int64 `json:"updated"`
   329  }
   330  
   331  // BillingPortalConfigurationList is a list of Configurations as retrieved from a list endpoint.
   332  type BillingPortalConfigurationList struct {
   333  	APIResource
   334  	ListMeta
   335  	Data []*BillingPortalConfiguration `json:"data"`
   336  }
   337  
   338  // UnmarshalJSON handles deserialization of a BillingPortalConfiguration.
   339  // This custom unmarshaling is needed because the resulting
   340  // property may be an id or the full struct if it was expanded.
   341  func (b *BillingPortalConfiguration) UnmarshalJSON(data []byte) error {
   342  	if id, ok := ParseID(data); ok {
   343  		b.ID = id
   344  		return nil
   345  	}
   346  
   347  	type billingPortalConfiguration BillingPortalConfiguration
   348  	var v billingPortalConfiguration
   349  	if err := json.Unmarshal(data, &v); err != nil {
   350  		return err
   351  	}
   352  
   353  	*b = BillingPortalConfiguration(v)
   354  	return nil
   355  }