stripe_shared/
payment_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 PaymentIntentNextAction {
5    pub alipay_handle_redirect: Option<stripe_shared::PaymentIntentNextActionAlipayHandleRedirect>,
6    pub boleto_display_details: Option<stripe_shared::PaymentIntentNextActionBoleto>,
7    pub card_await_notification:
8        Option<stripe_shared::PaymentIntentNextActionCardAwaitNotification>,
9    pub cashapp_handle_redirect_or_display_qr_code:
10        Option<stripe_shared::PaymentIntentNextActionCashappHandleRedirectOrDisplayQrCode>,
11    pub display_bank_transfer_instructions:
12        Option<stripe_shared::PaymentIntentNextActionDisplayBankTransferInstructions>,
13    pub konbini_display_details: Option<stripe_shared::PaymentIntentNextActionKonbini>,
14    pub multibanco_display_details:
15        Option<stripe_shared::PaymentIntentNextActionDisplayMultibancoDetails>,
16    pub oxxo_display_details: Option<stripe_shared::PaymentIntentNextActionDisplayOxxoDetails>,
17    pub paynow_display_qr_code: Option<stripe_shared::PaymentIntentNextActionPaynowDisplayQrCode>,
18    pub pix_display_qr_code: Option<stripe_shared::PaymentIntentNextActionPixDisplayQrCode>,
19    pub promptpay_display_qr_code:
20        Option<stripe_shared::PaymentIntentNextActionPromptpayDisplayQrCode>,
21    pub redirect_to_url: Option<stripe_shared::PaymentIntentNextActionRedirectToUrl>,
22    pub swish_handle_redirect_or_display_qr_code:
23        Option<stripe_shared::PaymentIntentNextActionSwishHandleRedirectOrDisplayQrCode>,
24    /// 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`.
25    #[cfg_attr(any(feature = "deserialize", feature = "serialize"), serde(rename = "type"))]
26    pub type_: String,
27    /// When confirming a PaymentIntent with Stripe.js, Stripe.js depends on the contents of this dictionary to invoke authentication flows.
28    /// The shape of the contents is subject to change and is only intended to be used by Stripe.js.
29    #[cfg_attr(
30        any(feature = "deserialize", feature = "serialize"),
31        serde(with = "stripe_types::with_serde_json_opt")
32    )]
33    pub use_stripe_sdk: Option<miniserde::json::Value>,
34    pub verify_with_microdeposits:
35        Option<stripe_shared::PaymentIntentNextActionVerifyWithMicrodeposits>,
36    pub wechat_pay_display_qr_code:
37        Option<stripe_shared::PaymentIntentNextActionWechatPayDisplayQrCode>,
38    pub wechat_pay_redirect_to_android_app:
39        Option<stripe_shared::PaymentIntentNextActionWechatPayRedirectToAndroidApp>,
40    pub wechat_pay_redirect_to_ios_app:
41        Option<stripe_shared::PaymentIntentNextActionWechatPayRedirectToIosApp>,
42}
43#[doc(hidden)]
44pub struct PaymentIntentNextActionBuilder {
45    alipay_handle_redirect:
46        Option<Option<stripe_shared::PaymentIntentNextActionAlipayHandleRedirect>>,
47    boleto_display_details: Option<Option<stripe_shared::PaymentIntentNextActionBoleto>>,
48    card_await_notification:
49        Option<Option<stripe_shared::PaymentIntentNextActionCardAwaitNotification>>,
50    cashapp_handle_redirect_or_display_qr_code:
51        Option<Option<stripe_shared::PaymentIntentNextActionCashappHandleRedirectOrDisplayQrCode>>,
52    display_bank_transfer_instructions:
53        Option<Option<stripe_shared::PaymentIntentNextActionDisplayBankTransferInstructions>>,
54    konbini_display_details: Option<Option<stripe_shared::PaymentIntentNextActionKonbini>>,
55    multibanco_display_details:
56        Option<Option<stripe_shared::PaymentIntentNextActionDisplayMultibancoDetails>>,
57    oxxo_display_details: Option<Option<stripe_shared::PaymentIntentNextActionDisplayOxxoDetails>>,
58    paynow_display_qr_code:
59        Option<Option<stripe_shared::PaymentIntentNextActionPaynowDisplayQrCode>>,
60    pix_display_qr_code: Option<Option<stripe_shared::PaymentIntentNextActionPixDisplayQrCode>>,
61    promptpay_display_qr_code:
62        Option<Option<stripe_shared::PaymentIntentNextActionPromptpayDisplayQrCode>>,
63    redirect_to_url: Option<Option<stripe_shared::PaymentIntentNextActionRedirectToUrl>>,
64    swish_handle_redirect_or_display_qr_code:
65        Option<Option<stripe_shared::PaymentIntentNextActionSwishHandleRedirectOrDisplayQrCode>>,
66    type_: Option<String>,
67    use_stripe_sdk: Option<Option<miniserde::json::Value>>,
68    verify_with_microdeposits:
69        Option<Option<stripe_shared::PaymentIntentNextActionVerifyWithMicrodeposits>>,
70    wechat_pay_display_qr_code:
71        Option<Option<stripe_shared::PaymentIntentNextActionWechatPayDisplayQrCode>>,
72    wechat_pay_redirect_to_android_app:
73        Option<Option<stripe_shared::PaymentIntentNextActionWechatPayRedirectToAndroidApp>>,
74    wechat_pay_redirect_to_ios_app:
75        Option<Option<stripe_shared::PaymentIntentNextActionWechatPayRedirectToIosApp>>,
76}
77
78#[allow(
79    unused_variables,
80    irrefutable_let_patterns,
81    clippy::let_unit_value,
82    clippy::match_single_binding,
83    clippy::single_match
84)]
85const _: () = {
86    use miniserde::de::{Map, Visitor};
87    use miniserde::json::Value;
88    use miniserde::{make_place, Deserialize, Result};
89    use stripe_types::miniserde_helpers::FromValueOpt;
90    use stripe_types::{MapBuilder, ObjectDeser};
91
92    make_place!(Place);
93
94    impl Deserialize for PaymentIntentNextAction {
95        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
96            Place::new(out)
97        }
98    }
99
100    struct Builder<'a> {
101        out: &'a mut Option<PaymentIntentNextAction>,
102        builder: PaymentIntentNextActionBuilder,
103    }
104
105    impl Visitor for Place<PaymentIntentNextAction> {
106        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
107            Ok(Box::new(Builder {
108                out: &mut self.out,
109                builder: PaymentIntentNextActionBuilder::deser_default(),
110            }))
111        }
112    }
113
114    impl MapBuilder for PaymentIntentNextActionBuilder {
115        type Out = PaymentIntentNextAction;
116        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
117            Ok(match k {
118                "alipay_handle_redirect" => Deserialize::begin(&mut self.alipay_handle_redirect),
119                "boleto_display_details" => Deserialize::begin(&mut self.boleto_display_details),
120                "card_await_notification" => Deserialize::begin(&mut self.card_await_notification),
121                "cashapp_handle_redirect_or_display_qr_code" => {
122                    Deserialize::begin(&mut self.cashapp_handle_redirect_or_display_qr_code)
123                }
124                "display_bank_transfer_instructions" => {
125                    Deserialize::begin(&mut self.display_bank_transfer_instructions)
126                }
127                "konbini_display_details" => Deserialize::begin(&mut self.konbini_display_details),
128                "multibanco_display_details" => {
129                    Deserialize::begin(&mut self.multibanco_display_details)
130                }
131                "oxxo_display_details" => Deserialize::begin(&mut self.oxxo_display_details),
132                "paynow_display_qr_code" => Deserialize::begin(&mut self.paynow_display_qr_code),
133                "pix_display_qr_code" => Deserialize::begin(&mut self.pix_display_qr_code),
134                "promptpay_display_qr_code" => {
135                    Deserialize::begin(&mut self.promptpay_display_qr_code)
136                }
137                "redirect_to_url" => Deserialize::begin(&mut self.redirect_to_url),
138                "swish_handle_redirect_or_display_qr_code" => {
139                    Deserialize::begin(&mut self.swish_handle_redirect_or_display_qr_code)
140                }
141                "type" => Deserialize::begin(&mut self.type_),
142                "use_stripe_sdk" => Deserialize::begin(&mut self.use_stripe_sdk),
143                "verify_with_microdeposits" => {
144                    Deserialize::begin(&mut self.verify_with_microdeposits)
145                }
146                "wechat_pay_display_qr_code" => {
147                    Deserialize::begin(&mut self.wechat_pay_display_qr_code)
148                }
149                "wechat_pay_redirect_to_android_app" => {
150                    Deserialize::begin(&mut self.wechat_pay_redirect_to_android_app)
151                }
152                "wechat_pay_redirect_to_ios_app" => {
153                    Deserialize::begin(&mut self.wechat_pay_redirect_to_ios_app)
154                }
155
156                _ => <dyn Visitor>::ignore(),
157            })
158        }
159
160        fn deser_default() -> Self {
161            Self {
162                alipay_handle_redirect: Deserialize::default(),
163                boleto_display_details: Deserialize::default(),
164                card_await_notification: Deserialize::default(),
165                cashapp_handle_redirect_or_display_qr_code: Deserialize::default(),
166                display_bank_transfer_instructions: Deserialize::default(),
167                konbini_display_details: Deserialize::default(),
168                multibanco_display_details: Deserialize::default(),
169                oxxo_display_details: Deserialize::default(),
170                paynow_display_qr_code: Deserialize::default(),
171                pix_display_qr_code: Deserialize::default(),
172                promptpay_display_qr_code: Deserialize::default(),
173                redirect_to_url: Deserialize::default(),
174                swish_handle_redirect_or_display_qr_code: Deserialize::default(),
175                type_: Deserialize::default(),
176                use_stripe_sdk: Deserialize::default(),
177                verify_with_microdeposits: Deserialize::default(),
178                wechat_pay_display_qr_code: Deserialize::default(),
179                wechat_pay_redirect_to_android_app: Deserialize::default(),
180                wechat_pay_redirect_to_ios_app: Deserialize::default(),
181            }
182        }
183
184        fn take_out(&mut self) -> Option<Self::Out> {
185            let (
186                Some(alipay_handle_redirect),
187                Some(boleto_display_details),
188                Some(card_await_notification),
189                Some(cashapp_handle_redirect_or_display_qr_code),
190                Some(display_bank_transfer_instructions),
191                Some(konbini_display_details),
192                Some(multibanco_display_details),
193                Some(oxxo_display_details),
194                Some(paynow_display_qr_code),
195                Some(pix_display_qr_code),
196                Some(promptpay_display_qr_code),
197                Some(redirect_to_url),
198                Some(swish_handle_redirect_or_display_qr_code),
199                Some(type_),
200                Some(use_stripe_sdk),
201                Some(verify_with_microdeposits),
202                Some(wechat_pay_display_qr_code),
203                Some(wechat_pay_redirect_to_android_app),
204                Some(wechat_pay_redirect_to_ios_app),
205            ) = (
206                self.alipay_handle_redirect.take(),
207                self.boleto_display_details.take(),
208                self.card_await_notification,
209                self.cashapp_handle_redirect_or_display_qr_code.take(),
210                self.display_bank_transfer_instructions.take(),
211                self.konbini_display_details.take(),
212                self.multibanco_display_details.take(),
213                self.oxxo_display_details.take(),
214                self.paynow_display_qr_code.take(),
215                self.pix_display_qr_code.take(),
216                self.promptpay_display_qr_code.take(),
217                self.redirect_to_url.take(),
218                self.swish_handle_redirect_or_display_qr_code.take(),
219                self.type_.take(),
220                self.use_stripe_sdk.take(),
221                self.verify_with_microdeposits.take(),
222                self.wechat_pay_display_qr_code.take(),
223                self.wechat_pay_redirect_to_android_app.take(),
224                self.wechat_pay_redirect_to_ios_app.take(),
225            )
226            else {
227                return None;
228            };
229            Some(Self::Out {
230                alipay_handle_redirect,
231                boleto_display_details,
232                card_await_notification,
233                cashapp_handle_redirect_or_display_qr_code,
234                display_bank_transfer_instructions,
235                konbini_display_details,
236                multibanco_display_details,
237                oxxo_display_details,
238                paynow_display_qr_code,
239                pix_display_qr_code,
240                promptpay_display_qr_code,
241                redirect_to_url,
242                swish_handle_redirect_or_display_qr_code,
243                type_,
244                use_stripe_sdk,
245                verify_with_microdeposits,
246                wechat_pay_display_qr_code,
247                wechat_pay_redirect_to_android_app,
248                wechat_pay_redirect_to_ios_app,
249            })
250        }
251    }
252
253    impl<'a> Map for Builder<'a> {
254        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
255            self.builder.key(k)
256        }
257
258        fn finish(&mut self) -> Result<()> {
259            *self.out = self.builder.take_out();
260            Ok(())
261        }
262    }
263
264    impl ObjectDeser for PaymentIntentNextAction {
265        type Builder = PaymentIntentNextActionBuilder;
266    }
267
268    impl FromValueOpt for PaymentIntentNextAction {
269        fn from_value(v: Value) -> Option<Self> {
270            let Value::Object(obj) = v else {
271                return None;
272            };
273            let mut b = PaymentIntentNextActionBuilder::deser_default();
274            for (k, v) in obj {
275                match k.as_str() {
276                    "alipay_handle_redirect" => {
277                        b.alipay_handle_redirect = FromValueOpt::from_value(v)
278                    }
279                    "boleto_display_details" => {
280                        b.boleto_display_details = FromValueOpt::from_value(v)
281                    }
282                    "card_await_notification" => {
283                        b.card_await_notification = FromValueOpt::from_value(v)
284                    }
285                    "cashapp_handle_redirect_or_display_qr_code" => {
286                        b.cashapp_handle_redirect_or_display_qr_code = FromValueOpt::from_value(v)
287                    }
288                    "display_bank_transfer_instructions" => {
289                        b.display_bank_transfer_instructions = FromValueOpt::from_value(v)
290                    }
291                    "konbini_display_details" => {
292                        b.konbini_display_details = FromValueOpt::from_value(v)
293                    }
294                    "multibanco_display_details" => {
295                        b.multibanco_display_details = FromValueOpt::from_value(v)
296                    }
297                    "oxxo_display_details" => b.oxxo_display_details = FromValueOpt::from_value(v),
298                    "paynow_display_qr_code" => {
299                        b.paynow_display_qr_code = FromValueOpt::from_value(v)
300                    }
301                    "pix_display_qr_code" => b.pix_display_qr_code = FromValueOpt::from_value(v),
302                    "promptpay_display_qr_code" => {
303                        b.promptpay_display_qr_code = FromValueOpt::from_value(v)
304                    }
305                    "redirect_to_url" => b.redirect_to_url = FromValueOpt::from_value(v),
306                    "swish_handle_redirect_or_display_qr_code" => {
307                        b.swish_handle_redirect_or_display_qr_code = FromValueOpt::from_value(v)
308                    }
309                    "type" => b.type_ = FromValueOpt::from_value(v),
310                    "use_stripe_sdk" => b.use_stripe_sdk = FromValueOpt::from_value(v),
311                    "verify_with_microdeposits" => {
312                        b.verify_with_microdeposits = FromValueOpt::from_value(v)
313                    }
314                    "wechat_pay_display_qr_code" => {
315                        b.wechat_pay_display_qr_code = FromValueOpt::from_value(v)
316                    }
317                    "wechat_pay_redirect_to_android_app" => {
318                        b.wechat_pay_redirect_to_android_app = FromValueOpt::from_value(v)
319                    }
320                    "wechat_pay_redirect_to_ios_app" => {
321                        b.wechat_pay_redirect_to_ios_app = FromValueOpt::from_value(v)
322                    }
323
324                    _ => {}
325                }
326            }
327            b.take_out()
328        }
329    }
330};