Skip to main content

stripe_shared/
api_errors.rs

1#[derive(Clone)]
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 ApiErrors {
6    /// For card errors resulting from a card issuer decline, a short string indicating [how to proceed with an error](https://docs.stripe.com/declines#retrying-issuer-declines) if they provide one.
7    pub advice_code: Option<String>,
8    /// For card errors, the ID of the failed charge.
9    pub charge: Option<String>,
10    /// For some errors that could be handled programmatically, a short string indicating the [error code](https://docs.stripe.com/error-codes) reported.
11    pub code: Option<ApiErrorsCode>,
12    /// For card errors resulting from a card issuer decline, a short string indicating the [card issuer's reason for the decline](https://docs.stripe.com/declines#issuer-declines) if they provide one.
13    pub decline_code: Option<String>,
14    /// A URL to more information about the [error code](https://docs.stripe.com/error-codes) reported.
15    pub doc_url: Option<String>,
16    /// A human-readable message providing more details about the error.
17    /// For card errors, these messages can be shown to your users.
18    pub message: Option<String>,
19    /// For card errors resulting from a card issuer decline, a 2 digit code which indicates the advice given to merchant by the card network on how to proceed with an error.
20    pub network_advice_code: Option<String>,
21    /// For payments declined by the network, an alphanumeric code which indicates the reason the payment failed.
22    pub network_decline_code: Option<String>,
23    /// If the error is parameter-specific, the parameter related to the error.
24    /// For example, you can use this to display a message near the correct form field.
25    pub param: Option<String>,
26    pub payment_intent: Option<stripe_shared::PaymentIntent>,
27    pub payment_method: Option<stripe_shared::PaymentMethod>,
28    /// If the error is specific to the type of payment method, the payment method type that had a problem.
29    /// This field is only populated for invoice-related errors.
30    pub payment_method_type: Option<String>,
31    /// A URL to the request log entry in your dashboard.
32    pub request_log_url: Option<String>,
33    pub setup_intent: Option<stripe_shared::SetupIntent>,
34    pub source: Option<stripe_shared::PaymentSource>,
35    /// The type of error returned.
36    /// One of `api_error`, `card_error`, `idempotency_error`, or `invalid_request_error`.
37    #[cfg_attr(any(feature = "deserialize", feature = "serialize"), serde(rename = "type"))]
38    pub type_: ApiErrorsType,
39}
40#[cfg(feature = "redact-generated-debug")]
41impl std::fmt::Debug for ApiErrors {
42    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
43        f.debug_struct("ApiErrors").finish_non_exhaustive()
44    }
45}
46#[doc(hidden)]
47pub struct ApiErrorsBuilder {
48    advice_code: Option<Option<String>>,
49    charge: Option<Option<String>>,
50    code: Option<Option<ApiErrorsCode>>,
51    decline_code: Option<Option<String>>,
52    doc_url: Option<Option<String>>,
53    message: Option<Option<String>>,
54    network_advice_code: Option<Option<String>>,
55    network_decline_code: Option<Option<String>>,
56    param: Option<Option<String>>,
57    payment_intent: Option<Option<stripe_shared::PaymentIntent>>,
58    payment_method: Option<Option<stripe_shared::PaymentMethod>>,
59    payment_method_type: Option<Option<String>>,
60    request_log_url: Option<Option<String>>,
61    setup_intent: Option<Option<stripe_shared::SetupIntent>>,
62    source: Option<Option<stripe_shared::PaymentSource>>,
63    type_: Option<ApiErrorsType>,
64}
65
66#[allow(
67    unused_variables,
68    irrefutable_let_patterns,
69    clippy::let_unit_value,
70    clippy::match_single_binding,
71    clippy::single_match
72)]
73const _: () = {
74    use miniserde::de::{Map, Visitor};
75    use miniserde::json::Value;
76    use miniserde::{Deserialize, Result, make_place};
77    use stripe_types::miniserde_helpers::FromValueOpt;
78    use stripe_types::{MapBuilder, ObjectDeser};
79
80    make_place!(Place);
81
82    impl Deserialize for ApiErrors {
83        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
84            Place::new(out)
85        }
86    }
87
88    struct Builder<'a> {
89        out: &'a mut Option<ApiErrors>,
90        builder: ApiErrorsBuilder,
91    }
92
93    impl Visitor for Place<ApiErrors> {
94        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
95            Ok(Box::new(Builder { out: &mut self.out, builder: ApiErrorsBuilder::deser_default() }))
96        }
97    }
98
99    impl MapBuilder for ApiErrorsBuilder {
100        type Out = ApiErrors;
101        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
102            Ok(match k {
103                "advice_code" => Deserialize::begin(&mut self.advice_code),
104                "charge" => Deserialize::begin(&mut self.charge),
105                "code" => Deserialize::begin(&mut self.code),
106                "decline_code" => Deserialize::begin(&mut self.decline_code),
107                "doc_url" => Deserialize::begin(&mut self.doc_url),
108                "message" => Deserialize::begin(&mut self.message),
109                "network_advice_code" => Deserialize::begin(&mut self.network_advice_code),
110                "network_decline_code" => Deserialize::begin(&mut self.network_decline_code),
111                "param" => Deserialize::begin(&mut self.param),
112                "payment_intent" => Deserialize::begin(&mut self.payment_intent),
113                "payment_method" => Deserialize::begin(&mut self.payment_method),
114                "payment_method_type" => Deserialize::begin(&mut self.payment_method_type),
115                "request_log_url" => Deserialize::begin(&mut self.request_log_url),
116                "setup_intent" => Deserialize::begin(&mut self.setup_intent),
117                "source" => Deserialize::begin(&mut self.source),
118                "type" => Deserialize::begin(&mut self.type_),
119                _ => <dyn Visitor>::ignore(),
120            })
121        }
122
123        fn deser_default() -> Self {
124            Self {
125                advice_code: Some(None),
126                charge: Some(None),
127                code: Some(None),
128                decline_code: Some(None),
129                doc_url: Some(None),
130                message: Some(None),
131                network_advice_code: Some(None),
132                network_decline_code: Some(None),
133                param: Some(None),
134                payment_intent: Some(None),
135                payment_method: Some(None),
136                payment_method_type: Some(None),
137                request_log_url: Some(None),
138                setup_intent: Some(None),
139                source: Some(None),
140                type_: None,
141            }
142        }
143
144        fn take_out(&mut self) -> Option<Self::Out> {
145            let (
146                Some(advice_code),
147                Some(charge),
148                Some(code),
149                Some(decline_code),
150                Some(doc_url),
151                Some(message),
152                Some(network_advice_code),
153                Some(network_decline_code),
154                Some(param),
155                Some(payment_intent),
156                Some(payment_method),
157                Some(payment_method_type),
158                Some(request_log_url),
159                Some(setup_intent),
160                Some(source),
161                Some(type_),
162            ) = (
163                self.advice_code.take(),
164                self.charge.take(),
165                self.code.take(),
166                self.decline_code.take(),
167                self.doc_url.take(),
168                self.message.take(),
169                self.network_advice_code.take(),
170                self.network_decline_code.take(),
171                self.param.take(),
172                self.payment_intent.take(),
173                self.payment_method.take(),
174                self.payment_method_type.take(),
175                self.request_log_url.take(),
176                self.setup_intent.take(),
177                self.source.take(),
178                self.type_.take(),
179            )
180            else {
181                return None;
182            };
183            Some(Self::Out {
184                advice_code,
185                charge,
186                code,
187                decline_code,
188                doc_url,
189                message,
190                network_advice_code,
191                network_decline_code,
192                param,
193                payment_intent,
194                payment_method,
195                payment_method_type,
196                request_log_url,
197                setup_intent,
198                source,
199                type_,
200            })
201        }
202    }
203
204    impl Map for Builder<'_> {
205        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
206            self.builder.key(k)
207        }
208
209        fn finish(&mut self) -> Result<()> {
210            *self.out = self.builder.take_out();
211            Ok(())
212        }
213    }
214
215    impl ObjectDeser for ApiErrors {
216        type Builder = ApiErrorsBuilder;
217    }
218
219    impl FromValueOpt for ApiErrors {
220        fn from_value(v: Value) -> Option<Self> {
221            let Value::Object(obj) = v else {
222                return None;
223            };
224            let mut b = ApiErrorsBuilder::deser_default();
225            for (k, v) in obj {
226                match k.as_str() {
227                    "advice_code" => b.advice_code = FromValueOpt::from_value(v),
228                    "charge" => b.charge = FromValueOpt::from_value(v),
229                    "code" => b.code = FromValueOpt::from_value(v),
230                    "decline_code" => b.decline_code = FromValueOpt::from_value(v),
231                    "doc_url" => b.doc_url = FromValueOpt::from_value(v),
232                    "message" => b.message = FromValueOpt::from_value(v),
233                    "network_advice_code" => b.network_advice_code = FromValueOpt::from_value(v),
234                    "network_decline_code" => b.network_decline_code = FromValueOpt::from_value(v),
235                    "param" => b.param = FromValueOpt::from_value(v),
236                    "payment_intent" => b.payment_intent = FromValueOpt::from_value(v),
237                    "payment_method" => b.payment_method = FromValueOpt::from_value(v),
238                    "payment_method_type" => b.payment_method_type = FromValueOpt::from_value(v),
239                    "request_log_url" => b.request_log_url = FromValueOpt::from_value(v),
240                    "setup_intent" => b.setup_intent = FromValueOpt::from_value(v),
241                    "source" => b.source = FromValueOpt::from_value(v),
242                    "type" => b.type_ = FromValueOpt::from_value(v),
243                    _ => {}
244                }
245            }
246            b.take_out()
247        }
248    }
249};
250/// For some errors that could be handled programmatically, a short string indicating the [error code](https://docs.stripe.com/error-codes) reported.
251#[derive(Clone, Eq, PartialEq)]
252#[non_exhaustive]
253pub enum ApiErrorsCode {
254    AccountClosed,
255    AccountCountryInvalidAddress,
256    AccountErrorCountryChangeRequiresAdditionalSteps,
257    AccountInformationMismatch,
258    AccountInvalid,
259    AccountNumberInvalid,
260    AccountTokenRequiredForV2Account,
261    AcssDebitSessionIncomplete,
262    ActionBlocked,
263    AlipayUpgradeRequired,
264    AmountTooLarge,
265    AmountTooSmall,
266    ApiKeyExpired,
267    ApplicationFeesNotAllowed,
268    ApprovalRequired,
269    AuthenticationRequired,
270    BalanceInsufficient,
271    BalanceInvalidParameter,
272    BankAccountBadRoutingNumbers,
273    BankAccountDeclined,
274    BankAccountExists,
275    BankAccountRestricted,
276    BankAccountUnusable,
277    BankAccountUnverified,
278    BankAccountVerificationFailed,
279    BillingInvalidMandate,
280    BitcoinUpgradeRequired,
281    CaptureChargeAuthorizationExpired,
282    CaptureUnauthorizedPayment,
283    CardDeclineRateLimitExceeded,
284    CardDeclined,
285    CardholderPhoneNumberRequired,
286    ChargeAlreadyCaptured,
287    ChargeAlreadyRefunded,
288    ChargeDisputed,
289    ChargeExceedsSourceLimit,
290    ChargeExceedsTransactionLimit,
291    ChargeExpiredForCapture,
292    ChargeInvalidParameter,
293    ChargeNotRefundable,
294    ClearingCodeUnsupported,
295    CountryCodeInvalid,
296    CountryUnsupported,
297    CouponExpired,
298    CustomerMaxPaymentMethods,
299    CustomerMaxSubscriptions,
300    CustomerSessionExpired,
301    CustomerTaxLocationInvalid,
302    DebitNotAuthorized,
303    EmailInvalid,
304    ExpiredCard,
305    FinancialConnectionsAccountInactive,
306    FinancialConnectionsAccountPendingAccountNumbers,
307    FinancialConnectionsAccountUnavailableAccountNumbers,
308    FinancialConnectionsNoSuccessfulTransactionRefresh,
309    ForwardingApiInactive,
310    ForwardingApiInvalidParameter,
311    ForwardingApiRetryableUpstreamError,
312    ForwardingApiUpstreamConnectionError,
313    ForwardingApiUpstreamConnectionTimeout,
314    ForwardingApiUpstreamError,
315    IdempotencyKeyInUse,
316    IncorrectAddress,
317    IncorrectCvc,
318    IncorrectNumber,
319    IncorrectZip,
320    IndiaRecurringPaymentMandateCanceled,
321    InstantPayoutsConfigDisabled,
322    InstantPayoutsCurrencyDisabled,
323    InstantPayoutsLimitExceeded,
324    InstantPayoutsUnsupported,
325    InsufficientFunds,
326    IntentInvalidState,
327    IntentVerificationMethodMissing,
328    InvalidCardType,
329    InvalidCharacters,
330    InvalidChargeAmount,
331    InvalidCvc,
332    InvalidExpiryMonth,
333    InvalidExpiryYear,
334    InvalidMandateReferencePrefixFormat,
335    InvalidNumber,
336    InvalidSourceUsage,
337    InvalidTaxLocation,
338    InvoiceNoCustomerLineItems,
339    InvoiceNoPaymentMethodTypes,
340    InvoiceNoSubscriptionLineItems,
341    InvoiceNotEditable,
342    InvoiceOnBehalfOfNotEditable,
343    InvoicePaymentIntentRequiresAction,
344    InvoiceUpcomingNone,
345    LivemodeMismatch,
346    LockTimeout,
347    Missing,
348    NoAccount,
349    NotAllowedOnStandardAccount,
350    OutOfInventory,
351    OwnershipDeclarationNotAllowed,
352    ParameterInvalidEmpty,
353    ParameterInvalidInteger,
354    ParameterInvalidStringBlank,
355    ParameterInvalidStringEmpty,
356    ParameterMissing,
357    ParameterUnknown,
358    ParametersExclusive,
359    PaymentIntentActionRequired,
360    PaymentIntentAuthenticationFailure,
361    PaymentIntentIncompatiblePaymentMethod,
362    PaymentIntentInvalidParameter,
363    PaymentIntentKonbiniRejectedConfirmationNumber,
364    PaymentIntentMandateInvalid,
365    PaymentIntentPaymentAttemptExpired,
366    PaymentIntentPaymentAttemptFailed,
367    PaymentIntentRateLimitExceeded,
368    PaymentIntentUnexpectedState,
369    PaymentMethodBankAccountAlreadyVerified,
370    PaymentMethodBankAccountBlocked,
371    PaymentMethodBillingDetailsAddressMissing,
372    PaymentMethodConfigurationFailures,
373    PaymentMethodCurrencyMismatch,
374    PaymentMethodCustomerDecline,
375    PaymentMethodInvalidParameter,
376    PaymentMethodInvalidParameterTestmode,
377    PaymentMethodMicrodepositFailed,
378    PaymentMethodMicrodepositVerificationAmountsInvalid,
379    PaymentMethodMicrodepositVerificationAmountsMismatch,
380    PaymentMethodMicrodepositVerificationAttemptsExceeded,
381    PaymentMethodMicrodepositVerificationDescriptorCodeMismatch,
382    PaymentMethodMicrodepositVerificationTimeout,
383    PaymentMethodNotAvailable,
384    PaymentMethodProviderDecline,
385    PaymentMethodProviderTimeout,
386    PaymentMethodUnactivated,
387    PaymentMethodUnexpectedState,
388    PaymentMethodUnsupportedType,
389    PayoutReconciliationNotReady,
390    PayoutsLimitExceeded,
391    PayoutsNotAllowed,
392    PlatformAccountRequired,
393    PlatformApiKeyExpired,
394    PostalCodeInvalid,
395    ProcessingError,
396    ProductInactive,
397    ProgressiveOnboardingLimitExceeded,
398    RateLimit,
399    ReferToCustomer,
400    RefundDisputedPayment,
401    RequestBlocked,
402    ResourceAlreadyExists,
403    ResourceMissing,
404    ReturnIntentAlreadyProcessed,
405    RoutingNumberInvalid,
406    SecretKeyRequired,
407    SepaUnsupportedAccount,
408    ServicePeriodCouponWithMeteredTieredItemUnsupported,
409    SetupAttemptFailed,
410    SetupIntentAuthenticationFailure,
411    SetupIntentInvalidParameter,
412    SetupIntentMandateInvalid,
413    SetupIntentMobileWalletUnsupported,
414    SetupIntentSetupAttemptExpired,
415    SetupIntentUnexpectedState,
416    ShippingAddressInvalid,
417    ShippingCalculationFailed,
418    SkuInactive,
419    StateUnsupported,
420    StatusTransitionInvalid,
421    StorerCapabilityMissing,
422    StorerCapabilityNotActive,
423    StripeTaxInactive,
424    TaxIdInvalid,
425    TaxIdProhibited,
426    TaxesCalculationFailed,
427    TerminalLocationCountryUnsupported,
428    TerminalReaderBusy,
429    TerminalReaderHardwareFault,
430    TerminalReaderInvalidLocationForActivation,
431    TerminalReaderInvalidLocationForPayment,
432    TerminalReaderOffline,
433    TerminalReaderTimeout,
434    TestmodeChargesOnly,
435    TlsVersionUnsupported,
436    TokenAlreadyUsed,
437    TokenCardNetworkInvalid,
438    TokenInUse,
439    TransferSourceBalanceParametersMismatch,
440    TransfersNotAllowed,
441    UrlInvalid,
442    /// An unrecognized value from Stripe. Should not be used as a request parameter.
443    Unknown(String),
444}
445impl ApiErrorsCode {
446    pub fn as_str(&self) -> &str {
447        use ApiErrorsCode::*;
448        match self {
449            AccountClosed => "account_closed",
450            AccountCountryInvalidAddress => "account_country_invalid_address",
451            AccountErrorCountryChangeRequiresAdditionalSteps => {
452                "account_error_country_change_requires_additional_steps"
453            }
454            AccountInformationMismatch => "account_information_mismatch",
455            AccountInvalid => "account_invalid",
456            AccountNumberInvalid => "account_number_invalid",
457            AccountTokenRequiredForV2Account => "account_token_required_for_v2_account",
458            AcssDebitSessionIncomplete => "acss_debit_session_incomplete",
459            ActionBlocked => "action_blocked",
460            AlipayUpgradeRequired => "alipay_upgrade_required",
461            AmountTooLarge => "amount_too_large",
462            AmountTooSmall => "amount_too_small",
463            ApiKeyExpired => "api_key_expired",
464            ApplicationFeesNotAllowed => "application_fees_not_allowed",
465            ApprovalRequired => "approval_required",
466            AuthenticationRequired => "authentication_required",
467            BalanceInsufficient => "balance_insufficient",
468            BalanceInvalidParameter => "balance_invalid_parameter",
469            BankAccountBadRoutingNumbers => "bank_account_bad_routing_numbers",
470            BankAccountDeclined => "bank_account_declined",
471            BankAccountExists => "bank_account_exists",
472            BankAccountRestricted => "bank_account_restricted",
473            BankAccountUnusable => "bank_account_unusable",
474            BankAccountUnverified => "bank_account_unverified",
475            BankAccountVerificationFailed => "bank_account_verification_failed",
476            BillingInvalidMandate => "billing_invalid_mandate",
477            BitcoinUpgradeRequired => "bitcoin_upgrade_required",
478            CaptureChargeAuthorizationExpired => "capture_charge_authorization_expired",
479            CaptureUnauthorizedPayment => "capture_unauthorized_payment",
480            CardDeclineRateLimitExceeded => "card_decline_rate_limit_exceeded",
481            CardDeclined => "card_declined",
482            CardholderPhoneNumberRequired => "cardholder_phone_number_required",
483            ChargeAlreadyCaptured => "charge_already_captured",
484            ChargeAlreadyRefunded => "charge_already_refunded",
485            ChargeDisputed => "charge_disputed",
486            ChargeExceedsSourceLimit => "charge_exceeds_source_limit",
487            ChargeExceedsTransactionLimit => "charge_exceeds_transaction_limit",
488            ChargeExpiredForCapture => "charge_expired_for_capture",
489            ChargeInvalidParameter => "charge_invalid_parameter",
490            ChargeNotRefundable => "charge_not_refundable",
491            ClearingCodeUnsupported => "clearing_code_unsupported",
492            CountryCodeInvalid => "country_code_invalid",
493            CountryUnsupported => "country_unsupported",
494            CouponExpired => "coupon_expired",
495            CustomerMaxPaymentMethods => "customer_max_payment_methods",
496            CustomerMaxSubscriptions => "customer_max_subscriptions",
497            CustomerSessionExpired => "customer_session_expired",
498            CustomerTaxLocationInvalid => "customer_tax_location_invalid",
499            DebitNotAuthorized => "debit_not_authorized",
500            EmailInvalid => "email_invalid",
501            ExpiredCard => "expired_card",
502            FinancialConnectionsAccountInactive => "financial_connections_account_inactive",
503            FinancialConnectionsAccountPendingAccountNumbers => {
504                "financial_connections_account_pending_account_numbers"
505            }
506            FinancialConnectionsAccountUnavailableAccountNumbers => {
507                "financial_connections_account_unavailable_account_numbers"
508            }
509            FinancialConnectionsNoSuccessfulTransactionRefresh => {
510                "financial_connections_no_successful_transaction_refresh"
511            }
512            ForwardingApiInactive => "forwarding_api_inactive",
513            ForwardingApiInvalidParameter => "forwarding_api_invalid_parameter",
514            ForwardingApiRetryableUpstreamError => "forwarding_api_retryable_upstream_error",
515            ForwardingApiUpstreamConnectionError => "forwarding_api_upstream_connection_error",
516            ForwardingApiUpstreamConnectionTimeout => "forwarding_api_upstream_connection_timeout",
517            ForwardingApiUpstreamError => "forwarding_api_upstream_error",
518            IdempotencyKeyInUse => "idempotency_key_in_use",
519            IncorrectAddress => "incorrect_address",
520            IncorrectCvc => "incorrect_cvc",
521            IncorrectNumber => "incorrect_number",
522            IncorrectZip => "incorrect_zip",
523            IndiaRecurringPaymentMandateCanceled => "india_recurring_payment_mandate_canceled",
524            InstantPayoutsConfigDisabled => "instant_payouts_config_disabled",
525            InstantPayoutsCurrencyDisabled => "instant_payouts_currency_disabled",
526            InstantPayoutsLimitExceeded => "instant_payouts_limit_exceeded",
527            InstantPayoutsUnsupported => "instant_payouts_unsupported",
528            InsufficientFunds => "insufficient_funds",
529            IntentInvalidState => "intent_invalid_state",
530            IntentVerificationMethodMissing => "intent_verification_method_missing",
531            InvalidCardType => "invalid_card_type",
532            InvalidCharacters => "invalid_characters",
533            InvalidChargeAmount => "invalid_charge_amount",
534            InvalidCvc => "invalid_cvc",
535            InvalidExpiryMonth => "invalid_expiry_month",
536            InvalidExpiryYear => "invalid_expiry_year",
537            InvalidMandateReferencePrefixFormat => "invalid_mandate_reference_prefix_format",
538            InvalidNumber => "invalid_number",
539            InvalidSourceUsage => "invalid_source_usage",
540            InvalidTaxLocation => "invalid_tax_location",
541            InvoiceNoCustomerLineItems => "invoice_no_customer_line_items",
542            InvoiceNoPaymentMethodTypes => "invoice_no_payment_method_types",
543            InvoiceNoSubscriptionLineItems => "invoice_no_subscription_line_items",
544            InvoiceNotEditable => "invoice_not_editable",
545            InvoiceOnBehalfOfNotEditable => "invoice_on_behalf_of_not_editable",
546            InvoicePaymentIntentRequiresAction => "invoice_payment_intent_requires_action",
547            InvoiceUpcomingNone => "invoice_upcoming_none",
548            LivemodeMismatch => "livemode_mismatch",
549            LockTimeout => "lock_timeout",
550            Missing => "missing",
551            NoAccount => "no_account",
552            NotAllowedOnStandardAccount => "not_allowed_on_standard_account",
553            OutOfInventory => "out_of_inventory",
554            OwnershipDeclarationNotAllowed => "ownership_declaration_not_allowed",
555            ParameterInvalidEmpty => "parameter_invalid_empty",
556            ParameterInvalidInteger => "parameter_invalid_integer",
557            ParameterInvalidStringBlank => "parameter_invalid_string_blank",
558            ParameterInvalidStringEmpty => "parameter_invalid_string_empty",
559            ParameterMissing => "parameter_missing",
560            ParameterUnknown => "parameter_unknown",
561            ParametersExclusive => "parameters_exclusive",
562            PaymentIntentActionRequired => "payment_intent_action_required",
563            PaymentIntentAuthenticationFailure => "payment_intent_authentication_failure",
564            PaymentIntentIncompatiblePaymentMethod => "payment_intent_incompatible_payment_method",
565            PaymentIntentInvalidParameter => "payment_intent_invalid_parameter",
566            PaymentIntentKonbiniRejectedConfirmationNumber => {
567                "payment_intent_konbini_rejected_confirmation_number"
568            }
569            PaymentIntentMandateInvalid => "payment_intent_mandate_invalid",
570            PaymentIntentPaymentAttemptExpired => "payment_intent_payment_attempt_expired",
571            PaymentIntentPaymentAttemptFailed => "payment_intent_payment_attempt_failed",
572            PaymentIntentRateLimitExceeded => "payment_intent_rate_limit_exceeded",
573            PaymentIntentUnexpectedState => "payment_intent_unexpected_state",
574            PaymentMethodBankAccountAlreadyVerified => {
575                "payment_method_bank_account_already_verified"
576            }
577            PaymentMethodBankAccountBlocked => "payment_method_bank_account_blocked",
578            PaymentMethodBillingDetailsAddressMissing => {
579                "payment_method_billing_details_address_missing"
580            }
581            PaymentMethodConfigurationFailures => "payment_method_configuration_failures",
582            PaymentMethodCurrencyMismatch => "payment_method_currency_mismatch",
583            PaymentMethodCustomerDecline => "payment_method_customer_decline",
584            PaymentMethodInvalidParameter => "payment_method_invalid_parameter",
585            PaymentMethodInvalidParameterTestmode => "payment_method_invalid_parameter_testmode",
586            PaymentMethodMicrodepositFailed => "payment_method_microdeposit_failed",
587            PaymentMethodMicrodepositVerificationAmountsInvalid => {
588                "payment_method_microdeposit_verification_amounts_invalid"
589            }
590            PaymentMethodMicrodepositVerificationAmountsMismatch => {
591                "payment_method_microdeposit_verification_amounts_mismatch"
592            }
593            PaymentMethodMicrodepositVerificationAttemptsExceeded => {
594                "payment_method_microdeposit_verification_attempts_exceeded"
595            }
596            PaymentMethodMicrodepositVerificationDescriptorCodeMismatch => {
597                "payment_method_microdeposit_verification_descriptor_code_mismatch"
598            }
599            PaymentMethodMicrodepositVerificationTimeout => {
600                "payment_method_microdeposit_verification_timeout"
601            }
602            PaymentMethodNotAvailable => "payment_method_not_available",
603            PaymentMethodProviderDecline => "payment_method_provider_decline",
604            PaymentMethodProviderTimeout => "payment_method_provider_timeout",
605            PaymentMethodUnactivated => "payment_method_unactivated",
606            PaymentMethodUnexpectedState => "payment_method_unexpected_state",
607            PaymentMethodUnsupportedType => "payment_method_unsupported_type",
608            PayoutReconciliationNotReady => "payout_reconciliation_not_ready",
609            PayoutsLimitExceeded => "payouts_limit_exceeded",
610            PayoutsNotAllowed => "payouts_not_allowed",
611            PlatformAccountRequired => "platform_account_required",
612            PlatformApiKeyExpired => "platform_api_key_expired",
613            PostalCodeInvalid => "postal_code_invalid",
614            ProcessingError => "processing_error",
615            ProductInactive => "product_inactive",
616            ProgressiveOnboardingLimitExceeded => "progressive_onboarding_limit_exceeded",
617            RateLimit => "rate_limit",
618            ReferToCustomer => "refer_to_customer",
619            RefundDisputedPayment => "refund_disputed_payment",
620            RequestBlocked => "request_blocked",
621            ResourceAlreadyExists => "resource_already_exists",
622            ResourceMissing => "resource_missing",
623            ReturnIntentAlreadyProcessed => "return_intent_already_processed",
624            RoutingNumberInvalid => "routing_number_invalid",
625            SecretKeyRequired => "secret_key_required",
626            SepaUnsupportedAccount => "sepa_unsupported_account",
627            ServicePeriodCouponWithMeteredTieredItemUnsupported => {
628                "service_period_coupon_with_metered_tiered_item_unsupported"
629            }
630            SetupAttemptFailed => "setup_attempt_failed",
631            SetupIntentAuthenticationFailure => "setup_intent_authentication_failure",
632            SetupIntentInvalidParameter => "setup_intent_invalid_parameter",
633            SetupIntentMandateInvalid => "setup_intent_mandate_invalid",
634            SetupIntentMobileWalletUnsupported => "setup_intent_mobile_wallet_unsupported",
635            SetupIntentSetupAttemptExpired => "setup_intent_setup_attempt_expired",
636            SetupIntentUnexpectedState => "setup_intent_unexpected_state",
637            ShippingAddressInvalid => "shipping_address_invalid",
638            ShippingCalculationFailed => "shipping_calculation_failed",
639            SkuInactive => "sku_inactive",
640            StateUnsupported => "state_unsupported",
641            StatusTransitionInvalid => "status_transition_invalid",
642            StorerCapabilityMissing => "storer_capability_missing",
643            StorerCapabilityNotActive => "storer_capability_not_active",
644            StripeTaxInactive => "stripe_tax_inactive",
645            TaxIdInvalid => "tax_id_invalid",
646            TaxIdProhibited => "tax_id_prohibited",
647            TaxesCalculationFailed => "taxes_calculation_failed",
648            TerminalLocationCountryUnsupported => "terminal_location_country_unsupported",
649            TerminalReaderBusy => "terminal_reader_busy",
650            TerminalReaderHardwareFault => "terminal_reader_hardware_fault",
651            TerminalReaderInvalidLocationForActivation => {
652                "terminal_reader_invalid_location_for_activation"
653            }
654            TerminalReaderInvalidLocationForPayment => {
655                "terminal_reader_invalid_location_for_payment"
656            }
657            TerminalReaderOffline => "terminal_reader_offline",
658            TerminalReaderTimeout => "terminal_reader_timeout",
659            TestmodeChargesOnly => "testmode_charges_only",
660            TlsVersionUnsupported => "tls_version_unsupported",
661            TokenAlreadyUsed => "token_already_used",
662            TokenCardNetworkInvalid => "token_card_network_invalid",
663            TokenInUse => "token_in_use",
664            TransferSourceBalanceParametersMismatch => {
665                "transfer_source_balance_parameters_mismatch"
666            }
667            TransfersNotAllowed => "transfers_not_allowed",
668            UrlInvalid => "url_invalid",
669            Unknown(v) => v,
670        }
671    }
672}
673
674impl std::str::FromStr for ApiErrorsCode {
675    type Err = std::convert::Infallible;
676    fn from_str(s: &str) -> Result<Self, Self::Err> {
677        use ApiErrorsCode::*;
678        match s {
679            "account_closed" => Ok(AccountClosed),
680            "account_country_invalid_address" => Ok(AccountCountryInvalidAddress),
681            "account_error_country_change_requires_additional_steps" => {
682                Ok(AccountErrorCountryChangeRequiresAdditionalSteps)
683            }
684            "account_information_mismatch" => Ok(AccountInformationMismatch),
685            "account_invalid" => Ok(AccountInvalid),
686            "account_number_invalid" => Ok(AccountNumberInvalid),
687            "account_token_required_for_v2_account" => Ok(AccountTokenRequiredForV2Account),
688            "acss_debit_session_incomplete" => Ok(AcssDebitSessionIncomplete),
689            "action_blocked" => Ok(ActionBlocked),
690            "alipay_upgrade_required" => Ok(AlipayUpgradeRequired),
691            "amount_too_large" => Ok(AmountTooLarge),
692            "amount_too_small" => Ok(AmountTooSmall),
693            "api_key_expired" => Ok(ApiKeyExpired),
694            "application_fees_not_allowed" => Ok(ApplicationFeesNotAllowed),
695            "approval_required" => Ok(ApprovalRequired),
696            "authentication_required" => Ok(AuthenticationRequired),
697            "balance_insufficient" => Ok(BalanceInsufficient),
698            "balance_invalid_parameter" => Ok(BalanceInvalidParameter),
699            "bank_account_bad_routing_numbers" => Ok(BankAccountBadRoutingNumbers),
700            "bank_account_declined" => Ok(BankAccountDeclined),
701            "bank_account_exists" => Ok(BankAccountExists),
702            "bank_account_restricted" => Ok(BankAccountRestricted),
703            "bank_account_unusable" => Ok(BankAccountUnusable),
704            "bank_account_unverified" => Ok(BankAccountUnverified),
705            "bank_account_verification_failed" => Ok(BankAccountVerificationFailed),
706            "billing_invalid_mandate" => Ok(BillingInvalidMandate),
707            "bitcoin_upgrade_required" => Ok(BitcoinUpgradeRequired),
708            "capture_charge_authorization_expired" => Ok(CaptureChargeAuthorizationExpired),
709            "capture_unauthorized_payment" => Ok(CaptureUnauthorizedPayment),
710            "card_decline_rate_limit_exceeded" => Ok(CardDeclineRateLimitExceeded),
711            "card_declined" => Ok(CardDeclined),
712            "cardholder_phone_number_required" => Ok(CardholderPhoneNumberRequired),
713            "charge_already_captured" => Ok(ChargeAlreadyCaptured),
714            "charge_already_refunded" => Ok(ChargeAlreadyRefunded),
715            "charge_disputed" => Ok(ChargeDisputed),
716            "charge_exceeds_source_limit" => Ok(ChargeExceedsSourceLimit),
717            "charge_exceeds_transaction_limit" => Ok(ChargeExceedsTransactionLimit),
718            "charge_expired_for_capture" => Ok(ChargeExpiredForCapture),
719            "charge_invalid_parameter" => Ok(ChargeInvalidParameter),
720            "charge_not_refundable" => Ok(ChargeNotRefundable),
721            "clearing_code_unsupported" => Ok(ClearingCodeUnsupported),
722            "country_code_invalid" => Ok(CountryCodeInvalid),
723            "country_unsupported" => Ok(CountryUnsupported),
724            "coupon_expired" => Ok(CouponExpired),
725            "customer_max_payment_methods" => Ok(CustomerMaxPaymentMethods),
726            "customer_max_subscriptions" => Ok(CustomerMaxSubscriptions),
727            "customer_session_expired" => Ok(CustomerSessionExpired),
728            "customer_tax_location_invalid" => Ok(CustomerTaxLocationInvalid),
729            "debit_not_authorized" => Ok(DebitNotAuthorized),
730            "email_invalid" => Ok(EmailInvalid),
731            "expired_card" => Ok(ExpiredCard),
732            "financial_connections_account_inactive" => Ok(FinancialConnectionsAccountInactive),
733            "financial_connections_account_pending_account_numbers" => {
734                Ok(FinancialConnectionsAccountPendingAccountNumbers)
735            }
736            "financial_connections_account_unavailable_account_numbers" => {
737                Ok(FinancialConnectionsAccountUnavailableAccountNumbers)
738            }
739            "financial_connections_no_successful_transaction_refresh" => {
740                Ok(FinancialConnectionsNoSuccessfulTransactionRefresh)
741            }
742            "forwarding_api_inactive" => Ok(ForwardingApiInactive),
743            "forwarding_api_invalid_parameter" => Ok(ForwardingApiInvalidParameter),
744            "forwarding_api_retryable_upstream_error" => Ok(ForwardingApiRetryableUpstreamError),
745            "forwarding_api_upstream_connection_error" => Ok(ForwardingApiUpstreamConnectionError),
746            "forwarding_api_upstream_connection_timeout" => {
747                Ok(ForwardingApiUpstreamConnectionTimeout)
748            }
749            "forwarding_api_upstream_error" => Ok(ForwardingApiUpstreamError),
750            "idempotency_key_in_use" => Ok(IdempotencyKeyInUse),
751            "incorrect_address" => Ok(IncorrectAddress),
752            "incorrect_cvc" => Ok(IncorrectCvc),
753            "incorrect_number" => Ok(IncorrectNumber),
754            "incorrect_zip" => Ok(IncorrectZip),
755            "india_recurring_payment_mandate_canceled" => Ok(IndiaRecurringPaymentMandateCanceled),
756            "instant_payouts_config_disabled" => Ok(InstantPayoutsConfigDisabled),
757            "instant_payouts_currency_disabled" => Ok(InstantPayoutsCurrencyDisabled),
758            "instant_payouts_limit_exceeded" => Ok(InstantPayoutsLimitExceeded),
759            "instant_payouts_unsupported" => Ok(InstantPayoutsUnsupported),
760            "insufficient_funds" => Ok(InsufficientFunds),
761            "intent_invalid_state" => Ok(IntentInvalidState),
762            "intent_verification_method_missing" => Ok(IntentVerificationMethodMissing),
763            "invalid_card_type" => Ok(InvalidCardType),
764            "invalid_characters" => Ok(InvalidCharacters),
765            "invalid_charge_amount" => Ok(InvalidChargeAmount),
766            "invalid_cvc" => Ok(InvalidCvc),
767            "invalid_expiry_month" => Ok(InvalidExpiryMonth),
768            "invalid_expiry_year" => Ok(InvalidExpiryYear),
769            "invalid_mandate_reference_prefix_format" => Ok(InvalidMandateReferencePrefixFormat),
770            "invalid_number" => Ok(InvalidNumber),
771            "invalid_source_usage" => Ok(InvalidSourceUsage),
772            "invalid_tax_location" => Ok(InvalidTaxLocation),
773            "invoice_no_customer_line_items" => Ok(InvoiceNoCustomerLineItems),
774            "invoice_no_payment_method_types" => Ok(InvoiceNoPaymentMethodTypes),
775            "invoice_no_subscription_line_items" => Ok(InvoiceNoSubscriptionLineItems),
776            "invoice_not_editable" => Ok(InvoiceNotEditable),
777            "invoice_on_behalf_of_not_editable" => Ok(InvoiceOnBehalfOfNotEditable),
778            "invoice_payment_intent_requires_action" => Ok(InvoicePaymentIntentRequiresAction),
779            "invoice_upcoming_none" => Ok(InvoiceUpcomingNone),
780            "livemode_mismatch" => Ok(LivemodeMismatch),
781            "lock_timeout" => Ok(LockTimeout),
782            "missing" => Ok(Missing),
783            "no_account" => Ok(NoAccount),
784            "not_allowed_on_standard_account" => Ok(NotAllowedOnStandardAccount),
785            "out_of_inventory" => Ok(OutOfInventory),
786            "ownership_declaration_not_allowed" => Ok(OwnershipDeclarationNotAllowed),
787            "parameter_invalid_empty" => Ok(ParameterInvalidEmpty),
788            "parameter_invalid_integer" => Ok(ParameterInvalidInteger),
789            "parameter_invalid_string_blank" => Ok(ParameterInvalidStringBlank),
790            "parameter_invalid_string_empty" => Ok(ParameterInvalidStringEmpty),
791            "parameter_missing" => Ok(ParameterMissing),
792            "parameter_unknown" => Ok(ParameterUnknown),
793            "parameters_exclusive" => Ok(ParametersExclusive),
794            "payment_intent_action_required" => Ok(PaymentIntentActionRequired),
795            "payment_intent_authentication_failure" => Ok(PaymentIntentAuthenticationFailure),
796            "payment_intent_incompatible_payment_method" => {
797                Ok(PaymentIntentIncompatiblePaymentMethod)
798            }
799            "payment_intent_invalid_parameter" => Ok(PaymentIntentInvalidParameter),
800            "payment_intent_konbini_rejected_confirmation_number" => {
801                Ok(PaymentIntentKonbiniRejectedConfirmationNumber)
802            }
803            "payment_intent_mandate_invalid" => Ok(PaymentIntentMandateInvalid),
804            "payment_intent_payment_attempt_expired" => Ok(PaymentIntentPaymentAttemptExpired),
805            "payment_intent_payment_attempt_failed" => Ok(PaymentIntentPaymentAttemptFailed),
806            "payment_intent_rate_limit_exceeded" => Ok(PaymentIntentRateLimitExceeded),
807            "payment_intent_unexpected_state" => Ok(PaymentIntentUnexpectedState),
808            "payment_method_bank_account_already_verified" => {
809                Ok(PaymentMethodBankAccountAlreadyVerified)
810            }
811            "payment_method_bank_account_blocked" => Ok(PaymentMethodBankAccountBlocked),
812            "payment_method_billing_details_address_missing" => {
813                Ok(PaymentMethodBillingDetailsAddressMissing)
814            }
815            "payment_method_configuration_failures" => Ok(PaymentMethodConfigurationFailures),
816            "payment_method_currency_mismatch" => Ok(PaymentMethodCurrencyMismatch),
817            "payment_method_customer_decline" => Ok(PaymentMethodCustomerDecline),
818            "payment_method_invalid_parameter" => Ok(PaymentMethodInvalidParameter),
819            "payment_method_invalid_parameter_testmode" => {
820                Ok(PaymentMethodInvalidParameterTestmode)
821            }
822            "payment_method_microdeposit_failed" => Ok(PaymentMethodMicrodepositFailed),
823            "payment_method_microdeposit_verification_amounts_invalid" => {
824                Ok(PaymentMethodMicrodepositVerificationAmountsInvalid)
825            }
826            "payment_method_microdeposit_verification_amounts_mismatch" => {
827                Ok(PaymentMethodMicrodepositVerificationAmountsMismatch)
828            }
829            "payment_method_microdeposit_verification_attempts_exceeded" => {
830                Ok(PaymentMethodMicrodepositVerificationAttemptsExceeded)
831            }
832            "payment_method_microdeposit_verification_descriptor_code_mismatch" => {
833                Ok(PaymentMethodMicrodepositVerificationDescriptorCodeMismatch)
834            }
835            "payment_method_microdeposit_verification_timeout" => {
836                Ok(PaymentMethodMicrodepositVerificationTimeout)
837            }
838            "payment_method_not_available" => Ok(PaymentMethodNotAvailable),
839            "payment_method_provider_decline" => Ok(PaymentMethodProviderDecline),
840            "payment_method_provider_timeout" => Ok(PaymentMethodProviderTimeout),
841            "payment_method_unactivated" => Ok(PaymentMethodUnactivated),
842            "payment_method_unexpected_state" => Ok(PaymentMethodUnexpectedState),
843            "payment_method_unsupported_type" => Ok(PaymentMethodUnsupportedType),
844            "payout_reconciliation_not_ready" => Ok(PayoutReconciliationNotReady),
845            "payouts_limit_exceeded" => Ok(PayoutsLimitExceeded),
846            "payouts_not_allowed" => Ok(PayoutsNotAllowed),
847            "platform_account_required" => Ok(PlatformAccountRequired),
848            "platform_api_key_expired" => Ok(PlatformApiKeyExpired),
849            "postal_code_invalid" => Ok(PostalCodeInvalid),
850            "processing_error" => Ok(ProcessingError),
851            "product_inactive" => Ok(ProductInactive),
852            "progressive_onboarding_limit_exceeded" => Ok(ProgressiveOnboardingLimitExceeded),
853            "rate_limit" => Ok(RateLimit),
854            "refer_to_customer" => Ok(ReferToCustomer),
855            "refund_disputed_payment" => Ok(RefundDisputedPayment),
856            "request_blocked" => Ok(RequestBlocked),
857            "resource_already_exists" => Ok(ResourceAlreadyExists),
858            "resource_missing" => Ok(ResourceMissing),
859            "return_intent_already_processed" => Ok(ReturnIntentAlreadyProcessed),
860            "routing_number_invalid" => Ok(RoutingNumberInvalid),
861            "secret_key_required" => Ok(SecretKeyRequired),
862            "sepa_unsupported_account" => Ok(SepaUnsupportedAccount),
863            "service_period_coupon_with_metered_tiered_item_unsupported" => {
864                Ok(ServicePeriodCouponWithMeteredTieredItemUnsupported)
865            }
866            "setup_attempt_failed" => Ok(SetupAttemptFailed),
867            "setup_intent_authentication_failure" => Ok(SetupIntentAuthenticationFailure),
868            "setup_intent_invalid_parameter" => Ok(SetupIntentInvalidParameter),
869            "setup_intent_mandate_invalid" => Ok(SetupIntentMandateInvalid),
870            "setup_intent_mobile_wallet_unsupported" => Ok(SetupIntentMobileWalletUnsupported),
871            "setup_intent_setup_attempt_expired" => Ok(SetupIntentSetupAttemptExpired),
872            "setup_intent_unexpected_state" => Ok(SetupIntentUnexpectedState),
873            "shipping_address_invalid" => Ok(ShippingAddressInvalid),
874            "shipping_calculation_failed" => Ok(ShippingCalculationFailed),
875            "sku_inactive" => Ok(SkuInactive),
876            "state_unsupported" => Ok(StateUnsupported),
877            "status_transition_invalid" => Ok(StatusTransitionInvalid),
878            "storer_capability_missing" => Ok(StorerCapabilityMissing),
879            "storer_capability_not_active" => Ok(StorerCapabilityNotActive),
880            "stripe_tax_inactive" => Ok(StripeTaxInactive),
881            "tax_id_invalid" => Ok(TaxIdInvalid),
882            "tax_id_prohibited" => Ok(TaxIdProhibited),
883            "taxes_calculation_failed" => Ok(TaxesCalculationFailed),
884            "terminal_location_country_unsupported" => Ok(TerminalLocationCountryUnsupported),
885            "terminal_reader_busy" => Ok(TerminalReaderBusy),
886            "terminal_reader_hardware_fault" => Ok(TerminalReaderHardwareFault),
887            "terminal_reader_invalid_location_for_activation" => {
888                Ok(TerminalReaderInvalidLocationForActivation)
889            }
890            "terminal_reader_invalid_location_for_payment" => {
891                Ok(TerminalReaderInvalidLocationForPayment)
892            }
893            "terminal_reader_offline" => Ok(TerminalReaderOffline),
894            "terminal_reader_timeout" => Ok(TerminalReaderTimeout),
895            "testmode_charges_only" => Ok(TestmodeChargesOnly),
896            "tls_version_unsupported" => Ok(TlsVersionUnsupported),
897            "token_already_used" => Ok(TokenAlreadyUsed),
898            "token_card_network_invalid" => Ok(TokenCardNetworkInvalid),
899            "token_in_use" => Ok(TokenInUse),
900            "transfer_source_balance_parameters_mismatch" => {
901                Ok(TransferSourceBalanceParametersMismatch)
902            }
903            "transfers_not_allowed" => Ok(TransfersNotAllowed),
904            "url_invalid" => Ok(UrlInvalid),
905            v => {
906                tracing::warn!("Unknown value '{}' for enum '{}'", v, "ApiErrorsCode");
907                Ok(Unknown(v.to_owned()))
908            }
909        }
910    }
911}
912impl std::fmt::Display for ApiErrorsCode {
913    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
914        f.write_str(self.as_str())
915    }
916}
917
918#[cfg(not(feature = "redact-generated-debug"))]
919impl std::fmt::Debug for ApiErrorsCode {
920    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
921        f.write_str(self.as_str())
922    }
923}
924#[cfg(feature = "redact-generated-debug")]
925impl std::fmt::Debug for ApiErrorsCode {
926    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
927        f.debug_struct(stringify!(ApiErrorsCode)).finish_non_exhaustive()
928    }
929}
930#[cfg(feature = "serialize")]
931impl serde::Serialize for ApiErrorsCode {
932    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
933    where
934        S: serde::Serializer,
935    {
936        serializer.serialize_str(self.as_str())
937    }
938}
939impl miniserde::Deserialize for ApiErrorsCode {
940    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
941        crate::Place::new(out)
942    }
943}
944
945impl miniserde::de::Visitor for crate::Place<ApiErrorsCode> {
946    fn string(&mut self, s: &str) -> miniserde::Result<()> {
947        use std::str::FromStr;
948        self.out = Some(ApiErrorsCode::from_str(s).expect("infallible"));
949        Ok(())
950    }
951}
952
953stripe_types::impl_from_val_with_from_str!(ApiErrorsCode);
954#[cfg(feature = "deserialize")]
955impl<'de> serde::Deserialize<'de> for ApiErrorsCode {
956    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
957        use std::str::FromStr;
958        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
959        Ok(Self::from_str(&s).expect("infallible"))
960    }
961}
962/// The type of error returned.
963/// One of `api_error`, `card_error`, `idempotency_error`, or `invalid_request_error`.
964#[derive(Clone, Eq, PartialEq)]
965#[non_exhaustive]
966pub enum ApiErrorsType {
967    ApiError,
968    CardError,
969    IdempotencyError,
970    InvalidRequestError,
971    /// An unrecognized value from Stripe. Should not be used as a request parameter.
972    Unknown(String),
973}
974impl ApiErrorsType {
975    pub fn as_str(&self) -> &str {
976        use ApiErrorsType::*;
977        match self {
978            ApiError => "api_error",
979            CardError => "card_error",
980            IdempotencyError => "idempotency_error",
981            InvalidRequestError => "invalid_request_error",
982            Unknown(v) => v,
983        }
984    }
985}
986
987impl std::str::FromStr for ApiErrorsType {
988    type Err = std::convert::Infallible;
989    fn from_str(s: &str) -> Result<Self, Self::Err> {
990        use ApiErrorsType::*;
991        match s {
992            "api_error" => Ok(ApiError),
993            "card_error" => Ok(CardError),
994            "idempotency_error" => Ok(IdempotencyError),
995            "invalid_request_error" => Ok(InvalidRequestError),
996            v => {
997                tracing::warn!("Unknown value '{}' for enum '{}'", v, "ApiErrorsType");
998                Ok(Unknown(v.to_owned()))
999            }
1000        }
1001    }
1002}
1003impl std::fmt::Display for ApiErrorsType {
1004    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1005        f.write_str(self.as_str())
1006    }
1007}
1008
1009#[cfg(not(feature = "redact-generated-debug"))]
1010impl std::fmt::Debug for ApiErrorsType {
1011    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1012        f.write_str(self.as_str())
1013    }
1014}
1015#[cfg(feature = "redact-generated-debug")]
1016impl std::fmt::Debug for ApiErrorsType {
1017    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1018        f.debug_struct(stringify!(ApiErrorsType)).finish_non_exhaustive()
1019    }
1020}
1021#[cfg(feature = "serialize")]
1022impl serde::Serialize for ApiErrorsType {
1023    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1024    where
1025        S: serde::Serializer,
1026    {
1027        serializer.serialize_str(self.as_str())
1028    }
1029}
1030impl miniserde::Deserialize for ApiErrorsType {
1031    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
1032        crate::Place::new(out)
1033    }
1034}
1035
1036impl miniserde::de::Visitor for crate::Place<ApiErrorsType> {
1037    fn string(&mut self, s: &str) -> miniserde::Result<()> {
1038        use std::str::FromStr;
1039        self.out = Some(ApiErrorsType::from_str(s).expect("infallible"));
1040        Ok(())
1041    }
1042}
1043
1044stripe_types::impl_from_val_with_from_str!(ApiErrorsType);
1045#[cfg(feature = "deserialize")]
1046impl<'de> serde::Deserialize<'de> for ApiErrorsType {
1047    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1048        use std::str::FromStr;
1049        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
1050        Ok(Self::from_str(&s).expect("infallible"))
1051    }
1052}