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