m2pfintech
Error Codes

Error Codes

Standardized API error code reference — response structure, HTTP status codes, naming conventions, and error handling best practices.

The M2P Prepaid Platform uses a standardized error code system across all APIs. This section provides complete error code catalogs organized by service.


Error Response Structure

{
  "type": "https://www.m2pfintech.com/problem/problem-with-message",
  "title": "Brief error summary",
  "status": 400,
  "detail": "Detailed error message with context",
  "path": "/api/endpoint/path",
  "message": "error.http.400",
  "business.code": "PPCUST_001"
}
FieldTypeDescription
typestringError type URI
titlestringBrief error summary
statusintegerHTTP status code
detailstringDetailed error description with context
pathstringAPI endpoint that returned the error
messagestringError category
business.codestringBusiness error code (e.g., PP_MIDD_020, PPCUST_002)

HTTP Status Codes

HTTP CodeCategoryWhen UsedRetryable
200SuccessRequest processed successfully
400Client ErrorInvalid request payload, validation failuresNo
401UnauthorizedMissing or invalid authenticationNo
403ForbiddenValid auth but insufficient permissionsNo
404Not FoundResource doesn't existNo
409ConflictBusiness rule violations, duplicate dataNo
429Too Many RequestsRate limit exceededYes (with backoff)
500Server ErrorInternal server errorsYes (after investigation)
503Service UnavailableService temporarily downYes (with backoff)

Naming Convention

Error codes follow the pattern: {SERVICE_PREFIX}_{SEQUENCE_NUMBER}

PrefixServiceExample
PP_MIDDpp-middlewarePP_MIDD_020
PPCUSTCustomer APIPPCUST_045
PP_CORPCorporate APIPP_CORP_128

Error messages support dynamic placeholders: {0}, {1}, etc.
Example: "Invalid Product id {0}""Invalid Product id PROD_12345"


Error Categories

CategoryHTTP CodeDescription
Validation Errors400Invalid request data, format issues, missing fields
Business Logic Errors409Business rule violations, conflicting states
Resource Not Found404Requested entity doesn't exist
Auth Errors401/403Authentication / authorization failures
System Errors500/503Technical / infrastructure failures

Error Catalogs


Error Handling Best Practices

if (response.status === 200) {
  processSuccess(response.data);
} else if (response.status === 400) {
  handleValidationError(response.data);  // Fix request
} else if (response.status === 409) {
  handleBusinessError(response.data);    // Inform user
} else if (response.status >= 500) {
  scheduleRetry(request);                // Retry with backoff
}
const RETRYABLE_ERRORS = [
  'PP_MIDD_018',  // Server down
  'PP_MIDD_019',  // Downstream error
  'PPCUST_007',   // Service unavailable
  'PP_CORP_022',  // Service unavailable
];

async function retryWithBackoff(request, maxRetries = 3) {
  for (let i = 0; i < maxRetries; i++) {
    try {
      return await makeRequest(request);
    } catch (error) {
      if (!RETRYABLE_ERRORS.includes(error.businessCode)
          || i === maxRetries - 1) throw error;
      await sleep(Math.pow(2, i) * 1000); // 1s, 2s, 4s
    }
  }
}
const USER_MESSAGES = {
  'PP_MIDD_003': 'Invalid PAN format. Use: ABCDE1234F',
  'PP_MIDD_016': 'Account locked for 24 hours due to failed attempts.',
  'PP_MIDD_035': 'Yearly wallet limit exceeded.',
  'PPCUST_079': 'Insufficient balance. Please add funds.',
  'PPCUST_105': 'Card is not active. Please activate first.',
  'PP_CORP_088': 'Customer already exists with these details.',
};

function getUserMessage(code, detail) {
  return USER_MESSAGES[code] || detail || 'An error occurred.';
}

Always log the full error response including business.code, detail, and path for debugging and support ticket resolution.

On this page