stripe_shared/
payment_intent_payment_method_options_swish.rs

1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct PaymentIntentPaymentMethodOptionsSwish {
5    /// A reference for this payment to be displayed in the Swish app.
6    pub reference: Option<String>,
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<PaymentIntentPaymentMethodOptionsSwishSetupFutureUsage>,
16}
17#[doc(hidden)]
18pub struct PaymentIntentPaymentMethodOptionsSwishBuilder {
19    reference: Option<Option<String>>,
20    setup_future_usage: Option<Option<PaymentIntentPaymentMethodOptionsSwishSetupFutureUsage>>,
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::{Deserialize, Result, make_place};
34    use stripe_types::miniserde_helpers::FromValueOpt;
35    use stripe_types::{MapBuilder, ObjectDeser};
36
37    make_place!(Place);
38
39    impl Deserialize for PaymentIntentPaymentMethodOptionsSwish {
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<PaymentIntentPaymentMethodOptionsSwish>,
47        builder: PaymentIntentPaymentMethodOptionsSwishBuilder,
48    }
49
50    impl Visitor for Place<PaymentIntentPaymentMethodOptionsSwish> {
51        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
52            Ok(Box::new(Builder {
53                out: &mut self.out,
54                builder: PaymentIntentPaymentMethodOptionsSwishBuilder::deser_default(),
55            }))
56        }
57    }
58
59    impl MapBuilder for PaymentIntentPaymentMethodOptionsSwishBuilder {
60        type Out = PaymentIntentPaymentMethodOptionsSwish;
61        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
62            Ok(match k {
63                "reference" => Deserialize::begin(&mut self.reference),
64                "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage),
65                _ => <dyn Visitor>::ignore(),
66            })
67        }
68
69        fn deser_default() -> Self {
70            Self { reference: Deserialize::default(), setup_future_usage: Deserialize::default() }
71        }
72
73        fn take_out(&mut self) -> Option<Self::Out> {
74            let (Some(reference), Some(setup_future_usage)) =
75                (self.reference.take(), self.setup_future_usage)
76            else {
77                return None;
78            };
79            Some(Self::Out { reference, setup_future_usage })
80        }
81    }
82
83    impl Map for Builder<'_> {
84        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
85            self.builder.key(k)
86        }
87
88        fn finish(&mut self) -> Result<()> {
89            *self.out = self.builder.take_out();
90            Ok(())
91        }
92    }
93
94    impl ObjectDeser for PaymentIntentPaymentMethodOptionsSwish {
95        type Builder = PaymentIntentPaymentMethodOptionsSwishBuilder;
96    }
97
98    impl FromValueOpt for PaymentIntentPaymentMethodOptionsSwish {
99        fn from_value(v: Value) -> Option<Self> {
100            let Value::Object(obj) = v else {
101                return None;
102            };
103            let mut b = PaymentIntentPaymentMethodOptionsSwishBuilder::deser_default();
104            for (k, v) in obj {
105                match k.as_str() {
106                    "reference" => b.reference = FromValueOpt::from_value(v),
107                    "setup_future_usage" => b.setup_future_usage = FromValueOpt::from_value(v),
108                    _ => {}
109                }
110            }
111            b.take_out()
112        }
113    }
114};
115/// Indicates that you intend to make future payments with this PaymentIntent's payment method.
116///
117/// 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.
118/// 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.
119///
120/// 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.
121///
122/// 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).
123#[derive(Copy, Clone, Eq, PartialEq)]
124pub enum PaymentIntentPaymentMethodOptionsSwishSetupFutureUsage {
125    None,
126}
127impl PaymentIntentPaymentMethodOptionsSwishSetupFutureUsage {
128    pub fn as_str(self) -> &'static str {
129        use PaymentIntentPaymentMethodOptionsSwishSetupFutureUsage::*;
130        match self {
131            None => "none",
132        }
133    }
134}
135
136impl std::str::FromStr for PaymentIntentPaymentMethodOptionsSwishSetupFutureUsage {
137    type Err = stripe_types::StripeParseError;
138    fn from_str(s: &str) -> Result<Self, Self::Err> {
139        use PaymentIntentPaymentMethodOptionsSwishSetupFutureUsage::*;
140        match s {
141            "none" => Ok(None),
142            _ => Err(stripe_types::StripeParseError),
143        }
144    }
145}
146impl std::fmt::Display for PaymentIntentPaymentMethodOptionsSwishSetupFutureUsage {
147    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
148        f.write_str(self.as_str())
149    }
150}
151
152impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsSwishSetupFutureUsage {
153    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
154        f.write_str(self.as_str())
155    }
156}
157#[cfg(feature = "serialize")]
158impl serde::Serialize for PaymentIntentPaymentMethodOptionsSwishSetupFutureUsage {
159    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
160    where
161        S: serde::Serializer,
162    {
163        serializer.serialize_str(self.as_str())
164    }
165}
166impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsSwishSetupFutureUsage {
167    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
168        crate::Place::new(out)
169    }
170}
171
172impl miniserde::de::Visitor
173    for crate::Place<PaymentIntentPaymentMethodOptionsSwishSetupFutureUsage>
174{
175    fn string(&mut self, s: &str) -> miniserde::Result<()> {
176        use std::str::FromStr;
177        self.out = Some(
178            PaymentIntentPaymentMethodOptionsSwishSetupFutureUsage::from_str(s)
179                .map_err(|_| miniserde::Error)?,
180        );
181        Ok(())
182    }
183}
184
185stripe_types::impl_from_val_with_from_str!(PaymentIntentPaymentMethodOptionsSwishSetupFutureUsage);
186#[cfg(feature = "deserialize")]
187impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsSwishSetupFutureUsage {
188    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
189        use std::str::FromStr;
190        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
191        Self::from_str(&s).map_err(|_| {
192            serde::de::Error::custom(
193                "Unknown value for PaymentIntentPaymentMethodOptionsSwishSetupFutureUsage",
194            )
195        })
196    }
197}