github.com/stripe/stripe-go/v76@v76.25.0/price.go (about) 1 // 2 // 3 // File generated from our OpenAPI spec 4 // 5 // 6 7 package stripe 8 9 import ( 10 "encoding/json" 11 "github.com/stripe/stripe-go/v76/form" 12 ) 13 14 // Describes how to compute the price per period. Either `per_unit` or `tiered`. `per_unit` indicates that the fixed amount (specified in `unit_amount` or `unit_amount_decimal`) will be charged per unit in `quantity` (for prices with `usage_type=licensed`), or per unit of total usage (for prices with `usage_type=metered`). `tiered` indicates that the unit pricing will be computed using a tiering strategy as defined using the `tiers` and `tiers_mode` attributes. 15 type PriceBillingScheme string 16 17 // List of values that PriceBillingScheme can take 18 const ( 19 PriceBillingSchemePerUnit PriceBillingScheme = "per_unit" 20 PriceBillingSchemeTiered PriceBillingScheme = "tiered" 21 ) 22 23 // Only required if a [default tax behavior](https://stripe.com/docs/tax/products-prices-tax-categories-tax-behavior#setting-a-default-tax-behavior-(recommended)) was not provided in the Stripe Tax settings. Specifies whether the price is considered inclusive of taxes or exclusive of taxes. One of `inclusive`, `exclusive`, or `unspecified`. Once specified as either `inclusive` or `exclusive`, it cannot be changed. 24 type PriceCurrencyOptionsTaxBehavior string 25 26 // List of values that PriceCurrencyOptionsTaxBehavior can take 27 const ( 28 PriceCurrencyOptionsTaxBehaviorExclusive PriceCurrencyOptionsTaxBehavior = "exclusive" 29 PriceCurrencyOptionsTaxBehaviorInclusive PriceCurrencyOptionsTaxBehavior = "inclusive" 30 PriceCurrencyOptionsTaxBehaviorUnspecified PriceCurrencyOptionsTaxBehavior = "unspecified" 31 ) 32 33 // Specifies a usage aggregation strategy for prices of `usage_type=metered`. Defaults to `sum`. 34 type PriceRecurringAggregateUsage string 35 36 // List of values that PriceRecurringAggregateUsage can take 37 const ( 38 PriceRecurringAggregateUsageLastDuringPeriod PriceRecurringAggregateUsage = "last_during_period" 39 PriceRecurringAggregateUsageLastEver PriceRecurringAggregateUsage = "last_ever" 40 PriceRecurringAggregateUsageMax PriceRecurringAggregateUsage = "max" 41 PriceRecurringAggregateUsageSum PriceRecurringAggregateUsage = "sum" 42 ) 43 44 // The frequency at which a subscription is billed. One of `day`, `week`, `month` or `year`. 45 type PriceRecurringInterval string 46 47 // List of values that PriceRecurringInterval can take 48 const ( 49 PriceRecurringIntervalDay PriceRecurringInterval = "day" 50 PriceRecurringIntervalMonth PriceRecurringInterval = "month" 51 PriceRecurringIntervalWeek PriceRecurringInterval = "week" 52 PriceRecurringIntervalYear PriceRecurringInterval = "year" 53 ) 54 55 // Configures how the quantity per period should be determined. Can be either `metered` or `licensed`. `licensed` automatically bills the `quantity` set when adding it to a subscription. `metered` aggregates the total usage based on usage records. Defaults to `licensed`. 56 type PriceRecurringUsageType string 57 58 // List of values that PriceRecurringUsageType can take 59 const ( 60 PriceRecurringUsageTypeLicensed PriceRecurringUsageType = "licensed" 61 PriceRecurringUsageTypeMetered PriceRecurringUsageType = "metered" 62 ) 63 64 // Only required if a [default tax behavior](https://stripe.com/docs/tax/products-prices-tax-categories-tax-behavior#setting-a-default-tax-behavior-(recommended)) was not provided in the Stripe Tax settings. Specifies whether the price is considered inclusive of taxes or exclusive of taxes. One of `inclusive`, `exclusive`, or `unspecified`. Once specified as either `inclusive` or `exclusive`, it cannot be changed. 65 type PriceTaxBehavior string 66 67 // List of values that PriceTaxBehavior can take 68 const ( 69 PriceTaxBehaviorExclusive PriceTaxBehavior = "exclusive" 70 PriceTaxBehaviorInclusive PriceTaxBehavior = "inclusive" 71 PriceTaxBehaviorUnspecified PriceTaxBehavior = "unspecified" 72 ) 73 74 // Defines if the tiering price should be `graduated` or `volume` based. In `volume`-based tiering, the maximum quantity within a period determines the per unit price. In `graduated` tiering, pricing can change as the quantity grows. 75 type PriceTiersMode string 76 77 // List of values that PriceTiersMode can take 78 const ( 79 PriceTiersModeGraduated PriceTiersMode = "graduated" 80 PriceTiersModeVolume PriceTiersMode = "volume" 81 ) 82 83 // After division, either round the result `up` or `down`. 84 type PriceTransformQuantityRound string 85 86 // List of values that PriceTransformQuantityRound can take 87 const ( 88 PriceTransformQuantityRoundDown PriceTransformQuantityRound = "down" 89 PriceTransformQuantityRoundUp PriceTransformQuantityRound = "up" 90 ) 91 92 // One of `one_time` or `recurring` depending on whether the price is for a one-time purchase or a recurring (subscription) purchase. 93 type PriceType string 94 95 // List of values that PriceType can take 96 const ( 97 PriceTypeOneTime PriceType = "one_time" 98 PriceTypeRecurring PriceType = "recurring" 99 ) 100 101 // Only return prices with these recurring fields. 102 type PriceListRecurringParams struct { 103 // Filter by billing frequency. Either `day`, `week`, `month` or `year`. 104 Interval *string `form:"interval"` 105 // Filter by the price's meter. 106 Meter *string `form:"meter"` 107 // Filter by the usage type for this price. Can be either `metered` or `licensed`. 108 UsageType *string `form:"usage_type"` 109 } 110 111 // Returns a list of your active prices, excluding [inline prices](https://stripe.com/docs/products-prices/pricing-models#inline-pricing). For the list of inactive prices, set active to false. 112 type PriceListParams struct { 113 ListParams `form:"*"` 114 // Only return prices that are active or inactive (e.g., pass `false` to list all inactive prices). 115 Active *bool `form:"active"` 116 // A filter on the list, based on the object `created` field. The value can be a string with an integer Unix timestamp, or it can be a dictionary with a number of different query options. 117 Created *int64 `form:"created"` 118 // A filter on the list, based on the object `created` field. The value can be a string with an integer Unix timestamp, or it can be a dictionary with a number of different query options. 119 CreatedRange *RangeQueryParams `form:"created"` 120 // Only return prices for the given currency. 121 Currency *string `form:"currency"` 122 // Specifies which fields in the response should be expanded. 123 Expand []*string `form:"expand"` 124 // Only return the price with these lookup_keys, if any exist. 125 LookupKeys []*string `form:"lookup_keys"` 126 // Only return prices for the given product. 127 Product *string `form:"product"` 128 // Only return prices with these recurring fields. 129 Recurring *PriceListRecurringParams `form:"recurring"` 130 // Only return prices of type `recurring` or `one_time`. 131 Type *string `form:"type"` 132 } 133 134 // AddExpand appends a new field to expand. 135 func (p *PriceListParams) AddExpand(f string) { 136 p.Expand = append(p.Expand, &f) 137 } 138 139 // When set, provides configuration for the amount to be adjusted by the customer during Checkout Sessions and Payment Links. 140 type PriceCurrencyOptionsCustomUnitAmountParams struct { 141 // Pass in `true` to enable `custom_unit_amount`, otherwise omit `custom_unit_amount`. 142 Enabled *bool `form:"enabled"` 143 // The maximum unit amount the customer can specify for this item. 144 Maximum *int64 `form:"maximum"` 145 // The minimum unit amount the customer can specify for this item. Must be at least the minimum charge amount. 146 Minimum *int64 `form:"minimum"` 147 // The starting unit amount which can be updated by the customer. 148 Preset *int64 `form:"preset"` 149 } 150 151 // Each element represents a pricing tier. This parameter requires `billing_scheme` to be set to `tiered`. See also the documentation for `billing_scheme`. 152 type PriceCurrencyOptionsTierParams struct { 153 // The flat billing amount for an entire tier, regardless of the number of units in the tier. 154 FlatAmount *int64 `form:"flat_amount"` 155 // Same as `flat_amount`, but accepts a decimal value representing an integer in the minor units of the currency. Only one of `flat_amount` and `flat_amount_decimal` can be set. 156 FlatAmountDecimal *float64 `form:"flat_amount_decimal,high_precision"` 157 // The per unit billing amount for each individual unit for which this tier applies. 158 UnitAmount *int64 `form:"unit_amount"` 159 // Same as `unit_amount`, but accepts a decimal value in cents (or local equivalent) with at most 12 decimal places. Only one of `unit_amount` and `unit_amount_decimal` can be set. 160 UnitAmountDecimal *float64 `form:"unit_amount_decimal,high_precision"` 161 // Specifies the upper bound of this tier. The lower bound of a tier is the upper bound of the previous tier adding one. Use `inf` to define a fallback tier. 162 UpTo *int64 `form:"up_to"` 163 UpToInf *bool `form:"-"` // See custom AppendTo 164 } 165 166 // AppendTo implements custom encoding logic for PriceCurrencyOptionsTierParams. 167 func (p *PriceCurrencyOptionsTierParams) AppendTo(body *form.Values, keyParts []string) { 168 if BoolValue(p.UpToInf) { 169 body.Add(form.FormatKey(append(keyParts, "up_to")), "inf") 170 } 171 } 172 173 // Prices defined in each available currency option. Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). 174 type PriceCurrencyOptionsParams struct { 175 // When set, provides configuration for the amount to be adjusted by the customer during Checkout Sessions and Payment Links. 176 CustomUnitAmount *PriceCurrencyOptionsCustomUnitAmountParams `form:"custom_unit_amount"` 177 // Only required if a [default tax behavior](https://stripe.com/docs/tax/products-prices-tax-categories-tax-behavior#setting-a-default-tax-behavior-(recommended)) was not provided in the Stripe Tax settings. Specifies whether the price is considered inclusive of taxes or exclusive of taxes. One of `inclusive`, `exclusive`, or `unspecified`. Once specified as either `inclusive` or `exclusive`, it cannot be changed. 178 TaxBehavior *string `form:"tax_behavior"` 179 // Each element represents a pricing tier. This parameter requires `billing_scheme` to be set to `tiered`. See also the documentation for `billing_scheme`. 180 Tiers []*PriceCurrencyOptionsTierParams `form:"tiers"` 181 // A positive integer in cents (or local equivalent) (or 0 for a free price) representing how much to charge. 182 UnitAmount *int64 `form:"unit_amount"` 183 // Same as `unit_amount`, but accepts a decimal value in cents (or local equivalent) with at most 12 decimal places. Only one of `unit_amount` and `unit_amount_decimal` can be set. 184 UnitAmountDecimal *float64 `form:"unit_amount_decimal,high_precision"` 185 } 186 187 // When set, provides configuration for the amount to be adjusted by the customer during Checkout Sessions and Payment Links. 188 type PriceCustomUnitAmountParams struct { 189 // Pass in `true` to enable `custom_unit_amount`, otherwise omit `custom_unit_amount`. 190 Enabled *bool `form:"enabled"` 191 // The maximum unit amount the customer can specify for this item. 192 Maximum *int64 `form:"maximum"` 193 // The minimum unit amount the customer can specify for this item. Must be at least the minimum charge amount. 194 Minimum *int64 `form:"minimum"` 195 // The starting unit amount which can be updated by the customer. 196 Preset *int64 `form:"preset"` 197 } 198 199 // These fields can be used to create a new product that this price will belong to. 200 type PriceProductDataParams struct { 201 // Whether the product is currently available for purchase. Defaults to `true`. 202 Active *bool `form:"active"` 203 // The identifier for the product. Must be unique. If not provided, an identifier will be randomly generated. 204 ID *string `form:"id"` 205 // 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`. 206 Metadata map[string]string `form:"metadata"` 207 // The product's name, meant to be displayable to the customer. 208 Name *string `form:"name"` 209 // An arbitrary string to be displayed on your customer's credit card or bank statement. While most banks display this information consistently, some may display it incorrectly or not at all. 210 // 211 // This may be up to 22 characters. The statement description may not include `<`, `>`, `\`, `"`, `'` characters, and will appear on your customer's statement in capital letters. Non-ASCII characters are automatically stripped. 212 StatementDescriptor *string `form:"statement_descriptor"` 213 // A [tax code](https://stripe.com/docs/tax/tax-categories) ID. 214 TaxCode *string `form:"tax_code"` 215 // A label that represents units of this product. When set, this will be included in customers' receipts, invoices, Checkout, and the customer portal. 216 UnitLabel *string `form:"unit_label"` 217 } 218 219 // AddMetadata adds a new key-value pair to the Metadata. 220 func (p *PriceProductDataParams) AddMetadata(key string, value string) { 221 if p.Metadata == nil { 222 p.Metadata = make(map[string]string) 223 } 224 225 p.Metadata[key] = value 226 } 227 228 // The recurring components of a price such as `interval` and `usage_type`. 229 type PriceRecurringParams struct { 230 // Specifies a usage aggregation strategy for prices of `usage_type=metered`. Defaults to `sum`. 231 AggregateUsage *string `form:"aggregate_usage"` 232 // Specifies billing frequency. Either `day`, `week`, `month` or `year`. 233 Interval *string `form:"interval"` 234 // The number of intervals between subscription billings. For example, `interval=month` and `interval_count=3` bills every 3 months. Maximum of three years interval allowed (3 years, 36 months, or 156 weeks). 235 IntervalCount *int64 `form:"interval_count"` 236 // The meter tracking the usage of a metered price 237 Meter *string `form:"meter"` 238 // Default number of trial days when subscribing a customer to this price using [`trial_from_plan=true`](https://stripe.com/docs/api#create_subscription-trial_from_plan). 239 TrialPeriodDays *int64 `form:"trial_period_days"` 240 // Configures how the quantity per period should be determined. Can be either `metered` or `licensed`. `licensed` automatically bills the `quantity` set when adding it to a subscription. `metered` aggregates the total usage based on usage records. Defaults to `licensed`. 241 UsageType *string `form:"usage_type"` 242 } 243 244 // Each element represents a pricing tier. This parameter requires `billing_scheme` to be set to `tiered`. See also the documentation for `billing_scheme`. 245 type PriceTierParams struct { 246 // The flat billing amount for an entire tier, regardless of the number of units in the tier. 247 FlatAmount *int64 `form:"flat_amount"` 248 // Same as `flat_amount`, but accepts a decimal value representing an integer in the minor units of the currency. Only one of `flat_amount` and `flat_amount_decimal` can be set. 249 FlatAmountDecimal *float64 `form:"flat_amount_decimal,high_precision"` 250 // The per unit billing amount for each individual unit for which this tier applies. 251 UnitAmount *int64 `form:"unit_amount"` 252 // Same as `unit_amount`, but accepts a decimal value in cents (or local equivalent) with at most 12 decimal places. Only one of `unit_amount` and `unit_amount_decimal` can be set. 253 UnitAmountDecimal *float64 `form:"unit_amount_decimal,high_precision"` 254 // Specifies the upper bound of this tier. The lower bound of a tier is the upper bound of the previous tier adding one. Use `inf` to define a fallback tier. 255 UpTo *int64 `form:"up_to"` 256 UpToInf *bool `form:"-"` // See custom AppendTo 257 } 258 259 // AppendTo implements custom encoding logic for PriceTierParams. 260 func (p *PriceTierParams) AppendTo(body *form.Values, keyParts []string) { 261 if BoolValue(p.UpToInf) { 262 body.Add(form.FormatKey(append(keyParts, "up_to")), "inf") 263 } 264 } 265 266 // Apply a transformation to the reported usage or set quantity before computing the billed price. Cannot be combined with `tiers`. 267 type PriceTransformQuantityParams struct { 268 // Divide usage by this number. 269 DivideBy *int64 `form:"divide_by"` 270 // After division, either round the result `up` or `down`. 271 Round *string `form:"round"` 272 } 273 274 // Creates a new price for an existing product. The price can be recurring or one-time. 275 type PriceParams struct { 276 Params `form:"*"` 277 // Whether the price can be used for new purchases. Defaults to `true`. 278 Active *bool `form:"active"` 279 // Describes how to compute the price per period. Either `per_unit` or `tiered`. `per_unit` indicates that the fixed amount (specified in `unit_amount` or `unit_amount_decimal`) will be charged per unit in `quantity` (for prices with `usage_type=licensed`), or per unit of total usage (for prices with `usage_type=metered`). `tiered` indicates that the unit pricing will be computed using a tiering strategy as defined using the `tiers` and `tiers_mode` attributes. 280 BillingScheme *string `form:"billing_scheme"` 281 // 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). 282 Currency *string `form:"currency"` 283 // Prices defined in each available currency option. Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). 284 CurrencyOptions map[string]*PriceCurrencyOptionsParams `form:"currency_options"` 285 // When set, provides configuration for the amount to be adjusted by the customer during Checkout Sessions and Payment Links. 286 CustomUnitAmount *PriceCustomUnitAmountParams `form:"custom_unit_amount"` 287 // Specifies which fields in the response should be expanded. 288 Expand []*string `form:"expand"` 289 // A lookup key used to retrieve prices dynamically from a static string. This may be up to 200 characters. 290 LookupKey *string `form:"lookup_key"` 291 // 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`. 292 Metadata map[string]string `form:"metadata"` 293 // A brief description of the price, hidden from customers. 294 Nickname *string `form:"nickname"` 295 // The ID of the product that this price will belong to. 296 Product *string `form:"product"` 297 // These fields can be used to create a new product that this price will belong to. 298 ProductData *PriceProductDataParams `form:"product_data"` 299 // The recurring components of a price such as `interval` and `usage_type`. 300 Recurring *PriceRecurringParams `form:"recurring"` 301 // Only required if a [default tax behavior](https://stripe.com/docs/tax/products-prices-tax-categories-tax-behavior#setting-a-default-tax-behavior-(recommended)) was not provided in the Stripe Tax settings. Specifies whether the price is considered inclusive of taxes or exclusive of taxes. One of `inclusive`, `exclusive`, or `unspecified`. Once specified as either `inclusive` or `exclusive`, it cannot be changed. 302 TaxBehavior *string `form:"tax_behavior"` 303 // Each element represents a pricing tier. This parameter requires `billing_scheme` to be set to `tiered`. See also the documentation for `billing_scheme`. 304 Tiers []*PriceTierParams `form:"tiers"` 305 // Defines if the tiering price should be `graduated` or `volume` based. In `volume`-based tiering, the maximum quantity within a period determines the per unit price, in `graduated` tiering pricing can successively change as the quantity grows. 306 TiersMode *string `form:"tiers_mode"` 307 // If set to true, will atomically remove the lookup key from the existing price, and assign it to this price. 308 TransferLookupKey *bool `form:"transfer_lookup_key"` 309 // Apply a transformation to the reported usage or set quantity before computing the billed price. Cannot be combined with `tiers`. 310 TransformQuantity *PriceTransformQuantityParams `form:"transform_quantity"` 311 // A positive integer in cents (or local equivalent) (or 0 for a free price) representing how much to charge. One of `unit_amount` or `custom_unit_amount` is required, unless `billing_scheme=tiered`. 312 UnitAmount *int64 `form:"unit_amount"` 313 // Same as `unit_amount`, but accepts a decimal value in cents (or local equivalent) with at most 12 decimal places. Only one of `unit_amount` and `unit_amount_decimal` can be set. 314 UnitAmountDecimal *float64 `form:"unit_amount_decimal,high_precision"` 315 } 316 317 // AddExpand appends a new field to expand. 318 func (p *PriceParams) AddExpand(f string) { 319 p.Expand = append(p.Expand, &f) 320 } 321 322 // AddMetadata adds a new key-value pair to the Metadata. 323 func (p *PriceParams) AddMetadata(key string, value string) { 324 if p.Metadata == nil { 325 p.Metadata = make(map[string]string) 326 } 327 328 p.Metadata[key] = value 329 } 330 331 // Search for prices you've previously created using Stripe's [Search Query Language](https://stripe.com/docs/search#search-query-language). 332 // Don't use search in read-after-write flows where strict consistency is necessary. Under normal operating 333 // conditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up 334 // to an hour behind during outages. Search functionality is not available to merchants in India. 335 type PriceSearchParams struct { 336 SearchParams `form:"*"` 337 // Specifies which fields in the response should be expanded. 338 Expand []*string `form:"expand"` 339 // 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. 340 Page *string `form:"page"` 341 } 342 343 // AddExpand appends a new field to expand. 344 func (p *PriceSearchParams) AddExpand(f string) { 345 p.Expand = append(p.Expand, &f) 346 } 347 348 // When set, provides configuration for the amount to be adjusted by the customer during Checkout Sessions and Payment Links. 349 type PriceCurrencyOptionsCustomUnitAmount struct { 350 // The maximum unit amount the customer can specify for this item. 351 Maximum int64 `json:"maximum"` 352 // The minimum unit amount the customer can specify for this item. Must be at least the minimum charge amount. 353 Minimum int64 `json:"minimum"` 354 // The starting unit amount which can be updated by the customer. 355 Preset int64 `json:"preset"` 356 } 357 358 // Each element represents a pricing tier. This parameter requires `billing_scheme` to be set to `tiered`. See also the documentation for `billing_scheme`. 359 type PriceCurrencyOptionsTier struct { 360 // Price for the entire tier. 361 FlatAmount int64 `json:"flat_amount"` 362 // Same as `flat_amount`, but contains a decimal value with at most 12 decimal places. 363 FlatAmountDecimal float64 `json:"flat_amount_decimal,string"` 364 // Per unit price for units relevant to the tier. 365 UnitAmount int64 `json:"unit_amount"` 366 // Same as `unit_amount`, but contains a decimal value with at most 12 decimal places. 367 UnitAmountDecimal float64 `json:"unit_amount_decimal,string"` 368 // Up to and including to this quantity will be contained in the tier. 369 UpTo int64 `json:"up_to"` 370 } 371 372 // Prices defined in each available currency option. Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). 373 type PriceCurrencyOptions struct { 374 // When set, provides configuration for the amount to be adjusted by the customer during Checkout Sessions and Payment Links. 375 CustomUnitAmount *PriceCurrencyOptionsCustomUnitAmount `json:"custom_unit_amount"` 376 // Only required if a [default tax behavior](https://stripe.com/docs/tax/products-prices-tax-categories-tax-behavior#setting-a-default-tax-behavior-(recommended)) was not provided in the Stripe Tax settings. Specifies whether the price is considered inclusive of taxes or exclusive of taxes. One of `inclusive`, `exclusive`, or `unspecified`. Once specified as either `inclusive` or `exclusive`, it cannot be changed. 377 TaxBehavior PriceCurrencyOptionsTaxBehavior `json:"tax_behavior"` 378 // Each element represents a pricing tier. This parameter requires `billing_scheme` to be set to `tiered`. See also the documentation for `billing_scheme`. 379 Tiers []*PriceCurrencyOptionsTier `json:"tiers"` 380 // The unit amount in cents (or local equivalent) to be charged, represented as a whole integer if possible. Only set if `billing_scheme=per_unit`. 381 UnitAmount int64 `json:"unit_amount"` 382 // The unit amount in cents (or local equivalent) to be charged, represented as a decimal string with at most 12 decimal places. Only set if `billing_scheme=per_unit`. 383 UnitAmountDecimal float64 `json:"unit_amount_decimal,string"` 384 } 385 386 // When set, provides configuration for the amount to be adjusted by the customer during Checkout Sessions and Payment Links. 387 type PriceCustomUnitAmount struct { 388 // The maximum unit amount the customer can specify for this item. 389 Maximum int64 `json:"maximum"` 390 // The minimum unit amount the customer can specify for this item. Must be at least the minimum charge amount. 391 Minimum int64 `json:"minimum"` 392 // The starting unit amount which can be updated by the customer. 393 Preset int64 `json:"preset"` 394 } 395 396 // The recurring components of a price such as `interval` and `usage_type`. 397 type PriceRecurring struct { 398 // Specifies a usage aggregation strategy for prices of `usage_type=metered`. Defaults to `sum`. 399 AggregateUsage PriceRecurringAggregateUsage `json:"aggregate_usage"` 400 // The frequency at which a subscription is billed. One of `day`, `week`, `month` or `year`. 401 Interval PriceRecurringInterval `json:"interval"` 402 // The number of intervals (specified in the `interval` attribute) between subscription billings. For example, `interval=month` and `interval_count=3` bills every 3 months. 403 IntervalCount int64 `json:"interval_count"` 404 // The meter tracking the usage of a metered price 405 Meter string `json:"meter"` 406 // Default number of trial days when subscribing a customer to this price using [`trial_from_plan=true`](https://stripe.com/docs/api#create_subscription-trial_from_plan). 407 TrialPeriodDays int64 `json:"trial_period_days"` 408 // Configures how the quantity per period should be determined. Can be either `metered` or `licensed`. `licensed` automatically bills the `quantity` set when adding it to a subscription. `metered` aggregates the total usage based on usage records. Defaults to `licensed`. 409 UsageType PriceRecurringUsageType `json:"usage_type"` 410 } 411 412 // Each element represents a pricing tier. This parameter requires `billing_scheme` to be set to `tiered`. See also the documentation for `billing_scheme`. 413 type PriceTier struct { 414 // Price for the entire tier. 415 FlatAmount int64 `json:"flat_amount"` 416 // Same as `flat_amount`, but contains a decimal value with at most 12 decimal places. 417 FlatAmountDecimal float64 `json:"flat_amount_decimal,string"` 418 // Per unit price for units relevant to the tier. 419 UnitAmount int64 `json:"unit_amount"` 420 // Same as `unit_amount`, but contains a decimal value with at most 12 decimal places. 421 UnitAmountDecimal float64 `json:"unit_amount_decimal,string"` 422 // Up to and including to this quantity will be contained in the tier. 423 UpTo int64 `json:"up_to"` 424 } 425 426 // Apply a transformation to the reported usage or set quantity before computing the amount billed. Cannot be combined with `tiers`. 427 type PriceTransformQuantity struct { 428 // Divide usage by this number. 429 DivideBy int64 `json:"divide_by"` 430 // After division, either round the result `up` or `down`. 431 Round PriceTransformQuantityRound `json:"round"` 432 } 433 434 // Prices define the unit cost, currency, and (optional) billing cycle for both recurring and one-time purchases of products. 435 // [Products](https://stripe.com/docs/api#products) help you track inventory or provisioning, and prices help you track payment terms. Different physical goods or levels of service should be represented by products, and pricing options should be represented by prices. This approach lets you change prices without having to change your provisioning scheme. 436 // 437 // For example, you might have a single "gold" product that has prices for $10/month, $100/year, and €9 once. 438 // 439 // Related guides: [Set up a subscription](https://stripe.com/docs/billing/subscriptions/set-up-subscription), [create an invoice](https://stripe.com/docs/billing/invoices/create), and more about [products and prices](https://stripe.com/docs/products-prices/overview). 440 type Price struct { 441 APIResource 442 // Whether the price can be used for new purchases. 443 Active bool `json:"active"` 444 // Describes how to compute the price per period. Either `per_unit` or `tiered`. `per_unit` indicates that the fixed amount (specified in `unit_amount` or `unit_amount_decimal`) will be charged per unit in `quantity` (for prices with `usage_type=licensed`), or per unit of total usage (for prices with `usage_type=metered`). `tiered` indicates that the unit pricing will be computed using a tiering strategy as defined using the `tiers` and `tiers_mode` attributes. 445 BillingScheme PriceBillingScheme `json:"billing_scheme"` 446 // Time at which the object was created. Measured in seconds since the Unix epoch. 447 Created int64 `json:"created"` 448 // 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). 449 Currency Currency `json:"currency"` 450 // Prices defined in each available currency option. Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). 451 CurrencyOptions map[string]*PriceCurrencyOptions `json:"currency_options"` 452 // When set, provides configuration for the amount to be adjusted by the customer during Checkout Sessions and Payment Links. 453 CustomUnitAmount *PriceCustomUnitAmount `json:"custom_unit_amount"` 454 Deleted bool `json:"deleted"` 455 // Unique identifier for the object. 456 ID string `json:"id"` 457 // Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. 458 Livemode bool `json:"livemode"` 459 // A lookup key used to retrieve prices dynamically from a static string. This may be up to 200 characters. 460 LookupKey string `json:"lookup_key"` 461 // 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. 462 Metadata map[string]string `json:"metadata"` 463 // A brief description of the price, hidden from customers. 464 Nickname string `json:"nickname"` 465 // String representing the object's type. Objects of the same type share the same value. 466 Object string `json:"object"` 467 // The ID of the product this price is associated with. 468 Product *Product `json:"product"` 469 // The recurring components of a price such as `interval` and `usage_type`. 470 Recurring *PriceRecurring `json:"recurring"` 471 // Only required if a [default tax behavior](https://stripe.com/docs/tax/products-prices-tax-categories-tax-behavior#setting-a-default-tax-behavior-(recommended)) was not provided in the Stripe Tax settings. Specifies whether the price is considered inclusive of taxes or exclusive of taxes. One of `inclusive`, `exclusive`, or `unspecified`. Once specified as either `inclusive` or `exclusive`, it cannot be changed. 472 TaxBehavior PriceTaxBehavior `json:"tax_behavior"` 473 // Each element represents a pricing tier. This parameter requires `billing_scheme` to be set to `tiered`. See also the documentation for `billing_scheme`. 474 Tiers []*PriceTier `json:"tiers"` 475 // Defines if the tiering price should be `graduated` or `volume` based. In `volume`-based tiering, the maximum quantity within a period determines the per unit price. In `graduated` tiering, pricing can change as the quantity grows. 476 TiersMode PriceTiersMode `json:"tiers_mode"` 477 // Apply a transformation to the reported usage or set quantity before computing the amount billed. Cannot be combined with `tiers`. 478 TransformQuantity *PriceTransformQuantity `json:"transform_quantity"` 479 // One of `one_time` or `recurring` depending on whether the price is for a one-time purchase or a recurring (subscription) purchase. 480 Type PriceType `json:"type"` 481 // The unit amount in cents (or local equivalent) to be charged, represented as a whole integer if possible. Only set if `billing_scheme=per_unit`. 482 UnitAmount int64 `json:"unit_amount"` 483 // The unit amount in cents (or local equivalent) to be charged, represented as a decimal string with at most 12 decimal places. Only set if `billing_scheme=per_unit`. 484 UnitAmountDecimal float64 `json:"unit_amount_decimal,string"` 485 } 486 487 // PriceList is a list of Prices as retrieved from a list endpoint. 488 type PriceList struct { 489 APIResource 490 ListMeta 491 Data []*Price `json:"data"` 492 } 493 494 // PriceSearchResult is a list of Price search results as retrieved from a search endpoint. 495 type PriceSearchResult struct { 496 APIResource 497 SearchMeta 498 Data []*Price `json:"data"` 499 } 500 501 // UnmarshalJSON handles deserialization of a Price. 502 // This custom unmarshaling is needed because the resulting 503 // property may be an id or the full struct if it was expanded. 504 func (p *Price) UnmarshalJSON(data []byte) error { 505 if id, ok := ParseID(data); ok { 506 p.ID = id 507 return nil 508 } 509 510 type price Price 511 var v price 512 if err := json.Unmarshal(data, &v); err != nil { 513 return err 514 } 515 516 *p = Price(v) 517 return nil 518 }