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::{make_place, Deserialize, Result};
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
79                _ => <dyn Visitor>::ignore(),
80            })
81        }
82
83        fn deser_default() -> Self {
84            Self {
85                country: Deserialize::default(),
86                payer_email: Deserialize::default(),
87                payer_id: Deserialize::default(),
88                payer_name: Deserialize::default(),
89                seller_protection: Deserialize::default(),
90                transaction_id: Deserialize::default(),
91            }
92        }
93
94        fn take_out(&mut self) -> Option<Self::Out> {
95            let (
96                Some(country),
97                Some(payer_email),
98                Some(payer_id),
99                Some(payer_name),
100                Some(seller_protection),
101                Some(transaction_id),
102            ) = (
103                self.country.take(),
104                self.payer_email.take(),
105                self.payer_id.take(),
106                self.payer_name.take(),
107                self.seller_protection.take(),
108                self.transaction_id.take(),
109            )
110            else {
111                return None;
112            };
113            Some(Self::Out {
114                country,
115                payer_email,
116                payer_id,
117                payer_name,
118                seller_protection,
119                transaction_id,
120            })
121        }
122    }
123
124    impl<'a> Map for Builder<'a> {
125        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
126            self.builder.key(k)
127        }
128
129        fn finish(&mut self) -> Result<()> {
130            *self.out = self.builder.take_out();
131            Ok(())
132        }
133    }
134
135    impl ObjectDeser for PaymentMethodDetailsPaypal {
136        type Builder = PaymentMethodDetailsPaypalBuilder;
137    }
138
139    impl FromValueOpt for PaymentMethodDetailsPaypal {
140        fn from_value(v: Value) -> Option<Self> {
141            let Value::Object(obj) = v else {
142                return None;
143            };
144            let mut b = PaymentMethodDetailsPaypalBuilder::deser_default();
145            for (k, v) in obj {
146                match k.as_str() {
147                    "country" => b.country = FromValueOpt::from_value(v),
148                    "payer_email" => b.payer_email = FromValueOpt::from_value(v),
149                    "payer_id" => b.payer_id = FromValueOpt::from_value(v),
150                    "payer_name" => b.payer_name = FromValueOpt::from_value(v),
151                    "seller_protection" => b.seller_protection = FromValueOpt::from_value(v),
152                    "transaction_id" => b.transaction_id = FromValueOpt::from_value(v),
153
154                    _ => {}
155                }
156            }
157            b.take_out()
158        }
159    }
160};