github.com/stripe/stripe-go/v76@v76.25.0/error.go (about) 1 package stripe 2 3 import "encoding/json" 4 5 // ErrorType is the list of allowed values for the error's type. 6 type ErrorType string 7 8 // List of values that ErrorType can take. 9 const ( 10 ErrorTypeAPI ErrorType = "api_error" 11 ErrorTypeCard ErrorType = "card_error" 12 ErrorTypeIdempotency ErrorType = "idempotency_error" 13 ErrorTypeInvalidRequest ErrorType = "invalid_request_error" 14 ) 15 16 // ErrorCode is the list of allowed values for the error's code. 17 type ErrorCode string 18 19 // DeclineCode is the list of reasons provided by card issuers for decline of payment. 20 type DeclineCode string 21 22 // List of values that ErrorCode can take. 23 // For descriptions see https://stripe.com/docs/error-codes 24 // The beginning of the section generated from our OpenAPI spec 25 const ( 26 ErrorCodeACSSDebitSessionIncomplete ErrorCode = "acss_debit_session_incomplete" 27 ErrorCodeAPIKeyExpired ErrorCode = "api_key_expired" 28 ErrorCodeAccountClosed ErrorCode = "account_closed" 29 ErrorCodeAccountCountryInvalidAddress ErrorCode = "account_country_invalid_address" 30 ErrorCodeAccountErrorCountryChangeRequiresAdditionalSteps ErrorCode = "account_error_country_change_requires_additional_steps" 31 ErrorCodeAccountInformationMismatch ErrorCode = "account_information_mismatch" 32 ErrorCodeAccountInvalid ErrorCode = "account_invalid" 33 ErrorCodeAccountNumberInvalid ErrorCode = "account_number_invalid" 34 ErrorCodeAlipayUpgradeRequired ErrorCode = "alipay_upgrade_required" 35 ErrorCodeAmountTooLarge ErrorCode = "amount_too_large" 36 ErrorCodeAmountTooSmall ErrorCode = "amount_too_small" 37 ErrorCodeApplicationFeesNotAllowed ErrorCode = "application_fees_not_allowed" 38 ErrorCodeAuthenticationRequired ErrorCode = "authentication_required" 39 ErrorCodeBalanceInsufficient ErrorCode = "balance_insufficient" 40 ErrorCodeBalanceInvalidParameter ErrorCode = "balance_invalid_parameter" 41 ErrorCodeBankAccountBadRoutingNumbers ErrorCode = "bank_account_bad_routing_numbers" 42 ErrorCodeBankAccountDeclined ErrorCode = "bank_account_declined" 43 ErrorCodeBankAccountExists ErrorCode = "bank_account_exists" 44 ErrorCodeBankAccountRestricted ErrorCode = "bank_account_restricted" 45 ErrorCodeBankAccountUnusable ErrorCode = "bank_account_unusable" 46 ErrorCodeBankAccountUnverified ErrorCode = "bank_account_unverified" 47 ErrorCodeBankAccountVerificationFailed ErrorCode = "bank_account_verification_failed" 48 ErrorCodeBillingInvalidMandate ErrorCode = "billing_invalid_mandate" 49 ErrorCodeBitcoinUpgradeRequired ErrorCode = "bitcoin_upgrade_required" 50 ErrorCodeCaptureChargeAuthorizationExpired ErrorCode = "capture_charge_authorization_expired" 51 ErrorCodeCaptureUnauthorizedPayment ErrorCode = "capture_unauthorized_payment" 52 ErrorCodeCardDeclineRateLimitExceeded ErrorCode = "card_decline_rate_limit_exceeded" 53 ErrorCodeCardDeclined ErrorCode = "card_declined" 54 ErrorCodeCardholderPhoneNumberRequired ErrorCode = "cardholder_phone_number_required" 55 ErrorCodeChargeAlreadyCaptured ErrorCode = "charge_already_captured" 56 ErrorCodeChargeAlreadyRefunded ErrorCode = "charge_already_refunded" 57 ErrorCodeChargeDisputed ErrorCode = "charge_disputed" 58 ErrorCodeChargeExceedsSourceLimit ErrorCode = "charge_exceeds_source_limit" 59 ErrorCodeChargeExpiredForCapture ErrorCode = "charge_expired_for_capture" 60 ErrorCodeChargeInvalidParameter ErrorCode = "charge_invalid_parameter" 61 ErrorCodeChargeNotRefundable ErrorCode = "charge_not_refundable" 62 ErrorCodeClearingCodeUnsupported ErrorCode = "clearing_code_unsupported" 63 ErrorCodeCountryCodeInvalid ErrorCode = "country_code_invalid" 64 ErrorCodeCountryUnsupported ErrorCode = "country_unsupported" 65 ErrorCodeCouponExpired ErrorCode = "coupon_expired" 66 ErrorCodeCustomerMaxPaymentMethods ErrorCode = "customer_max_payment_methods" 67 ErrorCodeCustomerMaxSubscriptions ErrorCode = "customer_max_subscriptions" 68 ErrorCodeCustomerTaxLocationInvalid ErrorCode = "customer_tax_location_invalid" 69 ErrorCodeDebitNotAuthorized ErrorCode = "debit_not_authorized" 70 ErrorCodeEmailInvalid ErrorCode = "email_invalid" 71 ErrorCodeExpiredCard ErrorCode = "expired_card" 72 ErrorCodeFinancialConnectionsAccountInactive ErrorCode = "financial_connections_account_inactive" 73 ErrorCodeFinancialConnectionsNoSuccessfulTransactionRefresh ErrorCode = "financial_connections_no_successful_transaction_refresh" 74 ErrorCodeForwardingAPIInactive ErrorCode = "forwarding_api_inactive" 75 ErrorCodeForwardingAPIInvalidParameter ErrorCode = "forwarding_api_invalid_parameter" 76 ErrorCodeForwardingAPIUpstreamConnectionError ErrorCode = "forwarding_api_upstream_connection_error" 77 ErrorCodeForwardingAPIUpstreamConnectionTimeout ErrorCode = "forwarding_api_upstream_connection_timeout" 78 ErrorCodeIdempotencyKeyInUse ErrorCode = "idempotency_key_in_use" 79 ErrorCodeIncorrectAddress ErrorCode = "incorrect_address" 80 ErrorCodeIncorrectCVC ErrorCode = "incorrect_cvc" 81 ErrorCodeIncorrectNumber ErrorCode = "incorrect_number" 82 ErrorCodeIncorrectZip ErrorCode = "incorrect_zip" 83 ErrorCodeInstantPayoutsConfigDisabled ErrorCode = "instant_payouts_config_disabled" 84 ErrorCodeInstantPayoutsCurrencyDisabled ErrorCode = "instant_payouts_currency_disabled" 85 ErrorCodeInstantPayoutsLimitExceeded ErrorCode = "instant_payouts_limit_exceeded" 86 ErrorCodeInstantPayoutsUnsupported ErrorCode = "instant_payouts_unsupported" 87 ErrorCodeInsufficientFunds ErrorCode = "insufficient_funds" 88 ErrorCodeIntentInvalidState ErrorCode = "intent_invalid_state" 89 ErrorCodeIntentVerificationMethodMissing ErrorCode = "intent_verification_method_missing" 90 ErrorCodeInvalidCVC ErrorCode = "invalid_cvc" 91 ErrorCodeInvalidCardType ErrorCode = "invalid_card_type" 92 ErrorCodeInvalidCharacters ErrorCode = "invalid_characters" 93 ErrorCodeInvalidChargeAmount ErrorCode = "invalid_charge_amount" 94 ErrorCodeInvalidExpiryMonth ErrorCode = "invalid_expiry_month" 95 ErrorCodeInvalidExpiryYear ErrorCode = "invalid_expiry_year" 96 ErrorCodeInvalidNumber ErrorCode = "invalid_number" 97 ErrorCodeInvalidSourceUsage ErrorCode = "invalid_source_usage" 98 ErrorCodeInvalidTaxLocation ErrorCode = "invalid_tax_location" 99 ErrorCodeInvoiceNoCustomerLineItems ErrorCode = "invoice_no_customer_line_items" 100 ErrorCodeInvoiceNoPaymentMethodTypes ErrorCode = "invoice_no_payment_method_types" 101 ErrorCodeInvoiceNoSubscriptionLineItems ErrorCode = "invoice_no_subscription_line_items" 102 ErrorCodeInvoiceNotEditable ErrorCode = "invoice_not_editable" 103 ErrorCodeInvoiceOnBehalfOfNotEditable ErrorCode = "invoice_on_behalf_of_not_editable" 104 ErrorCodeInvoicePaymentIntentRequiresAction ErrorCode = "invoice_payment_intent_requires_action" 105 ErrorCodeInvoiceUpcomingNone ErrorCode = "invoice_upcoming_none" 106 ErrorCodeLivemodeMismatch ErrorCode = "livemode_mismatch" 107 ErrorCodeLockTimeout ErrorCode = "lock_timeout" 108 ErrorCodeMissing ErrorCode = "missing" 109 ErrorCodeNoAccount ErrorCode = "no_account" 110 ErrorCodeNotAllowedOnStandardAccount ErrorCode = "not_allowed_on_standard_account" 111 ErrorCodeOutOfInventory ErrorCode = "out_of_inventory" 112 ErrorCodeOwnershipDeclarationNotAllowed ErrorCode = "ownership_declaration_not_allowed" 113 ErrorCodeParameterInvalidEmpty ErrorCode = "parameter_invalid_empty" 114 ErrorCodeParameterInvalidInteger ErrorCode = "parameter_invalid_integer" 115 ErrorCodeParameterInvalidStringBlank ErrorCode = "parameter_invalid_string_blank" 116 ErrorCodeParameterInvalidStringEmpty ErrorCode = "parameter_invalid_string_empty" 117 ErrorCodeParameterMissing ErrorCode = "parameter_missing" 118 ErrorCodeParameterUnknown ErrorCode = "parameter_unknown" 119 ErrorCodeParametersExclusive ErrorCode = "parameters_exclusive" 120 ErrorCodePaymentIntentActionRequired ErrorCode = "payment_intent_action_required" 121 ErrorCodePaymentIntentAuthenticationFailure ErrorCode = "payment_intent_authentication_failure" 122 ErrorCodePaymentIntentIncompatiblePaymentMethod ErrorCode = "payment_intent_incompatible_payment_method" 123 ErrorCodePaymentIntentInvalidParameter ErrorCode = "payment_intent_invalid_parameter" 124 ErrorCodePaymentIntentKonbiniRejectedConfirmationNumber ErrorCode = "payment_intent_konbini_rejected_confirmation_number" 125 ErrorCodePaymentIntentMandateInvalid ErrorCode = "payment_intent_mandate_invalid" 126 ErrorCodePaymentIntentPaymentAttemptExpired ErrorCode = "payment_intent_payment_attempt_expired" 127 ErrorCodePaymentIntentPaymentAttemptFailed ErrorCode = "payment_intent_payment_attempt_failed" 128 ErrorCodePaymentIntentUnexpectedState ErrorCode = "payment_intent_unexpected_state" 129 ErrorCodePaymentMethodBankAccountAlreadyVerified ErrorCode = "payment_method_bank_account_already_verified" 130 ErrorCodePaymentMethodBankAccountBlocked ErrorCode = "payment_method_bank_account_blocked" 131 ErrorCodePaymentMethodBillingDetailsAddressMissing ErrorCode = "payment_method_billing_details_address_missing" 132 ErrorCodePaymentMethodConfigurationFailures ErrorCode = "payment_method_configuration_failures" 133 ErrorCodePaymentMethodCurrencyMismatch ErrorCode = "payment_method_currency_mismatch" 134 ErrorCodePaymentMethodCustomerDecline ErrorCode = "payment_method_customer_decline" 135 ErrorCodePaymentMethodInvalidParameter ErrorCode = "payment_method_invalid_parameter" 136 ErrorCodePaymentMethodInvalidParameterTestmode ErrorCode = "payment_method_invalid_parameter_testmode" 137 ErrorCodePaymentMethodMicrodepositFailed ErrorCode = "payment_method_microdeposit_failed" 138 ErrorCodePaymentMethodMicrodepositVerificationAmountsInvalid ErrorCode = "payment_method_microdeposit_verification_amounts_invalid" 139 ErrorCodePaymentMethodMicrodepositVerificationAmountsMismatch ErrorCode = "payment_method_microdeposit_verification_amounts_mismatch" 140 ErrorCodePaymentMethodMicrodepositVerificationAttemptsExceeded ErrorCode = "payment_method_microdeposit_verification_attempts_exceeded" 141 ErrorCodePaymentMethodMicrodepositVerificationDescriptorCodeMismatch ErrorCode = "payment_method_microdeposit_verification_descriptor_code_mismatch" 142 ErrorCodePaymentMethodMicrodepositVerificationTimeout ErrorCode = "payment_method_microdeposit_verification_timeout" 143 ErrorCodePaymentMethodNotAvailable ErrorCode = "payment_method_not_available" 144 ErrorCodePaymentMethodProviderDecline ErrorCode = "payment_method_provider_decline" 145 ErrorCodePaymentMethodProviderTimeout ErrorCode = "payment_method_provider_timeout" 146 ErrorCodePaymentMethodUnactivated ErrorCode = "payment_method_unactivated" 147 ErrorCodePaymentMethodUnexpectedState ErrorCode = "payment_method_unexpected_state" 148 ErrorCodePaymentMethodUnsupportedType ErrorCode = "payment_method_unsupported_type" 149 ErrorCodePayoutReconciliationNotReady ErrorCode = "payout_reconciliation_not_ready" 150 ErrorCodePayoutsLimitExceeded ErrorCode = "payouts_limit_exceeded" 151 ErrorCodePayoutsNotAllowed ErrorCode = "payouts_not_allowed" 152 ErrorCodePlatformAPIKeyExpired ErrorCode = "platform_api_key_expired" 153 ErrorCodePlatformAccountRequired ErrorCode = "platform_account_required" 154 ErrorCodePostalCodeInvalid ErrorCode = "postal_code_invalid" 155 ErrorCodeProcessingError ErrorCode = "processing_error" 156 ErrorCodeProductInactive ErrorCode = "product_inactive" 157 ErrorCodeProgressiveOnboardingLimitExceeded ErrorCode = "progressive_onboarding_limit_exceeded" 158 ErrorCodeRateLimit ErrorCode = "rate_limit" 159 ErrorCodeReferToCustomer ErrorCode = "refer_to_customer" 160 ErrorCodeRefundDisputedPayment ErrorCode = "refund_disputed_payment" 161 ErrorCodeResourceAlreadyExists ErrorCode = "resource_already_exists" 162 ErrorCodeResourceMissing ErrorCode = "resource_missing" 163 ErrorCodeReturnIntentAlreadyProcessed ErrorCode = "return_intent_already_processed" 164 ErrorCodeRoutingNumberInvalid ErrorCode = "routing_number_invalid" 165 ErrorCodeSEPAUnsupportedAccount ErrorCode = "sepa_unsupported_account" 166 ErrorCodeSKUInactive ErrorCode = "sku_inactive" 167 ErrorCodeSecretKeyRequired ErrorCode = "secret_key_required" 168 ErrorCodeSetupAttemptFailed ErrorCode = "setup_attempt_failed" 169 ErrorCodeSetupIntentAuthenticationFailure ErrorCode = "setup_intent_authentication_failure" 170 ErrorCodeSetupIntentInvalidParameter ErrorCode = "setup_intent_invalid_parameter" 171 ErrorCodeSetupIntentMandateInvalid ErrorCode = "setup_intent_mandate_invalid" 172 ErrorCodeSetupIntentSetupAttemptExpired ErrorCode = "setup_intent_setup_attempt_expired" 173 ErrorCodeSetupIntentUnexpectedState ErrorCode = "setup_intent_unexpected_state" 174 ErrorCodeShippingCalculationFailed ErrorCode = "shipping_calculation_failed" 175 ErrorCodeStateUnsupported ErrorCode = "state_unsupported" 176 ErrorCodeStatusTransitionInvalid ErrorCode = "status_transition_invalid" 177 ErrorCodeStripeTaxInactive ErrorCode = "stripe_tax_inactive" 178 ErrorCodeTLSVersionUnsupported ErrorCode = "tls_version_unsupported" 179 ErrorCodeTaxIDInvalid ErrorCode = "tax_id_invalid" 180 ErrorCodeTaxesCalculationFailed ErrorCode = "taxes_calculation_failed" 181 ErrorCodeTerminalLocationCountryUnsupported ErrorCode = "terminal_location_country_unsupported" 182 ErrorCodeTerminalReaderBusy ErrorCode = "terminal_reader_busy" 183 ErrorCodeTerminalReaderHardwareFault ErrorCode = "terminal_reader_hardware_fault" 184 ErrorCodeTerminalReaderOffline ErrorCode = "terminal_reader_offline" 185 ErrorCodeTerminalReaderTimeout ErrorCode = "terminal_reader_timeout" 186 ErrorCodeTestmodeChargesOnly ErrorCode = "testmode_charges_only" 187 ErrorCodeTokenAlreadyUsed ErrorCode = "token_already_used" 188 ErrorCodeTokenCardNetworkInvalid ErrorCode = "token_card_network_invalid" 189 ErrorCodeTokenInUse ErrorCode = "token_in_use" 190 ErrorCodeTransferSourceBalanceParametersMismatch ErrorCode = "transfer_source_balance_parameters_mismatch" 191 ErrorCodeTransfersNotAllowed ErrorCode = "transfers_not_allowed" 192 ErrorCodeURLInvalid ErrorCode = "url_invalid" 193 ) 194 195 // The end of the section generated from our OpenAPI spec 196 197 // List of DeclineCode values. 198 // For descriptions see https://stripe.com/docs/declines/codes 199 const ( 200 DeclineCodeAuthenticationRequired DeclineCode = "authentication_required" 201 DeclineCodeApproveWithID DeclineCode = "approve_with_id" 202 DeclineCodeCallIssuer DeclineCode = "call_issuer" 203 DeclineCodeCardNotSupported DeclineCode = "card_not_supported" 204 DeclineCodeCardVelocityExceeded DeclineCode = "card_velocity_exceeded" 205 DeclineCodeCurrencyNotSupported DeclineCode = "currency_not_supported" 206 DeclineCodeDoNotHonor DeclineCode = "do_not_honor" 207 DeclineCodeDoNotTryAgain DeclineCode = "do_not_try_again" 208 DeclineCodeDuplicateTransaction DeclineCode = "duplicate_transaction" 209 DeclineCodeExpiredCard DeclineCode = "expired_card" 210 DeclineCodeFraudulent DeclineCode = "fraudulent" 211 DeclineCodeGenericDecline DeclineCode = "generic_decline" 212 DeclineCodeIncorrectNumber DeclineCode = "incorrect_number" 213 DeclineCodeIncorrectCVC DeclineCode = "incorrect_cvc" 214 DeclineCodeIncorrectPIN DeclineCode = "incorrect_pin" 215 DeclineCodeIncorrectZip DeclineCode = "incorrect_zip" 216 DeclineCodeInsufficientFunds DeclineCode = "insufficient_funds" 217 DeclineCodeInvalidAccount DeclineCode = "invalid_account" 218 DeclineCodeInvalidAmount DeclineCode = "invalid_amount" 219 DeclineCodeInvalidCVC DeclineCode = "invalid_cvc" 220 DeclineCodeInvalidExpiryMonth DeclineCode = "invalid_expiry_month" 221 DeclineCodeInvalidExpiryYear DeclineCode = "invalid_expiry_year" 222 DeclineCodeInvalidNumber DeclineCode = "invalid_number" 223 DeclineCodeInvalidPIN DeclineCode = "invalid_pin" 224 DeclineCodeIssuerNotAvailable DeclineCode = "issuer_not_available" 225 DeclineCodeLostCard DeclineCode = "lost_card" 226 DeclineCodeMerchantBlacklist DeclineCode = "merchant_blacklist" 227 DeclineCodeNewAccountInformationAvailable DeclineCode = "new_account_information_available" 228 DeclineCodeNoActionTaken DeclineCode = "no_action_taken" 229 DeclineCodeNotPermitted DeclineCode = "not_permitted" 230 DeclineCodeOfflinePINRequired DeclineCode = "offline_pin_required" 231 DeclineCodeOnlineOrOfflinePINRequired DeclineCode = "online_or_offline_pin_required" 232 DeclineCodePickupCard DeclineCode = "pickup_card" 233 DeclineCodePINTryExceeded DeclineCode = "pin_try_exceeded" 234 DeclineCodeProcessingError DeclineCode = "processing_error" 235 DeclineCodeReenterTransaction DeclineCode = "reenter_transaction" 236 DeclineCodeRestrictedCard DeclineCode = "restricted_card" 237 DeclineCodeRevocationOfAllAuthorizations DeclineCode = "revocation_of_all_authorizations" 238 DeclineCodeRevocationOfAuthorization DeclineCode = "revocation_of_authorization" 239 DeclineCodeSecurityViolation DeclineCode = "security_violation" 240 DeclineCodeServiceNotAllowed DeclineCode = "service_not_allowed" 241 DeclineCodeStolenCard DeclineCode = "stolen_card" 242 DeclineCodeStopPaymentOrder DeclineCode = "stop_payment_order" 243 DeclineCodeTestModeDecline DeclineCode = "testmode_decline" 244 DeclineCodeTransactionNotAllowed DeclineCode = "transaction_not_allowed" 245 DeclineCodeTryAgainLater DeclineCode = "try_again_later" 246 DeclineCodeWithdrawalCountLimitExceeded DeclineCode = "withdrawal_count_limit_exceeded" 247 ) 248 249 // Error is the response returned when a call is unsuccessful. 250 // For more details see https://stripe.com/docs/api#errors. 251 type Error struct { 252 APIResource 253 254 ChargeID string `json:"charge,omitempty"` 255 Code ErrorCode `json:"code,omitempty"` 256 DeclineCode DeclineCode `json:"decline_code,omitempty"` 257 DocURL string `json:"doc_url,omitempty"` 258 259 // Err contains an internal error with an additional level of granularity 260 // that can be used in some cases to get more detailed information about 261 // what went wrong. For example, Err may hold a CardError that indicates 262 // exactly what went wrong during charging a card. 263 Err error `json:"-"` 264 265 HTTPStatusCode int `json:"status,omitempty"` 266 Msg string `json:"message"` 267 Param string `json:"param,omitempty"` 268 PaymentIntent *PaymentIntent `json:"payment_intent,omitempty"` 269 PaymentMethod *PaymentMethod `json:"payment_method,omitempty"` 270 PaymentMethodType PaymentMethodType `json:"payment_method_type,omitempty"` 271 RequestID string `json:"request_id,omitempty"` 272 RequestLogURL string `json:"request_log_url,omitempty"` 273 SetupIntent *SetupIntent `json:"setup_intent,omitempty"` 274 Source *PaymentSource `json:"source,omitempty"` 275 Type ErrorType `json:"type"` 276 277 // OAuth specific Error properties. Named OAuthError because of name conflict. 278 OAuthError string `json:"error,omitempty"` 279 OAuthErrorDescription string `json:"error_description,omitempty"` 280 } 281 282 // Error serializes the error object to JSON and returns it as a string. 283 func (e *Error) Error() string { 284 ret, _ := json.Marshal(e) 285 return string(ret) 286 } 287 288 // Unwrap returns the wrapped typed error. 289 func (e *Error) Unwrap() error { 290 return e.Err 291 } 292 293 // APIError is a catch all for any errors not covered by other types (and 294 // should be extremely uncommon). 295 type APIError struct { 296 stripeErr *Error 297 } 298 299 // Error serializes the error object to JSON and returns it as a string. 300 func (e *APIError) Error() string { 301 return e.stripeErr.Error() 302 } 303 304 // CardError are the most common type of error you should expect to handle. 305 // They result when the user enters a card that can't be charged for some 306 // reason. 307 type CardError struct { 308 stripeErr *Error 309 // DeclineCode is a code indicating a card issuer's reason for declining a 310 // card (if they provided one). 311 DeclineCode DeclineCode `json:"decline_code,omitempty"` 312 } 313 314 // Error serializes the error object to JSON and returns it as a string. 315 func (e *CardError) Error() string { 316 return e.stripeErr.Error() 317 } 318 319 // InvalidRequestError is an error that occurs when a request contains invalid 320 // parameters. 321 type InvalidRequestError struct { 322 stripeErr *Error 323 } 324 325 // Error serializes the error object to JSON and returns it as a string. 326 func (e *InvalidRequestError) Error() string { 327 return e.stripeErr.Error() 328 } 329 330 // IdempotencyError occurs when an Idempotency-Key is re-used on a request 331 // that does not match the first request's API endpoint and parameters. 332 type IdempotencyError struct { 333 stripeErr *Error 334 } 335 336 // Error serializes the error object to JSON and returns it as a string. 337 func (e *IdempotencyError) Error() string { 338 return e.stripeErr.Error() 339 } 340 341 // redact returns a copy of the error object with sensitive fields replaced with 342 // a placeholder value. 343 func (e *Error) redact() *Error { 344 // Fast path, since this applies to most cases 345 if e.PaymentIntent == nil && e.SetupIntent == nil { 346 return e 347 } 348 errCopy := *e 349 if e.PaymentIntent != nil { 350 pi := *e.PaymentIntent 351 errCopy.PaymentIntent = &pi 352 errCopy.PaymentIntent.ClientSecret = "REDACTED" 353 } 354 if e.SetupIntent != nil { 355 si := *e.SetupIntent 356 errCopy.SetupIntent = &si 357 errCopy.SetupIntent.ClientSecret = "REDACTED" 358 } 359 return &errCopy 360 } 361 362 // rawError deserializes the outer JSON object returned in an error response 363 // from the API. 364 type rawError struct { 365 Error *Error `json:"error,omitempty"` 366 }