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 pub advice_code: Option<String>,
8 pub charge: Option<String>,
10 pub code: Option<ApiErrorsCode>,
12 pub decline_code: Option<String>,
14 pub doc_url: Option<String>,
16 pub message: Option<String>,
19 pub network_advice_code: Option<String>,
21 pub network_decline_code: Option<String>,
23 pub param: Option<String>,
26 pub payment_intent: Option<stripe_shared::PaymentIntent>,
27 pub payment_method: Option<stripe_shared::PaymentMethod>,
28 pub payment_method_type: Option<String>,
31 pub request_log_url: Option<String>,
33 pub setup_intent: Option<stripe_shared::SetupIntent>,
34 pub source: Option<stripe_shared::PaymentSource>,
35 #[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#[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 AnomalousMoneyMovementRequest,
267 ApiKeyExpired,
268 ApplicationFeesNotAllowed,
269 ApprovalRequired,
270 AuthenticationRequired,
271 BalanceInsufficient,
272 BalanceInvalidParameter,
273 BankAccountBadRoutingNumbers,
274 BankAccountDeclined,
275 BankAccountExists,
276 BankAccountRestricted,
277 BankAccountUnusable,
278 BankAccountUnverified,
279 BankAccountVerificationFailed,
280 BillingInvalidMandate,
281 BitcoinUpgradeRequired,
282 CaptureChargeAuthorizationExpired,
283 CaptureUnauthorizedPayment,
284 CardDeclineRateLimitExceeded,
285 CardDeclined,
286 CardholderPhoneNumberRequired,
287 ChargeAlreadyCaptured,
288 ChargeAlreadyRefunded,
289 ChargeDisputed,
290 ChargeExceedsSourceLimit,
291 ChargeExceedsTransactionLimit,
292 ChargeExpiredForCapture,
293 ChargeInvalidParameter,
294 ChargeNotRefundable,
295 ClearingCodeUnsupported,
296 CountryCodeInvalid,
297 CountryUnsupported,
298 CouponExpired,
299 CustomerMaxPaymentMethods,
300 CustomerMaxSubscriptions,
301 CustomerSessionExpired,
302 CustomerTaxLocationInvalid,
303 DebitNotAuthorized,
304 EmailInvalid,
305 ExpiredCard,
306 FailedTaxCalculation,
307 FinancialAccountBalanceDoesNotSupportCurrency,
308 FinancialAccountCapabilityNotEnabled,
309 FinancialAccountCapabilityRestricted,
310 FinancialConnectionsAccountInactive,
311 FinancialConnectionsAccountPendingAccountNumbers,
312 FinancialConnectionsAccountUnavailableAccountNumbers,
313 FinancialConnectionsNoSuccessfulTransactionRefresh,
314 ForwardingApiInactive,
315 ForwardingApiInvalidParameter,
316 ForwardingApiRetryableUpstreamError,
317 ForwardingApiUpstreamConnectionError,
318 ForwardingApiUpstreamConnectionTimeout,
319 ForwardingApiUpstreamError,
320 IdempotencyKeyInUse,
321 IncorrectAddress,
322 IncorrectCvc,
323 IncorrectNumber,
324 IncorrectZip,
325 IndiaRecurringPaymentMandateCanceled,
326 InstantPayoutsConfigDisabled,
327 InstantPayoutsCurrencyDisabled,
328 InstantPayoutsLimitExceeded,
329 InstantPayoutsUnsupported,
330 InsufficientFunds,
331 IntentInvalidState,
332 IntentVerificationMethodMissing,
333 InvalidCardType,
334 InvalidCharacters,
335 InvalidChargeAmount,
336 InvalidCvc,
337 InvalidExpiryMonth,
338 InvalidExpiryYear,
339 InvalidMandateReferencePrefixFormat,
340 InvalidNumber,
341 InvalidSourceUsage,
342 InvalidTaxLocation,
343 InvoiceNoCustomerLineItems,
344 InvoiceNoPaymentMethodTypes,
345 InvoiceNoSubscriptionLineItems,
346 InvoiceNotEditable,
347 InvoiceOnBehalfOfNotEditable,
348 InvoicePaymentIntentRequiresAction,
349 InvoiceUpcomingNone,
350 LivemodeMismatch,
351 LockTimeout,
352 Missing,
353 NoAccount,
354 NotAllowedOnStandardAccount,
355 OutOfInventory,
356 OwnershipDeclarationNotAllowed,
357 ParameterInvalidEmpty,
358 ParameterInvalidInteger,
359 ParameterInvalidStringBlank,
360 ParameterInvalidStringEmpty,
361 ParameterMissing,
362 ParameterUnknown,
363 ParametersExclusive,
364 PaymentIntentActionRequired,
365 PaymentIntentAuthenticationFailure,
366 PaymentIntentIncompatiblePaymentMethod,
367 PaymentIntentInvalidParameter,
368 PaymentIntentKonbiniRejectedConfirmationNumber,
369 PaymentIntentMandateInvalid,
370 PaymentIntentPaymentAttemptExpired,
371 PaymentIntentPaymentAttemptFailed,
372 PaymentIntentRateLimitExceeded,
373 PaymentIntentUnexpectedState,
374 PaymentMethodBankAccountAlreadyVerified,
375 PaymentMethodBankAccountBlocked,
376 PaymentMethodBillingDetailsAddressMissing,
377 PaymentMethodConfigurationFailures,
378 PaymentMethodCurrencyMismatch,
379 PaymentMethodCustomerDecline,
380 PaymentMethodInvalidParameter,
381 PaymentMethodInvalidParameterTestmode,
382 PaymentMethodMicrodepositFailed,
383 PaymentMethodMicrodepositProcessingError,
384 PaymentMethodMicrodepositVerificationAmountsInvalid,
385 PaymentMethodMicrodepositVerificationAmountsMismatch,
386 PaymentMethodMicrodepositVerificationAttemptsExceeded,
387 PaymentMethodMicrodepositVerificationDescriptorCodeMismatch,
388 PaymentMethodMicrodepositVerificationTimeout,
389 PaymentMethodNotAvailable,
390 PaymentMethodProviderDecline,
391 PaymentMethodProviderTimeout,
392 PaymentMethodUnactivated,
393 PaymentMethodUnexpectedState,
394 PaymentMethodUnsupportedType,
395 PayoutReconciliationNotReady,
396 PayoutsLimitExceeded,
397 PayoutsNotAllowed,
398 PlatformAccountRequired,
399 PlatformApiKeyExpired,
400 PostalCodeInvalid,
401 ProcessingError,
402 ProductInactive,
403 ProgressiveOnboardingLimitExceeded,
404 RateLimit,
405 ReferToCustomer,
406 RefundDisputedPayment,
407 RequestBlocked,
408 ResourceAlreadyExists,
409 ResourceMissing,
410 ReturnIntentAlreadyProcessed,
411 RoutingNumberInvalid,
412 SecretKeyRequired,
413 SepaUnsupportedAccount,
414 ServicePeriodCouponWithMeteredTieredItemUnsupported,
415 SetupAttemptFailed,
416 SetupIntentAuthenticationFailure,
417 SetupIntentInvalidParameter,
418 SetupIntentMandateInvalid,
419 SetupIntentMobileWalletUnsupported,
420 SetupIntentSetupAttemptExpired,
421 SetupIntentUnexpectedState,
422 ShippingAddressInvalid,
423 ShippingCalculationFailed,
424 SiretInvalid,
425 SkuInactive,
426 StateUnsupported,
427 StatusTransitionInvalid,
428 StorerCapabilityMissing,
429 StorerCapabilityNotActive,
430 StripeTaxInactive,
431 TaxIdInvalid,
432 TaxIdProhibited,
433 TaxesCalculationFailed,
434 TerminalLocationCountryUnsupported,
435 TerminalReaderBusy,
436 TerminalReaderHardwareFault,
437 TerminalReaderInvalidLocationForActivation,
438 TerminalReaderInvalidLocationForPayment,
439 TerminalReaderOffline,
440 TerminalReaderTimeout,
441 TestmodeChargesOnly,
442 TlsVersionUnsupported,
443 TokenAlreadyUsed,
444 TokenCardNetworkInvalid,
445 TokenInUse,
446 TransferSourceBalanceParametersMismatch,
447 TransfersNotAllowed,
448 UrlInvalid,
449 Unknown(String),
451}
452impl ApiErrorsCode {
453 pub fn as_str(&self) -> &str {
454 use ApiErrorsCode::*;
455 match self {
456 AccountClosed => "account_closed",
457 AccountCountryInvalidAddress => "account_country_invalid_address",
458 AccountErrorCountryChangeRequiresAdditionalSteps => {
459 "account_error_country_change_requires_additional_steps"
460 }
461 AccountInformationMismatch => "account_information_mismatch",
462 AccountInvalid => "account_invalid",
463 AccountNumberInvalid => "account_number_invalid",
464 AccountTokenRequiredForV2Account => "account_token_required_for_v2_account",
465 AcssDebitSessionIncomplete => "acss_debit_session_incomplete",
466 ActionBlocked => "action_blocked",
467 AlipayUpgradeRequired => "alipay_upgrade_required",
468 AmountTooLarge => "amount_too_large",
469 AmountTooSmall => "amount_too_small",
470 AnomalousMoneyMovementRequest => "anomalous_money_movement_request",
471 ApiKeyExpired => "api_key_expired",
472 ApplicationFeesNotAllowed => "application_fees_not_allowed",
473 ApprovalRequired => "approval_required",
474 AuthenticationRequired => "authentication_required",
475 BalanceInsufficient => "balance_insufficient",
476 BalanceInvalidParameter => "balance_invalid_parameter",
477 BankAccountBadRoutingNumbers => "bank_account_bad_routing_numbers",
478 BankAccountDeclined => "bank_account_declined",
479 BankAccountExists => "bank_account_exists",
480 BankAccountRestricted => "bank_account_restricted",
481 BankAccountUnusable => "bank_account_unusable",
482 BankAccountUnverified => "bank_account_unverified",
483 BankAccountVerificationFailed => "bank_account_verification_failed",
484 BillingInvalidMandate => "billing_invalid_mandate",
485 BitcoinUpgradeRequired => "bitcoin_upgrade_required",
486 CaptureChargeAuthorizationExpired => "capture_charge_authorization_expired",
487 CaptureUnauthorizedPayment => "capture_unauthorized_payment",
488 CardDeclineRateLimitExceeded => "card_decline_rate_limit_exceeded",
489 CardDeclined => "card_declined",
490 CardholderPhoneNumberRequired => "cardholder_phone_number_required",
491 ChargeAlreadyCaptured => "charge_already_captured",
492 ChargeAlreadyRefunded => "charge_already_refunded",
493 ChargeDisputed => "charge_disputed",
494 ChargeExceedsSourceLimit => "charge_exceeds_source_limit",
495 ChargeExceedsTransactionLimit => "charge_exceeds_transaction_limit",
496 ChargeExpiredForCapture => "charge_expired_for_capture",
497 ChargeInvalidParameter => "charge_invalid_parameter",
498 ChargeNotRefundable => "charge_not_refundable",
499 ClearingCodeUnsupported => "clearing_code_unsupported",
500 CountryCodeInvalid => "country_code_invalid",
501 CountryUnsupported => "country_unsupported",
502 CouponExpired => "coupon_expired",
503 CustomerMaxPaymentMethods => "customer_max_payment_methods",
504 CustomerMaxSubscriptions => "customer_max_subscriptions",
505 CustomerSessionExpired => "customer_session_expired",
506 CustomerTaxLocationInvalid => "customer_tax_location_invalid",
507 DebitNotAuthorized => "debit_not_authorized",
508 EmailInvalid => "email_invalid",
509 ExpiredCard => "expired_card",
510 FailedTaxCalculation => "failed_tax_calculation",
511 FinancialAccountBalanceDoesNotSupportCurrency => {
512 "financial_account_balance_does_not_support_currency"
513 }
514 FinancialAccountCapabilityNotEnabled => "financial_account_capability_not_enabled",
515 FinancialAccountCapabilityRestricted => "financial_account_capability_restricted",
516 FinancialConnectionsAccountInactive => "financial_connections_account_inactive",
517 FinancialConnectionsAccountPendingAccountNumbers => {
518 "financial_connections_account_pending_account_numbers"
519 }
520 FinancialConnectionsAccountUnavailableAccountNumbers => {
521 "financial_connections_account_unavailable_account_numbers"
522 }
523 FinancialConnectionsNoSuccessfulTransactionRefresh => {
524 "financial_connections_no_successful_transaction_refresh"
525 }
526 ForwardingApiInactive => "forwarding_api_inactive",
527 ForwardingApiInvalidParameter => "forwarding_api_invalid_parameter",
528 ForwardingApiRetryableUpstreamError => "forwarding_api_retryable_upstream_error",
529 ForwardingApiUpstreamConnectionError => "forwarding_api_upstream_connection_error",
530 ForwardingApiUpstreamConnectionTimeout => "forwarding_api_upstream_connection_timeout",
531 ForwardingApiUpstreamError => "forwarding_api_upstream_error",
532 IdempotencyKeyInUse => "idempotency_key_in_use",
533 IncorrectAddress => "incorrect_address",
534 IncorrectCvc => "incorrect_cvc",
535 IncorrectNumber => "incorrect_number",
536 IncorrectZip => "incorrect_zip",
537 IndiaRecurringPaymentMandateCanceled => "india_recurring_payment_mandate_canceled",
538 InstantPayoutsConfigDisabled => "instant_payouts_config_disabled",
539 InstantPayoutsCurrencyDisabled => "instant_payouts_currency_disabled",
540 InstantPayoutsLimitExceeded => "instant_payouts_limit_exceeded",
541 InstantPayoutsUnsupported => "instant_payouts_unsupported",
542 InsufficientFunds => "insufficient_funds",
543 IntentInvalidState => "intent_invalid_state",
544 IntentVerificationMethodMissing => "intent_verification_method_missing",
545 InvalidCardType => "invalid_card_type",
546 InvalidCharacters => "invalid_characters",
547 InvalidChargeAmount => "invalid_charge_amount",
548 InvalidCvc => "invalid_cvc",
549 InvalidExpiryMonth => "invalid_expiry_month",
550 InvalidExpiryYear => "invalid_expiry_year",
551 InvalidMandateReferencePrefixFormat => "invalid_mandate_reference_prefix_format",
552 InvalidNumber => "invalid_number",
553 InvalidSourceUsage => "invalid_source_usage",
554 InvalidTaxLocation => "invalid_tax_location",
555 InvoiceNoCustomerLineItems => "invoice_no_customer_line_items",
556 InvoiceNoPaymentMethodTypes => "invoice_no_payment_method_types",
557 InvoiceNoSubscriptionLineItems => "invoice_no_subscription_line_items",
558 InvoiceNotEditable => "invoice_not_editable",
559 InvoiceOnBehalfOfNotEditable => "invoice_on_behalf_of_not_editable",
560 InvoicePaymentIntentRequiresAction => "invoice_payment_intent_requires_action",
561 InvoiceUpcomingNone => "invoice_upcoming_none",
562 LivemodeMismatch => "livemode_mismatch",
563 LockTimeout => "lock_timeout",
564 Missing => "missing",
565 NoAccount => "no_account",
566 NotAllowedOnStandardAccount => "not_allowed_on_standard_account",
567 OutOfInventory => "out_of_inventory",
568 OwnershipDeclarationNotAllowed => "ownership_declaration_not_allowed",
569 ParameterInvalidEmpty => "parameter_invalid_empty",
570 ParameterInvalidInteger => "parameter_invalid_integer",
571 ParameterInvalidStringBlank => "parameter_invalid_string_blank",
572 ParameterInvalidStringEmpty => "parameter_invalid_string_empty",
573 ParameterMissing => "parameter_missing",
574 ParameterUnknown => "parameter_unknown",
575 ParametersExclusive => "parameters_exclusive",
576 PaymentIntentActionRequired => "payment_intent_action_required",
577 PaymentIntentAuthenticationFailure => "payment_intent_authentication_failure",
578 PaymentIntentIncompatiblePaymentMethod => "payment_intent_incompatible_payment_method",
579 PaymentIntentInvalidParameter => "payment_intent_invalid_parameter",
580 PaymentIntentKonbiniRejectedConfirmationNumber => {
581 "payment_intent_konbini_rejected_confirmation_number"
582 }
583 PaymentIntentMandateInvalid => "payment_intent_mandate_invalid",
584 PaymentIntentPaymentAttemptExpired => "payment_intent_payment_attempt_expired",
585 PaymentIntentPaymentAttemptFailed => "payment_intent_payment_attempt_failed",
586 PaymentIntentRateLimitExceeded => "payment_intent_rate_limit_exceeded",
587 PaymentIntentUnexpectedState => "payment_intent_unexpected_state",
588 PaymentMethodBankAccountAlreadyVerified => {
589 "payment_method_bank_account_already_verified"
590 }
591 PaymentMethodBankAccountBlocked => "payment_method_bank_account_blocked",
592 PaymentMethodBillingDetailsAddressMissing => {
593 "payment_method_billing_details_address_missing"
594 }
595 PaymentMethodConfigurationFailures => "payment_method_configuration_failures",
596 PaymentMethodCurrencyMismatch => "payment_method_currency_mismatch",
597 PaymentMethodCustomerDecline => "payment_method_customer_decline",
598 PaymentMethodInvalidParameter => "payment_method_invalid_parameter",
599 PaymentMethodInvalidParameterTestmode => "payment_method_invalid_parameter_testmode",
600 PaymentMethodMicrodepositFailed => "payment_method_microdeposit_failed",
601 PaymentMethodMicrodepositProcessingError => {
602 "payment_method_microdeposit_processing_error"
603 }
604 PaymentMethodMicrodepositVerificationAmountsInvalid => {
605 "payment_method_microdeposit_verification_amounts_invalid"
606 }
607 PaymentMethodMicrodepositVerificationAmountsMismatch => {
608 "payment_method_microdeposit_verification_amounts_mismatch"
609 }
610 PaymentMethodMicrodepositVerificationAttemptsExceeded => {
611 "payment_method_microdeposit_verification_attempts_exceeded"
612 }
613 PaymentMethodMicrodepositVerificationDescriptorCodeMismatch => {
614 "payment_method_microdeposit_verification_descriptor_code_mismatch"
615 }
616 PaymentMethodMicrodepositVerificationTimeout => {
617 "payment_method_microdeposit_verification_timeout"
618 }
619 PaymentMethodNotAvailable => "payment_method_not_available",
620 PaymentMethodProviderDecline => "payment_method_provider_decline",
621 PaymentMethodProviderTimeout => "payment_method_provider_timeout",
622 PaymentMethodUnactivated => "payment_method_unactivated",
623 PaymentMethodUnexpectedState => "payment_method_unexpected_state",
624 PaymentMethodUnsupportedType => "payment_method_unsupported_type",
625 PayoutReconciliationNotReady => "payout_reconciliation_not_ready",
626 PayoutsLimitExceeded => "payouts_limit_exceeded",
627 PayoutsNotAllowed => "payouts_not_allowed",
628 PlatformAccountRequired => "platform_account_required",
629 PlatformApiKeyExpired => "platform_api_key_expired",
630 PostalCodeInvalid => "postal_code_invalid",
631 ProcessingError => "processing_error",
632 ProductInactive => "product_inactive",
633 ProgressiveOnboardingLimitExceeded => "progressive_onboarding_limit_exceeded",
634 RateLimit => "rate_limit",
635 ReferToCustomer => "refer_to_customer",
636 RefundDisputedPayment => "refund_disputed_payment",
637 RequestBlocked => "request_blocked",
638 ResourceAlreadyExists => "resource_already_exists",
639 ResourceMissing => "resource_missing",
640 ReturnIntentAlreadyProcessed => "return_intent_already_processed",
641 RoutingNumberInvalid => "routing_number_invalid",
642 SecretKeyRequired => "secret_key_required",
643 SepaUnsupportedAccount => "sepa_unsupported_account",
644 ServicePeriodCouponWithMeteredTieredItemUnsupported => {
645 "service_period_coupon_with_metered_tiered_item_unsupported"
646 }
647 SetupAttemptFailed => "setup_attempt_failed",
648 SetupIntentAuthenticationFailure => "setup_intent_authentication_failure",
649 SetupIntentInvalidParameter => "setup_intent_invalid_parameter",
650 SetupIntentMandateInvalid => "setup_intent_mandate_invalid",
651 SetupIntentMobileWalletUnsupported => "setup_intent_mobile_wallet_unsupported",
652 SetupIntentSetupAttemptExpired => "setup_intent_setup_attempt_expired",
653 SetupIntentUnexpectedState => "setup_intent_unexpected_state",
654 ShippingAddressInvalid => "shipping_address_invalid",
655 ShippingCalculationFailed => "shipping_calculation_failed",
656 SiretInvalid => "siret_invalid",
657 SkuInactive => "sku_inactive",
658 StateUnsupported => "state_unsupported",
659 StatusTransitionInvalid => "status_transition_invalid",
660 StorerCapabilityMissing => "storer_capability_missing",
661 StorerCapabilityNotActive => "storer_capability_not_active",
662 StripeTaxInactive => "stripe_tax_inactive",
663 TaxIdInvalid => "tax_id_invalid",
664 TaxIdProhibited => "tax_id_prohibited",
665 TaxesCalculationFailed => "taxes_calculation_failed",
666 TerminalLocationCountryUnsupported => "terminal_location_country_unsupported",
667 TerminalReaderBusy => "terminal_reader_busy",
668 TerminalReaderHardwareFault => "terminal_reader_hardware_fault",
669 TerminalReaderInvalidLocationForActivation => {
670 "terminal_reader_invalid_location_for_activation"
671 }
672 TerminalReaderInvalidLocationForPayment => {
673 "terminal_reader_invalid_location_for_payment"
674 }
675 TerminalReaderOffline => "terminal_reader_offline",
676 TerminalReaderTimeout => "terminal_reader_timeout",
677 TestmodeChargesOnly => "testmode_charges_only",
678 TlsVersionUnsupported => "tls_version_unsupported",
679 TokenAlreadyUsed => "token_already_used",
680 TokenCardNetworkInvalid => "token_card_network_invalid",
681 TokenInUse => "token_in_use",
682 TransferSourceBalanceParametersMismatch => {
683 "transfer_source_balance_parameters_mismatch"
684 }
685 TransfersNotAllowed => "transfers_not_allowed",
686 UrlInvalid => "url_invalid",
687 Unknown(v) => v,
688 }
689 }
690}
691
692impl std::str::FromStr for ApiErrorsCode {
693 type Err = std::convert::Infallible;
694 fn from_str(s: &str) -> Result<Self, Self::Err> {
695 use ApiErrorsCode::*;
696 match s {
697 "account_closed" => Ok(AccountClosed),
698 "account_country_invalid_address" => Ok(AccountCountryInvalidAddress),
699 "account_error_country_change_requires_additional_steps" => {
700 Ok(AccountErrorCountryChangeRequiresAdditionalSteps)
701 }
702 "account_information_mismatch" => Ok(AccountInformationMismatch),
703 "account_invalid" => Ok(AccountInvalid),
704 "account_number_invalid" => Ok(AccountNumberInvalid),
705 "account_token_required_for_v2_account" => Ok(AccountTokenRequiredForV2Account),
706 "acss_debit_session_incomplete" => Ok(AcssDebitSessionIncomplete),
707 "action_blocked" => Ok(ActionBlocked),
708 "alipay_upgrade_required" => Ok(AlipayUpgradeRequired),
709 "amount_too_large" => Ok(AmountTooLarge),
710 "amount_too_small" => Ok(AmountTooSmall),
711 "anomalous_money_movement_request" => Ok(AnomalousMoneyMovementRequest),
712 "api_key_expired" => Ok(ApiKeyExpired),
713 "application_fees_not_allowed" => Ok(ApplicationFeesNotAllowed),
714 "approval_required" => Ok(ApprovalRequired),
715 "authentication_required" => Ok(AuthenticationRequired),
716 "balance_insufficient" => Ok(BalanceInsufficient),
717 "balance_invalid_parameter" => Ok(BalanceInvalidParameter),
718 "bank_account_bad_routing_numbers" => Ok(BankAccountBadRoutingNumbers),
719 "bank_account_declined" => Ok(BankAccountDeclined),
720 "bank_account_exists" => Ok(BankAccountExists),
721 "bank_account_restricted" => Ok(BankAccountRestricted),
722 "bank_account_unusable" => Ok(BankAccountUnusable),
723 "bank_account_unverified" => Ok(BankAccountUnverified),
724 "bank_account_verification_failed" => Ok(BankAccountVerificationFailed),
725 "billing_invalid_mandate" => Ok(BillingInvalidMandate),
726 "bitcoin_upgrade_required" => Ok(BitcoinUpgradeRequired),
727 "capture_charge_authorization_expired" => Ok(CaptureChargeAuthorizationExpired),
728 "capture_unauthorized_payment" => Ok(CaptureUnauthorizedPayment),
729 "card_decline_rate_limit_exceeded" => Ok(CardDeclineRateLimitExceeded),
730 "card_declined" => Ok(CardDeclined),
731 "cardholder_phone_number_required" => Ok(CardholderPhoneNumberRequired),
732 "charge_already_captured" => Ok(ChargeAlreadyCaptured),
733 "charge_already_refunded" => Ok(ChargeAlreadyRefunded),
734 "charge_disputed" => Ok(ChargeDisputed),
735 "charge_exceeds_source_limit" => Ok(ChargeExceedsSourceLimit),
736 "charge_exceeds_transaction_limit" => Ok(ChargeExceedsTransactionLimit),
737 "charge_expired_for_capture" => Ok(ChargeExpiredForCapture),
738 "charge_invalid_parameter" => Ok(ChargeInvalidParameter),
739 "charge_not_refundable" => Ok(ChargeNotRefundable),
740 "clearing_code_unsupported" => Ok(ClearingCodeUnsupported),
741 "country_code_invalid" => Ok(CountryCodeInvalid),
742 "country_unsupported" => Ok(CountryUnsupported),
743 "coupon_expired" => Ok(CouponExpired),
744 "customer_max_payment_methods" => Ok(CustomerMaxPaymentMethods),
745 "customer_max_subscriptions" => Ok(CustomerMaxSubscriptions),
746 "customer_session_expired" => Ok(CustomerSessionExpired),
747 "customer_tax_location_invalid" => Ok(CustomerTaxLocationInvalid),
748 "debit_not_authorized" => Ok(DebitNotAuthorized),
749 "email_invalid" => Ok(EmailInvalid),
750 "expired_card" => Ok(ExpiredCard),
751 "failed_tax_calculation" => Ok(FailedTaxCalculation),
752 "financial_account_balance_does_not_support_currency" => {
753 Ok(FinancialAccountBalanceDoesNotSupportCurrency)
754 }
755 "financial_account_capability_not_enabled" => Ok(FinancialAccountCapabilityNotEnabled),
756 "financial_account_capability_restricted" => Ok(FinancialAccountCapabilityRestricted),
757 "financial_connections_account_inactive" => Ok(FinancialConnectionsAccountInactive),
758 "financial_connections_account_pending_account_numbers" => {
759 Ok(FinancialConnectionsAccountPendingAccountNumbers)
760 }
761 "financial_connections_account_unavailable_account_numbers" => {
762 Ok(FinancialConnectionsAccountUnavailableAccountNumbers)
763 }
764 "financial_connections_no_successful_transaction_refresh" => {
765 Ok(FinancialConnectionsNoSuccessfulTransactionRefresh)
766 }
767 "forwarding_api_inactive" => Ok(ForwardingApiInactive),
768 "forwarding_api_invalid_parameter" => Ok(ForwardingApiInvalidParameter),
769 "forwarding_api_retryable_upstream_error" => Ok(ForwardingApiRetryableUpstreamError),
770 "forwarding_api_upstream_connection_error" => Ok(ForwardingApiUpstreamConnectionError),
771 "forwarding_api_upstream_connection_timeout" => {
772 Ok(ForwardingApiUpstreamConnectionTimeout)
773 }
774 "forwarding_api_upstream_error" => Ok(ForwardingApiUpstreamError),
775 "idempotency_key_in_use" => Ok(IdempotencyKeyInUse),
776 "incorrect_address" => Ok(IncorrectAddress),
777 "incorrect_cvc" => Ok(IncorrectCvc),
778 "incorrect_number" => Ok(IncorrectNumber),
779 "incorrect_zip" => Ok(IncorrectZip),
780 "india_recurring_payment_mandate_canceled" => Ok(IndiaRecurringPaymentMandateCanceled),
781 "instant_payouts_config_disabled" => Ok(InstantPayoutsConfigDisabled),
782 "instant_payouts_currency_disabled" => Ok(InstantPayoutsCurrencyDisabled),
783 "instant_payouts_limit_exceeded" => Ok(InstantPayoutsLimitExceeded),
784 "instant_payouts_unsupported" => Ok(InstantPayoutsUnsupported),
785 "insufficient_funds" => Ok(InsufficientFunds),
786 "intent_invalid_state" => Ok(IntentInvalidState),
787 "intent_verification_method_missing" => Ok(IntentVerificationMethodMissing),
788 "invalid_card_type" => Ok(InvalidCardType),
789 "invalid_characters" => Ok(InvalidCharacters),
790 "invalid_charge_amount" => Ok(InvalidChargeAmount),
791 "invalid_cvc" => Ok(InvalidCvc),
792 "invalid_expiry_month" => Ok(InvalidExpiryMonth),
793 "invalid_expiry_year" => Ok(InvalidExpiryYear),
794 "invalid_mandate_reference_prefix_format" => Ok(InvalidMandateReferencePrefixFormat),
795 "invalid_number" => Ok(InvalidNumber),
796 "invalid_source_usage" => Ok(InvalidSourceUsage),
797 "invalid_tax_location" => Ok(InvalidTaxLocation),
798 "invoice_no_customer_line_items" => Ok(InvoiceNoCustomerLineItems),
799 "invoice_no_payment_method_types" => Ok(InvoiceNoPaymentMethodTypes),
800 "invoice_no_subscription_line_items" => Ok(InvoiceNoSubscriptionLineItems),
801 "invoice_not_editable" => Ok(InvoiceNotEditable),
802 "invoice_on_behalf_of_not_editable" => Ok(InvoiceOnBehalfOfNotEditable),
803 "invoice_payment_intent_requires_action" => Ok(InvoicePaymentIntentRequiresAction),
804 "invoice_upcoming_none" => Ok(InvoiceUpcomingNone),
805 "livemode_mismatch" => Ok(LivemodeMismatch),
806 "lock_timeout" => Ok(LockTimeout),
807 "missing" => Ok(Missing),
808 "no_account" => Ok(NoAccount),
809 "not_allowed_on_standard_account" => Ok(NotAllowedOnStandardAccount),
810 "out_of_inventory" => Ok(OutOfInventory),
811 "ownership_declaration_not_allowed" => Ok(OwnershipDeclarationNotAllowed),
812 "parameter_invalid_empty" => Ok(ParameterInvalidEmpty),
813 "parameter_invalid_integer" => Ok(ParameterInvalidInteger),
814 "parameter_invalid_string_blank" => Ok(ParameterInvalidStringBlank),
815 "parameter_invalid_string_empty" => Ok(ParameterInvalidStringEmpty),
816 "parameter_missing" => Ok(ParameterMissing),
817 "parameter_unknown" => Ok(ParameterUnknown),
818 "parameters_exclusive" => Ok(ParametersExclusive),
819 "payment_intent_action_required" => Ok(PaymentIntentActionRequired),
820 "payment_intent_authentication_failure" => Ok(PaymentIntentAuthenticationFailure),
821 "payment_intent_incompatible_payment_method" => {
822 Ok(PaymentIntentIncompatiblePaymentMethod)
823 }
824 "payment_intent_invalid_parameter" => Ok(PaymentIntentInvalidParameter),
825 "payment_intent_konbini_rejected_confirmation_number" => {
826 Ok(PaymentIntentKonbiniRejectedConfirmationNumber)
827 }
828 "payment_intent_mandate_invalid" => Ok(PaymentIntentMandateInvalid),
829 "payment_intent_payment_attempt_expired" => Ok(PaymentIntentPaymentAttemptExpired),
830 "payment_intent_payment_attempt_failed" => Ok(PaymentIntentPaymentAttemptFailed),
831 "payment_intent_rate_limit_exceeded" => Ok(PaymentIntentRateLimitExceeded),
832 "payment_intent_unexpected_state" => Ok(PaymentIntentUnexpectedState),
833 "payment_method_bank_account_already_verified" => {
834 Ok(PaymentMethodBankAccountAlreadyVerified)
835 }
836 "payment_method_bank_account_blocked" => Ok(PaymentMethodBankAccountBlocked),
837 "payment_method_billing_details_address_missing" => {
838 Ok(PaymentMethodBillingDetailsAddressMissing)
839 }
840 "payment_method_configuration_failures" => Ok(PaymentMethodConfigurationFailures),
841 "payment_method_currency_mismatch" => Ok(PaymentMethodCurrencyMismatch),
842 "payment_method_customer_decline" => Ok(PaymentMethodCustomerDecline),
843 "payment_method_invalid_parameter" => Ok(PaymentMethodInvalidParameter),
844 "payment_method_invalid_parameter_testmode" => {
845 Ok(PaymentMethodInvalidParameterTestmode)
846 }
847 "payment_method_microdeposit_failed" => Ok(PaymentMethodMicrodepositFailed),
848 "payment_method_microdeposit_processing_error" => {
849 Ok(PaymentMethodMicrodepositProcessingError)
850 }
851 "payment_method_microdeposit_verification_amounts_invalid" => {
852 Ok(PaymentMethodMicrodepositVerificationAmountsInvalid)
853 }
854 "payment_method_microdeposit_verification_amounts_mismatch" => {
855 Ok(PaymentMethodMicrodepositVerificationAmountsMismatch)
856 }
857 "payment_method_microdeposit_verification_attempts_exceeded" => {
858 Ok(PaymentMethodMicrodepositVerificationAttemptsExceeded)
859 }
860 "payment_method_microdeposit_verification_descriptor_code_mismatch" => {
861 Ok(PaymentMethodMicrodepositVerificationDescriptorCodeMismatch)
862 }
863 "payment_method_microdeposit_verification_timeout" => {
864 Ok(PaymentMethodMicrodepositVerificationTimeout)
865 }
866 "payment_method_not_available" => Ok(PaymentMethodNotAvailable),
867 "payment_method_provider_decline" => Ok(PaymentMethodProviderDecline),
868 "payment_method_provider_timeout" => Ok(PaymentMethodProviderTimeout),
869 "payment_method_unactivated" => Ok(PaymentMethodUnactivated),
870 "payment_method_unexpected_state" => Ok(PaymentMethodUnexpectedState),
871 "payment_method_unsupported_type" => Ok(PaymentMethodUnsupportedType),
872 "payout_reconciliation_not_ready" => Ok(PayoutReconciliationNotReady),
873 "payouts_limit_exceeded" => Ok(PayoutsLimitExceeded),
874 "payouts_not_allowed" => Ok(PayoutsNotAllowed),
875 "platform_account_required" => Ok(PlatformAccountRequired),
876 "platform_api_key_expired" => Ok(PlatformApiKeyExpired),
877 "postal_code_invalid" => Ok(PostalCodeInvalid),
878 "processing_error" => Ok(ProcessingError),
879 "product_inactive" => Ok(ProductInactive),
880 "progressive_onboarding_limit_exceeded" => Ok(ProgressiveOnboardingLimitExceeded),
881 "rate_limit" => Ok(RateLimit),
882 "refer_to_customer" => Ok(ReferToCustomer),
883 "refund_disputed_payment" => Ok(RefundDisputedPayment),
884 "request_blocked" => Ok(RequestBlocked),
885 "resource_already_exists" => Ok(ResourceAlreadyExists),
886 "resource_missing" => Ok(ResourceMissing),
887 "return_intent_already_processed" => Ok(ReturnIntentAlreadyProcessed),
888 "routing_number_invalid" => Ok(RoutingNumberInvalid),
889 "secret_key_required" => Ok(SecretKeyRequired),
890 "sepa_unsupported_account" => Ok(SepaUnsupportedAccount),
891 "service_period_coupon_with_metered_tiered_item_unsupported" => {
892 Ok(ServicePeriodCouponWithMeteredTieredItemUnsupported)
893 }
894 "setup_attempt_failed" => Ok(SetupAttemptFailed),
895 "setup_intent_authentication_failure" => Ok(SetupIntentAuthenticationFailure),
896 "setup_intent_invalid_parameter" => Ok(SetupIntentInvalidParameter),
897 "setup_intent_mandate_invalid" => Ok(SetupIntentMandateInvalid),
898 "setup_intent_mobile_wallet_unsupported" => Ok(SetupIntentMobileWalletUnsupported),
899 "setup_intent_setup_attempt_expired" => Ok(SetupIntentSetupAttemptExpired),
900 "setup_intent_unexpected_state" => Ok(SetupIntentUnexpectedState),
901 "shipping_address_invalid" => Ok(ShippingAddressInvalid),
902 "shipping_calculation_failed" => Ok(ShippingCalculationFailed),
903 "siret_invalid" => Ok(SiretInvalid),
904 "sku_inactive" => Ok(SkuInactive),
905 "state_unsupported" => Ok(StateUnsupported),
906 "status_transition_invalid" => Ok(StatusTransitionInvalid),
907 "storer_capability_missing" => Ok(StorerCapabilityMissing),
908 "storer_capability_not_active" => Ok(StorerCapabilityNotActive),
909 "stripe_tax_inactive" => Ok(StripeTaxInactive),
910 "tax_id_invalid" => Ok(TaxIdInvalid),
911 "tax_id_prohibited" => Ok(TaxIdProhibited),
912 "taxes_calculation_failed" => Ok(TaxesCalculationFailed),
913 "terminal_location_country_unsupported" => Ok(TerminalLocationCountryUnsupported),
914 "terminal_reader_busy" => Ok(TerminalReaderBusy),
915 "terminal_reader_hardware_fault" => Ok(TerminalReaderHardwareFault),
916 "terminal_reader_invalid_location_for_activation" => {
917 Ok(TerminalReaderInvalidLocationForActivation)
918 }
919 "terminal_reader_invalid_location_for_payment" => {
920 Ok(TerminalReaderInvalidLocationForPayment)
921 }
922 "terminal_reader_offline" => Ok(TerminalReaderOffline),
923 "terminal_reader_timeout" => Ok(TerminalReaderTimeout),
924 "testmode_charges_only" => Ok(TestmodeChargesOnly),
925 "tls_version_unsupported" => Ok(TlsVersionUnsupported),
926 "token_already_used" => Ok(TokenAlreadyUsed),
927 "token_card_network_invalid" => Ok(TokenCardNetworkInvalid),
928 "token_in_use" => Ok(TokenInUse),
929 "transfer_source_balance_parameters_mismatch" => {
930 Ok(TransferSourceBalanceParametersMismatch)
931 }
932 "transfers_not_allowed" => Ok(TransfersNotAllowed),
933 "url_invalid" => Ok(UrlInvalid),
934 v => {
935 tracing::warn!("Unknown value '{}' for enum '{}'", v, "ApiErrorsCode");
936 Ok(Unknown(v.to_owned()))
937 }
938 }
939 }
940}
941impl std::fmt::Display for ApiErrorsCode {
942 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
943 f.write_str(self.as_str())
944 }
945}
946
947#[cfg(not(feature = "redact-generated-debug"))]
948impl std::fmt::Debug for ApiErrorsCode {
949 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
950 f.write_str(self.as_str())
951 }
952}
953#[cfg(feature = "redact-generated-debug")]
954impl std::fmt::Debug for ApiErrorsCode {
955 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
956 f.debug_struct(stringify!(ApiErrorsCode)).finish_non_exhaustive()
957 }
958}
959#[cfg(feature = "serialize")]
960impl serde::Serialize for ApiErrorsCode {
961 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
962 where
963 S: serde::Serializer,
964 {
965 serializer.serialize_str(self.as_str())
966 }
967}
968impl miniserde::Deserialize for ApiErrorsCode {
969 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
970 crate::Place::new(out)
971 }
972}
973
974impl miniserde::de::Visitor for crate::Place<ApiErrorsCode> {
975 fn string(&mut self, s: &str) -> miniserde::Result<()> {
976 use std::str::FromStr;
977 self.out = Some(ApiErrorsCode::from_str(s).expect("infallible"));
978 Ok(())
979 }
980}
981
982stripe_types::impl_from_val_with_from_str!(ApiErrorsCode);
983#[cfg(feature = "deserialize")]
984impl<'de> serde::Deserialize<'de> for ApiErrorsCode {
985 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
986 use std::str::FromStr;
987 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
988 Ok(Self::from_str(&s).expect("infallible"))
989 }
990}
991#[derive(Clone, Eq, PartialEq)]
994#[non_exhaustive]
995pub enum ApiErrorsType {
996 ApiError,
997 CardError,
998 IdempotencyError,
999 InvalidRequestError,
1000 Unknown(String),
1002}
1003impl ApiErrorsType {
1004 pub fn as_str(&self) -> &str {
1005 use ApiErrorsType::*;
1006 match self {
1007 ApiError => "api_error",
1008 CardError => "card_error",
1009 IdempotencyError => "idempotency_error",
1010 InvalidRequestError => "invalid_request_error",
1011 Unknown(v) => v,
1012 }
1013 }
1014}
1015
1016impl std::str::FromStr for ApiErrorsType {
1017 type Err = std::convert::Infallible;
1018 fn from_str(s: &str) -> Result<Self, Self::Err> {
1019 use ApiErrorsType::*;
1020 match s {
1021 "api_error" => Ok(ApiError),
1022 "card_error" => Ok(CardError),
1023 "idempotency_error" => Ok(IdempotencyError),
1024 "invalid_request_error" => Ok(InvalidRequestError),
1025 v => {
1026 tracing::warn!("Unknown value '{}' for enum '{}'", v, "ApiErrorsType");
1027 Ok(Unknown(v.to_owned()))
1028 }
1029 }
1030 }
1031}
1032impl std::fmt::Display for ApiErrorsType {
1033 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1034 f.write_str(self.as_str())
1035 }
1036}
1037
1038#[cfg(not(feature = "redact-generated-debug"))]
1039impl std::fmt::Debug for ApiErrorsType {
1040 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1041 f.write_str(self.as_str())
1042 }
1043}
1044#[cfg(feature = "redact-generated-debug")]
1045impl std::fmt::Debug for ApiErrorsType {
1046 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1047 f.debug_struct(stringify!(ApiErrorsType)).finish_non_exhaustive()
1048 }
1049}
1050#[cfg(feature = "serialize")]
1051impl serde::Serialize for ApiErrorsType {
1052 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1053 where
1054 S: serde::Serializer,
1055 {
1056 serializer.serialize_str(self.as_str())
1057 }
1058}
1059impl miniserde::Deserialize for ApiErrorsType {
1060 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
1061 crate::Place::new(out)
1062 }
1063}
1064
1065impl miniserde::de::Visitor for crate::Place<ApiErrorsType> {
1066 fn string(&mut self, s: &str) -> miniserde::Result<()> {
1067 use std::str::FromStr;
1068 self.out = Some(ApiErrorsType::from_str(s).expect("infallible"));
1069 Ok(())
1070 }
1071}
1072
1073stripe_types::impl_from_val_with_from_str!(ApiErrorsType);
1074#[cfg(feature = "deserialize")]
1075impl<'de> serde::Deserialize<'de> for ApiErrorsType {
1076 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1077 use std::str::FromStr;
1078 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
1079 Ok(Self::from_str(&s).expect("infallible"))
1080 }
1081}