stripe_shared/
payment_method_options_konbini.rs

1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct PaymentMethodOptionsKonbini {
5    /// An optional 10 to 11 digit numeric-only string determining the confirmation code at applicable convenience stores.
6    pub confirmation_number: Option<String>,
7    /// The number of calendar days (between 1 and 60) after which Konbini payment instructions will expire.
8    /// For example, if a PaymentIntent is confirmed with Konbini and `expires_after_days` set to 2 on Monday JST, the instructions will expire on Wednesday 23:59:59 JST.
9    pub expires_after_days: Option<u32>,
10    /// The timestamp at which the Konbini payment instructions will expire.
11    /// Only one of `expires_after_days` or `expires_at` may be set.
12    pub expires_at: Option<stripe_types::Timestamp>,
13    /// A product descriptor of up to 22 characters, which will appear to customers at the convenience store.
14    pub product_description: Option<String>,
15    /// Indicates that you intend to make future payments with this PaymentIntent's payment method.
16    ///
17    /// If you provide a Customer with the PaymentIntent, you can use this parameter to [attach the payment method](/payments/save-during-payment) to the Customer after the PaymentIntent is confirmed and the customer completes any required actions.
18    /// If you don't provide a Customer, you can still [attach](/api/payment_methods/attach) the payment method to a Customer after the transaction completes.
19    ///
20    /// If the payment method is `card_present` and isn't a digital wallet, Stripe creates and attaches a [generated_card](/api/charges/object#charge_object-payment_method_details-card_present-generated_card) payment method representing the card to the Customer instead.
21    ///
22    /// When processing card payments, Stripe uses `setup_future_usage` to help you comply with regional legislation and network rules, such as [SCA](/strong-customer-authentication).
23    pub setup_future_usage: Option<PaymentMethodOptionsKonbiniSetupFutureUsage>,
24}
25#[doc(hidden)]
26pub struct PaymentMethodOptionsKonbiniBuilder {
27    confirmation_number: Option<Option<String>>,
28    expires_after_days: Option<Option<u32>>,
29    expires_at: Option<Option<stripe_types::Timestamp>>,
30    product_description: Option<Option<String>>,
31    setup_future_usage: Option<Option<PaymentMethodOptionsKonbiniSetupFutureUsage>>,
32}
33
34#[allow(
35    unused_variables,
36    irrefutable_let_patterns,
37    clippy::let_unit_value,
38    clippy::match_single_binding,
39    clippy::single_match
40)]
41const _: () = {
42    use miniserde::de::{Map, Visitor};
43    use miniserde::json::Value;
44    use miniserde::{Deserialize, Result, make_place};
45    use stripe_types::miniserde_helpers::FromValueOpt;
46    use stripe_types::{MapBuilder, ObjectDeser};
47
48    make_place!(Place);
49
50    impl Deserialize for PaymentMethodOptionsKonbini {
51        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
52            Place::new(out)
53        }
54    }
55
56    struct Builder<'a> {
57        out: &'a mut Option<PaymentMethodOptionsKonbini>,
58        builder: PaymentMethodOptionsKonbiniBuilder,
59    }
60
61    impl Visitor for Place<PaymentMethodOptionsKonbini> {
62        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
63            Ok(Box::new(Builder {
64                out: &mut self.out,
65                builder: PaymentMethodOptionsKonbiniBuilder::deser_default(),
66            }))
67        }
68    }
69
70    impl MapBuilder for PaymentMethodOptionsKonbiniBuilder {
71        type Out = PaymentMethodOptionsKonbini;
72        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
73            Ok(match k {
74                "confirmation_number" => Deserialize::begin(&mut self.confirmation_number),
75                "expires_after_days" => Deserialize::begin(&mut self.expires_after_days),
76                "expires_at" => Deserialize::begin(&mut self.expires_at),
77                "product_description" => Deserialize::begin(&mut self.product_description),
78                "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage),
79                _ => <dyn Visitor>::ignore(),
80            })
81        }
82
83        fn deser_default() -> Self {
84            Self {
85                confirmation_number: Deserialize::default(),
86                expires_after_days: Deserialize::default(),
87                expires_at: Deserialize::default(),
88                product_description: Deserialize::default(),
89                setup_future_usage: Deserialize::default(),
90            }
91        }
92
93        fn take_out(&mut self) -> Option<Self::Out> {
94            let (
95                Some(confirmation_number),
96                Some(expires_after_days),
97                Some(expires_at),
98                Some(product_description),
99                Some(setup_future_usage),
100            ) = (
101                self.confirmation_number.take(),
102                self.expires_after_days,
103                self.expires_at,
104                self.product_description.take(),
105                self.setup_future_usage,
106            )
107            else {
108                return None;
109            };
110            Some(Self::Out {
111                confirmation_number,
112                expires_after_days,
113                expires_at,
114                product_description,
115                setup_future_usage,
116            })
117        }
118    }
119
120    impl Map for Builder<'_> {
121        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
122            self.builder.key(k)
123        }
124
125        fn finish(&mut self) -> Result<()> {
126            *self.out = self.builder.take_out();
127            Ok(())
128        }
129    }
130
131    impl ObjectDeser for PaymentMethodOptionsKonbini {
132        type Builder = PaymentMethodOptionsKonbiniBuilder;
133    }
134
135    impl FromValueOpt for PaymentMethodOptionsKonbini {
136        fn from_value(v: Value) -> Option<Self> {
137            let Value::Object(obj) = v else {
138                return None;
139            };
140            let mut b = PaymentMethodOptionsKonbiniBuilder::deser_default();
141            for (k, v) in obj {
142                match k.as_str() {
143                    "confirmation_number" => b.confirmation_number = FromValueOpt::from_value(v),
144                    "expires_after_days" => b.expires_after_days = FromValueOpt::from_value(v),
145                    "expires_at" => b.expires_at = FromValueOpt::from_value(v),
146                    "product_description" => b.product_description = FromValueOpt::from_value(v),
147                    "setup_future_usage" => b.setup_future_usage = FromValueOpt::from_value(v),
148                    _ => {}
149                }
150            }
151            b.take_out()
152        }
153    }
154};
155/// Indicates that you intend to make future payments with this PaymentIntent's payment method.
156///
157/// If you provide a Customer with the PaymentIntent, you can use this parameter to [attach the payment method](/payments/save-during-payment) to the Customer after the PaymentIntent is confirmed and the customer completes any required actions.
158/// If you don't provide a Customer, you can still [attach](/api/payment_methods/attach) the payment method to a Customer after the transaction completes.
159///
160/// If the payment method is `card_present` and isn't a digital wallet, Stripe creates and attaches a [generated_card](/api/charges/object#charge_object-payment_method_details-card_present-generated_card) payment method representing the card to the Customer instead.
161///
162/// When processing card payments, Stripe uses `setup_future_usage` to help you comply with regional legislation and network rules, such as [SCA](/strong-customer-authentication).
163#[derive(Copy, Clone, Eq, PartialEq)]
164pub enum PaymentMethodOptionsKonbiniSetupFutureUsage {
165    None,
166}
167impl PaymentMethodOptionsKonbiniSetupFutureUsage {
168    pub fn as_str(self) -> &'static str {
169        use PaymentMethodOptionsKonbiniSetupFutureUsage::*;
170        match self {
171            None => "none",
172        }
173    }
174}
175
176impl std::str::FromStr for PaymentMethodOptionsKonbiniSetupFutureUsage {
177    type Err = stripe_types::StripeParseError;
178    fn from_str(s: &str) -> Result<Self, Self::Err> {
179        use PaymentMethodOptionsKonbiniSetupFutureUsage::*;
180        match s {
181            "none" => Ok(None),
182            _ => Err(stripe_types::StripeParseError),
183        }
184    }
185}
186impl std::fmt::Display for PaymentMethodOptionsKonbiniSetupFutureUsage {
187    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
188        f.write_str(self.as_str())
189    }
190}
191
192impl std::fmt::Debug for PaymentMethodOptionsKonbiniSetupFutureUsage {
193    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
194        f.write_str(self.as_str())
195    }
196}
197#[cfg(feature = "serialize")]
198impl serde::Serialize for PaymentMethodOptionsKonbiniSetupFutureUsage {
199    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
200    where
201        S: serde::Serializer,
202    {
203        serializer.serialize_str(self.as_str())
204    }
205}
206impl miniserde::Deserialize for PaymentMethodOptionsKonbiniSetupFutureUsage {
207    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
208        crate::Place::new(out)
209    }
210}
211
212impl miniserde::de::Visitor for crate::Place<PaymentMethodOptionsKonbiniSetupFutureUsage> {
213    fn string(&mut self, s: &str) -> miniserde::Result<()> {
214        use std::str::FromStr;
215        self.out = Some(
216            PaymentMethodOptionsKonbiniSetupFutureUsage::from_str(s)
217                .map_err(|_| miniserde::Error)?,
218        );
219        Ok(())
220    }
221}
222
223stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsKonbiniSetupFutureUsage);
224#[cfg(feature = "deserialize")]
225impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsKonbiniSetupFutureUsage {
226    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
227        use std::str::FromStr;
228        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
229        Self::from_str(&s).map_err(|_| {
230            serde::de::Error::custom(
231                "Unknown value for PaymentMethodOptionsKonbiniSetupFutureUsage",
232            )
233        })
234    }
235}