Request Authorization
Connection Host
All API requests must be sent to the following host address:
https://api.payp.io/&/v2
Authorization Header
To authorize a request to the API, include your API KEY in the Authorization header as follows:
Authorization: Token <API KEY>
Example Request
Example of using the Authorization header in an API request:
php
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.payp.io/&/v2/invoice/merchant/canceled");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(array("uuid" => "INV-XXXXXXXX")));
$headers = array(
"Authorization: Token <API KEY>",
"Content-Type: application/json"
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
} else {
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($statusCode == 200) {
echo "Success: " . $response;
} else {
echo "Fail: " . $statusCode . " " . $response;
}
}
curl_close($ch);
?>
Python
import requests
import json
url = "https://api.payp.io/&/v2/invoice"
headers = {
"Authorization": "Token <API KEY>",
"Content-Type": "application/json"
}
data = {
"amount": 100.0,
"currency": "USD",
"description": "Pay"
}
response = requests.post(url, headers=headers, json=data)
# Check response
if response.status_code == 200:
print("Success:", response.json())
else:
print("Fail:", response.status_code, response.text)
js
const url = 'https://api.payp.io/&/v2/invoice';
const headers = new Headers({
'Authorization': 'Token <API KEY>',
'Content-Type': 'application/json'
});
const data = {
amount: 100.0,
currency: 'USD',
description: 'Pay'
};
fetch(url, {
method: 'POST',
headers,
body: JSON.stringify(data)
})
.then(response => {
if (response.ok) {
return response.json();
} else {
return Promise.reject('Error');
}
})
.then(data => {
console.log('Success:', data);
})
.catch(error => {
console.error('Fail:', error);
});
You do not need to send a separate authorization request. The API KEY must be included in the Authorization header.
Example Error Response
Response
json
// Check your API key
{
"status": 401,
"name": "UnauthorizedError",
"message": "shop not found",
"details": "check api key"
}
json
// Check if the fields are correctly specified
{
"status": 400,
"name": "BadRequestError",
"message": "Required field is missing",
"details": "currency"
}