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