Error Codes
Complete reference of Payvessel API error codes and their corresponding error messages.
This page contains all the error codes you may encounter when using the Payvessel API, along with their descriptions and suggested actions.
๏ฟฝ Payment Errors Card and payment method related errors
๏ฟฝ Authentication Errors API credentials and permission errors
All Payvessel API errors follow a consistent structure:
{
"error" : {
"type" : "card_error" ,
"code" : "card_declined" ,
"message" : "Your card was declined" ,
"param" : "payment_method" ,
"request_id" : "req_abc123"
}
}
Authentication Errors
Error Code Error Message Description invalid_api_keyInvalid API key provided The API key is malformed or incorrect missing_api_keyAPI key is required No API key was provided in the request headers invalid_api_secretInvalid API secret provided The API secret is malformed or incorrect missing_api_secretAPI secret is required No API secret was provided in the request headers account_inactiveAccount is inactive Your Payvessel account has been deactivated insufficient_permissionsInsufficient permissions for this operation Your API key doesnโt have permission for this action
Request Validation Errors
Error Code Error Message Description missing_required_fieldMissing required field: [field_name] A required parameter was not provided invalid_field_formatInvalid format for field: [field_name] The field value doesnโt match the expected format invalid_amountInvalid amount specified Amount must be a positive number invalid_currencyInvalid currency code Currency code is not supported or malformed amount_too_smallAmount below minimum limit Payment amount is below the minimum allowed amount_too_largeAmount exceeds maximum limit Payment amount exceeds the maximum allowed invalid_emailInvalid email address format The provided email address is not valid invalid_phoneInvalid phone number format The provided phone number is not valid
Card Payment Errors
Error Code Error Message Description card_declinedYour card was declined The card issuer declined the payment insufficient_fundsInsufficient funds The card does not have enough available balance expired_cardYour card has expired The card expiry date has passed incorrect_cvcYour cardโs security code is incorrect The CVC/CVV code provided is invalid incorrect_numberYour card number is incorrect The card number is invalid or malformed lost_cardYour card has been reported lost The card has been reported as lost by the cardholder stolen_cardYour card has been reported stolen The card has been reported as stolen by the cardholder pickup_cardYour card cannot be used for this payment The card issuer requests that the card be retained restricted_cardYour card has restrictions The card has restrictions that prevent this payment security_violationSecurity violation detected The payment was flagged for potential fraud service_not_allowedService not allowed The card issuer does not allow this type of transaction transaction_not_allowedTransaction not allowed The transaction type is not permitted for this card processing_errorAn error occurred processing your card A technical error occurred during card processing issuer_not_availableCard issuer temporarily unavailable The card issuerโs system is temporarily down try_again_laterPlease try again later Temporary processing issue, retry may succeed
Bank Transfer Errors
Error Code Error Message Description invalid_account_numberInvalid bank account number The provided bank account number is invalid invalid_routing_numberInvalid routing number The routing number is invalid or not found account_closedBank account is closed The specified bank account has been closed account_frozenBank account is frozen The account is temporarily frozen or restricted insufficient_funds_bankInsufficient funds in bank account The bank account does not have sufficient funds invalid_account_holderAccount holder name mismatch The account holder name doesnโt match records bank_declinedBank declined the transfer The bank rejected the transfer request transfer_limit_exceededTransfer limit exceeded The transfer amount exceeds daily/monthly limits
Mobile Money Errors
Error Code Error Message Description invalid_mobile_numberInvalid mobile number The mobile number format is incorrect mobile_money_not_registeredMobile money account not found No mobile money account found for this number mobile_money_insufficient_fundsInsufficient mobile money balance The mobile money account has insufficient funds mobile_money_declinedMobile money payment declined The mobile money provider declined the payment mobile_money_timeoutMobile money transaction timeout The mobile money transaction timed out mobile_money_limit_exceededMobile money limit exceeded Transaction exceeds mobile money daily limits
Error Handling Implementation
๐ Retry Logic
Implement intelligent retry logic for different error types:
class PaymentErrorHandler {
constructor () {
this . maxRetries = 3 ;
this . retryableErrors = [ 'api_error' , 'rate_limit_error' ];
this . nonRetryableErrors = [ 'authentication_error' , 'invalid_request_error' ];
}
async handlePaymentRequest ( paymentData ) {
let attempt = 0 ;
while ( attempt < this . maxRetries ) {
try {
const response = await this . makePaymentRequest ( paymentData );
return response ;
} catch ( error ) {
attempt ++ ;
// Don't retry on client errors
if ( this . isClientError ( error )) {
throw this . formatUserError ( error );
}
// Don't retry on final attempt
if ( attempt >= this . maxRetries ) {
throw error ;
}
// Calculate delay with exponential backoff
const delay = this . calculateRetryDelay ( attempt , error );
await this . sleep ( delay );
}
}
}
isClientError ( error ) {
return error . status >= 400 && error . status < 500 ;
}
calculateRetryDelay ( attempt , error ) {
// Use retry_after header if available (rate limiting)
if ( error . retry_after ) {
return error . retry_after * 1000 ;
}
// Exponential backoff with jitter
const baseDelay = 1000 ; // 1 second
const maxDelay = 30000 ; // 30 seconds
const exponentialDelay = baseDelay * Math . pow ( 2 , attempt - 1 );
const jitter = Math . random () * 1000 ;
return Math . min ( maxDelay , exponentialDelay + jitter );
}
formatUserError ( error ) {
const userMessages = {
'card_declined' : 'Your card was declined. Please try a different payment method.' ,
'insufficient_funds' : 'Your card has insufficient funds. Please use a different card.' ,
'expired_card' : 'Your card has expired. Please update your payment information.' ,
'incorrect_cvc' : 'The security code is incorrect. Please check and try again.' ,
'invalid_api_key' : 'Authentication failed. Please contact support.'
};
return {
userMessage: userMessages [ error . code ] || 'An error occurred processing your payment.' ,
errorCode: error . code ,
canRetry: this . retryableErrors . includes ( error . type )
};
}
}
๐ฏ User-Friendly Error Messages
Display appropriate messages to users:
// Error message mapping
const getUserErrorMessage = ( error ) => {
const messages = {
// Card errors
'card_declined' : 'Your card was declined. Please try a different payment method or contact your bank.' ,
'insufficient_funds' : 'Your account has insufficient funds. Please use a different card or add funds to your account.' ,
'expired_card' : 'Your card has expired. Please update your payment information with a valid card.' ,
'incorrect_cvc' : 'The security code is incorrect. Please check the 3-4 digit code on your card and try again.' ,
'lost_card' : 'Your card has been reported lost. Please use a different payment method.' ,
'stolen_card' : 'Your card has been reported stolen. Please use a different payment method.' ,
// Processing errors
'processing_error' : 'We encountered an error processing your payment. Please try again.' ,
'issuer_not_available' : 'Your card issuer is temporarily unavailable. Please try again later.' ,
'try_again_later' : 'Please try again in a few minutes.' ,
// Request errors
'invalid_amount' : 'The payment amount is invalid. Please check and try again.' ,
'currency_not_supported' : 'This currency is not supported. Please select a different currency.' ,
// General fallback
'default' : 'An unexpected error occurred. Please try again or contact support if the problem persists.'
};
return messages [ error . code ] || messages . default ;
};
// Usage in UI
const handlePaymentError = ( error ) => {
const userMessage = getUserErrorMessage ( error );
// Display to user
showErrorMessage ( userMessage );
// Log technical details for debugging
console . error ( 'Payment error:' , {
code: error . code ,
type: error . type ,
requestId: error . request_id ,
timestamp: new Date (). toISOString ()
});
};
Debugging and Logging
๐ Request ID Tracking
Use request IDs for debugging:
// Include request ID in error logging
const logPaymentError = ( error , context ) => {
const logEntry = {
timestamp: new Date (). toISOString (),
level: 'error' ,
message: 'Payment processing failed' ,
error: {
type: error . type ,
code: error . code ,
message: error . message ,
request_id: error . request_id
},
context: {
user_id: context . userId ,
payment_amount: context . amount ,
payment_method: context . paymentMethod ,
session_id: context . sessionId
}
};
console . error ( JSON . stringify ( logEntry ));
// Send to monitoring service
errorMonitoring . captureError ( logEntry );
};
๐ Error Monitoring
Set up comprehensive error monitoring:
class ErrorMonitoring {
constructor () {
this . errorCounts = new Map ();
this . alertThresholds = {
'card_declined' : 0.15 , // Alert if > 15% decline rate
'api_error' : 0.01 , // Alert if > 1% API errors
'timeout' : 0.05 // Alert if > 5% timeouts
};
}
recordError ( errorType , errorCode ) {
const key = ` ${ errorType } : ${ errorCode } ` ;
const current = this . errorCounts . get ( key ) || 0 ;
this . errorCounts . set ( key , current + 1 );
this . checkAlertThresholds ( errorType , errorCode );
}
checkAlertThresholds ( errorType , errorCode ) {
const threshold = this . alertThresholds [ errorCode ];
if ( ! threshold ) return ;
const errorRate = this . calculateErrorRate ( errorType , errorCode );
if ( errorRate > threshold ) {
this . sendAlert ({
type: 'high_error_rate' ,
errorCode: errorCode ,
currentRate: errorRate ,
threshold: threshold
});
}
}
sendAlert ( alertData ) {
// Send to monitoring service
console . warn ( 'Error rate alert:' , alertData );
}
}
Testing Error Scenarios
๐งช Error Testing
Test error handling with specific test cases:
// Test different error scenarios
describe ( 'Payment Error Handling' , () => {
const testCards = {
declined: '4000000000000002' ,
insufficientFunds: '4000000000009995' ,
expired: '4000000000000069' ,
incorrectCvc: '4000000000000127'
};
test ( 'handles declined card gracefully' , async () => {
const payment = await createPayment ({
card: testCards . declined ,
amount: 1000
});
expect ( payment . error . code ). toBe ( 'card_declined' );
expect ( payment . error . type ). toBe ( 'card_error' );
});
test ( 'handles rate limiting' , async () => {
// Simulate rate limit by making many requests
const promises = Array ( 100 ). fill (). map (() =>
createPayment ({ card: '4111111111111111' , amount: 100 })
);
const results = await Promise . allSettled ( promises );
const rateLimited = results . some ( r =>
r . status === 'rejected' &&
r . reason . error . code === 'rate_limit_exceeded'
);
expect ( rateLimited ). toBe ( true );
});
});
Never Ignore Errors: Always handle API errors appropriately. Unhandled errors can lead to poor user experience and failed transactions.
Ready to implement robust error handling?