stripe_shared/
issuing_authorization.rs

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