stripe_shared/
payment_intent_next_action_card_await_notification.rs

1#[derive(Copy, Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct PaymentIntentNextActionCardAwaitNotification {
5    /// The time that payment will be attempted.
6    /// If customer approval is required, they need to provide approval before this time.
7    pub charge_attempt_at: Option<stripe_types::Timestamp>,
8    /// For payments greater than INR 15000, the customer must provide explicit approval of the payment with their bank.
9    /// For payments of lower amount, no customer action is required.
10    pub customer_approval_required: Option<bool>,
11}
12#[doc(hidden)]
13pub struct PaymentIntentNextActionCardAwaitNotificationBuilder {
14    charge_attempt_at: Option<Option<stripe_types::Timestamp>>,
15    customer_approval_required: Option<Option<bool>>,
16}
17
18#[allow(
19    unused_variables,
20    irrefutable_let_patterns,
21    clippy::let_unit_value,
22    clippy::match_single_binding,
23    clippy::single_match
24)]
25const _: () = {
26    use miniserde::de::{Map, Visitor};
27    use miniserde::json::Value;
28    use miniserde::{Deserialize, Result, make_place};
29    use stripe_types::miniserde_helpers::FromValueOpt;
30    use stripe_types::{MapBuilder, ObjectDeser};
31
32    make_place!(Place);
33
34    impl Deserialize for PaymentIntentNextActionCardAwaitNotification {
35        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
36            Place::new(out)
37        }
38    }
39
40    struct Builder<'a> {
41        out: &'a mut Option<PaymentIntentNextActionCardAwaitNotification>,
42        builder: PaymentIntentNextActionCardAwaitNotificationBuilder,
43    }
44
45    impl Visitor for Place<PaymentIntentNextActionCardAwaitNotification> {
46        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
47            Ok(Box::new(Builder {
48                out: &mut self.out,
49                builder: PaymentIntentNextActionCardAwaitNotificationBuilder::deser_default(),
50            }))
51        }
52    }
53
54    impl MapBuilder for PaymentIntentNextActionCardAwaitNotificationBuilder {
55        type Out = PaymentIntentNextActionCardAwaitNotification;
56        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
57            Ok(match k {
58                "charge_attempt_at" => Deserialize::begin(&mut self.charge_attempt_at),
59                "customer_approval_required" => {
60                    Deserialize::begin(&mut self.customer_approval_required)
61                }
62
63                _ => <dyn Visitor>::ignore(),
64            })
65        }
66
67        fn deser_default() -> Self {
68            Self {
69                charge_attempt_at: Deserialize::default(),
70                customer_approval_required: Deserialize::default(),
71            }
72        }
73
74        fn take_out(&mut self) -> Option<Self::Out> {
75            let (Some(charge_attempt_at), Some(customer_approval_required)) =
76                (self.charge_attempt_at, self.customer_approval_required)
77            else {
78                return None;
79            };
80            Some(Self::Out { charge_attempt_at, customer_approval_required })
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 PaymentIntentNextActionCardAwaitNotification {
96        type Builder = PaymentIntentNextActionCardAwaitNotificationBuilder;
97    }
98
99    impl FromValueOpt for PaymentIntentNextActionCardAwaitNotification {
100        fn from_value(v: Value) -> Option<Self> {
101            let Value::Object(obj) = v else {
102                return None;
103            };
104            let mut b = PaymentIntentNextActionCardAwaitNotificationBuilder::deser_default();
105            for (k, v) in obj {
106                match k.as_str() {
107                    "charge_attempt_at" => b.charge_attempt_at = FromValueOpt::from_value(v),
108                    "customer_approval_required" => {
109                        b.customer_approval_required = FromValueOpt::from_value(v)
110                    }
111
112                    _ => {}
113                }
114            }
115            b.take_out()
116        }
117    }
118};