stripe/resources/generated/
product.rs

1// ======================================
2// This file was automatically generated.
3// ======================================
4
5use crate::client::{Client, Response};
6use crate::ids::{ProductId, TaxCodeId};
7use crate::params::{
8    CurrencyMap, Deleted, Expand, Expandable, List, Metadata, Object, Paginable, RangeQuery,
9    Timestamp,
10};
11use crate::resources::{Currency, Price, TaxCode, UpTo};
12use serde::{Deserialize, Serialize};
13
14/// The resource representing a Stripe "Product".
15///
16/// For more details see <https://stripe.com/docs/api/products/object>
17#[derive(Clone, Debug, Default, Deserialize, Serialize)]
18pub struct Product {
19    /// Unique identifier for the object.
20    pub id: ProductId,
21
22    /// Whether the product is currently available for purchase.
23    #[serde(skip_serializing_if = "Option::is_none")]
24    pub active: Option<bool>,
25
26    /// Time at which the object was created.
27    ///
28    /// Measured in seconds since the Unix epoch.
29    #[serde(skip_serializing_if = "Option::is_none")]
30    pub created: Option<Timestamp>,
31
32    /// The ID of the [Price](https://stripe.com/docs/api/prices) object that is the default price for this product.
33    #[serde(skip_serializing_if = "Option::is_none")]
34    pub default_price: Option<Expandable<Price>>,
35
36    // Always true for a deleted object
37    #[serde(default)]
38    pub deleted: bool,
39
40    /// The product's description, meant to be displayable to the customer.
41    ///
42    /// Use this field to optionally store a long form explanation of the product being sold for your own rendering purposes.
43    #[serde(skip_serializing_if = "Option::is_none")]
44    pub description: Option<String>,
45
46    /// A list of up to 15 features for this product.
47    ///
48    /// These are displayed in [pricing tables](https://stripe.com/docs/payments/checkout/pricing-table).
49    #[serde(skip_serializing_if = "Option::is_none")]
50    pub features: Option<Vec<ProductFeature>>,
51
52    /// A list of up to 8 URLs of images for this product, meant to be displayable to the customer.
53    #[serde(skip_serializing_if = "Option::is_none")]
54    pub images: Option<Vec<String>>,
55
56    /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
57    #[serde(skip_serializing_if = "Option::is_none")]
58    pub livemode: Option<bool>,
59
60    /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object.
61    ///
62    /// This can be useful for storing additional information about the object in a structured format.
63    #[serde(skip_serializing_if = "Option::is_none")]
64    pub metadata: Option<Metadata>,
65
66    /// The product's name, meant to be displayable to the customer.
67    #[serde(skip_serializing_if = "Option::is_none")]
68    pub name: Option<String>,
69
70    /// The dimensions of this product for shipping purposes.
71    #[serde(skip_serializing_if = "Option::is_none")]
72    pub package_dimensions: Option<PackageDimensions>,
73
74    /// Whether this product is shipped (i.e., physical goods).
75    #[serde(skip_serializing_if = "Option::is_none")]
76    pub shippable: Option<bool>,
77
78    /// Extra information about a product which will appear on your customer's credit card statement.
79    ///
80    /// In the case that multiple products are billed at once, the first statement descriptor will be used.
81    #[serde(skip_serializing_if = "Option::is_none")]
82    pub statement_descriptor: Option<String>,
83
84    /// A [tax code](https://stripe.com/docs/tax/tax-categories) ID.
85    #[serde(skip_serializing_if = "Option::is_none")]
86    pub tax_code: Option<Expandable<TaxCode>>,
87
88    /// The type of the product.
89    ///
90    /// The product is either of type `good`, which is eligible for use with Orders and SKUs, or `service`, which is eligible for use with Subscriptions and Plans.
91    #[serde(rename = "type")]
92    #[serde(skip_serializing_if = "Option::is_none")]
93    pub type_: Option<ProductType>,
94
95    /// A label that represents units of this product.
96    ///
97    /// When set, this will be included in customers' receipts, invoices, Checkout, and the customer portal.
98    #[serde(skip_serializing_if = "Option::is_none")]
99    pub unit_label: Option<String>,
100
101    /// Time at which the object was last updated.
102    ///
103    /// Measured in seconds since the Unix epoch.
104    #[serde(skip_serializing_if = "Option::is_none")]
105    pub updated: Option<Timestamp>,
106
107    /// A URL of a publicly-accessible webpage for this product.
108    #[serde(skip_serializing_if = "Option::is_none")]
109    pub url: Option<String>,
110}
111
112impl Product {
113    /// Returns a list of your products.
114    ///
115    /// The products are returned sorted by creation date, with the most recently created products appearing first.
116    pub fn list(client: &Client, params: &ListProducts<'_>) -> Response<List<Product>> {
117        client.get_query("/products", params)
118    }
119
120    /// Creates a new product object.
121    pub fn create(client: &Client, params: CreateProduct<'_>) -> Response<Product> {
122        #[allow(clippy::needless_borrows_for_generic_args)]
123        client.post_form("/products", &params)
124    }
125
126    /// Retrieves the details of an existing product.
127    ///
128    /// Supply the unique product ID from either a product creation request or the product list, and Stripe will return the corresponding product information.
129    pub fn retrieve(client: &Client, id: &ProductId, expand: &[&str]) -> Response<Product> {
130        client.get_query(&format!("/products/{}", id), Expand { expand })
131    }
132
133    /// Updates the specific product by setting the values of the parameters passed.
134    ///
135    /// Any parameters not provided will be left unchanged.
136    pub fn update(client: &Client, id: &ProductId, params: UpdateProduct<'_>) -> Response<Product> {
137        #[allow(clippy::needless_borrows_for_generic_args)]
138        client.post_form(&format!("/products/{}", id), &params)
139    }
140
141    /// Delete a product.
142    ///
143    /// Deleting a product is only possible if it has no prices associated with it.
144    /// Additionally, deleting a product with `type=good` is only possible if it has no SKUs associated with it.
145    pub fn delete(client: &Client, id: &ProductId) -> Response<Deleted<ProductId>> {
146        client.delete(&format!("/products/{}", id))
147    }
148}
149
150impl Object for Product {
151    type Id = ProductId;
152    fn id(&self) -> Self::Id {
153        self.id.clone()
154    }
155    fn object(&self) -> &'static str {
156        "product"
157    }
158}
159
160#[derive(Clone, Debug, Default, Deserialize, Serialize)]
161pub struct PackageDimensions {
162    /// Height, in inches.
163    pub height: f64,
164
165    /// Length, in inches.
166    pub length: f64,
167
168    /// Weight, in ounces.
169    pub weight: f64,
170
171    /// Width, in inches.
172    pub width: f64,
173}
174
175#[derive(Clone, Debug, Default, Deserialize, Serialize)]
176pub struct ProductFeature {
177    /// The feature's name.
178    ///
179    /// Up to 80 characters long.
180    #[serde(skip_serializing_if = "Option::is_none")]
181    pub name: Option<String>,
182}
183
184/// The parameters for `Product::create`.
185#[derive(Clone, Debug, Serialize)]
186pub struct CreateProduct<'a> {
187    /// Whether the product is currently available for purchase.
188    ///
189    /// Defaults to `true`.
190    #[serde(skip_serializing_if = "Option::is_none")]
191    pub active: Option<bool>,
192
193    /// Data used to generate a new [Price](https://stripe.com/docs/api/prices) object.
194    ///
195    /// This Price will be set as the default price for this product.
196    #[serde(skip_serializing_if = "Option::is_none")]
197    pub default_price_data: Option<CreateProductDefaultPriceData>,
198
199    /// The product's description, meant to be displayable to the customer.
200    ///
201    /// Use this field to optionally store a long form explanation of the product being sold for your own rendering purposes.
202    #[serde(skip_serializing_if = "Option::is_none")]
203    pub description: Option<&'a str>,
204
205    /// Specifies which fields in the response should be expanded.
206    #[serde(skip_serializing_if = "Expand::is_empty")]
207    pub expand: &'a [&'a str],
208
209    /// A list of up to 15 features for this product.
210    ///
211    /// These are displayed in [pricing tables](https://stripe.com/docs/payments/checkout/pricing-table).
212    #[serde(skip_serializing_if = "Option::is_none")]
213    pub features: Option<Vec<CreateProductFeatures>>,
214
215    /// An identifier will be randomly generated by Stripe.
216    ///
217    /// You can optionally override this ID, but the ID must be unique across all products in your Stripe account.
218    #[serde(skip_serializing_if = "Option::is_none")]
219    pub id: Option<&'a str>,
220
221    /// A list of up to 8 URLs of images for this product, meant to be displayable to the customer.
222    #[serde(skip_serializing_if = "Option::is_none")]
223    pub images: Option<Vec<String>>,
224
225    /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object.
226    ///
227    /// This can be useful for storing additional information about the object in a structured format.
228    /// Individual keys can be unset by posting an empty value to them.
229    /// All keys can be unset by posting an empty value to `metadata`.
230    #[serde(skip_serializing_if = "Option::is_none")]
231    pub metadata: Option<Metadata>,
232
233    /// The product's name, meant to be displayable to the customer.
234    pub name: &'a str,
235
236    /// The dimensions of this product for shipping purposes.
237    #[serde(skip_serializing_if = "Option::is_none")]
238    pub package_dimensions: Option<PackageDimensions>,
239
240    /// Whether this product is shipped (i.e., physical goods).
241    #[serde(skip_serializing_if = "Option::is_none")]
242    pub shippable: Option<bool>,
243
244    /// An arbitrary string to be displayed on your customer's credit card or bank statement.
245    ///
246    /// While most banks display this information consistently, some may display it incorrectly or not at all.  This may be up to 22 characters.
247    /// The statement description may not include `<`, `>`, `\`, `"`, `'` characters, and will appear on your customer's statement in capital letters.
248    /// Non-ASCII characters are automatically stripped.  It must contain at least one letter.
249    #[serde(skip_serializing_if = "Option::is_none")]
250    pub statement_descriptor: Option<&'a str>,
251
252    /// A [tax code](https://stripe.com/docs/tax/tax-categories) ID.
253    #[serde(skip_serializing_if = "Option::is_none")]
254    pub tax_code: Option<TaxCodeId>,
255
256    /// The type of the product.
257    ///
258    /// Defaults to `service` if not explicitly specified, enabling use of this product with Subscriptions and Plans.
259    /// Set this parameter to `good` to use this product with Orders and SKUs.
260    /// On API versions before `2018-02-05`, this field defaults to `good` for compatibility reasons.
261    #[serde(rename = "type")]
262    #[serde(skip_serializing_if = "Option::is_none")]
263    pub type_: Option<ProductType>,
264
265    /// A label that represents units of this product.
266    ///
267    /// When set, this will be included in customers' receipts, invoices, Checkout, and the customer portal.
268    #[serde(skip_serializing_if = "Option::is_none")]
269    pub unit_label: Option<&'a str>,
270
271    /// A URL of a publicly-accessible webpage for this product.
272    #[serde(skip_serializing_if = "Option::is_none")]
273    pub url: Option<&'a str>,
274}
275
276impl<'a> CreateProduct<'a> {
277    pub fn new(name: &'a str) -> Self {
278        CreateProduct {
279            active: Default::default(),
280            default_price_data: Default::default(),
281            description: Default::default(),
282            expand: Default::default(),
283            features: Default::default(),
284            id: Default::default(),
285            images: Default::default(),
286            metadata: Default::default(),
287            name,
288            package_dimensions: Default::default(),
289            shippable: Default::default(),
290            statement_descriptor: Default::default(),
291            tax_code: Default::default(),
292            type_: Default::default(),
293            unit_label: Default::default(),
294            url: Default::default(),
295        }
296    }
297}
298
299/// The parameters for `Product::list`.
300#[derive(Clone, Debug, Serialize, Default)]
301pub struct ListProducts<'a> {
302    /// Only return products that are active or inactive (e.g., pass `false` to list all inactive products).
303    #[serde(skip_serializing_if = "Option::is_none")]
304    pub active: Option<bool>,
305
306    /// Only return products that were created during the given date interval.
307    #[serde(skip_serializing_if = "Option::is_none")]
308    pub created: Option<RangeQuery<Timestamp>>,
309
310    /// A cursor for use in pagination.
311    ///
312    /// `ending_before` is an object ID that defines your place in the list.
313    /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list.
314    #[serde(skip_serializing_if = "Option::is_none")]
315    pub ending_before: Option<ProductId>,
316
317    /// Specifies which fields in the response should be expanded.
318    #[serde(skip_serializing_if = "Expand::is_empty")]
319    pub expand: &'a [&'a str],
320
321    /// Only return products with the given IDs.
322    ///
323    /// Cannot be used with [starting_after](https://stripe.com/docs/api#list_products-starting_after) or [ending_before](https://stripe.com/docs/api#list_products-ending_before).
324    #[serde(skip_serializing_if = "Option::is_none")]
325    pub ids: Option<Vec<String>>,
326
327    /// A limit on the number of objects to be returned.
328    ///
329    /// Limit can range between 1 and 100, and the default is 10.
330    #[serde(skip_serializing_if = "Option::is_none")]
331    pub limit: Option<u64>,
332
333    /// Only return products that can be shipped (i.e., physical, not digital products).
334    #[serde(skip_serializing_if = "Option::is_none")]
335    pub shippable: Option<bool>,
336
337    /// A cursor for use in pagination.
338    ///
339    /// `starting_after` is an object ID that defines your place in the list.
340    /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list.
341    #[serde(skip_serializing_if = "Option::is_none")]
342    pub starting_after: Option<ProductId>,
343
344    /// Only return products of this type.
345    #[serde(rename = "type")]
346    #[serde(skip_serializing_if = "Option::is_none")]
347    pub type_: Option<ProductType>,
348
349    /// Only return products with the given url.
350    #[serde(skip_serializing_if = "Option::is_none")]
351    pub url: Option<&'a str>,
352}
353
354impl<'a> ListProducts<'a> {
355    pub fn new() -> Self {
356        ListProducts {
357            active: Default::default(),
358            created: Default::default(),
359            ending_before: Default::default(),
360            expand: Default::default(),
361            ids: Default::default(),
362            limit: Default::default(),
363            shippable: Default::default(),
364            starting_after: Default::default(),
365            type_: Default::default(),
366            url: Default::default(),
367        }
368    }
369}
370impl Paginable for ListProducts<'_> {
371    type O = Product;
372    fn set_last(&mut self, item: Self::O) {
373        self.starting_after = Some(item.id());
374    }
375}
376/// The parameters for `Product::update`.
377#[derive(Clone, Debug, Serialize, Default)]
378pub struct UpdateProduct<'a> {
379    /// Whether the product is available for purchase.
380    #[serde(skip_serializing_if = "Option::is_none")]
381    pub active: Option<bool>,
382
383    /// The ID of the [Price](https://stripe.com/docs/api/prices) object that is the default price for this product.
384    #[serde(skip_serializing_if = "Option::is_none")]
385    pub default_price: Option<&'a str>,
386
387    /// The product's description, meant to be displayable to the customer.
388    ///
389    /// Use this field to optionally store a long form explanation of the product being sold for your own rendering purposes.
390    #[serde(skip_serializing_if = "Option::is_none")]
391    pub description: Option<String>,
392
393    /// Specifies which fields in the response should be expanded.
394    #[serde(skip_serializing_if = "Expand::is_empty")]
395    pub expand: &'a [&'a str],
396
397    /// A list of up to 15 features for this product.
398    ///
399    /// These are displayed in [pricing tables](https://stripe.com/docs/payments/checkout/pricing-table).
400    #[serde(skip_serializing_if = "Option::is_none")]
401    pub features: Option<Vec<UpdateProductFeatures>>,
402
403    /// A list of up to 8 URLs of images for this product, meant to be displayable to the customer.
404    #[serde(skip_serializing_if = "Option::is_none")]
405    pub images: Option<Vec<String>>,
406
407    /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object.
408    ///
409    /// This can be useful for storing additional information about the object in a structured format.
410    /// Individual keys can be unset by posting an empty value to them.
411    /// All keys can be unset by posting an empty value to `metadata`.
412    #[serde(skip_serializing_if = "Option::is_none")]
413    pub metadata: Option<Metadata>,
414
415    /// The product's name, meant to be displayable to the customer.
416    #[serde(skip_serializing_if = "Option::is_none")]
417    pub name: Option<&'a str>,
418
419    /// The dimensions of this product for shipping purposes.
420    #[serde(skip_serializing_if = "Option::is_none")]
421    pub package_dimensions: Option<PackageDimensions>,
422
423    /// Whether this product is shipped (i.e., physical goods).
424    #[serde(skip_serializing_if = "Option::is_none")]
425    pub shippable: Option<bool>,
426
427    /// An arbitrary string to be displayed on your customer's credit card or bank statement.
428    ///
429    /// While most banks display this information consistently, some may display it incorrectly or not at all.  This may be up to 22 characters.
430    /// The statement description may not include `<`, `>`, `\`, `"`, `'` characters, and will appear on your customer's statement in capital letters.
431    /// Non-ASCII characters are automatically stripped.  It must contain at least one letter.
432    /// May only be set if `type=service`.
433    #[serde(skip_serializing_if = "Option::is_none")]
434    pub statement_descriptor: Option<&'a str>,
435
436    /// A [tax code](https://stripe.com/docs/tax/tax-categories) ID.
437    #[serde(skip_serializing_if = "Option::is_none")]
438    pub tax_code: Option<String>,
439
440    /// A label that represents units of this product.
441    ///
442    /// When set, this will be included in customers' receipts, invoices, Checkout, and the customer portal.
443    /// May only be set if `type=service`.
444    #[serde(skip_serializing_if = "Option::is_none")]
445    pub unit_label: Option<String>,
446
447    /// A URL of a publicly-accessible webpage for this product.
448    #[serde(skip_serializing_if = "Option::is_none")]
449    pub url: Option<String>,
450}
451
452impl<'a> UpdateProduct<'a> {
453    pub fn new() -> Self {
454        UpdateProduct {
455            active: Default::default(),
456            default_price: Default::default(),
457            description: Default::default(),
458            expand: Default::default(),
459            features: Default::default(),
460            images: Default::default(),
461            metadata: Default::default(),
462            name: Default::default(),
463            package_dimensions: Default::default(),
464            shippable: Default::default(),
465            statement_descriptor: Default::default(),
466            tax_code: Default::default(),
467            unit_label: Default::default(),
468            url: Default::default(),
469        }
470    }
471}
472
473#[derive(Clone, Debug, Default, Deserialize, Serialize)]
474pub struct CreateProductDefaultPriceData {
475    /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase.
476    ///
477    /// Must be a [supported currency](https://stripe.com/docs/currencies).
478    pub currency: Currency,
479
480    /// Prices defined in each available currency option.
481    ///
482    /// 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).
483    #[serde(skip_serializing_if = "Option::is_none")]
484    pub currency_options: Option<CurrencyMap<CreateProductDefaultPriceDataCurrencyOptions>>,
485
486    /// The recurring components of a price such as `interval` and `interval_count`.
487    #[serde(skip_serializing_if = "Option::is_none")]
488    pub recurring: Option<CreateProductDefaultPriceDataRecurring>,
489
490    /// 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.
491    ///
492    /// Specifies whether the price is considered inclusive of taxes or exclusive of taxes.
493    /// One of `inclusive`, `exclusive`, or `unspecified`.
494    /// Once specified as either `inclusive` or `exclusive`, it cannot be changed.
495    #[serde(skip_serializing_if = "Option::is_none")]
496    pub tax_behavior: Option<CreateProductDefaultPriceDataTaxBehavior>,
497
498    /// A positive integer in cents (or local equivalent) (or 0 for a free price) representing how much to charge.
499    ///
500    /// One of `unit_amount` or `unit_amount_decimal` is required.
501    #[serde(skip_serializing_if = "Option::is_none")]
502    pub unit_amount: Option<i64>,
503
504    /// Same as `unit_amount`, but accepts a decimal value in cents (or local equivalent) with at most 12 decimal places.
505    ///
506    /// Only one of `unit_amount` and `unit_amount_decimal` can be set.
507    #[serde(skip_serializing_if = "Option::is_none")]
508    pub unit_amount_decimal: Option<String>,
509}
510
511#[derive(Clone, Debug, Default, Deserialize, Serialize)]
512pub struct CreateProductFeatures {
513    /// The feature's name.
514    ///
515    /// Up to 80 characters long.
516    pub name: String,
517}
518
519#[derive(Clone, Debug, Default, Deserialize, Serialize)]
520pub struct UpdateProductFeatures {
521    /// The feature's name.
522    ///
523    /// Up to 80 characters long.
524    pub name: String,
525}
526
527#[derive(Clone, Debug, Default, Deserialize, Serialize)]
528pub struct CreateProductDefaultPriceDataCurrencyOptions {
529    /// When set, provides configuration for the amount to be adjusted by the customer during Checkout Sessions and Payment Links.
530    #[serde(skip_serializing_if = "Option::is_none")]
531    pub custom_unit_amount: Option<CreateProductDefaultPriceDataCurrencyOptionsCustomUnitAmount>,
532
533    /// 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.
534    ///
535    /// Specifies whether the price is considered inclusive of taxes or exclusive of taxes.
536    /// One of `inclusive`, `exclusive`, or `unspecified`.
537    /// Once specified as either `inclusive` or `exclusive`, it cannot be changed.
538    #[serde(skip_serializing_if = "Option::is_none")]
539    pub tax_behavior: Option<CreateProductDefaultPriceDataCurrencyOptionsTaxBehavior>,
540
541    /// Each element represents a pricing tier.
542    ///
543    /// This parameter requires `billing_scheme` to be set to `tiered`.
544    /// See also the documentation for `billing_scheme`.
545    #[serde(skip_serializing_if = "Option::is_none")]
546    pub tiers: Option<Vec<CreateProductDefaultPriceDataCurrencyOptionsTiers>>,
547
548    /// A positive integer in cents (or local equivalent) (or 0 for a free price) representing how much to charge.
549    #[serde(skip_serializing_if = "Option::is_none")]
550    pub unit_amount: Option<i64>,
551
552    /// Same as `unit_amount`, but accepts a decimal value in cents (or local equivalent) with at most 12 decimal places.
553    ///
554    /// Only one of `unit_amount` and `unit_amount_decimal` can be set.
555    #[serde(skip_serializing_if = "Option::is_none")]
556    pub unit_amount_decimal: Option<String>,
557}
558
559#[derive(Clone, Debug, Default, Deserialize, Serialize)]
560pub struct CreateProductDefaultPriceDataRecurring {
561    /// Specifies billing frequency.
562    ///
563    /// Either `day`, `week`, `month` or `year`.
564    pub interval: CreateProductDefaultPriceDataRecurringInterval,
565
566    /// The number of intervals between subscription billings.
567    ///
568    /// For example, `interval=month` and `interval_count=3` bills every 3 months.
569    /// Maximum of three years interval allowed (3 years, 36 months, or 156 weeks).
570    #[serde(skip_serializing_if = "Option::is_none")]
571    pub interval_count: Option<u64>,
572}
573
574#[derive(Clone, Debug, Default, Deserialize, Serialize)]
575pub struct CreateProductDefaultPriceDataCurrencyOptionsCustomUnitAmount {
576    /// Pass in `true` to enable `custom_unit_amount`, otherwise omit `custom_unit_amount`.
577    pub enabled: bool,
578
579    /// The maximum unit amount the customer can specify for this item.
580    #[serde(skip_serializing_if = "Option::is_none")]
581    pub maximum: Option<i64>,
582
583    /// The minimum unit amount the customer can specify for this item.
584    ///
585    /// Must be at least the minimum charge amount.
586    #[serde(skip_serializing_if = "Option::is_none")]
587    pub minimum: Option<i64>,
588
589    /// The starting unit amount which can be updated by the customer.
590    #[serde(skip_serializing_if = "Option::is_none")]
591    pub preset: Option<i64>,
592}
593
594#[derive(Clone, Debug, Default, Deserialize, Serialize)]
595pub struct CreateProductDefaultPriceDataCurrencyOptionsTiers {
596    /// The flat billing amount for an entire tier, regardless of the number of units in the tier.
597    #[serde(skip_serializing_if = "Option::is_none")]
598    pub flat_amount: Option<i64>,
599
600    /// Same as `flat_amount`, but accepts a decimal value representing an integer in the minor units of the currency.
601    ///
602    /// Only one of `flat_amount` and `flat_amount_decimal` can be set.
603    #[serde(skip_serializing_if = "Option::is_none")]
604    pub flat_amount_decimal: Option<String>,
605
606    /// The per unit billing amount for each individual unit for which this tier applies.
607    #[serde(skip_serializing_if = "Option::is_none")]
608    pub unit_amount: Option<i64>,
609
610    /// Same as `unit_amount`, but accepts a decimal value in cents (or local equivalent) with at most 12 decimal places.
611    ///
612    /// Only one of `unit_amount` and `unit_amount_decimal` can be set.
613    #[serde(skip_serializing_if = "Option::is_none")]
614    pub unit_amount_decimal: Option<String>,
615
616    /// Specifies the upper bound of this tier.
617    ///
618    /// The lower bound of a tier is the upper bound of the previous tier adding one.
619    /// Use `inf` to define a fallback tier.
620    pub up_to: Option<UpTo>,
621}
622
623/// An enum representing the possible values of an `CreateProductDefaultPriceDataCurrencyOptions`'s `tax_behavior` field.
624#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
625#[serde(rename_all = "snake_case")]
626pub enum CreateProductDefaultPriceDataCurrencyOptionsTaxBehavior {
627    Exclusive,
628    Inclusive,
629    Unspecified,
630}
631
632impl CreateProductDefaultPriceDataCurrencyOptionsTaxBehavior {
633    pub fn as_str(self) -> &'static str {
634        match self {
635            CreateProductDefaultPriceDataCurrencyOptionsTaxBehavior::Exclusive => "exclusive",
636            CreateProductDefaultPriceDataCurrencyOptionsTaxBehavior::Inclusive => "inclusive",
637            CreateProductDefaultPriceDataCurrencyOptionsTaxBehavior::Unspecified => "unspecified",
638        }
639    }
640}
641
642impl AsRef<str> for CreateProductDefaultPriceDataCurrencyOptionsTaxBehavior {
643    fn as_ref(&self) -> &str {
644        self.as_str()
645    }
646}
647
648impl std::fmt::Display for CreateProductDefaultPriceDataCurrencyOptionsTaxBehavior {
649    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
650        self.as_str().fmt(f)
651    }
652}
653impl std::default::Default for CreateProductDefaultPriceDataCurrencyOptionsTaxBehavior {
654    fn default() -> Self {
655        Self::Exclusive
656    }
657}
658
659/// An enum representing the possible values of an `CreateProductDefaultPriceDataRecurring`'s `interval` field.
660#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
661#[serde(rename_all = "snake_case")]
662pub enum CreateProductDefaultPriceDataRecurringInterval {
663    Day,
664    Month,
665    Week,
666    Year,
667}
668
669impl CreateProductDefaultPriceDataRecurringInterval {
670    pub fn as_str(self) -> &'static str {
671        match self {
672            CreateProductDefaultPriceDataRecurringInterval::Day => "day",
673            CreateProductDefaultPriceDataRecurringInterval::Month => "month",
674            CreateProductDefaultPriceDataRecurringInterval::Week => "week",
675            CreateProductDefaultPriceDataRecurringInterval::Year => "year",
676        }
677    }
678}
679
680impl AsRef<str> for CreateProductDefaultPriceDataRecurringInterval {
681    fn as_ref(&self) -> &str {
682        self.as_str()
683    }
684}
685
686impl std::fmt::Display for CreateProductDefaultPriceDataRecurringInterval {
687    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
688        self.as_str().fmt(f)
689    }
690}
691impl std::default::Default for CreateProductDefaultPriceDataRecurringInterval {
692    fn default() -> Self {
693        Self::Day
694    }
695}
696
697/// An enum representing the possible values of an `CreateProductDefaultPriceData`'s `tax_behavior` field.
698#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
699#[serde(rename_all = "snake_case")]
700pub enum CreateProductDefaultPriceDataTaxBehavior {
701    Exclusive,
702    Inclusive,
703    Unspecified,
704}
705
706impl CreateProductDefaultPriceDataTaxBehavior {
707    pub fn as_str(self) -> &'static str {
708        match self {
709            CreateProductDefaultPriceDataTaxBehavior::Exclusive => "exclusive",
710            CreateProductDefaultPriceDataTaxBehavior::Inclusive => "inclusive",
711            CreateProductDefaultPriceDataTaxBehavior::Unspecified => "unspecified",
712        }
713    }
714}
715
716impl AsRef<str> for CreateProductDefaultPriceDataTaxBehavior {
717    fn as_ref(&self) -> &str {
718        self.as_str()
719    }
720}
721
722impl std::fmt::Display for CreateProductDefaultPriceDataTaxBehavior {
723    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
724        self.as_str().fmt(f)
725    }
726}
727impl std::default::Default for CreateProductDefaultPriceDataTaxBehavior {
728    fn default() -> Self {
729        Self::Exclusive
730    }
731}
732
733/// An enum representing the possible values of an `Product`'s `type` field.
734#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
735#[serde(rename_all = "snake_case")]
736pub enum ProductType {
737    Good,
738    Service,
739}
740
741impl ProductType {
742    pub fn as_str(self) -> &'static str {
743        match self {
744            ProductType::Good => "good",
745            ProductType::Service => "service",
746        }
747    }
748}
749
750impl AsRef<str> for ProductType {
751    fn as_ref(&self) -> &str {
752        self.as_str()
753    }
754}
755
756impl std::fmt::Display for ProductType {
757    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
758        self.as_str().fmt(f)
759    }
760}
761impl std::default::Default for ProductType {
762    fn default() -> Self {
763        Self::Good
764    }
765}