Skip to main content

stripe_shared/
payment_intent_payment_method_options_mobilepay.rs

1#[derive(Clone, Eq, PartialEq)]
2#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
3#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
4#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
5pub struct PaymentIntentPaymentMethodOptionsMobilepay {
6    /// Controls when the funds will be captured from the customer's account.
7    pub capture_method: Option<PaymentIntentPaymentMethodOptionsMobilepayCaptureMethod>,
8    /// Indicates that you intend to make future payments with this PaymentIntent's payment method.
9    ///
10    /// If you provide a Customer with the PaymentIntent, you can use this parameter to [attach the payment method](/payments/save-during-payment) to the Customer after the PaymentIntent is confirmed and the customer completes any required actions.
11    /// If you don't provide a Customer, you can still [attach](/api/payment_methods/attach) the payment method to a Customer after the transaction completes.
12    ///
13    /// If the payment method is `card_present` and isn't a digital wallet, Stripe creates and attaches a [generated_card](/api/charges/object#charge_object-payment_method_details-card_present-generated_card) payment method representing the card to the Customer instead.
14    ///
15    /// When processing card payments, Stripe uses `setup_future_usage` to help you comply with regional legislation and network rules, such as [SCA](/strong-customer-authentication).
16    pub setup_future_usage: Option<PaymentIntentPaymentMethodOptionsMobilepaySetupFutureUsage>,
17}
18#[cfg(feature = "redact-generated-debug")]
19impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsMobilepay {
20    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
21        f.debug_struct("PaymentIntentPaymentMethodOptionsMobilepay").finish_non_exhaustive()
22    }
23}
24#[doc(hidden)]
25pub struct PaymentIntentPaymentMethodOptionsMobilepayBuilder {
26    capture_method: Option<Option<PaymentIntentPaymentMethodOptionsMobilepayCaptureMethod>>,
27    setup_future_usage: Option<Option<PaymentIntentPaymentMethodOptionsMobilepaySetupFutureUsage>>,
28}
29
30#[allow(
31    unused_variables,
32    irrefutable_let_patterns,
33    clippy::let_unit_value,
34    clippy::match_single_binding,
35    clippy::single_match
36)]
37const _: () = {
38    use miniserde::de::{Map, Visitor};
39    use miniserde::json::Value;
40    use miniserde::{Deserialize, Result, make_place};
41    use stripe_types::miniserde_helpers::FromValueOpt;
42    use stripe_types::{MapBuilder, ObjectDeser};
43
44    make_place!(Place);
45
46    impl Deserialize for PaymentIntentPaymentMethodOptionsMobilepay {
47        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
48            Place::new(out)
49        }
50    }
51
52    struct Builder<'a> {
53        out: &'a mut Option<PaymentIntentPaymentMethodOptionsMobilepay>,
54        builder: PaymentIntentPaymentMethodOptionsMobilepayBuilder,
55    }
56
57    impl Visitor for Place<PaymentIntentPaymentMethodOptionsMobilepay> {
58        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
59            Ok(Box::new(Builder {
60                out: &mut self.out,
61                builder: PaymentIntentPaymentMethodOptionsMobilepayBuilder::deser_default(),
62            }))
63        }
64    }
65
66    impl MapBuilder for PaymentIntentPaymentMethodOptionsMobilepayBuilder {
67        type Out = PaymentIntentPaymentMethodOptionsMobilepay;
68        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
69            Ok(match k {
70                "capture_method" => Deserialize::begin(&mut self.capture_method),
71                "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage),
72                _ => <dyn Visitor>::ignore(),
73            })
74        }
75
76        fn deser_default() -> Self {
77            Self {
78                capture_method: Deserialize::default(),
79                setup_future_usage: Deserialize::default(),
80            }
81        }
82
83        fn take_out(&mut self) -> Option<Self::Out> {
84            let (Some(capture_method), Some(setup_future_usage)) =
85                (self.capture_method.take(), self.setup_future_usage.take())
86            else {
87                return None;
88            };
89            Some(Self::Out { capture_method, setup_future_usage })
90        }
91    }
92
93    impl Map for Builder<'_> {
94        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
95            self.builder.key(k)
96        }
97
98        fn finish(&mut self) -> Result<()> {
99            *self.out = self.builder.take_out();
100            Ok(())
101        }
102    }
103
104    impl ObjectDeser for PaymentIntentPaymentMethodOptionsMobilepay {
105        type Builder = PaymentIntentPaymentMethodOptionsMobilepayBuilder;
106    }
107
108    impl FromValueOpt for PaymentIntentPaymentMethodOptionsMobilepay {
109        fn from_value(v: Value) -> Option<Self> {
110            let Value::Object(obj) = v else {
111                return None;
112            };
113            let mut b = PaymentIntentPaymentMethodOptionsMobilepayBuilder::deser_default();
114            for (k, v) in obj {
115                match k.as_str() {
116                    "capture_method" => b.capture_method = FromValueOpt::from_value(v),
117                    "setup_future_usage" => b.setup_future_usage = FromValueOpt::from_value(v),
118                    _ => {}
119                }
120            }
121            b.take_out()
122        }
123    }
124};
125/// Controls when the funds will be captured from the customer's account.
126#[derive(Clone, Eq, PartialEq)]
127#[non_exhaustive]
128pub enum PaymentIntentPaymentMethodOptionsMobilepayCaptureMethod {
129    Manual,
130    /// An unrecognized value from Stripe. Should not be used as a request parameter.
131    Unknown(String),
132}
133impl PaymentIntentPaymentMethodOptionsMobilepayCaptureMethod {
134    pub fn as_str(&self) -> &str {
135        use PaymentIntentPaymentMethodOptionsMobilepayCaptureMethod::*;
136        match self {
137            Manual => "manual",
138            Unknown(v) => v,
139        }
140    }
141}
142
143impl std::str::FromStr for PaymentIntentPaymentMethodOptionsMobilepayCaptureMethod {
144    type Err = std::convert::Infallible;
145    fn from_str(s: &str) -> Result<Self, Self::Err> {
146        use PaymentIntentPaymentMethodOptionsMobilepayCaptureMethod::*;
147        match s {
148            "manual" => Ok(Manual),
149            v => {
150                tracing::warn!(
151                    "Unknown value '{}' for enum '{}'",
152                    v,
153                    "PaymentIntentPaymentMethodOptionsMobilepayCaptureMethod"
154                );
155                Ok(Unknown(v.to_owned()))
156            }
157        }
158    }
159}
160impl std::fmt::Display for PaymentIntentPaymentMethodOptionsMobilepayCaptureMethod {
161    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
162        f.write_str(self.as_str())
163    }
164}
165
166#[cfg(not(feature = "redact-generated-debug"))]
167impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsMobilepayCaptureMethod {
168    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
169        f.write_str(self.as_str())
170    }
171}
172#[cfg(feature = "redact-generated-debug")]
173impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsMobilepayCaptureMethod {
174    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
175        f.debug_struct(stringify!(PaymentIntentPaymentMethodOptionsMobilepayCaptureMethod))
176            .finish_non_exhaustive()
177    }
178}
179#[cfg(feature = "serialize")]
180impl serde::Serialize for PaymentIntentPaymentMethodOptionsMobilepayCaptureMethod {
181    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
182    where
183        S: serde::Serializer,
184    {
185        serializer.serialize_str(self.as_str())
186    }
187}
188impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsMobilepayCaptureMethod {
189    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
190        crate::Place::new(out)
191    }
192}
193
194impl miniserde::de::Visitor
195    for crate::Place<PaymentIntentPaymentMethodOptionsMobilepayCaptureMethod>
196{
197    fn string(&mut self, s: &str) -> miniserde::Result<()> {
198        use std::str::FromStr;
199        self.out = Some(
200            PaymentIntentPaymentMethodOptionsMobilepayCaptureMethod::from_str(s)
201                .expect("infallible"),
202        );
203        Ok(())
204    }
205}
206
207stripe_types::impl_from_val_with_from_str!(PaymentIntentPaymentMethodOptionsMobilepayCaptureMethod);
208#[cfg(feature = "deserialize")]
209impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsMobilepayCaptureMethod {
210    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
211        use std::str::FromStr;
212        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
213        Ok(Self::from_str(&s).expect("infallible"))
214    }
215}
216/// Indicates that you intend to make future payments with this PaymentIntent's payment method.
217///
218/// If you provide a Customer with the PaymentIntent, you can use this parameter to [attach the payment method](/payments/save-during-payment) to the Customer after the PaymentIntent is confirmed and the customer completes any required actions.
219/// If you don't provide a Customer, you can still [attach](/api/payment_methods/attach) the payment method to a Customer after the transaction completes.
220///
221/// If the payment method is `card_present` and isn't a digital wallet, Stripe creates and attaches a [generated_card](/api/charges/object#charge_object-payment_method_details-card_present-generated_card) payment method representing the card to the Customer instead.
222///
223/// When processing card payments, Stripe uses `setup_future_usage` to help you comply with regional legislation and network rules, such as [SCA](/strong-customer-authentication).
224#[derive(Clone, Eq, PartialEq)]
225#[non_exhaustive]
226pub enum PaymentIntentPaymentMethodOptionsMobilepaySetupFutureUsage {
227    None,
228    /// An unrecognized value from Stripe. Should not be used as a request parameter.
229    Unknown(String),
230}
231impl PaymentIntentPaymentMethodOptionsMobilepaySetupFutureUsage {
232    pub fn as_str(&self) -> &str {
233        use PaymentIntentPaymentMethodOptionsMobilepaySetupFutureUsage::*;
234        match self {
235            None => "none",
236            Unknown(v) => v,
237        }
238    }
239}
240
241impl std::str::FromStr for PaymentIntentPaymentMethodOptionsMobilepaySetupFutureUsage {
242    type Err = std::convert::Infallible;
243    fn from_str(s: &str) -> Result<Self, Self::Err> {
244        use PaymentIntentPaymentMethodOptionsMobilepaySetupFutureUsage::*;
245        match s {
246            "none" => Ok(None),
247            v => {
248                tracing::warn!(
249                    "Unknown value '{}' for enum '{}'",
250                    v,
251                    "PaymentIntentPaymentMethodOptionsMobilepaySetupFutureUsage"
252                );
253                Ok(Unknown(v.to_owned()))
254            }
255        }
256    }
257}
258impl std::fmt::Display for PaymentIntentPaymentMethodOptionsMobilepaySetupFutureUsage {
259    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
260        f.write_str(self.as_str())
261    }
262}
263
264#[cfg(not(feature = "redact-generated-debug"))]
265impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsMobilepaySetupFutureUsage {
266    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
267        f.write_str(self.as_str())
268    }
269}
270#[cfg(feature = "redact-generated-debug")]
271impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsMobilepaySetupFutureUsage {
272    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
273        f.debug_struct(stringify!(PaymentIntentPaymentMethodOptionsMobilepaySetupFutureUsage))
274            .finish_non_exhaustive()
275    }
276}
277#[cfg(feature = "serialize")]
278impl serde::Serialize for PaymentIntentPaymentMethodOptionsMobilepaySetupFutureUsage {
279    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
280    where
281        S: serde::Serializer,
282    {
283        serializer.serialize_str(self.as_str())
284    }
285}
286impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsMobilepaySetupFutureUsage {
287    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
288        crate::Place::new(out)
289    }
290}
291
292impl miniserde::de::Visitor
293    for crate::Place<PaymentIntentPaymentMethodOptionsMobilepaySetupFutureUsage>
294{
295    fn string(&mut self, s: &str) -> miniserde::Result<()> {
296        use std::str::FromStr;
297        self.out = Some(
298            PaymentIntentPaymentMethodOptionsMobilepaySetupFutureUsage::from_str(s)
299                .expect("infallible"),
300        );
301        Ok(())
302    }
303}
304
305stripe_types::impl_from_val_with_from_str!(
306    PaymentIntentPaymentMethodOptionsMobilepaySetupFutureUsage
307);
308#[cfg(feature = "deserialize")]
309impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsMobilepaySetupFutureUsage {
310    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
311        use std::str::FromStr;
312        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
313        Ok(Self::from_str(&s).expect("infallible"))
314    }
315}