Skip to main content

stripe_shared/
payment_method_details_alipay.rs

1#[derive(Clone, Eq, PartialEq)]
2#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
3#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
4#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
5pub struct PaymentMethodDetailsAlipay {
6    /// Uniquely identifies this particular Alipay account.
7    /// You can use this attribute to check whether two Alipay accounts are the same.
8    pub buyer_id: Option<String>,
9    /// Uniquely identifies this particular Alipay account.
10    /// You can use this attribute to check whether two Alipay accounts are the same.
11    pub fingerprint: Option<String>,
12    /// Transaction ID of this particular Alipay transaction.
13    pub transaction_id: Option<String>,
14}
15#[cfg(feature = "redact-generated-debug")]
16impl std::fmt::Debug for PaymentMethodDetailsAlipay {
17    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
18        f.debug_struct("PaymentMethodDetailsAlipay").finish_non_exhaustive()
19    }
20}
21#[doc(hidden)]
22pub struct PaymentMethodDetailsAlipayBuilder {
23    buyer_id: Option<Option<String>>,
24    fingerprint: Option<Option<String>>,
25    transaction_id: Option<Option<String>>,
26}
27
28#[allow(
29    unused_variables,
30    irrefutable_let_patterns,
31    clippy::let_unit_value,
32    clippy::match_single_binding,
33    clippy::single_match
34)]
35const _: () = {
36    use miniserde::de::{Map, Visitor};
37    use miniserde::json::Value;
38    use miniserde::{Deserialize, Result, make_place};
39    use stripe_types::miniserde_helpers::FromValueOpt;
40    use stripe_types::{MapBuilder, ObjectDeser};
41
42    make_place!(Place);
43
44    impl Deserialize for PaymentMethodDetailsAlipay {
45        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
46            Place::new(out)
47        }
48    }
49
50    struct Builder<'a> {
51        out: &'a mut Option<PaymentMethodDetailsAlipay>,
52        builder: PaymentMethodDetailsAlipayBuilder,
53    }
54
55    impl Visitor for Place<PaymentMethodDetailsAlipay> {
56        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
57            Ok(Box::new(Builder {
58                out: &mut self.out,
59                builder: PaymentMethodDetailsAlipayBuilder::deser_default(),
60            }))
61        }
62    }
63
64    impl MapBuilder for PaymentMethodDetailsAlipayBuilder {
65        type Out = PaymentMethodDetailsAlipay;
66        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
67            Ok(match k {
68                "buyer_id" => Deserialize::begin(&mut self.buyer_id),
69                "fingerprint" => Deserialize::begin(&mut self.fingerprint),
70                "transaction_id" => Deserialize::begin(&mut self.transaction_id),
71                _ => <dyn Visitor>::ignore(),
72            })
73        }
74
75        fn deser_default() -> Self {
76            Self { buyer_id: Some(None), fingerprint: Some(None), transaction_id: Some(None) }
77        }
78
79        fn take_out(&mut self) -> Option<Self::Out> {
80            let (Some(buyer_id), Some(fingerprint), Some(transaction_id)) =
81                (self.buyer_id.take(), self.fingerprint.take(), self.transaction_id.take())
82            else {
83                return None;
84            };
85            Some(Self::Out { buyer_id, fingerprint, transaction_id })
86        }
87    }
88
89    impl Map for Builder<'_> {
90        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
91            self.builder.key(k)
92        }
93
94        fn finish(&mut self) -> Result<()> {
95            *self.out = self.builder.take_out();
96            Ok(())
97        }
98    }
99
100    impl ObjectDeser for PaymentMethodDetailsAlipay {
101        type Builder = PaymentMethodDetailsAlipayBuilder;
102    }
103
104    impl FromValueOpt for PaymentMethodDetailsAlipay {
105        fn from_value(v: Value) -> Option<Self> {
106            let Value::Object(obj) = v else {
107                return None;
108            };
109            let mut b = PaymentMethodDetailsAlipayBuilder::deser_default();
110            for (k, v) in obj {
111                match k.as_str() {
112                    "buyer_id" => b.buyer_id = FromValueOpt::from_value(v),
113                    "fingerprint" => b.fingerprint = FromValueOpt::from_value(v),
114                    "transaction_id" => b.transaction_id = FromValueOpt::from_value(v),
115                    _ => {}
116                }
117            }
118            b.take_out()
119        }
120    }
121};