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::{make_place, Deserialize, Result};
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
67                _ => <dyn Visitor>::ignore(),
68            })
69        }
70
71        fn deser_default() -> Self {
72            Self {
73                request_extended_authorization: Deserialize::default(),
74                request_incremental_authorization_support: Deserialize::default(),
75                routing: Deserialize::default(),
76            }
77        }
78
79        fn take_out(&mut self) -> Option<Self::Out> {
80            let (
81                Some(request_extended_authorization),
82                Some(request_incremental_authorization_support),
83                Some(routing),
84            ) = (
85                self.request_extended_authorization,
86                self.request_incremental_authorization_support,
87                self.routing,
88            )
89            else {
90                return None;
91            };
92            Some(Self::Out {
93                request_extended_authorization,
94                request_incremental_authorization_support,
95                routing,
96            })
97        }
98    }
99
100    impl<'a> Map for Builder<'a> {
101        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
102            self.builder.key(k)
103        }
104
105        fn finish(&mut self) -> Result<()> {
106            *self.out = self.builder.take_out();
107            Ok(())
108        }
109    }
110
111    impl ObjectDeser for PaymentMethodOptionsCardPresent {
112        type Builder = PaymentMethodOptionsCardPresentBuilder;
113    }
114
115    impl FromValueOpt for PaymentMethodOptionsCardPresent {
116        fn from_value(v: Value) -> Option<Self> {
117            let Value::Object(obj) = v else {
118                return None;
119            };
120            let mut b = PaymentMethodOptionsCardPresentBuilder::deser_default();
121            for (k, v) in obj {
122                match k.as_str() {
123                    "request_extended_authorization" => {
124                        b.request_extended_authorization = FromValueOpt::from_value(v)
125                    }
126                    "request_incremental_authorization_support" => {
127                        b.request_incremental_authorization_support = FromValueOpt::from_value(v)
128                    }
129                    "routing" => b.routing = FromValueOpt::from_value(v),
130
131                    _ => {}
132                }
133            }
134            b.take_out()
135        }
136    }
137};