stripe_shared/
payment_intent_payment_method_options_mobilepay.rs

1#[derive(Copy, Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct PaymentIntentPaymentMethodOptionsMobilepay {
5    /// Controls when the funds will be captured from the customer's account.
6    pub capture_method: Option<PaymentIntentPaymentMethodOptionsMobilepayCaptureMethod>,
7    /// Indicates that you intend to make future payments with this PaymentIntent's payment method.
8    ///
9    /// 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.
10    /// 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.
11    ///
12    /// 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.
13    ///
14    /// 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).
15    pub setup_future_usage: Option<PaymentIntentPaymentMethodOptionsMobilepaySetupFutureUsage>,
16}
17#[doc(hidden)]
18pub struct PaymentIntentPaymentMethodOptionsMobilepayBuilder {
19    capture_method: Option<Option<PaymentIntentPaymentMethodOptionsMobilepayCaptureMethod>>,
20    setup_future_usage: Option<Option<PaymentIntentPaymentMethodOptionsMobilepaySetupFutureUsage>>,
21}
22
23#[allow(
24    unused_variables,
25    irrefutable_let_patterns,
26    clippy::let_unit_value,
27    clippy::match_single_binding,
28    clippy::single_match
29)]
30const _: () = {
31    use miniserde::de::{Map, Visitor};
32    use miniserde::json::Value;
33    use miniserde::{make_place, Deserialize, Result};
34    use stripe_types::miniserde_helpers::FromValueOpt;
35    use stripe_types::{MapBuilder, ObjectDeser};
36
37    make_place!(Place);
38
39    impl Deserialize for PaymentIntentPaymentMethodOptionsMobilepay {
40        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
41            Place::new(out)
42        }
43    }
44
45    struct Builder<'a> {
46        out: &'a mut Option<PaymentIntentPaymentMethodOptionsMobilepay>,
47        builder: PaymentIntentPaymentMethodOptionsMobilepayBuilder,
48    }
49
50    impl Visitor for Place<PaymentIntentPaymentMethodOptionsMobilepay> {
51        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
52            Ok(Box::new(Builder {
53                out: &mut self.out,
54                builder: PaymentIntentPaymentMethodOptionsMobilepayBuilder::deser_default(),
55            }))
56        }
57    }
58
59    impl MapBuilder for PaymentIntentPaymentMethodOptionsMobilepayBuilder {
60        type Out = PaymentIntentPaymentMethodOptionsMobilepay;
61        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
62            Ok(match k {
63                "capture_method" => Deserialize::begin(&mut self.capture_method),
64                "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage),
65
66                _ => <dyn Visitor>::ignore(),
67            })
68        }
69
70        fn deser_default() -> Self {
71            Self {
72                capture_method: Deserialize::default(),
73                setup_future_usage: Deserialize::default(),
74            }
75        }
76
77        fn take_out(&mut self) -> Option<Self::Out> {
78            let (Some(capture_method), Some(setup_future_usage)) =
79                (self.capture_method, self.setup_future_usage)
80            else {
81                return None;
82            };
83            Some(Self::Out { capture_method, setup_future_usage })
84        }
85    }
86
87    impl Map for Builder<'_> {
88        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
89            self.builder.key(k)
90        }
91
92        fn finish(&mut self) -> Result<()> {
93            *self.out = self.builder.take_out();
94            Ok(())
95        }
96    }
97
98    impl ObjectDeser for PaymentIntentPaymentMethodOptionsMobilepay {
99        type Builder = PaymentIntentPaymentMethodOptionsMobilepayBuilder;
100    }
101
102    impl FromValueOpt for PaymentIntentPaymentMethodOptionsMobilepay {
103        fn from_value(v: Value) -> Option<Self> {
104            let Value::Object(obj) = v else {
105                return None;
106            };
107            let mut b = PaymentIntentPaymentMethodOptionsMobilepayBuilder::deser_default();
108            for (k, v) in obj {
109                match k.as_str() {
110                    "capture_method" => b.capture_method = FromValueOpt::from_value(v),
111                    "setup_future_usage" => b.setup_future_usage = FromValueOpt::from_value(v),
112
113                    _ => {}
114                }
115            }
116            b.take_out()
117        }
118    }
119};
120/// Controls when the funds will be captured from the customer's account.
121#[derive(Copy, Clone, Eq, PartialEq)]
122pub enum PaymentIntentPaymentMethodOptionsMobilepayCaptureMethod {
123    Manual,
124}
125impl PaymentIntentPaymentMethodOptionsMobilepayCaptureMethod {
126    pub fn as_str(self) -> &'static str {
127        use PaymentIntentPaymentMethodOptionsMobilepayCaptureMethod::*;
128        match self {
129            Manual => "manual",
130        }
131    }
132}
133
134impl std::str::FromStr for PaymentIntentPaymentMethodOptionsMobilepayCaptureMethod {
135    type Err = stripe_types::StripeParseError;
136    fn from_str(s: &str) -> Result<Self, Self::Err> {
137        use PaymentIntentPaymentMethodOptionsMobilepayCaptureMethod::*;
138        match s {
139            "manual" => Ok(Manual),
140            _ => Err(stripe_types::StripeParseError),
141        }
142    }
143}
144impl std::fmt::Display for PaymentIntentPaymentMethodOptionsMobilepayCaptureMethod {
145    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
146        f.write_str(self.as_str())
147    }
148}
149
150impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsMobilepayCaptureMethod {
151    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
152        f.write_str(self.as_str())
153    }
154}
155#[cfg(feature = "serialize")]
156impl serde::Serialize for PaymentIntentPaymentMethodOptionsMobilepayCaptureMethod {
157    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
158    where
159        S: serde::Serializer,
160    {
161        serializer.serialize_str(self.as_str())
162    }
163}
164impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsMobilepayCaptureMethod {
165    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
166        crate::Place::new(out)
167    }
168}
169
170impl miniserde::de::Visitor
171    for crate::Place<PaymentIntentPaymentMethodOptionsMobilepayCaptureMethod>
172{
173    fn string(&mut self, s: &str) -> miniserde::Result<()> {
174        use std::str::FromStr;
175        self.out = Some(
176            PaymentIntentPaymentMethodOptionsMobilepayCaptureMethod::from_str(s)
177                .map_err(|_| miniserde::Error)?,
178        );
179        Ok(())
180    }
181}
182
183stripe_types::impl_from_val_with_from_str!(PaymentIntentPaymentMethodOptionsMobilepayCaptureMethod);
184#[cfg(feature = "deserialize")]
185impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsMobilepayCaptureMethod {
186    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
187        use std::str::FromStr;
188        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
189        Self::from_str(&s).map_err(|_| {
190            serde::de::Error::custom(
191                "Unknown value for PaymentIntentPaymentMethodOptionsMobilepayCaptureMethod",
192            )
193        })
194    }
195}
196/// Indicates that you intend to make future payments with this PaymentIntent's payment method.
197///
198/// 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.
199/// 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.
200///
201/// 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.
202///
203/// 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).
204#[derive(Copy, Clone, Eq, PartialEq)]
205pub enum PaymentIntentPaymentMethodOptionsMobilepaySetupFutureUsage {
206    None,
207}
208impl PaymentIntentPaymentMethodOptionsMobilepaySetupFutureUsage {
209    pub fn as_str(self) -> &'static str {
210        use PaymentIntentPaymentMethodOptionsMobilepaySetupFutureUsage::*;
211        match self {
212            None => "none",
213        }
214    }
215}
216
217impl std::str::FromStr for PaymentIntentPaymentMethodOptionsMobilepaySetupFutureUsage {
218    type Err = stripe_types::StripeParseError;
219    fn from_str(s: &str) -> Result<Self, Self::Err> {
220        use PaymentIntentPaymentMethodOptionsMobilepaySetupFutureUsage::*;
221        match s {
222            "none" => Ok(None),
223            _ => Err(stripe_types::StripeParseError),
224        }
225    }
226}
227impl std::fmt::Display for PaymentIntentPaymentMethodOptionsMobilepaySetupFutureUsage {
228    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
229        f.write_str(self.as_str())
230    }
231}
232
233impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsMobilepaySetupFutureUsage {
234    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
235        f.write_str(self.as_str())
236    }
237}
238#[cfg(feature = "serialize")]
239impl serde::Serialize for PaymentIntentPaymentMethodOptionsMobilepaySetupFutureUsage {
240    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
241    where
242        S: serde::Serializer,
243    {
244        serializer.serialize_str(self.as_str())
245    }
246}
247impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsMobilepaySetupFutureUsage {
248    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
249        crate::Place::new(out)
250    }
251}
252
253impl miniserde::de::Visitor
254    for crate::Place<PaymentIntentPaymentMethodOptionsMobilepaySetupFutureUsage>
255{
256    fn string(&mut self, s: &str) -> miniserde::Result<()> {
257        use std::str::FromStr;
258        self.out = Some(
259            PaymentIntentPaymentMethodOptionsMobilepaySetupFutureUsage::from_str(s)
260                .map_err(|_| miniserde::Error)?,
261        );
262        Ok(())
263    }
264}
265
266stripe_types::impl_from_val_with_from_str!(
267    PaymentIntentPaymentMethodOptionsMobilepaySetupFutureUsage
268);
269#[cfg(feature = "deserialize")]
270impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsMobilepaySetupFutureUsage {
271    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
272        use std::str::FromStr;
273        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
274        Self::from_str(&s).map_err(|_| {
275            serde::de::Error::custom(
276                "Unknown value for PaymentIntentPaymentMethodOptionsMobilepaySetupFutureUsage",
277            )
278        })
279    }
280}