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
| Code | Description |
|---|---|
AUTHENTICATION_ERROR | Invalid client ID or secret |
VALIDATION_ERROR | Invalid request parameters |
API_ERROR | Server-side error |
NETWORK_ERROR | Network connectivity issue |
TIMEOUT_ERROR | Request timed out |
SIGNATURE_MISMATCH | Invalid payment signature |
UNKNOWN_ERROR | Unexpected SDK or runtime error |
Test Cards
See the dedicated Test Cards page for approved and rejected sandbox card numbers.