Skip to main content

stripe_shared/
issuing_authorization.rs

1/// When an [issued card](https://docs.stripe.com/issuing) is used to make a purchase, an Issuing `Authorization`.
2/// object is created.
3/// [Authorizations](https://docs.stripe.com/issuing/purchases/authorizations) must be approved for the.
4/// purchase to be completed successfully.
5///
6/// Related guide: [Issued card authorizations](https://docs.stripe.com/issuing/purchases/authorizations).
7///
8/// For more details see <<https://stripe.com/docs/api/issuing/authorizations/object>>.
9#[derive(Clone)]
10#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
11#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
12pub struct IssuingAuthorization {
13    /// The total amount that was authorized or rejected.
14    /// This amount is in `currency` and in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal).
15    /// `amount` should be the same as `merchant_amount`, unless `currency` and `merchant_currency` are different.
16    pub amount: i64,
17    /// Detailed breakdown of amount components.
18    /// These amounts are denominated in `currency` and in the [smallest currency unit](https://docs.stripe.com/currencies#zero-decimal).
19    pub amount_details: Option<stripe_shared::IssuingAuthorizationAmountDetails>,
20    /// Whether the authorization has been approved.
21    pub approved: bool,
22    /// How the card details were provided.
23    pub authorization_method: stripe_shared::IssuingAuthorizationAuthorizationMethod,
24    /// List of balance transactions associated with this authorization.
25    pub balance_transactions: Vec<stripe_shared::BalanceTransaction>,
26    pub card: stripe_shared::IssuingCard,
27    /// Whether the card was present at the point of sale for the authorization.
28    pub card_presence: Option<IssuingAuthorizationCardPresence>,
29    /// The cardholder to whom this authorization belongs.
30    pub cardholder: Option<stripe_types::Expandable<stripe_shared::IssuingCardholder>>,
31    /// Time at which the object was created. Measured in seconds since the Unix epoch.
32    pub created: stripe_types::Timestamp,
33    /// The currency of the cardholder.
34    /// This currency can be different from the currency presented at authorization and the `merchant_currency` field on this authorization.
35    /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase.
36    /// Must be a [supported currency](https://stripe.com/docs/currencies).
37    pub currency: stripe_types::Currency,
38    /// Fleet-specific information for authorizations using Fleet cards.
39    pub fleet: Option<stripe_shared::IssuingAuthorizationFleetData>,
40    /// Fraud challenges sent to the cardholder, if this authorization was declined for fraud risk reasons.
41    pub fraud_challenges: Option<Vec<stripe_shared::IssuingAuthorizationFraudChallenge>>,
42    /// Information about fuel that was purchased with this transaction.
43    /// Typically this information is received from the merchant after the authorization has been approved and the fuel dispensed.
44    pub fuel: Option<stripe_shared::IssuingAuthorizationFuelData>,
45    /// Unique identifier for the object.
46    pub id: stripe_shared::IssuingAuthorizationId,
47    /// If the object exists in live mode, the value is `true`.
48    /// If the object exists in test mode, the value is `false`.
49    pub livemode: bool,
50    /// The total amount that was authorized or rejected.
51    /// This amount is in the `merchant_currency` and in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal).
52    /// `merchant_amount` should be the same as `amount`, unless `merchant_currency` and `currency` are different.
53    pub merchant_amount: i64,
54    /// The local currency that was presented to the cardholder for the authorization.
55    /// This currency can be different from the cardholder currency and the `currency` field on this authorization.
56    /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase.
57    /// Must be a [supported currency](https://stripe.com/docs/currencies).
58    pub merchant_currency: stripe_types::Currency,
59    pub merchant_data: stripe_shared::IssuingAuthorizationMerchantData,
60    /// Set of [key-value pairs](https://docs.stripe.com/api/metadata) that you can attach to an object.
61    /// This can be useful for storing additional information about the object in a structured format.
62    pub metadata: std::collections::HashMap<String, String>,
63    /// Details about the authorization, such as identifiers, set by the card network.
64    pub network_data: Option<stripe_shared::IssuingAuthorizationNetworkData>,
65    /// The pending authorization request.
66    /// This field will only be non-null during an `issuing_authorization.request` webhook.
67    pub pending_request: Option<stripe_shared::IssuingAuthorizationPendingRequest>,
68    /// History of every time a `pending_request` authorization was approved/declined, either by you directly or by Stripe (e.g.
69    /// based on your spending_controls).
70    /// If the merchant changes the authorization by performing an incremental authorization, you can look at this field to see the previous requests for the authorization.
71    /// This field can be helpful in determining why a given authorization was approved/declined.
72    pub request_history: Vec<stripe_shared::IssuingAuthorizationRequest>,
73    /// The current status of the authorization in its lifecycle.
74    pub status: stripe_shared::IssuingAuthorizationStatus,
75    /// [Token](https://docs.stripe.com/api/issuing/tokens/object) object used for this authorization.
76    /// If a network token was not used for this authorization, this field will be null.
77    pub token: Option<stripe_types::Expandable<stripe_shared::IssuingToken>>,
78    /// List of [transactions](https://docs.stripe.com/api/issuing/transactions) associated with this authorization.
79    pub transactions: Vec<stripe_shared::IssuingTransaction>,
80    /// [Treasury](https://docs.stripe.com/api/treasury) details related to this authorization if it was created on a [FinancialAccount](https://docs.stripe.com/api/treasury/financial_accounts).
81    pub treasury: Option<stripe_shared::IssuingAuthorizationTreasury>,
82    pub verification_data: stripe_shared::IssuingAuthorizationVerificationData,
83    /// Whether the authorization bypassed fraud risk checks because the cardholder has previously completed a fraud challenge on a similar high-risk authorization from the same merchant.
84    pub verified_by_fraud_challenge: Option<bool>,
85    /// The digital wallet used for this transaction.
86    /// One of `apple_pay`, `google_pay`, or `samsung_pay`.
87    /// Will populate as `null` when no digital wallet was utilized.
88    pub wallet: Option<String>,
89}
90#[cfg(feature = "redact-generated-debug")]
91impl std::fmt::Debug for IssuingAuthorization {
92    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
93        f.debug_struct("IssuingAuthorization").finish_non_exhaustive()
94    }
95}
96#[doc(hidden)]
97pub struct IssuingAuthorizationBuilder {
98    amount: Option<i64>,
99    amount_details: Option<Option<stripe_shared::IssuingAuthorizationAmountDetails>>,
100    approved: Option<bool>,
101    authorization_method: Option<stripe_shared::IssuingAuthorizationAuthorizationMethod>,
102    balance_transactions: Option<Vec<stripe_shared::BalanceTransaction>>,
103    card: Option<stripe_shared::IssuingCard>,
104    card_presence: Option<Option<IssuingAuthorizationCardPresence>>,
105    cardholder: Option<Option<stripe_types::Expandable<stripe_shared::IssuingCardholder>>>,
106    created: Option<stripe_types::Timestamp>,
107    currency: Option<stripe_types::Currency>,
108    fleet: Option<Option<stripe_shared::IssuingAuthorizationFleetData>>,
109    fraud_challenges: Option<Option<Vec<stripe_shared::IssuingAuthorizationFraudChallenge>>>,
110    fuel: Option<Option<stripe_shared::IssuingAuthorizationFuelData>>,
111    id: Option<stripe_shared::IssuingAuthorizationId>,
112    livemode: Option<bool>,
113    merchant_amount: Option<i64>,
114    merchant_currency: Option<stripe_types::Currency>,
115    merchant_data: Option<stripe_shared::IssuingAuthorizationMerchantData>,
116    metadata: Option<std::collections::HashMap<String, String>>,
117    network_data: Option<Option<stripe_shared::IssuingAuthorizationNetworkData>>,
118    pending_request: Option<Option<stripe_shared::IssuingAuthorizationPendingRequest>>,
119    request_history: Option<Vec<stripe_shared::IssuingAuthorizationRequest>>,
120    status: Option<stripe_shared::IssuingAuthorizationStatus>,
121    token: Option<Option<stripe_types::Expandable<stripe_shared::IssuingToken>>>,
122    transactions: Option<Vec<stripe_shared::IssuingTransaction>>,
123    treasury: Option<Option<stripe_shared::IssuingAuthorizationTreasury>>,
124    verification_data: Option<stripe_shared::IssuingAuthorizationVerificationData>,
125    verified_by_fraud_challenge: Option<Option<bool>>,
126    wallet: Option<Option<String>>,
127}
128
129#[allow(
130    unused_variables,
131    irrefutable_let_patterns,
132    clippy::let_unit_value,
133    clippy::match_single_binding,
134    clippy::single_match
135)]
136const _: () = {
137    use miniserde::de::{Map, Visitor};
138    use miniserde::json::Value;
139    use miniserde::{Deserialize, Result, make_place};
140    use stripe_types::miniserde_helpers::FromValueOpt;
141    use stripe_types::{MapBuilder, ObjectDeser};
142
143    make_place!(Place);
144
145    impl Deserialize for IssuingAuthorization {
146        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
147            Place::new(out)
148        }
149    }
150
151    struct Builder<'a> {
152        out: &'a mut Option<IssuingAuthorization>,
153        builder: IssuingAuthorizationBuilder,
154    }
155
156    impl Visitor for Place<IssuingAuthorization> {
157        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
158            Ok(Box::new(Builder {
159                out: &mut self.out,
160                builder: IssuingAuthorizationBuilder::deser_default(),
161            }))
162        }
163    }
164
165    impl MapBuilder for IssuingAuthorizationBuilder {
166        type Out = IssuingAuthorization;
167        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
168            Ok(match k {
169                "amount" => Deserialize::begin(&mut self.amount),
170                "amount_details" => Deserialize::begin(&mut self.amount_details),
171                "approved" => Deserialize::begin(&mut self.approved),
172                "authorization_method" => Deserialize::begin(&mut self.authorization_method),
173                "balance_transactions" => Deserialize::begin(&mut self.balance_transactions),
174                "card" => Deserialize::begin(&mut self.card),
175                "card_presence" => Deserialize::begin(&mut self.card_presence),
176                "cardholder" => Deserialize::begin(&mut self.cardholder),
177                "created" => Deserialize::begin(&mut self.created),
178                "currency" => Deserialize::begin(&mut self.currency),
179                "fleet" => Deserialize::begin(&mut self.fleet),
180                "fraud_challenges" => Deserialize::begin(&mut self.fraud_challenges),
181                "fuel" => Deserialize::begin(&mut self.fuel),
182                "id" => Deserialize::begin(&mut self.id),
183                "livemode" => Deserialize::begin(&mut self.livemode),
184                "merchant_amount" => Deserialize::begin(&mut self.merchant_amount),
185                "merchant_currency" => Deserialize::begin(&mut self.merchant_currency),
186                "merchant_data" => Deserialize::begin(&mut self.merchant_data),
187                "metadata" => Deserialize::begin(&mut self.metadata),
188                "network_data" => Deserialize::begin(&mut self.network_data),
189                "pending_request" => Deserialize::begin(&mut self.pending_request),
190                "request_history" => Deserialize::begin(&mut self.request_history),
191                "status" => Deserialize::begin(&mut self.status),
192                "token" => Deserialize::begin(&mut self.token),
193                "transactions" => Deserialize::begin(&mut self.transactions),
194                "treasury" => Deserialize::begin(&mut self.treasury),
195                "verification_data" => Deserialize::begin(&mut self.verification_data),
196                "verified_by_fraud_challenge" => {
197                    Deserialize::begin(&mut self.verified_by_fraud_challenge)
198                }
199                "wallet" => Deserialize::begin(&mut self.wallet),
200                _ => <dyn Visitor>::ignore(),
201            })
202        }
203
204        fn deser_default() -> Self {
205            Self {
206                amount: None,
207                amount_details: Some(None),
208                approved: None,
209                authorization_method: None,
210                balance_transactions: None,
211                card: None,
212                card_presence: Some(None),
213                cardholder: Some(None),
214                created: None,
215                currency: None,
216                fleet: Some(None),
217                fraud_challenges: Some(None),
218                fuel: Some(None),
219                id: None,
220                livemode: None,
221                merchant_amount: None,
222                merchant_currency: None,
223                merchant_data: None,
224                metadata: None,
225                network_data: Some(None),
226                pending_request: Some(None),
227                request_history: None,
228                status: None,
229                token: Some(None),
230                transactions: None,
231                treasury: Some(None),
232                verification_data: None,
233                verified_by_fraud_challenge: Some(None),
234                wallet: Some(None),
235            }
236        }
237
238        fn take_out(&mut self) -> Option<Self::Out> {
239            let (
240                Some(amount),
241                Some(amount_details),
242                Some(approved),
243                Some(authorization_method),
244                Some(balance_transactions),
245                Some(card),
246                Some(card_presence),
247                Some(cardholder),
248                Some(created),
249                Some(currency),
250                Some(fleet),
251                Some(fraud_challenges),
252                Some(fuel),
253                Some(id),
254                Some(livemode),
255                Some(merchant_amount),
256                Some(merchant_currency),
257                Some(merchant_data),
258                Some(metadata),
259                Some(network_data),
260                Some(pending_request),
261                Some(request_history),
262                Some(status),
263                Some(token),
264                Some(transactions),
265                Some(treasury),
266                Some(verification_data),
267                Some(verified_by_fraud_challenge),
268                Some(wallet),
269            ) = (
270                self.amount,
271                self.amount_details,
272                self.approved,
273                self.authorization_method.take(),
274                self.balance_transactions.take(),
275                self.card.take(),
276                self.card_presence.take(),
277                self.cardholder.take(),
278                self.created,
279                self.currency.take(),
280                self.fleet.take(),
281                self.fraud_challenges.take(),
282                self.fuel.take(),
283                self.id.take(),
284                self.livemode,
285                self.merchant_amount,
286                self.merchant_currency.take(),
287                self.merchant_data.take(),
288                self.metadata.take(),
289                self.network_data.take(),
290                self.pending_request.take(),
291                self.request_history.take(),
292                self.status.take(),
293                self.token.take(),
294                self.transactions.take(),
295                self.treasury.take(),
296                self.verification_data.take(),
297                self.verified_by_fraud_challenge,
298                self.wallet.take(),
299            )
300            else {
301                return None;
302            };
303            Some(Self::Out {
304                amount,
305                amount_details,
306                approved,
307                authorization_method,
308                balance_transactions,
309                card,
310                card_presence,
311                cardholder,
312                created,
313                currency,
314                fleet,
315                fraud_challenges,
316                fuel,
317                id,
318                livemode,
319                merchant_amount,
320                merchant_currency,
321                merchant_data,
322                metadata,
323                network_data,
324                pending_request,
325                request_history,
326                status,
327                token,
328                transactions,
329                treasury,
330                verification_data,
331                verified_by_fraud_challenge,
332                wallet,
333            })
334        }
335    }
336
337    impl Map for Builder<'_> {
338        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
339            self.builder.key(k)
340        }
341
342        fn finish(&mut self) -> Result<()> {
343            *self.out = self.builder.take_out();
344            Ok(())
345        }
346    }
347
348    impl ObjectDeser for IssuingAuthorization {
349        type Builder = IssuingAuthorizationBuilder;
350    }
351
352    impl FromValueOpt for IssuingAuthorization {
353        fn from_value(v: Value) -> Option<Self> {
354            let Value::Object(obj) = v else {
355                return None;
356            };
357            let mut b = IssuingAuthorizationBuilder::deser_default();
358            for (k, v) in obj {
359                match k.as_str() {
360                    "amount" => b.amount = FromValueOpt::from_value(v),
361                    "amount_details" => b.amount_details = FromValueOpt::from_value(v),
362                    "approved" => b.approved = FromValueOpt::from_value(v),
363                    "authorization_method" => b.authorization_method = FromValueOpt::from_value(v),
364                    "balance_transactions" => b.balance_transactions = FromValueOpt::from_value(v),
365                    "card" => b.card = FromValueOpt::from_value(v),
366                    "card_presence" => b.card_presence = FromValueOpt::from_value(v),
367                    "cardholder" => b.cardholder = FromValueOpt::from_value(v),
368                    "created" => b.created = FromValueOpt::from_value(v),
369                    "currency" => b.currency = FromValueOpt::from_value(v),
370                    "fleet" => b.fleet = FromValueOpt::from_value(v),
371                    "fraud_challenges" => b.fraud_challenges = FromValueOpt::from_value(v),
372                    "fuel" => b.fuel = FromValueOpt::from_value(v),
373                    "id" => b.id = FromValueOpt::from_value(v),
374                    "livemode" => b.livemode = FromValueOpt::from_value(v),
375                    "merchant_amount" => b.merchant_amount = FromValueOpt::from_value(v),
376                    "merchant_currency" => b.merchant_currency = FromValueOpt::from_value(v),
377                    "merchant_data" => b.merchant_data = FromValueOpt::from_value(v),
378                    "metadata" => b.metadata = FromValueOpt::from_value(v),
379                    "network_data" => b.network_data = FromValueOpt::from_value(v),
380                    "pending_request" => b.pending_request = FromValueOpt::from_value(v),
381                    "request_history" => b.request_history = FromValueOpt::from_value(v),
382                    "status" => b.status = FromValueOpt::from_value(v),
383                    "token" => b.token = FromValueOpt::from_value(v),
384                    "transactions" => b.transactions = FromValueOpt::from_value(v),
385                    "treasury" => b.treasury = FromValueOpt::from_value(v),
386                    "verification_data" => b.verification_data = FromValueOpt::from_value(v),
387                    "verified_by_fraud_challenge" => {
388                        b.verified_by_fraud_challenge = FromValueOpt::from_value(v)
389                    }
390                    "wallet" => b.wallet = FromValueOpt::from_value(v),
391                    _ => {}
392                }
393            }
394            b.take_out()
395        }
396    }
397};
398#[cfg(feature = "serialize")]
399impl serde::Serialize for IssuingAuthorization {
400    fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
401        use serde::ser::SerializeStruct;
402        let mut s = s.serialize_struct("IssuingAuthorization", 30)?;
403        s.serialize_field("amount", &self.amount)?;
404        s.serialize_field("amount_details", &self.amount_details)?;
405        s.serialize_field("approved", &self.approved)?;
406        s.serialize_field("authorization_method", &self.authorization_method)?;
407        s.serialize_field("balance_transactions", &self.balance_transactions)?;
408        s.serialize_field("card", &self.card)?;
409        s.serialize_field("card_presence", &self.card_presence)?;
410        s.serialize_field("cardholder", &self.cardholder)?;
411        s.serialize_field("created", &self.created)?;
412        s.serialize_field("currency", &self.currency)?;
413        s.serialize_field("fleet", &self.fleet)?;
414        s.serialize_field("fraud_challenges", &self.fraud_challenges)?;
415        s.serialize_field("fuel", &self.fuel)?;
416        s.serialize_field("id", &self.id)?;
417        s.serialize_field("livemode", &self.livemode)?;
418        s.serialize_field("merchant_amount", &self.merchant_amount)?;
419        s.serialize_field("merchant_currency", &self.merchant_currency)?;
420        s.serialize_field("merchant_data", &self.merchant_data)?;
421        s.serialize_field("metadata", &self.metadata)?;
422        s.serialize_field("network_data", &self.network_data)?;
423        s.serialize_field("pending_request", &self.pending_request)?;
424        s.serialize_field("request_history", &self.request_history)?;
425        s.serialize_field("status", &self.status)?;
426        s.serialize_field("token", &self.token)?;
427        s.serialize_field("transactions", &self.transactions)?;
428        s.serialize_field("treasury", &self.treasury)?;
429        s.serialize_field("verification_data", &self.verification_data)?;
430        s.serialize_field("verified_by_fraud_challenge", &self.verified_by_fraud_challenge)?;
431        s.serialize_field("wallet", &self.wallet)?;
432
433        s.serialize_field("object", "issuing.authorization")?;
434        s.end()
435    }
436}
437/// Whether the card was present at the point of sale for the authorization.
438#[derive(Clone, Eq, PartialEq)]
439#[non_exhaustive]
440pub enum IssuingAuthorizationCardPresence {
441    NotPresent,
442    Present,
443    /// An unrecognized value from Stripe. Should not be used as a request parameter.
444    Unknown(String),
445}
446impl IssuingAuthorizationCardPresence {
447    pub fn as_str(&self) -> &str {
448        use IssuingAuthorizationCardPresence::*;
449        match self {
450            NotPresent => "not_present",
451            Present => "present",
452            Unknown(v) => v,
453        }
454    }
455}
456
457impl std::str::FromStr for IssuingAuthorizationCardPresence {
458    type Err = std::convert::Infallible;
459    fn from_str(s: &str) -> Result<Self, Self::Err> {
460        use IssuingAuthorizationCardPresence::*;
461        match s {
462            "not_present" => Ok(NotPresent),
463            "present" => Ok(Present),
464            v => {
465                tracing::warn!(
466                    "Unknown value '{}' for enum '{}'",
467                    v,
468                    "IssuingAuthorizationCardPresence"
469                );
470                Ok(Unknown(v.to_owned()))
471            }
472        }
473    }
474}
475impl std::fmt::Display for IssuingAuthorizationCardPresence {
476    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
477        f.write_str(self.as_str())
478    }
479}
480
481#[cfg(not(feature = "redact-generated-debug"))]
482impl std::fmt::Debug for IssuingAuthorizationCardPresence {
483    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
484        f.write_str(self.as_str())
485    }
486}
487#[cfg(feature = "redact-generated-debug")]
488impl std::fmt::Debug for IssuingAuthorizationCardPresence {
489    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
490        f.debug_struct(stringify!(IssuingAuthorizationCardPresence)).finish_non_exhaustive()
491    }
492}
493#[cfg(feature = "serialize")]
494impl serde::Serialize for IssuingAuthorizationCardPresence {
495    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
496    where
497        S: serde::Serializer,
498    {
499        serializer.serialize_str(self.as_str())
500    }
501}
502impl miniserde::Deserialize for IssuingAuthorizationCardPresence {
503    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
504        crate::Place::new(out)
505    }
506}
507
508impl miniserde::de::Visitor for crate::Place<IssuingAuthorizationCardPresence> {
509    fn string(&mut self, s: &str) -> miniserde::Result<()> {
510        use std::str::FromStr;
511        self.out = Some(IssuingAuthorizationCardPresence::from_str(s).expect("infallible"));
512        Ok(())
513    }
514}
515
516stripe_types::impl_from_val_with_from_str!(IssuingAuthorizationCardPresence);
517#[cfg(feature = "deserialize")]
518impl<'de> serde::Deserialize<'de> for IssuingAuthorizationCardPresence {
519    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
520        use std::str::FromStr;
521        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
522        Ok(Self::from_str(&s).expect("infallible"))
523    }
524}
525impl stripe_types::Object for IssuingAuthorization {
526    type Id = stripe_shared::IssuingAuthorizationId;
527    fn id(&self) -> &Self::Id {
528        &self.id
529    }
530
531    fn into_id(self) -> Self::Id {
532        self.id
533    }
534}
535stripe_types::def_id!(IssuingAuthorizationId);
536#[derive(Clone, Eq, PartialEq)]
537#[non_exhaustive]
538pub enum IssuingAuthorizationAuthorizationMethod {
539    Chip,
540    Contactless,
541    KeyedIn,
542    Online,
543    Swipe,
544    /// An unrecognized value from Stripe. Should not be used as a request parameter.
545    Unknown(String),
546}
547impl IssuingAuthorizationAuthorizationMethod {
548    pub fn as_str(&self) -> &str {
549        use IssuingAuthorizationAuthorizationMethod::*;
550        match self {
551            Chip => "chip",
552            Contactless => "contactless",
553            KeyedIn => "keyed_in",
554            Online => "online",
555            Swipe => "swipe",
556            Unknown(v) => v,
557        }
558    }
559}
560
561impl std::str::FromStr for IssuingAuthorizationAuthorizationMethod {
562    type Err = std::convert::Infallible;
563    fn from_str(s: &str) -> Result<Self, Self::Err> {
564        use IssuingAuthorizationAuthorizationMethod::*;
565        match s {
566            "chip" => Ok(Chip),
567            "contactless" => Ok(Contactless),
568            "keyed_in" => Ok(KeyedIn),
569            "online" => Ok(Online),
570            "swipe" => Ok(Swipe),
571            v => {
572                tracing::warn!(
573                    "Unknown value '{}' for enum '{}'",
574                    v,
575                    "IssuingAuthorizationAuthorizationMethod"
576                );
577                Ok(Unknown(v.to_owned()))
578            }
579        }
580    }
581}
582impl std::fmt::Display for IssuingAuthorizationAuthorizationMethod {
583    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
584        f.write_str(self.as_str())
585    }
586}
587
588#[cfg(not(feature = "redact-generated-debug"))]
589impl std::fmt::Debug for IssuingAuthorizationAuthorizationMethod {
590    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
591        f.write_str(self.as_str())
592    }
593}
594#[cfg(feature = "redact-generated-debug")]
595impl std::fmt::Debug for IssuingAuthorizationAuthorizationMethod {
596    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
597        f.debug_struct(stringify!(IssuingAuthorizationAuthorizationMethod)).finish_non_exhaustive()
598    }
599}
600impl serde::Serialize for IssuingAuthorizationAuthorizationMethod {
601    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
602    where
603        S: serde::Serializer,
604    {
605        serializer.serialize_str(self.as_str())
606    }
607}
608impl miniserde::Deserialize for IssuingAuthorizationAuthorizationMethod {
609    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
610        crate::Place::new(out)
611    }
612}
613
614impl miniserde::de::Visitor for crate::Place<IssuingAuthorizationAuthorizationMethod> {
615    fn string(&mut self, s: &str) -> miniserde::Result<()> {
616        use std::str::FromStr;
617        self.out = Some(IssuingAuthorizationAuthorizationMethod::from_str(s).expect("infallible"));
618        Ok(())
619    }
620}
621
622stripe_types::impl_from_val_with_from_str!(IssuingAuthorizationAuthorizationMethod);
623#[cfg(feature = "deserialize")]
624impl<'de> serde::Deserialize<'de> for IssuingAuthorizationAuthorizationMethod {
625    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
626        use std::str::FromStr;
627        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
628        Ok(Self::from_str(&s).expect("infallible"))
629    }
630}
631#[derive(Clone, Eq, PartialEq)]
632#[non_exhaustive]
633pub enum IssuingAuthorizationStatus {
634    Closed,
635    Expired,
636    Pending,
637    Reversed,
638    /// An unrecognized value from Stripe. Should not be used as a request parameter.
639    Unknown(String),
640}
641impl IssuingAuthorizationStatus {
642    pub fn as_str(&self) -> &str {
643        use IssuingAuthorizationStatus::*;
644        match self {
645            Closed => "closed",
646            Expired => "expired",
647            Pending => "pending",
648            Reversed => "reversed",
649            Unknown(v) => v,
650        }
651    }
652}
653
654impl std::str::FromStr for IssuingAuthorizationStatus {
655    type Err = std::convert::Infallible;
656    fn from_str(s: &str) -> Result<Self, Self::Err> {
657        use IssuingAuthorizationStatus::*;
658        match s {
659            "closed" => Ok(Closed),
660            "expired" => Ok(Expired),
661            "pending" => Ok(Pending),
662            "reversed" => Ok(Reversed),
663            v => {
664                tracing::warn!("Unknown value '{}' for enum '{}'", v, "IssuingAuthorizationStatus");
665                Ok(Unknown(v.to_owned()))
666            }
667        }
668    }
669}
670impl std::fmt::Display for IssuingAuthorizationStatus {
671    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
672        f.write_str(self.as_str())
673    }
674}
675
676#[cfg(not(feature = "redact-generated-debug"))]
677impl std::fmt::Debug for IssuingAuthorizationStatus {
678    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
679        f.write_str(self.as_str())
680    }
681}
682#[cfg(feature = "redact-generated-debug")]
683impl std::fmt::Debug for IssuingAuthorizationStatus {
684    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
685        f.debug_struct(stringify!(IssuingAuthorizationStatus)).finish_non_exhaustive()
686    }
687}
688impl serde::Serialize for IssuingAuthorizationStatus {
689    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
690    where
691        S: serde::Serializer,
692    {
693        serializer.serialize_str(self.as_str())
694    }
695}
696impl miniserde::Deserialize for IssuingAuthorizationStatus {
697    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
698        crate::Place::new(out)
699    }
700}
701
702impl miniserde::de::Visitor for crate::Place<IssuingAuthorizationStatus> {
703    fn string(&mut self, s: &str) -> miniserde::Result<()> {
704        use std::str::FromStr;
705        self.out = Some(IssuingAuthorizationStatus::from_str(s).expect("infallible"));
706        Ok(())
707    }
708}
709
710stripe_types::impl_from_val_with_from_str!(IssuingAuthorizationStatus);
711#[cfg(feature = "deserialize")]
712impl<'de> serde::Deserialize<'de> for IssuingAuthorizationStatus {
713    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
714        use std::str::FromStr;
715        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
716        Ok(Self::from_str(&s).expect("infallible"))
717    }
718}