OMPAYOMPAY
SDKsompay.js

Errors and Testing

Handle SDK errors and use sandbox test cards with ompay.js.

Errors and Testing

Use this page for runtime error handling and sandbox card values.

Error Handling

import { OMPayClient, OMPayError } from 'ompay.js';

try {
  const order = await client.createCheckout({
    amount: 100.0,
    currency: 'OMR',
    customerFields: {
      name: 'Jane Doe',
      email: 'jane@example.com',
      phone: '91234567',
    },
  });
} catch (error) {
  if (error instanceof OMPayError) {
    console.error('Error code:', error.code);
    console.error('Message:', error.message);
    console.error('Status:', error.statusCode);
  }
}

Error Codes

CodeDescription
AUTHENTICATION_ERRORInvalid client ID or secret
VALIDATION_ERRORInvalid request parameters
API_ERRORServer-side error
NETWORK_ERRORNetwork connectivity issue
TIMEOUT_ERRORRequest timed out
SIGNATURE_MISMATCHInvalid payment signature
UNKNOWN_ERRORUnexpected SDK or runtime error

Test Cards

See the dedicated Test Cards page for approved and rejected sandbox card numbers.

Next Steps

On this page