Skip to main content

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

Error Response Format

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 CodeError MessageDescription
invalid_api_keyInvalid API key providedThe API key is malformed or incorrect
missing_api_keyAPI key is requiredNo API key was provided in the request headers
invalid_api_secretInvalid API secret providedThe API secret is malformed or incorrect
missing_api_secretAPI secret is requiredNo API secret was provided in the request headers
account_inactiveAccount is inactiveYour Payvessel account has been deactivated
insufficient_permissionsInsufficient permissions for this operationYour API key doesnโ€™t have permission for this action

Request Validation Errors

Error CodeError MessageDescription
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 specifiedAmount must be a positive number
invalid_currencyInvalid currency codeCurrency code is not supported or malformed
amount_too_smallAmount below minimum limitPayment amount is below the minimum allowed
amount_too_largeAmount exceeds maximum limitPayment amount exceeds the maximum allowed
invalid_emailInvalid email address formatThe provided email address is not valid
invalid_phoneInvalid phone number formatThe provided phone number is not valid

Card Payment Errors

Error CodeError MessageDescription
card_declinedYour card was declinedThe card issuer declined the payment
insufficient_fundsInsufficient fundsThe card does not have enough available balance
expired_cardYour card has expiredThe card expiry date has passed
incorrect_cvcYour cardโ€™s security code is incorrectThe CVC/CVV code provided is invalid
incorrect_numberYour card number is incorrectThe card number is invalid or malformed
lost_cardYour card has been reported lostThe card has been reported as lost by the cardholder
stolen_cardYour card has been reported stolenThe card has been reported as stolen by the cardholder
pickup_cardYour card cannot be used for this paymentThe card issuer requests that the card be retained
restricted_cardYour card has restrictionsThe card has restrictions that prevent this payment
security_violationSecurity violation detectedThe payment was flagged for potential fraud
service_not_allowedService not allowedThe card issuer does not allow this type of transaction
transaction_not_allowedTransaction not allowedThe transaction type is not permitted for this card
processing_errorAn error occurred processing your cardA technical error occurred during card processing
issuer_not_availableCard issuer temporarily unavailableThe card issuerโ€™s system is temporarily down
try_again_laterPlease try again laterTemporary processing issue, retry may succeed

Bank Transfer Errors

Error CodeError MessageDescription
invalid_account_numberInvalid bank account numberThe provided bank account number is invalid
invalid_routing_numberInvalid routing numberThe routing number is invalid or not found
account_closedBank account is closedThe specified bank account has been closed
account_frozenBank account is frozenThe account is temporarily frozen or restricted
insufficient_funds_bankInsufficient funds in bank accountThe bank account does not have sufficient funds
invalid_account_holderAccount holder name mismatchThe account holder name doesnโ€™t match records
bank_declinedBank declined the transferThe bank rejected the transfer request
transfer_limit_exceededTransfer limit exceededThe transfer amount exceeds daily/monthly limits

Mobile Money Errors

Error CodeError MessageDescription
invalid_mobile_numberInvalid mobile numberThe mobile number format is incorrect
mobile_money_not_registeredMobile money account not foundNo mobile money account found for this number
mobile_money_insufficient_fundsInsufficient mobile money balanceThe mobile money account has insufficient funds
mobile_money_declinedMobile money payment declinedThe mobile money provider declined the payment
mobile_money_timeoutMobile money transaction timeoutThe mobile money transaction timed out
mobile_money_limit_exceededMobile money limit exceededTransaction 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.