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