ChapaChapa Docs

Error Codes

Standardized error codes and how to handle them in your integration.

Chapa uses standardized HTTP status codes combined with machine-readable error codes and human-readable messages to help you quickly understand, debug, and handle errors correctly.

Every error response follows a predictable structure, making it easy to build robust and consistent error-handling logic.

Error Response Structure

All error responses follow this format:

{
  "status": "error",
  "message": "Invalid Currency",
  "error": {
    "code": "INVALID_VALUE",
    "details": null
  }
}

Fields Explained

FieldDescription
statusAlways set to error
messageA human-readable description of the error
error.codeA machine-readable error identifier representing the error type
error.detailsAdditional information about the error, if available; otherwise null

HTTP Status Code Categories

StatusMeaningWhat To Do
400Client ErrorFix request payload or parameters
404Not FoundCheck references or IDs
409Conflict / Invalid StateFix flow logic (duplicate or invalid action)
500Server ErrorRetry later

Payment Error Codes

Validation & Request Errors (400)

Error TypeError CodeMessageDescription
INVALID_FORMATINVALID_FORMATInvalid payment methodPayment method not recognized
INVALID_VALUEINVALID_VALUEInvalid currencyUnsupported currency
INVALID_VALUEINVALID_VALUEAmount must be greater than minimumAmount below allowed limit
INVALID_VALUEINVALID_VALUEAmount must be between {min} and {max}Amount out of range
MISSING_REQUIRED_FIELDMISSING_REQUIRED_FIELDReference parameter is requiredMissing payment reference
INVALID_STATEINVALID_STATETransaction reference has been used beforeDuplicate reference

Payment Not Found (404)

Error CodeMessageDescription
NOT_FOUNDPayment not foundInvalid or unknown reference
NOT_FOUNDPayment request not foundInitialization missing

Payment Processing Errors (500)

Error CodeMessageDescription
PROCESSING_FAILEDFailed to initialize paymentTemporary system issue
PROCESSING_FAILEDFailed to fetch paymentsRetrieval error

Payout Error Codes

Validation Errors (400)

Error TypeError CodeMessageDescription
INVALID_FORMATINVALID_BANK_SLUGInvalid bank slugBank identifier invalid
INVALID_FORMATINVALID_ACCOUNT_NUMBERInvalid account numberBank validation failed
INVALID_VALUEINVALID_CURRENCYCurrency not supported by bankCurrency mismatch
OPERATION_NOT_SUPPORTEDOPERATION_NOT_SUPPORTEDDirect charge not allowedRegion or currency restriction

Payout State Errors (404 / 409)

HTTPError CodeMessageDescription
404NOT_FOUNDPayout not foundInvalid payout reference
409INVALID_STATEPayout already processedDuplicate or invalid operation

Payout System Errors (500)

Error CodeMessage
PROCESSING_FAILEDFailed to create payout
PROCESSING_FAILEDFailed to fetch payouts
PROCESSING_FAILEDFailed to fetch bank information

Refund Error Codes

Refund Validation Errors (400 / 409)

Error CodeMessageDescription
MISSING_REQUIRED_FIELDRefund ID is requiredMissing refund reference
INVALID_STATEPayment is still pendingRefund not allowed
INVALID_STATEPayment already fully refundedDouble refund blocked
INVALID_STATEPayment failed or cancelledInvalid refund state

Refund Retrieval Errors (404 / 500)

HTTPError CodeMessage
404NOT_FOUNDRefund not found
500PROCESSING_FAILEDFailed to fetch refunds

Subaccount Error Codes

Error TypeError CodeMessageDescription
INVALID_VALUEINVALID_SPLIT_TYPESplit type must be percentage or flatInvalid split type
INVALID_VALUEINVALID_SPLIT_VALUESplit value invalidOut-of-range value
RESOURCE_CONFLICTRESOURCE_CONFLICTSubaccount already existsDuplicate account
NOT_FOUNDNOT_FOUNDSubaccount not foundInvalid reference

Customer & Merchant Errors

Error CodeMessageDescription
INVALID_FORMATInvalid phone numberPhone format incorrect
INVALID_VALUEEmail must be validEmail validation failed
INVALID_STATECustomer is inactiveCustomer blocked
INVALID_VALUEAPI key environment mismatchTest vs Live mismatch

Best Practices for Handling Errors

1. Never Rely on Message Strings

  • Don't parse message
  • Always branch logic using error_code

2. Handle by Category

CategoryAction
400Fix request
404Fix reference
409Fix state flow
500Retry later

3. Log Errors Safely

Log:

  • error_code
  • Transaction reference
  • Timestamp

Never log:

  • API keys
  • PINs or OTPs
  • Full payloads with PII

4. Graceful User Messaging

Show users:

  • "Payment failed. Please try again."

Do not expose:

  • Internal error codes
  • Compliance or risk reasons

Key Takeaways

PointDescription
Consistent structureError codes are consistent and predictable
Use error_codeAlways branch logic using error_code
Retry 500 errors500 errors are usually retryable
Fix 409 errors409 errors usually indicate flow mistakes
Build trustProper error handling improves reliability and trust

Next Steps

On this page