stripe_shared/
api_errors.rs

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