Resources
Error Handling
In case of an error, the API will return an error response containing a specific error code 400, 403 Failed and a user-friendly message. Refer to our API documentation for a comprehensive list of error codes and their descriptions.
Error object
type
string
Required
Always error for failed requests.
Example:
errormessage.code
integer
Required
Same as the HTTP status code.
Example:
400message.error
array
Required
One or more readable error messages.
data
array
Required
Empty for errors.
Example:
[]Recommended handling
- 400 — Show the message to your team and fix the request. Do not retry unchanged.
- 401 — Request a new access token and retry once.
- 403 / 404 — Check your API keys and the selected environment.
- 500 — Wait a moment and retry. Contact support if it keeps failing.
See all codes on the Response Codes page.
Handle errors
<?php
$response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
$result = json_decode($response, true);
if ($status !== 200 || ($result['type'] ?? '') !== 'success') {
$errors = $result['message']['error'] ?? ['Unknown error'];
if ($status === 401) {
// token expired: request a new access token and retry once
}
throw new Exception(implode(', ', $errors));
}
$data = $result['data'];
$response = Http::acceptJson()
->withToken($accessToken)
->post($baseUrl . '/payment/create', $payload);
if ($response->status() === 401) {
// token expired: request a new access token and retry once
}
if ($response->failed() || $response->json('type') !== 'success') {
$errors = $response->json('message.error', ['Unknown error']);
Log::warning('Payment API error', ['errors' => $errors]);
return back()->withErrors($errors);
}
return redirect()->away($response->json('data.payment_url'));
const response = await fetch(`${baseUrl}/payment/create`, options);
const result = await response.json();
if (!response.ok || result.type !== 'success') {
const errors = result?.message?.error ?? ['Unknown error'];
if (response.status === 401) {
// token expired: request a new access token and retry once
}
throw new Error(errors.join(', '));
}
const { payment_url } = result.data;
response = requests.post(f"{base_url}/payment/create", json=payload, headers=headers)
result = response.json()
if response.status_code != 200 or result.get("type") != "success":
errors = result.get("message", {}).get("error", ["Unknown error"])
if response.status_code == 401:
pass # token expired: request a new access token and retry once
raise Exception(", ".join(errors))
payment_url = result["data"]["payment_url"]
Response
Validation failed
{
"message": {
"code": 400,
"error": [
"The amount field is required.",
"The currency field is required."
]
},
"data": [],
"type": "error"
}
Access token expired
{
"message": {
"code": 401,
"error": [
"Request token is expired"
]
},
"data": [],
"type": "error"
}
Missing or invalid access token
{
"message": {
"code": 403,
"error": [
"Access denied! Token not found"
]
},
"data": [],
"type": "error"
}