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