Skip to main content

Error Codes

The API returns errors in JSON format.

Response Format

{
"error": "PAY_002",
"message": "Invalid request body"
}

Authorization Errors (AUTH)

CodeHTTPDescription
AUTH_001401Invalid API key
AUTH_002401Invalid request signature
AUTH_003401Merchant not found
AUTH_004401Missing X-Identity header
AUTH_005403Merchant blocked
AUTH_006401Missing X-Signature header
AUTH_007403Terminal disabled

Payment Errors (PAY)

CodeHTTPDescription
PAY_001500Internal error
PAY_002400Invalid request parameters
PAY_003409Order with this ext_id already exists
PAY_004503No available requisites
PAY_005429Too many payments with the same amount
PAY_006404Payment not found
PAY_007400Payment cannot be cancelled
PAY_008400Payment cannot be confirmed
PAY_009400File too large (max 10MB)

Withdrawal Errors (WDR)

CodeHTTPDescription
WDR_001400Invalid request parameters
WDR_002400Insufficient funds
WDR_003404Withdrawal not found

Dispute Errors (DIS)

CodeHTTPDescription
DIS_001400A dispute can only be opened for CANCELLED
DIS_002409Dispute already exists

System Errors (SYS)

CodeHTTPDescription
SYS_001500Internal error

JavaScript

async function createPayment(data) {
const response = await fetch('https://api.bopay.io/v1/payments', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Identity': apiKey,
'X-Signature': signature
},
body: JSON.stringify(data)
});

if (!response.ok) {
const error = await response.json();

switch (error.error) {
case 'AUTH_001':
case 'AUTH_002':
throw new Error('Authorization error: check your keys');
case 'PAY_003':
throw new Error('Order already exists');
case 'PAY_004':
throw new Error('No available requisites, try again later');
case 'WDR_002':
throw new Error('Insufficient funds for withdrawal');
default:
throw new Error(error.message);
}
}

return response.json();
}

Python

import requests

def create_payment(data):
response = requests.post(
'https://api.bopay.io/v1/payments',
json=data,
headers={
'X-Identity': api_key,
'X-Signature': signature
}
)

if not response.ok:
error = response.json()
code = error.get('error')

if code in ['AUTH_001', 'AUTH_002']:
raise Exception('Authorization error: check your keys')
elif code == 'PAY_004':
raise Exception('No available requisites')
elif code == 'WDR_002':
raise Exception('Insufficient funds for withdrawal')
else:
raise Exception(error.get('message'))

return response.json()