Error Mapping

Payment processors speak different error languages. Stripe says "card_declined." Adyen says "Refused." PayPal says "INSTRUMENT_DECLINED." Prism translates all of them into a single set of error codes your application handles once.

The Mapping Problem

Without unified error mapping, your code looks like this:

// Without Prism—handle every connector's errors separately
if (connector === 'stripe') {
    if (error.code === 'card_declined') {
        // handle decline
    }
} else if (connector === 'adyen') {
    if (error.resultCode === 'Refused') {
        // handle decline
    }
} else if (connector === 'paypal') {
    if (error.details[0].issue === 'INSTRUMENT_DECLINED') {
        // handle decline
    }
}
// Repeat for 50+ connectors...

With Prism, you write the handling logic once:

How Mapping Works

Each connector adapter includes an error mapper that translates connector-specific codes to unified codes:

The mapper analyzes:

  • HTTP status codes

  • Error codes in the response body

  • Error messages

  • Decline reasons

Then selects the appropriate unified error code.

Unified Error Structure

Every error follows this structure:

Error Code Reference

Unified Code
Description
Stripe Equivalent
Adyen Equivalent

PAYMENT_DECLINED

Generic decline

card_declined

Refused

INSUFFICIENT_FUNDS

Not enough money

card_declined + decline_code: insufficient_funds

Not enough balance

EXPIRED_CARD

Card expired

expired_card

Expiry Date not valid

INCORRECT_CVV

Wrong security code

incorrect_cvc

CVC Declined

INVALID_CARD_NUMBER

Bad card number

incorrect_number

Invalid card number

PROCESSING_ERROR

Generic processor error

processing_error

Error

NETWORK_TIMEOUT

Request timed out

HTTP 504

Timeout

RATE_LIMITED

Too many requests

HTTP 429

HTTP 401

INVALID_API_KEY

Auth failed

HTTP 401

HTTP 401

VALIDATION_ERROR

Bad request format

HTTP 400

HTTP 422

Mapping Examples

Stripe Error Mapping

Adyen Error Mapping

Category Classification

Errors are classified into categories for routing and handling:

Category determines:

  • PAYMENT_ERROR: Show customer-friendly message

  • NETWORK_ERROR: Retry with exponential backoff

  • CONFIGURATION_ERROR: Alert ops team immediately

  • VALIDATION_ERROR: Fix request and retry

  • UNKNOWN: Log everything, contact support

Connector-Specific Details Preserved

While mapping to unified codes, Prism preserves original error details:

This lets you:

  • Handle errors generically with unified codes

  • Access original details for debugging

  • Show connector-specific messaging if needed

Adding New Error Mappings

When adding a new connector, you define error mappings in the adapter:

Benefits

  • Single error handling path: Write once, works for all connectors

  • Consistent customer experience: Same messages regardless of processor

  • Debugging preserved: Original error details available

  • Extensible: Add new connectors without changing error handling code

Your application handles 50+ payment processors with one set of error handlers.

Last updated

Was this helpful?