stripe_shared/
payment_method_options_card_present.rs

1#[derive(Copy, Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct PaymentMethodOptionsCardPresent {
5    /// Request ability to capture this payment beyond the standard [authorization validity window](https://stripe.com/docs/terminal/features/extended-authorizations#authorization-validity).
6    pub request_extended_authorization: Option<bool>,
7    /// Request ability to [increment](https://stripe.com/docs/terminal/features/incremental-authorizations) this PaymentIntent if the combination of MCC and card brand is eligible.
8    /// Check [incremental_authorization_supported](https://stripe.com/docs/api/charges/object#charge_object-payment_method_details-card_present-incremental_authorization_supported) in the [Confirm](https://stripe.com/docs/api/payment_intents/confirm) response to verify support.
9    pub request_incremental_authorization_support: Option<bool>,
10    pub routing: Option<stripe_shared::PaymentMethodOptionsCardPresentRouting>,
11}
12#[doc(hidden)]
13pub struct PaymentMethodOptionsCardPresentBuilder {
14    request_extended_authorization: Option<Option<bool>>,
15    request_incremental_authorization_support: Option<Option<bool>>,
16    routing: Option<Option<stripe_shared::PaymentMethodOptionsCardPresentRouting>>,
17}
18
19#[allow(
20    unused_variables,
21    irrefutable_let_patterns,
22    clippy::let_unit_value,
23    clippy::match_single_binding,
24    clippy::single_match
25)]
26const _: () = {
27    use miniserde::de::{Map, Visitor};
28    use miniserde::json::Value;
29    use miniserde::{Deserialize, Result, make_place};
30    use stripe_types::miniserde_helpers::FromValueOpt;
31    use stripe_types::{MapBuilder, ObjectDeser};
32
33    make_place!(Place);
34
35    impl Deserialize for PaymentMethodOptionsCardPresent {
36        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
37            Place::new(out)
38        }
39    }
40
41    struct Builder<'a> {
42        out: &'a mut Option<PaymentMethodOptionsCardPresent>,
43        builder: PaymentMethodOptionsCardPresentBuilder,
44    }
45
46    impl Visitor for Place<PaymentMethodOptionsCardPresent> {
47        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
48            Ok(Box::new(Builder {
49                out: &mut self.out,
50                builder: PaymentMethodOptionsCardPresentBuilder::deser_default(),
51            }))
52        }
53    }
54
55    impl MapBuilder for PaymentMethodOptionsCardPresentBuilder {
56        type Out = PaymentMethodOptionsCardPresent;
57        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
58            Ok(match k {
59                "request_extended_authorization" => {
60                    Deserialize::begin(&mut self.request_extended_authorization)
61                }
62                "request_incremental_authorization_support" => {
63                    Deserialize::begin(&mut self.request_incremental_authorization_support)
64                }
65                "routing" => Deserialize::begin(&mut self.routing),
66                _ => <dyn Visitor>::ignore(),
67            })
68        }
69
70        fn deser_default() -> Self {
71            Self {
72                request_extended_authorization: Deserialize::default(),
73                request_incremental_authorization_support: Deserialize::default(),
74                routing: Deserialize::default(),
75            }
76        }
77
78        fn take_out(&mut self) -> Option<Self::Out> {
79            let (
80                Some(request_extended_authorization),
81                Some(request_incremental_authorization_support),
82                Some(routing),
83            ) = (
84                self.request_extended_authorization,
85                self.request_incremental_authorization_support,
86                self.routing,
87            )
88            else {
89                return None;
90            };
91            Some(Self::Out {
92                request_extended_authorization,
93                request_incremental_authorization_support,
94                routing,
95            })
96        }
97    }
98
99    impl Map for Builder<'_> {
100        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
101            self.builder.key(k)
102        }
103
104        fn finish(&mut self) -> Result<()> {
105            *self.out = self.builder.take_out();
106            Ok(())
107        }
108    }
109
110    impl ObjectDeser for PaymentMethodOptionsCardPresent {
111        type Builder = PaymentMethodOptionsCardPresentBuilder;
112    }
113
114    impl FromValueOpt for PaymentMethodOptionsCardPresent {
115        fn from_value(v: Value) -> Option<Self> {
116            let Value::Object(obj) = v else {
117                return None;
118            };
119            let mut b = PaymentMethodOptionsCardPresentBuilder::deser_default();
120            for (k, v) in obj {
121                match k.as_str() {
122                    "request_extended_authorization" => {
123                        b.request_extended_authorization = FromValueOpt::from_value(v)
124                    }
125                    "request_incremental_authorization_support" => {
126                        b.request_incremental_authorization_support = FromValueOpt::from_value(v)
127                    }
128                    "routing" => b.routing = FromValueOpt::from_value(v),
129                    _ => {}
130                }
131            }
132            b.take_out()
133        }
134    }
135};