stripe_shared/
payment_method_details_paypal.rs

1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct PaymentMethodDetailsPaypal {
5    /// Two-letter ISO code representing the buyer's country.
6    /// Values are provided by PayPal directly (if supported) at the time of authorization or settlement.
7    /// They cannot be set or mutated.
8    pub country: Option<String>,
9    /// Owner's email. Values are provided by PayPal directly
10    /// (if supported) at the time of authorization or settlement. They cannot be set or mutated.
11    pub payer_email: Option<String>,
12    /// PayPal account PayerID. This identifier uniquely identifies the PayPal customer.
13    pub payer_id: Option<String>,
14    /// Owner's full name. Values provided by PayPal directly
15    /// (if supported) at the time of authorization or settlement. They cannot be set or mutated.
16    pub payer_name: Option<String>,
17    /// The level of protection offered as defined by PayPal Seller Protection for Merchants, for this transaction.
18    pub seller_protection: Option<stripe_shared::PaypalSellerProtection>,
19    /// A unique ID generated by PayPal for this transaction.
20    pub transaction_id: Option<String>,
21}
22#[doc(hidden)]
23pub struct PaymentMethodDetailsPaypalBuilder {
24    country: Option<Option<String>>,
25    payer_email: Option<Option<String>>,
26    payer_id: Option<Option<String>>,
27    payer_name: Option<Option<String>>,
28    seller_protection: Option<Option<stripe_shared::PaypalSellerProtection>>,
29    transaction_id: Option<Option<String>>,
30}
31
32#[allow(
33    unused_variables,
34    irrefutable_let_patterns,
35    clippy::let_unit_value,
36    clippy::match_single_binding,
37    clippy::single_match
38)]
39const _: () = {
40    use miniserde::de::{Map, Visitor};
41    use miniserde::json::Value;
42    use miniserde::{Deserialize, Result, make_place};
43    use stripe_types::miniserde_helpers::FromValueOpt;
44    use stripe_types::{MapBuilder, ObjectDeser};
45
46    make_place!(Place);
47
48    impl Deserialize for PaymentMethodDetailsPaypal {
49        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
50            Place::new(out)
51        }
52    }
53
54    struct Builder<'a> {
55        out: &'a mut Option<PaymentMethodDetailsPaypal>,
56        builder: PaymentMethodDetailsPaypalBuilder,
57    }
58
59    impl Visitor for Place<PaymentMethodDetailsPaypal> {
60        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
61            Ok(Box::new(Builder {
62                out: &mut self.out,
63                builder: PaymentMethodDetailsPaypalBuilder::deser_default(),
64            }))
65        }
66    }
67
68    impl MapBuilder for PaymentMethodDetailsPaypalBuilder {
69        type Out = PaymentMethodDetailsPaypal;
70        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
71            Ok(match k {
72                "country" => Deserialize::begin(&mut self.country),
73                "payer_email" => Deserialize::begin(&mut self.payer_email),
74                "payer_id" => Deserialize::begin(&mut self.payer_id),
75                "payer_name" => Deserialize::begin(&mut self.payer_name),
76                "seller_protection" => Deserialize::begin(&mut self.seller_protection),
77                "transaction_id" => Deserialize::begin(&mut self.transaction_id),
78                _ => <dyn Visitor>::ignore(),
79            })
80        }
81
82        fn deser_default() -> Self {
83            Self {
84                country: Deserialize::default(),
85                payer_email: Deserialize::default(),
86                payer_id: Deserialize::default(),
87                payer_name: Deserialize::default(),
88                seller_protection: Deserialize::default(),
89                transaction_id: Deserialize::default(),
90            }
91        }
92
93        fn take_out(&mut self) -> Option<Self::Out> {
94            let (
95                Some(country),
96                Some(payer_email),
97                Some(payer_id),
98                Some(payer_name),
99                Some(seller_protection),
100                Some(transaction_id),
101            ) = (
102                self.country.take(),
103                self.payer_email.take(),
104                self.payer_id.take(),
105                self.payer_name.take(),
106                self.seller_protection.take(),
107                self.transaction_id.take(),
108            )
109            else {
110                return None;
111            };
112            Some(Self::Out {
113                country,
114                payer_email,
115                payer_id,
116                payer_name,
117                seller_protection,
118                transaction_id,
119            })
120        }
121    }
122
123    impl Map for Builder<'_> {
124        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
125            self.builder.key(k)
126        }
127
128        fn finish(&mut self) -> Result<()> {
129            *self.out = self.builder.take_out();
130            Ok(())
131        }
132    }
133
134    impl ObjectDeser for PaymentMethodDetailsPaypal {
135        type Builder = PaymentMethodDetailsPaypalBuilder;
136    }
137
138    impl FromValueOpt for PaymentMethodDetailsPaypal {
139        fn from_value(v: Value) -> Option<Self> {
140            let Value::Object(obj) = v else {
141                return None;
142            };
143            let mut b = PaymentMethodDetailsPaypalBuilder::deser_default();
144            for (k, v) in obj {
145                match k.as_str() {
146                    "country" => b.country = FromValueOpt::from_value(v),
147                    "payer_email" => b.payer_email = FromValueOpt::from_value(v),
148                    "payer_id" => b.payer_id = FromValueOpt::from_value(v),
149                    "payer_name" => b.payer_name = FromValueOpt::from_value(v),
150                    "seller_protection" => b.seller_protection = FromValueOpt::from_value(v),
151                    "transaction_id" => b.transaction_id = FromValueOpt::from_value(v),
152                    _ => {}
153                }
154            }
155            b.take_out()
156        }
157    }
158};