stripe_shared/
setup_intent_next_action.rs

1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct SetupIntentNextAction {
5    pub cashapp_handle_redirect_or_display_qr_code:
6        Option<stripe_shared::PaymentIntentNextActionCashappHandleRedirectOrDisplayQrCode>,
7    pub redirect_to_url: Option<stripe_shared::SetupIntentNextActionRedirectToUrl>,
8    /// Type of the next action to perform, one of `redirect_to_url`, `use_stripe_sdk`, `alipay_handle_redirect`, `oxxo_display_details`, or `verify_with_microdeposits`.
9    #[cfg_attr(any(feature = "deserialize", feature = "serialize"), serde(rename = "type"))]
10    pub type_: String,
11    /// When confirming a SetupIntent with Stripe.js, Stripe.js depends on the contents of this dictionary to invoke authentication flows.
12    /// The shape of the contents is subject to change and is only intended to be used by Stripe.js.
13    #[cfg_attr(
14        any(feature = "deserialize", feature = "serialize"),
15        serde(with = "stripe_types::with_serde_json_opt")
16    )]
17    pub use_stripe_sdk: Option<miniserde::json::Value>,
18    pub verify_with_microdeposits:
19        Option<stripe_shared::SetupIntentNextActionVerifyWithMicrodeposits>,
20}
21#[doc(hidden)]
22pub struct SetupIntentNextActionBuilder {
23    cashapp_handle_redirect_or_display_qr_code:
24        Option<Option<stripe_shared::PaymentIntentNextActionCashappHandleRedirectOrDisplayQrCode>>,
25    redirect_to_url: Option<Option<stripe_shared::SetupIntentNextActionRedirectToUrl>>,
26    type_: Option<String>,
27    use_stripe_sdk: Option<Option<miniserde::json::Value>>,
28    verify_with_microdeposits:
29        Option<Option<stripe_shared::SetupIntentNextActionVerifyWithMicrodeposits>>,
30}
31
32#[allow(
33    unused_variables,
34    irrefutable_let_patterns,
35    clippy::let_unit_value,
36    clippy::match_single_binding,
37    clippy::single_match
38)]
39const _: () = {
40    use miniserde::de::{Map, Visitor};
41    use miniserde::json::Value;
42    use miniserde::{make_place, Deserialize, Result};
43    use stripe_types::miniserde_helpers::FromValueOpt;
44    use stripe_types::{MapBuilder, ObjectDeser};
45
46    make_place!(Place);
47
48    impl Deserialize for SetupIntentNextAction {
49        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
50            Place::new(out)
51        }
52    }
53
54    struct Builder<'a> {
55        out: &'a mut Option<SetupIntentNextAction>,
56        builder: SetupIntentNextActionBuilder,
57    }
58
59    impl Visitor for Place<SetupIntentNextAction> {
60        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
61            Ok(Box::new(Builder {
62                out: &mut self.out,
63                builder: SetupIntentNextActionBuilder::deser_default(),
64            }))
65        }
66    }
67
68    impl MapBuilder for SetupIntentNextActionBuilder {
69        type Out = SetupIntentNextAction;
70        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
71            Ok(match k {
72                "cashapp_handle_redirect_or_display_qr_code" => {
73                    Deserialize::begin(&mut self.cashapp_handle_redirect_or_display_qr_code)
74                }
75                "redirect_to_url" => Deserialize::begin(&mut self.redirect_to_url),
76                "type" => Deserialize::begin(&mut self.type_),
77                "use_stripe_sdk" => Deserialize::begin(&mut self.use_stripe_sdk),
78                "verify_with_microdeposits" => {
79                    Deserialize::begin(&mut self.verify_with_microdeposits)
80                }
81
82                _ => <dyn Visitor>::ignore(),
83            })
84        }
85
86        fn deser_default() -> Self {
87            Self {
88                cashapp_handle_redirect_or_display_qr_code: Deserialize::default(),
89                redirect_to_url: Deserialize::default(),
90                type_: Deserialize::default(),
91                use_stripe_sdk: Deserialize::default(),
92                verify_with_microdeposits: Deserialize::default(),
93            }
94        }
95
96        fn take_out(&mut self) -> Option<Self::Out> {
97            let (
98                Some(cashapp_handle_redirect_or_display_qr_code),
99                Some(redirect_to_url),
100                Some(type_),
101                Some(use_stripe_sdk),
102                Some(verify_with_microdeposits),
103            ) = (
104                self.cashapp_handle_redirect_or_display_qr_code.take(),
105                self.redirect_to_url.take(),
106                self.type_.take(),
107                self.use_stripe_sdk.take(),
108                self.verify_with_microdeposits.take(),
109            )
110            else {
111                return None;
112            };
113            Some(Self::Out {
114                cashapp_handle_redirect_or_display_qr_code,
115                redirect_to_url,
116                type_,
117                use_stripe_sdk,
118                verify_with_microdeposits,
119            })
120        }
121    }
122
123    impl<'a> Map for Builder<'a> {
124        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
125            self.builder.key(k)
126        }
127
128        fn finish(&mut self) -> Result<()> {
129            *self.out = self.builder.take_out();
130            Ok(())
131        }
132    }
133
134    impl ObjectDeser for SetupIntentNextAction {
135        type Builder = SetupIntentNextActionBuilder;
136    }
137
138    impl FromValueOpt for SetupIntentNextAction {
139        fn from_value(v: Value) -> Option<Self> {
140            let Value::Object(obj) = v else {
141                return None;
142            };
143            let mut b = SetupIntentNextActionBuilder::deser_default();
144            for (k, v) in obj {
145                match k.as_str() {
146                    "cashapp_handle_redirect_or_display_qr_code" => {
147                        b.cashapp_handle_redirect_or_display_qr_code = FromValueOpt::from_value(v)
148                    }
149                    "redirect_to_url" => b.redirect_to_url = FromValueOpt::from_value(v),
150                    "type" => b.type_ = FromValueOpt::from_value(v),
151                    "use_stripe_sdk" => b.use_stripe_sdk = FromValueOpt::from_value(v),
152                    "verify_with_microdeposits" => {
153                        b.verify_with_microdeposits = FromValueOpt::from_value(v)
154                    }
155
156                    _ => {}
157                }
158            }
159            b.take_out()
160        }
161    }
162};