Skip to main content

stripe_core/customer_session/
requests.rs

1use stripe_client_core::{
2    RequestBuilder, StripeBlockingClient, StripeClient, StripeMethod, StripeRequest,
3};
4
5#[derive(Clone, Eq, PartialEq)]
6#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
7#[derive(serde::Serialize)]
8struct CreateCustomerSessionBuilder {
9    components: CreateCustomerSessionComponents,
10    #[serde(skip_serializing_if = "Option::is_none")]
11    customer: Option<String>,
12    #[serde(skip_serializing_if = "Option::is_none")]
13    customer_account: Option<String>,
14    #[serde(skip_serializing_if = "Option::is_none")]
15    expand: Option<Vec<String>>,
16}
17#[cfg(feature = "redact-generated-debug")]
18impl std::fmt::Debug for CreateCustomerSessionBuilder {
19    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
20        f.debug_struct("CreateCustomerSessionBuilder").finish_non_exhaustive()
21    }
22}
23impl CreateCustomerSessionBuilder {
24    fn new(components: impl Into<CreateCustomerSessionComponents>) -> Self {
25        Self { components: components.into(), customer: None, customer_account: None, expand: None }
26    }
27}
28/// Configuration for each component. At least 1 component must be enabled.
29#[derive(Clone, Eq, PartialEq)]
30#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
31#[derive(serde::Serialize)]
32pub struct CreateCustomerSessionComponents {
33    /// Configuration for buy button.
34    #[serde(skip_serializing_if = "Option::is_none")]
35    pub buy_button: Option<CreateCustomerSessionComponentsBuyButton>,
36    /// Configuration for the customer sheet.
37    #[serde(skip_serializing_if = "Option::is_none")]
38    pub customer_sheet: Option<CreateCustomerSessionComponentsCustomerSheet>,
39    /// Configuration for the mobile payment element.
40    #[serde(skip_serializing_if = "Option::is_none")]
41    pub mobile_payment_element: Option<CreateCustomerSessionComponentsMobilePaymentElement>,
42    /// Configuration for the Payment Element.
43    #[serde(skip_serializing_if = "Option::is_none")]
44    pub payment_element: Option<CreateCustomerSessionComponentsPaymentElement>,
45    /// Configuration for the pricing table.
46    #[serde(skip_serializing_if = "Option::is_none")]
47    pub pricing_table: Option<CreateCustomerSessionComponentsPricingTable>,
48}
49#[cfg(feature = "redact-generated-debug")]
50impl std::fmt::Debug for CreateCustomerSessionComponents {
51    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
52        f.debug_struct("CreateCustomerSessionComponents").finish_non_exhaustive()
53    }
54}
55impl CreateCustomerSessionComponents {
56    pub fn new() -> Self {
57        Self {
58            buy_button: None,
59            customer_sheet: None,
60            mobile_payment_element: None,
61            payment_element: None,
62            pricing_table: None,
63        }
64    }
65}
66impl Default for CreateCustomerSessionComponents {
67    fn default() -> Self {
68        Self::new()
69    }
70}
71/// Configuration for buy button.
72#[derive(Copy, Clone, Eq, PartialEq)]
73#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
74#[derive(serde::Serialize)]
75pub struct CreateCustomerSessionComponentsBuyButton {
76    /// Whether the buy button is enabled.
77    pub enabled: bool,
78}
79#[cfg(feature = "redact-generated-debug")]
80impl std::fmt::Debug for CreateCustomerSessionComponentsBuyButton {
81    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
82        f.debug_struct("CreateCustomerSessionComponentsBuyButton").finish_non_exhaustive()
83    }
84}
85impl CreateCustomerSessionComponentsBuyButton {
86    pub fn new(enabled: impl Into<bool>) -> Self {
87        Self { enabled: enabled.into() }
88    }
89}
90/// Configuration for the customer sheet.
91#[derive(Clone, Eq, PartialEq)]
92#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
93#[derive(serde::Serialize)]
94pub struct CreateCustomerSessionComponentsCustomerSheet {
95    /// Whether the customer sheet is enabled.
96    pub enabled: bool,
97    /// This hash defines whether the customer sheet supports certain features.
98    #[serde(skip_serializing_if = "Option::is_none")]
99    pub features: Option<CreateCustomerSessionComponentsCustomerSheetFeatures>,
100}
101#[cfg(feature = "redact-generated-debug")]
102impl std::fmt::Debug for CreateCustomerSessionComponentsCustomerSheet {
103    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
104        f.debug_struct("CreateCustomerSessionComponentsCustomerSheet").finish_non_exhaustive()
105    }
106}
107impl CreateCustomerSessionComponentsCustomerSheet {
108    pub fn new(enabled: impl Into<bool>) -> Self {
109        Self { enabled: enabled.into(), features: None }
110    }
111}
112/// This hash defines whether the customer sheet supports certain features.
113#[derive(Clone, Eq, PartialEq)]
114#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
115#[derive(serde::Serialize)]
116pub struct CreateCustomerSessionComponentsCustomerSheetFeatures {
117    /// A list of [`allow_redisplay`](https://docs.stripe.com/api/payment_methods/object#payment_method_object-allow_redisplay) values that controls which saved payment methods the customer sheet displays by filtering to only show payment methods with an `allow_redisplay` value that is present in this list.
118    ///
119    /// If not specified, defaults to ["always"].
120    /// In order to display all saved payment methods, specify ["always", "limited", "unspecified"].
121    #[serde(skip_serializing_if = "Option::is_none")]
122    pub payment_method_allow_redisplay_filters: Option<
123        Vec<CreateCustomerSessionComponentsCustomerSheetFeaturesPaymentMethodAllowRedisplayFilters>,
124    >,
125    /// Controls whether the customer sheet displays the option to remove a saved payment method."
126    ///
127    /// Allowing buyers to remove their saved payment methods impacts subscriptions that depend on that payment method.
128    /// Removing the payment method detaches the [`customer` object](https://docs.stripe.com/api/payment_methods/object#payment_method_object-customer) from that [PaymentMethod](https://docs.stripe.com/api/payment_methods).
129    #[serde(skip_serializing_if = "Option::is_none")]
130    pub payment_method_remove:
131        Option<CreateCustomerSessionComponentsCustomerSheetFeaturesPaymentMethodRemove>,
132}
133#[cfg(feature = "redact-generated-debug")]
134impl std::fmt::Debug for CreateCustomerSessionComponentsCustomerSheetFeatures {
135    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
136        f.debug_struct("CreateCustomerSessionComponentsCustomerSheetFeatures")
137            .finish_non_exhaustive()
138    }
139}
140impl CreateCustomerSessionComponentsCustomerSheetFeatures {
141    pub fn new() -> Self {
142        Self { payment_method_allow_redisplay_filters: None, payment_method_remove: None }
143    }
144}
145impl Default for CreateCustomerSessionComponentsCustomerSheetFeatures {
146    fn default() -> Self {
147        Self::new()
148    }
149}
150/// A list of [`allow_redisplay`](https://docs.stripe.com/api/payment_methods/object#payment_method_object-allow_redisplay) values that controls which saved payment methods the customer sheet displays by filtering to only show payment methods with an `allow_redisplay` value that is present in this list.
151///
152/// If not specified, defaults to ["always"].
153/// In order to display all saved payment methods, specify ["always", "limited", "unspecified"].
154#[derive(Clone, Eq, PartialEq)]
155#[non_exhaustive]
156pub enum CreateCustomerSessionComponentsCustomerSheetFeaturesPaymentMethodAllowRedisplayFilters {
157    Always,
158    Limited,
159    Unspecified,
160    /// An unrecognized value from Stripe. Should not be used as a request parameter.
161    Unknown(String),
162}
163impl CreateCustomerSessionComponentsCustomerSheetFeaturesPaymentMethodAllowRedisplayFilters {
164    pub fn as_str(&self) -> &str {
165        use CreateCustomerSessionComponentsCustomerSheetFeaturesPaymentMethodAllowRedisplayFilters::*;
166        match self {
167            Always => "always",
168            Limited => "limited",
169            Unspecified => "unspecified",
170            Unknown(v) => v,
171        }
172    }
173}
174
175impl std::str::FromStr
176    for CreateCustomerSessionComponentsCustomerSheetFeaturesPaymentMethodAllowRedisplayFilters
177{
178    type Err = std::convert::Infallible;
179    fn from_str(s: &str) -> Result<Self, Self::Err> {
180        use CreateCustomerSessionComponentsCustomerSheetFeaturesPaymentMethodAllowRedisplayFilters::*;
181        match s {
182            "always" => Ok(Always),
183            "limited" => Ok(Limited),
184            "unspecified" => Ok(Unspecified),
185            v => {
186                tracing::warn!(
187                    "Unknown value '{}' for enum '{}'",
188                    v,
189                    "CreateCustomerSessionComponentsCustomerSheetFeaturesPaymentMethodAllowRedisplayFilters"
190                );
191                Ok(Unknown(v.to_owned()))
192            }
193        }
194    }
195}
196impl std::fmt::Display
197    for CreateCustomerSessionComponentsCustomerSheetFeaturesPaymentMethodAllowRedisplayFilters
198{
199    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
200        f.write_str(self.as_str())
201    }
202}
203
204#[cfg(not(feature = "redact-generated-debug"))]
205impl std::fmt::Debug
206    for CreateCustomerSessionComponentsCustomerSheetFeaturesPaymentMethodAllowRedisplayFilters
207{
208    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
209        f.write_str(self.as_str())
210    }
211}
212#[cfg(feature = "redact-generated-debug")]
213impl std::fmt::Debug
214    for CreateCustomerSessionComponentsCustomerSheetFeaturesPaymentMethodAllowRedisplayFilters
215{
216    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
217        f.debug_struct(stringify!(
218            CreateCustomerSessionComponentsCustomerSheetFeaturesPaymentMethodAllowRedisplayFilters
219        ))
220        .finish_non_exhaustive()
221    }
222}
223impl serde::Serialize
224    for CreateCustomerSessionComponentsCustomerSheetFeaturesPaymentMethodAllowRedisplayFilters
225{
226    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
227    where
228        S: serde::Serializer,
229    {
230        serializer.serialize_str(self.as_str())
231    }
232}
233#[cfg(feature = "deserialize")]
234impl<'de> serde::Deserialize<'de>
235    for CreateCustomerSessionComponentsCustomerSheetFeaturesPaymentMethodAllowRedisplayFilters
236{
237    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
238        use std::str::FromStr;
239        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
240        Ok(Self::from_str(&s).expect("infallible"))
241    }
242}
243/// Controls whether the customer sheet displays the option to remove a saved payment method."
244///
245/// Allowing buyers to remove their saved payment methods impacts subscriptions that depend on that payment method.
246/// Removing the payment method detaches the [`customer` object](https://docs.stripe.com/api/payment_methods/object#payment_method_object-customer) from that [PaymentMethod](https://docs.stripe.com/api/payment_methods).
247#[derive(Clone, Eq, PartialEq)]
248#[non_exhaustive]
249pub enum CreateCustomerSessionComponentsCustomerSheetFeaturesPaymentMethodRemove {
250    Disabled,
251    Enabled,
252    /// An unrecognized value from Stripe. Should not be used as a request parameter.
253    Unknown(String),
254}
255impl CreateCustomerSessionComponentsCustomerSheetFeaturesPaymentMethodRemove {
256    pub fn as_str(&self) -> &str {
257        use CreateCustomerSessionComponentsCustomerSheetFeaturesPaymentMethodRemove::*;
258        match self {
259            Disabled => "disabled",
260            Enabled => "enabled",
261            Unknown(v) => v,
262        }
263    }
264}
265
266impl std::str::FromStr for CreateCustomerSessionComponentsCustomerSheetFeaturesPaymentMethodRemove {
267    type Err = std::convert::Infallible;
268    fn from_str(s: &str) -> Result<Self, Self::Err> {
269        use CreateCustomerSessionComponentsCustomerSheetFeaturesPaymentMethodRemove::*;
270        match s {
271            "disabled" => Ok(Disabled),
272            "enabled" => Ok(Enabled),
273            v => {
274                tracing::warn!(
275                    "Unknown value '{}' for enum '{}'",
276                    v,
277                    "CreateCustomerSessionComponentsCustomerSheetFeaturesPaymentMethodRemove"
278                );
279                Ok(Unknown(v.to_owned()))
280            }
281        }
282    }
283}
284impl std::fmt::Display for CreateCustomerSessionComponentsCustomerSheetFeaturesPaymentMethodRemove {
285    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
286        f.write_str(self.as_str())
287    }
288}
289
290#[cfg(not(feature = "redact-generated-debug"))]
291impl std::fmt::Debug for CreateCustomerSessionComponentsCustomerSheetFeaturesPaymentMethodRemove {
292    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
293        f.write_str(self.as_str())
294    }
295}
296#[cfg(feature = "redact-generated-debug")]
297impl std::fmt::Debug for CreateCustomerSessionComponentsCustomerSheetFeaturesPaymentMethodRemove {
298    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
299        f.debug_struct(stringify!(
300            CreateCustomerSessionComponentsCustomerSheetFeaturesPaymentMethodRemove
301        ))
302        .finish_non_exhaustive()
303    }
304}
305impl serde::Serialize for CreateCustomerSessionComponentsCustomerSheetFeaturesPaymentMethodRemove {
306    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
307    where
308        S: serde::Serializer,
309    {
310        serializer.serialize_str(self.as_str())
311    }
312}
313#[cfg(feature = "deserialize")]
314impl<'de> serde::Deserialize<'de>
315    for CreateCustomerSessionComponentsCustomerSheetFeaturesPaymentMethodRemove
316{
317    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
318        use std::str::FromStr;
319        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
320        Ok(Self::from_str(&s).expect("infallible"))
321    }
322}
323/// Configuration for the mobile payment element.
324#[derive(Clone, Eq, PartialEq)]
325#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
326#[derive(serde::Serialize)]
327pub struct CreateCustomerSessionComponentsMobilePaymentElement {
328    /// Whether the mobile payment element is enabled.
329    pub enabled: bool,
330    /// This hash defines whether the mobile payment element supports certain features.
331    #[serde(skip_serializing_if = "Option::is_none")]
332    pub features: Option<CreateCustomerSessionComponentsMobilePaymentElementFeatures>,
333}
334#[cfg(feature = "redact-generated-debug")]
335impl std::fmt::Debug for CreateCustomerSessionComponentsMobilePaymentElement {
336    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
337        f.debug_struct("CreateCustomerSessionComponentsMobilePaymentElement")
338            .finish_non_exhaustive()
339    }
340}
341impl CreateCustomerSessionComponentsMobilePaymentElement {
342    pub fn new(enabled: impl Into<bool>) -> Self {
343        Self { enabled: enabled.into(), features: None }
344    }
345}
346/// This hash defines whether the mobile payment element supports certain features.
347#[derive(Clone, Eq, PartialEq)]
348#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
349#[derive(serde::Serialize)]
350pub struct CreateCustomerSessionComponentsMobilePaymentElementFeatures {
351        /// A list of [`allow_redisplay`](https://docs.stripe.com/api/payment_methods/object#payment_method_object-allow_redisplay) values that controls which saved payment methods the mobile payment element displays by filtering to only show payment methods with an `allow_redisplay` value that is present in this list.
352    ///
353        /// If not specified, defaults to ["always"].
354    /// In order to display all saved payment methods, specify ["always", "limited", "unspecified"].
355#[serde(skip_serializing_if = "Option::is_none")]
356pub payment_method_allow_redisplay_filters: Option<Vec<CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodAllowRedisplayFilters>>,
357    /// Controls whether or not the mobile payment element shows saved payment methods.
358#[serde(skip_serializing_if = "Option::is_none")]
359pub payment_method_redisplay: Option<CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodRedisplay>,
360    /// Controls whether the mobile payment element displays the option to remove a saved payment method."
361    ///
362        /// Allowing buyers to remove their saved payment methods impacts subscriptions that depend on that payment method.
363    /// Removing the payment method detaches the [`customer` object](https://docs.stripe.com/api/payment_methods/object#payment_method_object-customer) from that [PaymentMethod](https://docs.stripe.com/api/payment_methods).
364#[serde(skip_serializing_if = "Option::is_none")]
365pub payment_method_remove: Option<CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodRemove>,
366        /// Controls whether the mobile payment element displays a checkbox offering to save a new payment method.
367    ///
368        /// If a customer checks the box, the [`allow_redisplay`](https://docs.stripe.com/api/payment_methods/object#payment_method_object-allow_redisplay) value on the PaymentMethod is set to `'always'` at confirmation time.
369    /// For PaymentIntents, the [`setup_future_usage`](https://docs.stripe.com/api/payment_intents/object#payment_intent_object-setup_future_usage) value is also set to the value defined in `payment_method_save_usage`.
370#[serde(skip_serializing_if = "Option::is_none")]
371pub payment_method_save: Option<CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodSave>,
372        /// Allows overriding the value of allow_override when saving a new payment method when payment_method_save is set to disabled.
373    /// Use values: "always", "limited", or "unspecified".
374    ///
375    /// If not specified, defaults to `nil` (no override value).
376#[serde(skip_serializing_if = "Option::is_none")]
377pub payment_method_save_allow_redisplay_override: Option<CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodSaveAllowRedisplayOverride>,
378
379}
380#[cfg(feature = "redact-generated-debug")]
381impl std::fmt::Debug for CreateCustomerSessionComponentsMobilePaymentElementFeatures {
382    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
383        f.debug_struct("CreateCustomerSessionComponentsMobilePaymentElementFeatures")
384            .finish_non_exhaustive()
385    }
386}
387impl CreateCustomerSessionComponentsMobilePaymentElementFeatures {
388    pub fn new() -> Self {
389        Self {
390            payment_method_allow_redisplay_filters: None,
391            payment_method_redisplay: None,
392            payment_method_remove: None,
393            payment_method_save: None,
394            payment_method_save_allow_redisplay_override: None,
395        }
396    }
397}
398impl Default for CreateCustomerSessionComponentsMobilePaymentElementFeatures {
399    fn default() -> Self {
400        Self::new()
401    }
402}
403/// A list of [`allow_redisplay`](https://docs.stripe.com/api/payment_methods/object#payment_method_object-allow_redisplay) values that controls which saved payment methods the mobile payment element displays by filtering to only show payment methods with an `allow_redisplay` value that is present in this list.
404///
405/// If not specified, defaults to ["always"].
406/// In order to display all saved payment methods, specify ["always", "limited", "unspecified"].
407#[derive(Clone, Eq, PartialEq)]
408#[non_exhaustive]
409pub enum CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodAllowRedisplayFilters
410{
411    Always,
412    Limited,
413    Unspecified,
414    /// An unrecognized value from Stripe. Should not be used as a request parameter.
415    Unknown(String),
416}
417impl CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodAllowRedisplayFilters {
418    pub fn as_str(&self) -> &str {
419        use CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodAllowRedisplayFilters::*;
420        match self {
421            Always => "always",
422            Limited => "limited",
423            Unspecified => "unspecified",
424            Unknown(v) => v,
425        }
426    }
427}
428
429impl std::str::FromStr for CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodAllowRedisplayFilters {
430    type Err = std::convert::Infallible;
431    fn from_str(s: &str) -> Result<Self, Self::Err> {
432        use CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodAllowRedisplayFilters::*;
433        match s {
434    "always" => Ok(Always),
435"limited" => Ok(Limited),
436"unspecified" => Ok(Unspecified),
437v => { tracing::warn!("Unknown value '{}' for enum '{}'", v, "CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodAllowRedisplayFilters"); Ok(Unknown(v.to_owned())) }
438
439        }
440    }
441}
442impl std::fmt::Display for CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodAllowRedisplayFilters {
443    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
444        f.write_str(self.as_str())
445    }
446}
447
448#[cfg(not(feature = "redact-generated-debug"))]
449impl std::fmt::Debug for CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodAllowRedisplayFilters {
450    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
451        f.write_str(self.as_str())
452    }
453}
454#[cfg(feature = "redact-generated-debug")]
455impl std::fmt::Debug for CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodAllowRedisplayFilters {
456    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
457        f.debug_struct(stringify!(CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodAllowRedisplayFilters)).finish_non_exhaustive()
458    }
459}
460impl serde::Serialize for CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodAllowRedisplayFilters {
461    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer {
462        serializer.serialize_str(self.as_str())
463    }
464}
465#[cfg(feature = "deserialize")]
466impl<'de> serde::Deserialize<'de> for CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodAllowRedisplayFilters {
467    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
468        use std::str::FromStr;
469        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
470        Ok(Self::from_str(&s).expect("infallible"))
471    }
472}
473/// Controls whether or not the mobile payment element shows saved payment methods.
474#[derive(Clone, Eq, PartialEq)]
475#[non_exhaustive]
476pub enum CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodRedisplay {
477    Disabled,
478    Enabled,
479    /// An unrecognized value from Stripe. Should not be used as a request parameter.
480    Unknown(String),
481}
482impl CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodRedisplay {
483    pub fn as_str(&self) -> &str {
484        use CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodRedisplay::*;
485        match self {
486            Disabled => "disabled",
487            Enabled => "enabled",
488            Unknown(v) => v,
489        }
490    }
491}
492
493impl std::str::FromStr
494    for CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodRedisplay
495{
496    type Err = std::convert::Infallible;
497    fn from_str(s: &str) -> Result<Self, Self::Err> {
498        use CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodRedisplay::*;
499        match s {
500            "disabled" => Ok(Disabled),
501            "enabled" => Ok(Enabled),
502            v => {
503                tracing::warn!(
504                    "Unknown value '{}' for enum '{}'",
505                    v,
506                    "CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodRedisplay"
507                );
508                Ok(Unknown(v.to_owned()))
509            }
510        }
511    }
512}
513impl std::fmt::Display
514    for CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodRedisplay
515{
516    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
517        f.write_str(self.as_str())
518    }
519}
520
521#[cfg(not(feature = "redact-generated-debug"))]
522impl std::fmt::Debug
523    for CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodRedisplay
524{
525    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
526        f.write_str(self.as_str())
527    }
528}
529#[cfg(feature = "redact-generated-debug")]
530impl std::fmt::Debug
531    for CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodRedisplay
532{
533    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
534        f.debug_struct(stringify!(
535            CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodRedisplay
536        ))
537        .finish_non_exhaustive()
538    }
539}
540impl serde::Serialize
541    for CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodRedisplay
542{
543    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
544    where
545        S: serde::Serializer,
546    {
547        serializer.serialize_str(self.as_str())
548    }
549}
550#[cfg(feature = "deserialize")]
551impl<'de> serde::Deserialize<'de>
552    for CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodRedisplay
553{
554    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
555        use std::str::FromStr;
556        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
557        Ok(Self::from_str(&s).expect("infallible"))
558    }
559}
560/// Controls whether the mobile payment element displays the option to remove a saved payment method."
561///
562/// Allowing buyers to remove their saved payment methods impacts subscriptions that depend on that payment method.
563/// Removing the payment method detaches the [`customer` object](https://docs.stripe.com/api/payment_methods/object#payment_method_object-customer) from that [PaymentMethod](https://docs.stripe.com/api/payment_methods).
564#[derive(Clone, Eq, PartialEq)]
565#[non_exhaustive]
566pub enum CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodRemove {
567    Disabled,
568    Enabled,
569    /// An unrecognized value from Stripe. Should not be used as a request parameter.
570    Unknown(String),
571}
572impl CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodRemove {
573    pub fn as_str(&self) -> &str {
574        use CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodRemove::*;
575        match self {
576            Disabled => "disabled",
577            Enabled => "enabled",
578            Unknown(v) => v,
579        }
580    }
581}
582
583impl std::str::FromStr
584    for CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodRemove
585{
586    type Err = std::convert::Infallible;
587    fn from_str(s: &str) -> Result<Self, Self::Err> {
588        use CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodRemove::*;
589        match s {
590            "disabled" => Ok(Disabled),
591            "enabled" => Ok(Enabled),
592            v => {
593                tracing::warn!(
594                    "Unknown value '{}' for enum '{}'",
595                    v,
596                    "CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodRemove"
597                );
598                Ok(Unknown(v.to_owned()))
599            }
600        }
601    }
602}
603impl std::fmt::Display
604    for CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodRemove
605{
606    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
607        f.write_str(self.as_str())
608    }
609}
610
611#[cfg(not(feature = "redact-generated-debug"))]
612impl std::fmt::Debug
613    for CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodRemove
614{
615    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
616        f.write_str(self.as_str())
617    }
618}
619#[cfg(feature = "redact-generated-debug")]
620impl std::fmt::Debug
621    for CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodRemove
622{
623    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
624        f.debug_struct(stringify!(
625            CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodRemove
626        ))
627        .finish_non_exhaustive()
628    }
629}
630impl serde::Serialize
631    for CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodRemove
632{
633    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
634    where
635        S: serde::Serializer,
636    {
637        serializer.serialize_str(self.as_str())
638    }
639}
640#[cfg(feature = "deserialize")]
641impl<'de> serde::Deserialize<'de>
642    for CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodRemove
643{
644    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
645        use std::str::FromStr;
646        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
647        Ok(Self::from_str(&s).expect("infallible"))
648    }
649}
650/// Controls whether the mobile payment element displays a checkbox offering to save a new payment method.
651///
652/// If a customer checks the box, the [`allow_redisplay`](https://docs.stripe.com/api/payment_methods/object#payment_method_object-allow_redisplay) value on the PaymentMethod is set to `'always'` at confirmation time.
653/// For PaymentIntents, the [`setup_future_usage`](https://docs.stripe.com/api/payment_intents/object#payment_intent_object-setup_future_usage) value is also set to the value defined in `payment_method_save_usage`.
654#[derive(Clone, Eq, PartialEq)]
655#[non_exhaustive]
656pub enum CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodSave {
657    Disabled,
658    Enabled,
659    /// An unrecognized value from Stripe. Should not be used as a request parameter.
660    Unknown(String),
661}
662impl CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodSave {
663    pub fn as_str(&self) -> &str {
664        use CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodSave::*;
665        match self {
666            Disabled => "disabled",
667            Enabled => "enabled",
668            Unknown(v) => v,
669        }
670    }
671}
672
673impl std::str::FromStr
674    for CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodSave
675{
676    type Err = std::convert::Infallible;
677    fn from_str(s: &str) -> Result<Self, Self::Err> {
678        use CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodSave::*;
679        match s {
680            "disabled" => Ok(Disabled),
681            "enabled" => Ok(Enabled),
682            v => {
683                tracing::warn!(
684                    "Unknown value '{}' for enum '{}'",
685                    v,
686                    "CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodSave"
687                );
688                Ok(Unknown(v.to_owned()))
689            }
690        }
691    }
692}
693impl std::fmt::Display
694    for CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodSave
695{
696    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
697        f.write_str(self.as_str())
698    }
699}
700
701#[cfg(not(feature = "redact-generated-debug"))]
702impl std::fmt::Debug
703    for CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodSave
704{
705    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
706        f.write_str(self.as_str())
707    }
708}
709#[cfg(feature = "redact-generated-debug")]
710impl std::fmt::Debug
711    for CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodSave
712{
713    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
714        f.debug_struct(stringify!(
715            CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodSave
716        ))
717        .finish_non_exhaustive()
718    }
719}
720impl serde::Serialize
721    for CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodSave
722{
723    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
724    where
725        S: serde::Serializer,
726    {
727        serializer.serialize_str(self.as_str())
728    }
729}
730#[cfg(feature = "deserialize")]
731impl<'de> serde::Deserialize<'de>
732    for CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodSave
733{
734    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
735        use std::str::FromStr;
736        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
737        Ok(Self::from_str(&s).expect("infallible"))
738    }
739}
740/// Allows overriding the value of allow_override when saving a new payment method when payment_method_save is set to disabled.
741/// Use values: "always", "limited", or "unspecified".
742///
743/// If not specified, defaults to `nil` (no override value).
744#[derive(Clone, Eq, PartialEq)]
745#[non_exhaustive]
746pub enum CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodSaveAllowRedisplayOverride
747{
748    Always,
749    Limited,
750    Unspecified,
751    /// An unrecognized value from Stripe. Should not be used as a request parameter.
752    Unknown(String),
753}
754impl CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodSaveAllowRedisplayOverride {
755    pub fn as_str(&self) -> &str {
756        use CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodSaveAllowRedisplayOverride::*;
757        match self {
758Always => "always",
759Limited => "limited",
760Unspecified => "unspecified",
761Unknown(v) => v,
762
763        }
764    }
765}
766
767impl std::str::FromStr for CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodSaveAllowRedisplayOverride {
768    type Err = std::convert::Infallible;
769    fn from_str(s: &str) -> Result<Self, Self::Err> {
770        use CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodSaveAllowRedisplayOverride::*;
771        match s {
772    "always" => Ok(Always),
773"limited" => Ok(Limited),
774"unspecified" => Ok(Unspecified),
775v => { tracing::warn!("Unknown value '{}' for enum '{}'", v, "CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodSaveAllowRedisplayOverride"); Ok(Unknown(v.to_owned())) }
776
777        }
778    }
779}
780impl std::fmt::Display for CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodSaveAllowRedisplayOverride {
781    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
782        f.write_str(self.as_str())
783    }
784}
785
786#[cfg(not(feature = "redact-generated-debug"))]
787impl std::fmt::Debug for CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodSaveAllowRedisplayOverride {
788    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
789        f.write_str(self.as_str())
790    }
791}
792#[cfg(feature = "redact-generated-debug")]
793impl std::fmt::Debug for CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodSaveAllowRedisplayOverride {
794    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
795        f.debug_struct(stringify!(CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodSaveAllowRedisplayOverride)).finish_non_exhaustive()
796    }
797}
798impl serde::Serialize for CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodSaveAllowRedisplayOverride {
799    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer {
800        serializer.serialize_str(self.as_str())
801    }
802}
803#[cfg(feature = "deserialize")]
804impl<'de> serde::Deserialize<'de> for CreateCustomerSessionComponentsMobilePaymentElementFeaturesPaymentMethodSaveAllowRedisplayOverride {
805    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
806        use std::str::FromStr;
807        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
808        Ok(Self::from_str(&s).expect("infallible"))
809    }
810}
811/// Configuration for the Payment Element.
812#[derive(Clone, Eq, PartialEq)]
813#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
814#[derive(serde::Serialize)]
815pub struct CreateCustomerSessionComponentsPaymentElement {
816    /// Whether the Payment Element is enabled.
817    pub enabled: bool,
818    /// This hash defines whether the Payment Element supports certain features.
819    #[serde(skip_serializing_if = "Option::is_none")]
820    pub features: Option<CreateCustomerSessionComponentsPaymentElementFeatures>,
821}
822#[cfg(feature = "redact-generated-debug")]
823impl std::fmt::Debug for CreateCustomerSessionComponentsPaymentElement {
824    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
825        f.debug_struct("CreateCustomerSessionComponentsPaymentElement").finish_non_exhaustive()
826    }
827}
828impl CreateCustomerSessionComponentsPaymentElement {
829    pub fn new(enabled: impl Into<bool>) -> Self {
830        Self { enabled: enabled.into(), features: None }
831    }
832}
833/// This hash defines whether the Payment Element supports certain features.
834#[derive(Clone, Eq, PartialEq)]
835#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
836#[derive(serde::Serialize)]
837pub struct CreateCustomerSessionComponentsPaymentElementFeatures {
838    /// A list of [`allow_redisplay`](https://docs.stripe.com/api/payment_methods/object#payment_method_object-allow_redisplay) values that controls which saved payment methods the Payment Element displays by filtering to only show payment methods with an `allow_redisplay` value that is present in this list.
839    ///
840    /// If not specified, defaults to ["always"].
841    /// In order to display all saved payment methods, specify ["always", "limited", "unspecified"].
842    #[serde(skip_serializing_if = "Option::is_none")]
843    pub payment_method_allow_redisplay_filters: Option<
844        Vec<
845            CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodAllowRedisplayFilters,
846        >,
847    >,
848    /// Controls whether or not the Payment Element shows saved payment methods.
849    /// This parameter defaults to `disabled`.
850    #[serde(skip_serializing_if = "Option::is_none")]
851    pub payment_method_redisplay:
852        Option<CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodRedisplay>,
853    /// Determines the max number of saved payment methods for the Payment Element to display.
854    /// This parameter defaults to `3`.
855    /// The maximum redisplay limit is `10`.
856    #[serde(skip_serializing_if = "Option::is_none")]
857    pub payment_method_redisplay_limit: Option<i64>,
858    /// Controls whether the Payment Element displays the option to remove a saved payment method.
859    /// This parameter defaults to `disabled`.
860    ///
861    /// Allowing buyers to remove their saved payment methods impacts subscriptions that depend on that payment method.
862    /// Removing the payment method detaches the [`customer` object](https://docs.stripe.com/api/payment_methods/object#payment_method_object-customer) from that [PaymentMethod](https://docs.stripe.com/api/payment_methods).
863    #[serde(skip_serializing_if = "Option::is_none")]
864    pub payment_method_remove:
865        Option<CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodRemove>,
866    /// Controls whether the Payment Element displays a checkbox offering to save a new payment method.
867    /// This parameter defaults to `disabled`.
868    ///
869    /// If a customer checks the box, the [`allow_redisplay`](https://docs.stripe.com/api/payment_methods/object#payment_method_object-allow_redisplay) value on the PaymentMethod is set to `'always'` at confirmation time.
870    /// For PaymentIntents, the [`setup_future_usage`](https://docs.stripe.com/api/payment_intents/object#payment_intent_object-setup_future_usage) value is also set to the value defined in `payment_method_save_usage`.
871    #[serde(skip_serializing_if = "Option::is_none")]
872    pub payment_method_save:
873        Option<CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodSave>,
874    /// When using PaymentIntents and the customer checks the save checkbox, this field determines the [`setup_future_usage`](https://docs.stripe.com/api/payment_intents/object#payment_intent_object-setup_future_usage) value used to confirm the PaymentIntent.
875    ///
876    /// When using SetupIntents, directly configure the [`usage`](https://docs.stripe.com/api/setup_intents/object#setup_intent_object-usage) value on SetupIntent creation.
877    #[serde(skip_serializing_if = "Option::is_none")]
878    pub payment_method_save_usage:
879        Option<CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodSaveUsage>,
880}
881#[cfg(feature = "redact-generated-debug")]
882impl std::fmt::Debug for CreateCustomerSessionComponentsPaymentElementFeatures {
883    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
884        f.debug_struct("CreateCustomerSessionComponentsPaymentElementFeatures")
885            .finish_non_exhaustive()
886    }
887}
888impl CreateCustomerSessionComponentsPaymentElementFeatures {
889    pub fn new() -> Self {
890        Self {
891            payment_method_allow_redisplay_filters: None,
892            payment_method_redisplay: None,
893            payment_method_redisplay_limit: None,
894            payment_method_remove: None,
895            payment_method_save: None,
896            payment_method_save_usage: None,
897        }
898    }
899}
900impl Default for CreateCustomerSessionComponentsPaymentElementFeatures {
901    fn default() -> Self {
902        Self::new()
903    }
904}
905/// A list of [`allow_redisplay`](https://docs.stripe.com/api/payment_methods/object#payment_method_object-allow_redisplay) values that controls which saved payment methods the Payment Element displays by filtering to only show payment methods with an `allow_redisplay` value that is present in this list.
906///
907/// If not specified, defaults to ["always"].
908/// In order to display all saved payment methods, specify ["always", "limited", "unspecified"].
909#[derive(Clone, Eq, PartialEq)]
910#[non_exhaustive]
911pub enum CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodAllowRedisplayFilters {
912    Always,
913    Limited,
914    Unspecified,
915    /// An unrecognized value from Stripe. Should not be used as a request parameter.
916    Unknown(String),
917}
918impl CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodAllowRedisplayFilters {
919    pub fn as_str(&self) -> &str {
920        use CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodAllowRedisplayFilters::*;
921        match self {
922            Always => "always",
923            Limited => "limited",
924            Unspecified => "unspecified",
925            Unknown(v) => v,
926        }
927    }
928}
929
930impl std::str::FromStr
931    for CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodAllowRedisplayFilters
932{
933    type Err = std::convert::Infallible;
934    fn from_str(s: &str) -> Result<Self, Self::Err> {
935        use CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodAllowRedisplayFilters::*;
936        match s {
937            "always" => Ok(Always),
938            "limited" => Ok(Limited),
939            "unspecified" => Ok(Unspecified),
940            v => {
941                tracing::warn!(
942                    "Unknown value '{}' for enum '{}'",
943                    v,
944                    "CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodAllowRedisplayFilters"
945                );
946                Ok(Unknown(v.to_owned()))
947            }
948        }
949    }
950}
951impl std::fmt::Display
952    for CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodAllowRedisplayFilters
953{
954    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
955        f.write_str(self.as_str())
956    }
957}
958
959#[cfg(not(feature = "redact-generated-debug"))]
960impl std::fmt::Debug
961    for CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodAllowRedisplayFilters
962{
963    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
964        f.write_str(self.as_str())
965    }
966}
967#[cfg(feature = "redact-generated-debug")]
968impl std::fmt::Debug
969    for CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodAllowRedisplayFilters
970{
971    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
972        f.debug_struct(stringify!(
973            CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodAllowRedisplayFilters
974        ))
975        .finish_non_exhaustive()
976    }
977}
978impl serde::Serialize
979    for CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodAllowRedisplayFilters
980{
981    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
982    where
983        S: serde::Serializer,
984    {
985        serializer.serialize_str(self.as_str())
986    }
987}
988#[cfg(feature = "deserialize")]
989impl<'de> serde::Deserialize<'de>
990    for CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodAllowRedisplayFilters
991{
992    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
993        use std::str::FromStr;
994        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
995        Ok(Self::from_str(&s).expect("infallible"))
996    }
997}
998/// Controls whether or not the Payment Element shows saved payment methods.
999/// This parameter defaults to `disabled`.
1000#[derive(Clone, Eq, PartialEq)]
1001#[non_exhaustive]
1002pub enum CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodRedisplay {
1003    Disabled,
1004    Enabled,
1005    /// An unrecognized value from Stripe. Should not be used as a request parameter.
1006    Unknown(String),
1007}
1008impl CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodRedisplay {
1009    pub fn as_str(&self) -> &str {
1010        use CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodRedisplay::*;
1011        match self {
1012            Disabled => "disabled",
1013            Enabled => "enabled",
1014            Unknown(v) => v,
1015        }
1016    }
1017}
1018
1019impl std::str::FromStr
1020    for CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodRedisplay
1021{
1022    type Err = std::convert::Infallible;
1023    fn from_str(s: &str) -> Result<Self, Self::Err> {
1024        use CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodRedisplay::*;
1025        match s {
1026            "disabled" => Ok(Disabled),
1027            "enabled" => Ok(Enabled),
1028            v => {
1029                tracing::warn!(
1030                    "Unknown value '{}' for enum '{}'",
1031                    v,
1032                    "CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodRedisplay"
1033                );
1034                Ok(Unknown(v.to_owned()))
1035            }
1036        }
1037    }
1038}
1039impl std::fmt::Display
1040    for CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodRedisplay
1041{
1042    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1043        f.write_str(self.as_str())
1044    }
1045}
1046
1047#[cfg(not(feature = "redact-generated-debug"))]
1048impl std::fmt::Debug
1049    for CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodRedisplay
1050{
1051    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1052        f.write_str(self.as_str())
1053    }
1054}
1055#[cfg(feature = "redact-generated-debug")]
1056impl std::fmt::Debug
1057    for CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodRedisplay
1058{
1059    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1060        f.debug_struct(stringify!(
1061            CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodRedisplay
1062        ))
1063        .finish_non_exhaustive()
1064    }
1065}
1066impl serde::Serialize
1067    for CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodRedisplay
1068{
1069    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1070    where
1071        S: serde::Serializer,
1072    {
1073        serializer.serialize_str(self.as_str())
1074    }
1075}
1076#[cfg(feature = "deserialize")]
1077impl<'de> serde::Deserialize<'de>
1078    for CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodRedisplay
1079{
1080    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1081        use std::str::FromStr;
1082        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
1083        Ok(Self::from_str(&s).expect("infallible"))
1084    }
1085}
1086/// Controls whether the Payment Element displays the option to remove a saved payment method.
1087/// This parameter defaults to `disabled`.
1088///
1089/// Allowing buyers to remove their saved payment methods impacts subscriptions that depend on that payment method.
1090/// Removing the payment method detaches the [`customer` object](https://docs.stripe.com/api/payment_methods/object#payment_method_object-customer) from that [PaymentMethod](https://docs.stripe.com/api/payment_methods).
1091#[derive(Clone, Eq, PartialEq)]
1092#[non_exhaustive]
1093pub enum CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodRemove {
1094    Disabled,
1095    Enabled,
1096    /// An unrecognized value from Stripe. Should not be used as a request parameter.
1097    Unknown(String),
1098}
1099impl CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodRemove {
1100    pub fn as_str(&self) -> &str {
1101        use CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodRemove::*;
1102        match self {
1103            Disabled => "disabled",
1104            Enabled => "enabled",
1105            Unknown(v) => v,
1106        }
1107    }
1108}
1109
1110impl std::str::FromStr
1111    for CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodRemove
1112{
1113    type Err = std::convert::Infallible;
1114    fn from_str(s: &str) -> Result<Self, Self::Err> {
1115        use CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodRemove::*;
1116        match s {
1117            "disabled" => Ok(Disabled),
1118            "enabled" => Ok(Enabled),
1119            v => {
1120                tracing::warn!(
1121                    "Unknown value '{}' for enum '{}'",
1122                    v,
1123                    "CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodRemove"
1124                );
1125                Ok(Unknown(v.to_owned()))
1126            }
1127        }
1128    }
1129}
1130impl std::fmt::Display
1131    for CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodRemove
1132{
1133    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1134        f.write_str(self.as_str())
1135    }
1136}
1137
1138#[cfg(not(feature = "redact-generated-debug"))]
1139impl std::fmt::Debug for CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodRemove {
1140    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1141        f.write_str(self.as_str())
1142    }
1143}
1144#[cfg(feature = "redact-generated-debug")]
1145impl std::fmt::Debug for CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodRemove {
1146    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1147        f.debug_struct(stringify!(
1148            CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodRemove
1149        ))
1150        .finish_non_exhaustive()
1151    }
1152}
1153impl serde::Serialize for CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodRemove {
1154    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1155    where
1156        S: serde::Serializer,
1157    {
1158        serializer.serialize_str(self.as_str())
1159    }
1160}
1161#[cfg(feature = "deserialize")]
1162impl<'de> serde::Deserialize<'de>
1163    for CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodRemove
1164{
1165    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1166        use std::str::FromStr;
1167        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
1168        Ok(Self::from_str(&s).expect("infallible"))
1169    }
1170}
1171/// Controls whether the Payment Element displays a checkbox offering to save a new payment method.
1172/// This parameter defaults to `disabled`.
1173///
1174/// If a customer checks the box, the [`allow_redisplay`](https://docs.stripe.com/api/payment_methods/object#payment_method_object-allow_redisplay) value on the PaymentMethod is set to `'always'` at confirmation time.
1175/// For PaymentIntents, the [`setup_future_usage`](https://docs.stripe.com/api/payment_intents/object#payment_intent_object-setup_future_usage) value is also set to the value defined in `payment_method_save_usage`.
1176#[derive(Clone, Eq, PartialEq)]
1177#[non_exhaustive]
1178pub enum CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodSave {
1179    Disabled,
1180    Enabled,
1181    /// An unrecognized value from Stripe. Should not be used as a request parameter.
1182    Unknown(String),
1183}
1184impl CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodSave {
1185    pub fn as_str(&self) -> &str {
1186        use CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodSave::*;
1187        match self {
1188            Disabled => "disabled",
1189            Enabled => "enabled",
1190            Unknown(v) => v,
1191        }
1192    }
1193}
1194
1195impl std::str::FromStr for CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodSave {
1196    type Err = std::convert::Infallible;
1197    fn from_str(s: &str) -> Result<Self, Self::Err> {
1198        use CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodSave::*;
1199        match s {
1200            "disabled" => Ok(Disabled),
1201            "enabled" => Ok(Enabled),
1202            v => {
1203                tracing::warn!(
1204                    "Unknown value '{}' for enum '{}'",
1205                    v,
1206                    "CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodSave"
1207                );
1208                Ok(Unknown(v.to_owned()))
1209            }
1210        }
1211    }
1212}
1213impl std::fmt::Display for CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodSave {
1214    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1215        f.write_str(self.as_str())
1216    }
1217}
1218
1219#[cfg(not(feature = "redact-generated-debug"))]
1220impl std::fmt::Debug for CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodSave {
1221    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1222        f.write_str(self.as_str())
1223    }
1224}
1225#[cfg(feature = "redact-generated-debug")]
1226impl std::fmt::Debug for CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodSave {
1227    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1228        f.debug_struct(stringify!(
1229            CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodSave
1230        ))
1231        .finish_non_exhaustive()
1232    }
1233}
1234impl serde::Serialize for CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodSave {
1235    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1236    where
1237        S: serde::Serializer,
1238    {
1239        serializer.serialize_str(self.as_str())
1240    }
1241}
1242#[cfg(feature = "deserialize")]
1243impl<'de> serde::Deserialize<'de>
1244    for CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodSave
1245{
1246    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1247        use std::str::FromStr;
1248        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
1249        Ok(Self::from_str(&s).expect("infallible"))
1250    }
1251}
1252/// When using PaymentIntents and the customer checks the save checkbox, this field determines the [`setup_future_usage`](https://docs.stripe.com/api/payment_intents/object#payment_intent_object-setup_future_usage) value used to confirm the PaymentIntent.
1253///
1254/// When using SetupIntents, directly configure the [`usage`](https://docs.stripe.com/api/setup_intents/object#setup_intent_object-usage) value on SetupIntent creation.
1255#[derive(Clone, Eq, PartialEq)]
1256#[non_exhaustive]
1257pub enum CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodSaveUsage {
1258    OffSession,
1259    OnSession,
1260    /// An unrecognized value from Stripe. Should not be used as a request parameter.
1261    Unknown(String),
1262}
1263impl CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodSaveUsage {
1264    pub fn as_str(&self) -> &str {
1265        use CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodSaveUsage::*;
1266        match self {
1267            OffSession => "off_session",
1268            OnSession => "on_session",
1269            Unknown(v) => v,
1270        }
1271    }
1272}
1273
1274impl std::str::FromStr
1275    for CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodSaveUsage
1276{
1277    type Err = std::convert::Infallible;
1278    fn from_str(s: &str) -> Result<Self, Self::Err> {
1279        use CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodSaveUsage::*;
1280        match s {
1281            "off_session" => Ok(OffSession),
1282            "on_session" => Ok(OnSession),
1283            v => {
1284                tracing::warn!(
1285                    "Unknown value '{}' for enum '{}'",
1286                    v,
1287                    "CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodSaveUsage"
1288                );
1289                Ok(Unknown(v.to_owned()))
1290            }
1291        }
1292    }
1293}
1294impl std::fmt::Display
1295    for CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodSaveUsage
1296{
1297    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1298        f.write_str(self.as_str())
1299    }
1300}
1301
1302#[cfg(not(feature = "redact-generated-debug"))]
1303impl std::fmt::Debug
1304    for CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodSaveUsage
1305{
1306    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1307        f.write_str(self.as_str())
1308    }
1309}
1310#[cfg(feature = "redact-generated-debug")]
1311impl std::fmt::Debug
1312    for CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodSaveUsage
1313{
1314    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1315        f.debug_struct(stringify!(
1316            CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodSaveUsage
1317        ))
1318        .finish_non_exhaustive()
1319    }
1320}
1321impl serde::Serialize
1322    for CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodSaveUsage
1323{
1324    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1325    where
1326        S: serde::Serializer,
1327    {
1328        serializer.serialize_str(self.as_str())
1329    }
1330}
1331#[cfg(feature = "deserialize")]
1332impl<'de> serde::Deserialize<'de>
1333    for CreateCustomerSessionComponentsPaymentElementFeaturesPaymentMethodSaveUsage
1334{
1335    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1336        use std::str::FromStr;
1337        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
1338        Ok(Self::from_str(&s).expect("infallible"))
1339    }
1340}
1341/// Configuration for the pricing table.
1342#[derive(Copy, Clone, Eq, PartialEq)]
1343#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
1344#[derive(serde::Serialize)]
1345pub struct CreateCustomerSessionComponentsPricingTable {
1346    /// Whether the pricing table is enabled.
1347    pub enabled: bool,
1348}
1349#[cfg(feature = "redact-generated-debug")]
1350impl std::fmt::Debug for CreateCustomerSessionComponentsPricingTable {
1351    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1352        f.debug_struct("CreateCustomerSessionComponentsPricingTable").finish_non_exhaustive()
1353    }
1354}
1355impl CreateCustomerSessionComponentsPricingTable {
1356    pub fn new(enabled: impl Into<bool>) -> Self {
1357        Self { enabled: enabled.into() }
1358    }
1359}
1360/// Creates a Customer Session object that includes a single-use client secret that you can use on your front-end to grant client-side API access for certain customer resources.
1361#[derive(Clone)]
1362#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
1363#[derive(serde::Serialize)]
1364pub struct CreateCustomerSession {
1365    inner: CreateCustomerSessionBuilder,
1366}
1367#[cfg(feature = "redact-generated-debug")]
1368impl std::fmt::Debug for CreateCustomerSession {
1369    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1370        f.debug_struct("CreateCustomerSession").finish_non_exhaustive()
1371    }
1372}
1373impl CreateCustomerSession {
1374    /// Construct a new `CreateCustomerSession`.
1375    pub fn new(components: impl Into<CreateCustomerSessionComponents>) -> Self {
1376        Self { inner: CreateCustomerSessionBuilder::new(components.into()) }
1377    }
1378    /// The ID of an existing customer for which to create the Customer Session.
1379    pub fn customer(mut self, customer: impl Into<String>) -> Self {
1380        self.inner.customer = Some(customer.into());
1381        self
1382    }
1383    /// The ID of an existing Account for which to create the Customer Session.
1384    pub fn customer_account(mut self, customer_account: impl Into<String>) -> Self {
1385        self.inner.customer_account = Some(customer_account.into());
1386        self
1387    }
1388    /// Specifies which fields in the response should be expanded.
1389    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
1390        self.inner.expand = Some(expand.into());
1391        self
1392    }
1393}
1394impl CreateCustomerSession {
1395    /// Send the request and return the deserialized response.
1396    pub async fn send<C: StripeClient>(
1397        &self,
1398        client: &C,
1399    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
1400        self.customize().send(client).await
1401    }
1402
1403    /// Send the request and return the deserialized response, blocking until completion.
1404    pub fn send_blocking<C: StripeBlockingClient>(
1405        &self,
1406        client: &C,
1407    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
1408        self.customize().send_blocking(client)
1409    }
1410}
1411
1412impl StripeRequest for CreateCustomerSession {
1413    type Output = stripe_core::CustomerSession;
1414
1415    fn build(&self) -> RequestBuilder {
1416        RequestBuilder::new(StripeMethod::Post, "/customer_sessions").form(&self.inner)
1417    }
1418}