Skip to main content

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