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::{make_place, Deserialize, Result};
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
189                _ => <dyn Visitor>::ignore(),
190            })
191        }
192
193        fn deser_default() -> Self {
194            Self {
195                amount: Deserialize::default(),
196                amount_details: Deserialize::default(),
197                approved: Deserialize::default(),
198                authorization_method: Deserialize::default(),
199                balance_transactions: Deserialize::default(),
200                card: Deserialize::default(),
201                cardholder: Deserialize::default(),
202                created: Deserialize::default(),
203                currency: Deserialize::default(),
204                fleet: Deserialize::default(),
205                fraud_challenges: Deserialize::default(),
206                fuel: Deserialize::default(),
207                id: Deserialize::default(),
208                livemode: Deserialize::default(),
209                merchant_amount: Deserialize::default(),
210                merchant_currency: Deserialize::default(),
211                merchant_data: Deserialize::default(),
212                metadata: Deserialize::default(),
213                network_data: Deserialize::default(),
214                pending_request: Deserialize::default(),
215                request_history: Deserialize::default(),
216                status: Deserialize::default(),
217                token: Deserialize::default(),
218                transactions: Deserialize::default(),
219                treasury: Deserialize::default(),
220                verification_data: Deserialize::default(),
221                verified_by_fraud_challenge: Deserialize::default(),
222                wallet: Deserialize::default(),
223            }
224        }
225
226        fn take_out(&mut self) -> Option<Self::Out> {
227            let (
228                Some(amount),
229                Some(amount_details),
230                Some(approved),
231                Some(authorization_method),
232                Some(balance_transactions),
233                Some(card),
234                Some(cardholder),
235                Some(created),
236                Some(currency),
237                Some(fleet),
238                Some(fraud_challenges),
239                Some(fuel),
240                Some(id),
241                Some(livemode),
242                Some(merchant_amount),
243                Some(merchant_currency),
244                Some(merchant_data),
245                Some(metadata),
246                Some(network_data),
247                Some(pending_request),
248                Some(request_history),
249                Some(status),
250                Some(token),
251                Some(transactions),
252                Some(treasury),
253                Some(verification_data),
254                Some(verified_by_fraud_challenge),
255                Some(wallet),
256            ) = (
257                self.amount,
258                self.amount_details,
259                self.approved,
260                self.authorization_method,
261                self.balance_transactions.take(),
262                self.card.take(),
263                self.cardholder.take(),
264                self.created,
265                self.currency,
266                self.fleet.take(),
267                self.fraud_challenges.take(),
268                self.fuel.take(),
269                self.id.take(),
270                self.livemode,
271                self.merchant_amount,
272                self.merchant_currency,
273                self.merchant_data.take(),
274                self.metadata.take(),
275                self.network_data.take(),
276                self.pending_request,
277                self.request_history.take(),
278                self.status,
279                self.token.take(),
280                self.transactions.take(),
281                self.treasury.take(),
282                self.verification_data.take(),
283                self.verified_by_fraud_challenge,
284                self.wallet.take(),
285            )
286            else {
287                return None;
288            };
289            Some(Self::Out {
290                amount,
291                amount_details,
292                approved,
293                authorization_method,
294                balance_transactions,
295                card,
296                cardholder,
297                created,
298                currency,
299                fleet,
300                fraud_challenges,
301                fuel,
302                id,
303                livemode,
304                merchant_amount,
305                merchant_currency,
306                merchant_data,
307                metadata,
308                network_data,
309                pending_request,
310                request_history,
311                status,
312                token,
313                transactions,
314                treasury,
315                verification_data,
316                verified_by_fraud_challenge,
317                wallet,
318            })
319        }
320    }
321
322    impl<'a> Map for Builder<'a> {
323        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
324            self.builder.key(k)
325        }
326
327        fn finish(&mut self) -> Result<()> {
328            *self.out = self.builder.take_out();
329            Ok(())
330        }
331    }
332
333    impl ObjectDeser for IssuingAuthorization {
334        type Builder = IssuingAuthorizationBuilder;
335    }
336
337    impl FromValueOpt for IssuingAuthorization {
338        fn from_value(v: Value) -> Option<Self> {
339            let Value::Object(obj) = v else {
340                return None;
341            };
342            let mut b = IssuingAuthorizationBuilder::deser_default();
343            for (k, v) in obj {
344                match k.as_str() {
345                    "amount" => b.amount = FromValueOpt::from_value(v),
346                    "amount_details" => b.amount_details = FromValueOpt::from_value(v),
347                    "approved" => b.approved = FromValueOpt::from_value(v),
348                    "authorization_method" => b.authorization_method = FromValueOpt::from_value(v),
349                    "balance_transactions" => b.balance_transactions = FromValueOpt::from_value(v),
350                    "card" => b.card = FromValueOpt::from_value(v),
351                    "cardholder" => b.cardholder = FromValueOpt::from_value(v),
352                    "created" => b.created = FromValueOpt::from_value(v),
353                    "currency" => b.currency = FromValueOpt::from_value(v),
354                    "fleet" => b.fleet = FromValueOpt::from_value(v),
355                    "fraud_challenges" => b.fraud_challenges = FromValueOpt::from_value(v),
356                    "fuel" => b.fuel = FromValueOpt::from_value(v),
357                    "id" => b.id = FromValueOpt::from_value(v),
358                    "livemode" => b.livemode = FromValueOpt::from_value(v),
359                    "merchant_amount" => b.merchant_amount = FromValueOpt::from_value(v),
360                    "merchant_currency" => b.merchant_currency = FromValueOpt::from_value(v),
361                    "merchant_data" => b.merchant_data = FromValueOpt::from_value(v),
362                    "metadata" => b.metadata = FromValueOpt::from_value(v),
363                    "network_data" => b.network_data = FromValueOpt::from_value(v),
364                    "pending_request" => b.pending_request = FromValueOpt::from_value(v),
365                    "request_history" => b.request_history = FromValueOpt::from_value(v),
366                    "status" => b.status = FromValueOpt::from_value(v),
367                    "token" => b.token = FromValueOpt::from_value(v),
368                    "transactions" => b.transactions = FromValueOpt::from_value(v),
369                    "treasury" => b.treasury = FromValueOpt::from_value(v),
370                    "verification_data" => b.verification_data = FromValueOpt::from_value(v),
371                    "verified_by_fraud_challenge" => {
372                        b.verified_by_fraud_challenge = FromValueOpt::from_value(v)
373                    }
374                    "wallet" => b.wallet = FromValueOpt::from_value(v),
375
376                    _ => {}
377                }
378            }
379            b.take_out()
380        }
381    }
382};
383#[cfg(feature = "serialize")]
384impl serde::Serialize for IssuingAuthorization {
385    fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
386        use serde::ser::SerializeStruct;
387        let mut s = s.serialize_struct("IssuingAuthorization", 29)?;
388        s.serialize_field("amount", &self.amount)?;
389        s.serialize_field("amount_details", &self.amount_details)?;
390        s.serialize_field("approved", &self.approved)?;
391        s.serialize_field("authorization_method", &self.authorization_method)?;
392        s.serialize_field("balance_transactions", &self.balance_transactions)?;
393        s.serialize_field("card", &self.card)?;
394        s.serialize_field("cardholder", &self.cardholder)?;
395        s.serialize_field("created", &self.created)?;
396        s.serialize_field("currency", &self.currency)?;
397        s.serialize_field("fleet", &self.fleet)?;
398        s.serialize_field("fraud_challenges", &self.fraud_challenges)?;
399        s.serialize_field("fuel", &self.fuel)?;
400        s.serialize_field("id", &self.id)?;
401        s.serialize_field("livemode", &self.livemode)?;
402        s.serialize_field("merchant_amount", &self.merchant_amount)?;
403        s.serialize_field("merchant_currency", &self.merchant_currency)?;
404        s.serialize_field("merchant_data", &self.merchant_data)?;
405        s.serialize_field("metadata", &self.metadata)?;
406        s.serialize_field("network_data", &self.network_data)?;
407        s.serialize_field("pending_request", &self.pending_request)?;
408        s.serialize_field("request_history", &self.request_history)?;
409        s.serialize_field("status", &self.status)?;
410        s.serialize_field("token", &self.token)?;
411        s.serialize_field("transactions", &self.transactions)?;
412        s.serialize_field("treasury", &self.treasury)?;
413        s.serialize_field("verification_data", &self.verification_data)?;
414        s.serialize_field("verified_by_fraud_challenge", &self.verified_by_fraud_challenge)?;
415        s.serialize_field("wallet", &self.wallet)?;
416
417        s.serialize_field("object", "issuing.authorization")?;
418        s.end()
419    }
420}
421impl stripe_types::Object for IssuingAuthorization {
422    type Id = stripe_shared::IssuingAuthorizationId;
423    fn id(&self) -> &Self::Id {
424        &self.id
425    }
426
427    fn into_id(self) -> Self::Id {
428        self.id
429    }
430}
431stripe_types::def_id!(IssuingAuthorizationId);
432#[derive(Copy, Clone, Eq, PartialEq)]
433pub enum IssuingAuthorizationAuthorizationMethod {
434    Chip,
435    Contactless,
436    KeyedIn,
437    Online,
438    Swipe,
439}
440impl IssuingAuthorizationAuthorizationMethod {
441    pub fn as_str(self) -> &'static str {
442        use IssuingAuthorizationAuthorizationMethod::*;
443        match self {
444            Chip => "chip",
445            Contactless => "contactless",
446            KeyedIn => "keyed_in",
447            Online => "online",
448            Swipe => "swipe",
449        }
450    }
451}
452
453impl std::str::FromStr for IssuingAuthorizationAuthorizationMethod {
454    type Err = stripe_types::StripeParseError;
455    fn from_str(s: &str) -> Result<Self, Self::Err> {
456        use IssuingAuthorizationAuthorizationMethod::*;
457        match s {
458            "chip" => Ok(Chip),
459            "contactless" => Ok(Contactless),
460            "keyed_in" => Ok(KeyedIn),
461            "online" => Ok(Online),
462            "swipe" => Ok(Swipe),
463            _ => Err(stripe_types::StripeParseError),
464        }
465    }
466}
467impl std::fmt::Display for IssuingAuthorizationAuthorizationMethod {
468    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
469        f.write_str(self.as_str())
470    }
471}
472
473impl std::fmt::Debug for IssuingAuthorizationAuthorizationMethod {
474    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
475        f.write_str(self.as_str())
476    }
477}
478impl serde::Serialize for IssuingAuthorizationAuthorizationMethod {
479    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
480    where
481        S: serde::Serializer,
482    {
483        serializer.serialize_str(self.as_str())
484    }
485}
486impl miniserde::Deserialize for IssuingAuthorizationAuthorizationMethod {
487    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
488        crate::Place::new(out)
489    }
490}
491
492impl miniserde::de::Visitor for crate::Place<IssuingAuthorizationAuthorizationMethod> {
493    fn string(&mut self, s: &str) -> miniserde::Result<()> {
494        use std::str::FromStr;
495        self.out = Some(
496            IssuingAuthorizationAuthorizationMethod::from_str(s).map_err(|_| miniserde::Error)?,
497        );
498        Ok(())
499    }
500}
501
502stripe_types::impl_from_val_with_from_str!(IssuingAuthorizationAuthorizationMethod);
503#[cfg(feature = "deserialize")]
504impl<'de> serde::Deserialize<'de> for IssuingAuthorizationAuthorizationMethod {
505    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
506        use std::str::FromStr;
507        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
508        Self::from_str(&s).map_err(|_| {
509            serde::de::Error::custom("Unknown value for IssuingAuthorizationAuthorizationMethod")
510        })
511    }
512}
513#[derive(Copy, Clone, Eq, PartialEq)]
514pub enum IssuingAuthorizationStatus {
515    Closed,
516    Expired,
517    Pending,
518    Reversed,
519}
520impl IssuingAuthorizationStatus {
521    pub fn as_str(self) -> &'static str {
522        use IssuingAuthorizationStatus::*;
523        match self {
524            Closed => "closed",
525            Expired => "expired",
526            Pending => "pending",
527            Reversed => "reversed",
528        }
529    }
530}
531
532impl std::str::FromStr for IssuingAuthorizationStatus {
533    type Err = stripe_types::StripeParseError;
534    fn from_str(s: &str) -> Result<Self, Self::Err> {
535        use IssuingAuthorizationStatus::*;
536        match s {
537            "closed" => Ok(Closed),
538            "expired" => Ok(Expired),
539            "pending" => Ok(Pending),
540            "reversed" => Ok(Reversed),
541            _ => Err(stripe_types::StripeParseError),
542        }
543    }
544}
545impl std::fmt::Display for IssuingAuthorizationStatus {
546    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
547        f.write_str(self.as_str())
548    }
549}
550
551impl std::fmt::Debug for IssuingAuthorizationStatus {
552    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
553        f.write_str(self.as_str())
554    }
555}
556impl serde::Serialize for IssuingAuthorizationStatus {
557    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
558    where
559        S: serde::Serializer,
560    {
561        serializer.serialize_str(self.as_str())
562    }
563}
564impl miniserde::Deserialize for IssuingAuthorizationStatus {
565    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
566        crate::Place::new(out)
567    }
568}
569
570impl miniserde::de::Visitor for crate::Place<IssuingAuthorizationStatus> {
571    fn string(&mut self, s: &str) -> miniserde::Result<()> {
572        use std::str::FromStr;
573        self.out = Some(IssuingAuthorizationStatus::from_str(s).map_err(|_| miniserde::Error)?);
574        Ok(())
575    }
576}
577
578stripe_types::impl_from_val_with_from_str!(IssuingAuthorizationStatus);
579#[cfg(feature = "deserialize")]
580impl<'de> serde::Deserialize<'de> for IssuingAuthorizationStatus {
581    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
582        use std::str::FromStr;
583        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
584        Self::from_str(&s)
585            .map_err(|_| serde::de::Error::custom("Unknown value for IssuingAuthorizationStatus"))
586    }
587}