Error Handling
Error Response Format
JSON
{
"status": "error",
"message": "Invalid amount",
"error_code": "RZ_001",
"retry_after": null,
"timestamp": "2024-01-15T10:30:00Z"
}
Error Codes
| Code | Message | Solution |
|---|---|---|
RZ_001 | Invalid amount | Amount must be numeric and ≥ 0.01 |
RZ_002 | Invalid or inactive public_key_id | Check your public key in dashboard |
RZ_005 | Failed to create transaction | Try again or contact support |
RZ_008 | Invalid expiry_minutes | Set expiry between 1-60 minutes |
RZ_020 | Rate limit exceeded | Wait and retry with exponential backoff |
Handle Errors in Code
try {
const result = await RazCrypto.createPayment({ amount: 10.00 });
} catch (error) {
switch (error.message) {
case 'RZ_001': alert('Invalid amount — minimum 0.01 USDT'); break;
case 'RZ_002': alert('Invalid API key — check dashboard'); break;
case 'RZ_020': alert('Too many requests — please wait'); break;
default: alert('Payment failed: ' + error.message);
}
}
<?php
$result = json_decode($response, true);
if ($result['status'] === 'error') {
switch ($result['error_code']) {
case 'RZ_001': throw new Exception('Invalid amount'); break;
case 'RZ_002': throw new Exception('Invalid API key'); break;
case 'RZ_020': sleep(2); // retry; break;
default: throw new Exception($result['message']);
}
}
?>