Skip to main content

stripe_shared/
payment_method_options_konbini.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 PaymentMethodOptionsKonbini {
6    /// An optional 10 to 11 digit numeric-only string determining the confirmation code at applicable convenience stores.
7    pub confirmation_number: Option<String>,
8    /// The number of calendar days (between 1 and 60) after which Konbini payment instructions will expire.
9    /// 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.
10    pub expires_after_days: Option<u32>,
11    /// The timestamp at which the Konbini payment instructions will expire.
12    /// Only one of `expires_after_days` or `expires_at` may be set.
13    pub expires_at: Option<stripe_types::Timestamp>,
14    /// A product descriptor of up to 22 characters, which will appear to customers at the convenience store.
15    pub product_description: Option<String>,
16    /// Indicates that you intend to make future payments with this PaymentIntent's payment method.
17    ///
18    /// 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.
19    /// 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.
20    ///
21    /// 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.
22    ///
23    /// 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).
24    pub setup_future_usage: Option<PaymentMethodOptionsKonbiniSetupFutureUsage>,
25}
26#[cfg(feature = "redact-generated-debug")]
27impl std::fmt::Debug for PaymentMethodOptionsKonbini {
28    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
29        f.debug_struct("PaymentMethodOptionsKonbini").finish_non_exhaustive()
30    }
31}
32#[doc(hidden)]
33pub struct PaymentMethodOptionsKonbiniBuilder {
34    confirmation_number: Option<Option<String>>,
35    expires_after_days: Option<Option<u32>>,
36    expires_at: Option<Option<stripe_types::Timestamp>>,
37    product_description: Option<Option<String>>,
38    setup_future_usage: Option<Option<PaymentMethodOptionsKonbiniSetupFutureUsage>>,
39}
40
41#[allow(
42    unused_variables,
43    irrefutable_let_patterns,
44    clippy::let_unit_value,
45    clippy::match_single_binding,
46    clippy::single_match
47)]
48const _: () = {
49    use miniserde::de::{Map, Visitor};
50    use miniserde::json::Value;
51    use miniserde::{Deserialize, Result, make_place};
52    use stripe_types::miniserde_helpers::FromValueOpt;
53    use stripe_types::{MapBuilder, ObjectDeser};
54
55    make_place!(Place);
56
57    impl Deserialize for PaymentMethodOptionsKonbini {
58        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
59            Place::new(out)
60        }
61    }
62
63    struct Builder<'a> {
64        out: &'a mut Option<PaymentMethodOptionsKonbini>,
65        builder: PaymentMethodOptionsKonbiniBuilder,
66    }
67
68    impl Visitor for Place<PaymentMethodOptionsKonbini> {
69        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
70            Ok(Box::new(Builder {
71                out: &mut self.out,
72                builder: PaymentMethodOptionsKonbiniBuilder::deser_default(),
73            }))
74        }
75    }
76
77    impl MapBuilder for PaymentMethodOptionsKonbiniBuilder {
78        type Out = PaymentMethodOptionsKonbini;
79        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
80            Ok(match k {
81                "confirmation_number" => Deserialize::begin(&mut self.confirmation_number),
82                "expires_after_days" => Deserialize::begin(&mut self.expires_after_days),
83                "expires_at" => Deserialize::begin(&mut self.expires_at),
84                "product_description" => Deserialize::begin(&mut self.product_description),
85                "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage),
86                _ => <dyn Visitor>::ignore(),
87            })
88        }
89
90        fn deser_default() -> Self {
91            Self {
92                confirmation_number: Some(None),
93                expires_after_days: Some(None),
94                expires_at: Some(None),
95                product_description: Some(None),
96                setup_future_usage: Some(None),
97            }
98        }
99
100        fn take_out(&mut self) -> Option<Self::Out> {
101            let (
102                Some(confirmation_number),
103                Some(expires_after_days),
104                Some(expires_at),
105                Some(product_description),
106                Some(setup_future_usage),
107            ) = (
108                self.confirmation_number.take(),
109                self.expires_after_days,
110                self.expires_at,
111                self.product_description.take(),
112                self.setup_future_usage.take(),
113            )
114            else {
115                return None;
116            };
117            Some(Self::Out {
118                confirmation_number,
119                expires_after_days,
120                expires_at,
121                product_description,
122                setup_future_usage,
123            })
124        }
125    }
126
127    impl Map for Builder<'_> {
128        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
129            self.builder.key(k)
130        }
131
132        fn finish(&mut self) -> Result<()> {
133            *self.out = self.builder.take_out();
134            Ok(())
135        }
136    }
137
138    impl ObjectDeser for PaymentMethodOptionsKonbini {
139        type Builder = PaymentMethodOptionsKonbiniBuilder;
140    }
141
142    impl FromValueOpt for PaymentMethodOptionsKonbini {
143        fn from_value(v: Value) -> Option<Self> {
144            let Value::Object(obj) = v else {
145                return None;
146            };
147            let mut b = PaymentMethodOptionsKonbiniBuilder::deser_default();
148            for (k, v) in obj {
149                match k.as_str() {
150                    "confirmation_number" => b.confirmation_number = FromValueOpt::from_value(v),
151                    "expires_after_days" => b.expires_after_days = FromValueOpt::from_value(v),
152                    "expires_at" => b.expires_at = FromValueOpt::from_value(v),
153                    "product_description" => b.product_description = FromValueOpt::from_value(v),
154                    "setup_future_usage" => b.setup_future_usage = FromValueOpt::from_value(v),
155                    _ => {}
156                }
157            }
158            b.take_out()
159        }
160    }
161};
162/// Indicates that you intend to make future payments with this PaymentIntent's payment method.
163///
164/// 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.
165/// 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.
166///
167/// 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.
168///
169/// 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).
170#[derive(Clone, Eq, PartialEq)]
171#[non_exhaustive]
172pub enum PaymentMethodOptionsKonbiniSetupFutureUsage {
173    None,
174    /// An unrecognized value from Stripe. Should not be used as a request parameter.
175    Unknown(String),
176}
177impl PaymentMethodOptionsKonbiniSetupFutureUsage {
178    pub fn as_str(&self) -> &str {
179        use PaymentMethodOptionsKonbiniSetupFutureUsage::*;
180        match self {
181            None => "none",
182            Unknown(v) => v,
183        }
184    }
185}
186
187impl std::str::FromStr for PaymentMethodOptionsKonbiniSetupFutureUsage {
188    type Err = std::convert::Infallible;
189    fn from_str(s: &str) -> Result<Self, Self::Err> {
190        use PaymentMethodOptionsKonbiniSetupFutureUsage::*;
191        match s {
192            "none" => Ok(None),
193            v => {
194                tracing::warn!(
195                    "Unknown value '{}' for enum '{}'",
196                    v,
197                    "PaymentMethodOptionsKonbiniSetupFutureUsage"
198                );
199                Ok(Unknown(v.to_owned()))
200            }
201        }
202    }
203}
204impl std::fmt::Display for PaymentMethodOptionsKonbiniSetupFutureUsage {
205    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
206        f.write_str(self.as_str())
207    }
208}
209
210#[cfg(not(feature = "redact-generated-debug"))]
211impl std::fmt::Debug for PaymentMethodOptionsKonbiniSetupFutureUsage {
212    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
213        f.write_str(self.as_str())
214    }
215}
216#[cfg(feature = "redact-generated-debug")]
217impl std::fmt::Debug for PaymentMethodOptionsKonbiniSetupFutureUsage {
218    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
219        f.debug_struct(stringify!(PaymentMethodOptionsKonbiniSetupFutureUsage))
220            .finish_non_exhaustive()
221    }
222}
223#[cfg(feature = "serialize")]
224impl serde::Serialize for PaymentMethodOptionsKonbiniSetupFutureUsage {
225    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
226    where
227        S: serde::Serializer,
228    {
229        serializer.serialize_str(self.as_str())
230    }
231}
232impl miniserde::Deserialize for PaymentMethodOptionsKonbiniSetupFutureUsage {
233    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
234        crate::Place::new(out)
235    }
236}
237
238impl miniserde::de::Visitor for crate::Place<PaymentMethodOptionsKonbiniSetupFutureUsage> {
239    fn string(&mut self, s: &str) -> miniserde::Result<()> {
240        use std::str::FromStr;
241        self.out =
242            Some(PaymentMethodOptionsKonbiniSetupFutureUsage::from_str(s).expect("infallible"));
243        Ok(())
244    }
245}
246
247stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsKonbiniSetupFutureUsage);
248#[cfg(feature = "deserialize")]
249impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsKonbiniSetupFutureUsage {
250    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
251        use std::str::FromStr;
252        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
253        Ok(Self::from_str(&s).expect("infallible"))
254    }
255}