Skip to content

Invoice Creation

To create an invoice, you need to send a POST request.

POST

url
https://api.payp.io/&/v2/invoice

Headers

NameTypeDescription
AuthorizationstringToken API KEY

Request Body

NameTypeDescription
currency*stringCurrency for the invoice
amount*stringAmount to be invoiced
titlestringTitle or description of the invoice
emailstringCustomer's email (optional)

Response

json
{
    "uid": "ef7fb874-ab76-4798-a414-c22e50b020bd",
    "status": "success",
    "pay_url": "uidef7fb874-ab76-4798-a414-c22e50b020bd",
    "createdAt": "2025-03-11T20:03:44.723Z"
}
json
// Check the correctness of the API key 
{
    "status": 401,
    "name": "UnauthorizedError",
    "message": "shop not found",
    "details": "check api key"
}
json
// Check if fields are correctly specified
{
    "status": 400,
    "name": "BadRequestError",
    "message": "Required field is missing",
    "details": "currency"
}

Request Examples

These examples show how to send a request to create an invoice using Python and JavaScript. Note that you need to provide your API key in the Authorization header for successful request authorization.

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 the 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);
    });

Payp