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::{make_place, Deserialize, Result};
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
80                _ => <dyn Visitor>::ignore(),
81            })
82        }
83
84        fn deser_default() -> Self {
85            Self {
86                confirmation_number: Deserialize::default(),
87                expires_after_days: Deserialize::default(),
88                expires_at: Deserialize::default(),
89                product_description: Deserialize::default(),
90                setup_future_usage: Deserialize::default(),
91            }
92        }
93
94        fn take_out(&mut self) -> Option<Self::Out> {
95            let (
96                Some(confirmation_number),
97                Some(expires_after_days),
98                Some(expires_at),
99                Some(product_description),
100                Some(setup_future_usage),
101            ) = (
102                self.confirmation_number.take(),
103                self.expires_after_days,
104                self.expires_at,
105                self.product_description.take(),
106                self.setup_future_usage,
107            )
108            else {
109                return None;
110            };
111            Some(Self::Out {
112                confirmation_number,
113                expires_after_days,
114                expires_at,
115                product_description,
116                setup_future_usage,
117            })
118        }
119    }
120
121    impl<'a> Map for Builder<'a> {
122        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
123            self.builder.key(k)
124        }
125
126        fn finish(&mut self) -> Result<()> {
127            *self.out = self.builder.take_out();
128            Ok(())
129        }
130    }
131
132    impl ObjectDeser for PaymentMethodOptionsKonbini {
133        type Builder = PaymentMethodOptionsKonbiniBuilder;
134    }
135
136    impl FromValueOpt for PaymentMethodOptionsKonbini {
137        fn from_value(v: Value) -> Option<Self> {
138            let Value::Object(obj) = v else {
139                return None;
140            };
141            let mut b = PaymentMethodOptionsKonbiniBuilder::deser_default();
142            for (k, v) in obj {
143                match k.as_str() {
144                    "confirmation_number" => b.confirmation_number = FromValueOpt::from_value(v),
145                    "expires_after_days" => b.expires_after_days = FromValueOpt::from_value(v),
146                    "expires_at" => b.expires_at = FromValueOpt::from_value(v),
147                    "product_description" => b.product_description = FromValueOpt::from_value(v),
148                    "setup_future_usage" => b.setup_future_usage = FromValueOpt::from_value(v),
149
150                    _ => {}
151                }
152            }
153            b.take_out()
154        }
155    }
156};
157/// Indicates that you intend to make future payments with this PaymentIntent's payment method.
158///
159/// 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.
160/// 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.
161///
162/// 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.
163///
164/// 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).
165#[derive(Copy, Clone, Eq, PartialEq)]
166pub enum PaymentMethodOptionsKonbiniSetupFutureUsage {
167    None,
168}
169impl PaymentMethodOptionsKonbiniSetupFutureUsage {
170    pub fn as_str(self) -> &'static str {
171        use PaymentMethodOptionsKonbiniSetupFutureUsage::*;
172        match self {
173            None => "none",
174        }
175    }
176}
177
178impl std::str::FromStr for PaymentMethodOptionsKonbiniSetupFutureUsage {
179    type Err = stripe_types::StripeParseError;
180    fn from_str(s: &str) -> Result<Self, Self::Err> {
181        use PaymentMethodOptionsKonbiniSetupFutureUsage::*;
182        match s {
183            "none" => Ok(None),
184            _ => Err(stripe_types::StripeParseError),
185        }
186    }
187}
188impl std::fmt::Display for PaymentMethodOptionsKonbiniSetupFutureUsage {
189    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
190        f.write_str(self.as_str())
191    }
192}
193
194impl std::fmt::Debug for PaymentMethodOptionsKonbiniSetupFutureUsage {
195    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
196        f.write_str(self.as_str())
197    }
198}
199#[cfg(feature = "serialize")]
200impl serde::Serialize for PaymentMethodOptionsKonbiniSetupFutureUsage {
201    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
202    where
203        S: serde::Serializer,
204    {
205        serializer.serialize_str(self.as_str())
206    }
207}
208impl miniserde::Deserialize for PaymentMethodOptionsKonbiniSetupFutureUsage {
209    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
210        crate::Place::new(out)
211    }
212}
213
214impl miniserde::de::Visitor for crate::Place<PaymentMethodOptionsKonbiniSetupFutureUsage> {
215    fn string(&mut self, s: &str) -> miniserde::Result<()> {
216        use std::str::FromStr;
217        self.out = Some(
218            PaymentMethodOptionsKonbiniSetupFutureUsage::from_str(s)
219                .map_err(|_| miniserde::Error)?,
220        );
221        Ok(())
222    }
223}
224
225stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsKonbiniSetupFutureUsage);
226#[cfg(feature = "deserialize")]
227impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsKonbiniSetupFutureUsage {
228    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
229        use std::str::FromStr;
230        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
231        Self::from_str(&s).map_err(|_| {
232            serde::de::Error::custom(
233                "Unknown value for PaymentMethodOptionsKonbiniSetupFutureUsage",
234            )
235        })
236    }
237}