Create Invoice
POST /invoice/create
Create a new invoice specifying currency, amount, expiration time, and other relevant parameters.
Headers
Content-Type
application/json
X-API-KEY
<token>
Body
amount*
string
Amount of invoice like: 200 USD 0.015 BNB
expires_time*
number
Expiration time of invoice in minutes: 30-1440
label*
string
Label of invoice
postback_url
string
Destination URL for sending post
success_url
string
URL for User after successful payment
fail_url
string
URL for User after failed payment
Important: currency and allowed_currencies cannot be used together.
If you want to lock the invoice to a single currency, set currency and leave allowed_currencies = null.
Otherwise, set currency = null and specify allowed_currencies as a list of at least two currency codes.
Response
{
"id": 0,
"uuid": "string",
"currency": "string",
"tx_hash": "string",
"address": "string",
"amount": 0,
"amount_usd": 0,
"confirmations": 0,
"created_at": "2019-08-24T14:15:22Z",
"expires_at": "2019-08-24T14:15:22Z",
"is_expired": true,
"is_paid": true,
"label": "string",
"postback_url": "http://example.com",
"success_url": "http://example.com",
"fail_url": "http://example.com",
"url": "http://example.com"
}{
"detail": "Currency does not exist"
}{
"detail": "Invalid amount. Should be in range ({minimum_deposit of currency}-100,000,000)"
}{
"detail": "Invalid expires_time. Should be in range (5-60) minutes"
}{
"detail": "Max length of label is 255 characters"
}{
"detail": "Max length of postback_url is 255 characters"
}{
"detail": "Max length of success_url is 255 characters"
}{
"detail": [
{
"loc": [],
"msg": "string",
"type": "string"
}
]
}Example
curl -X POST "https://api.nord-pay.com/invoice/create" \
-H "Content-Type: application/json" \
-H "X-API-KEY: YOUR_API_KEY" \
-d '{
"currency": "USDTBEP20",
"amount": "200 USD",
"expires_time": 1,
"label": "Order #123",
"postback_url": "https://example.com/postback",
"success_url": "https://example.com/success",
"fail_url": "http://example.com"
}'import requests
def create_invoice(currency, label, amount, expires_time, postback_url=None, success_url=None):
url = "https://api.nord-pay.com/invoice/create"
headers = {
"Content-Type": "application/json",
"X-API-KEY": "YOUR_API_KEY"
}
payload = {
"currency": currency,
"label": label,
"amount": amount,
"expires_time": expires_time
}
if postback_url:
payload["postback_url"] = postback_url
if success_url:
payload["success_url"] = success_url
resp = requests.post(url, json=payload, headers=headers)
resp.raise_for_status()
return resp.json()
# usage:
invoice = create_invoice(
currency="USDTBEP20",
label="Order #123",
amount="200 USD",
expires_time=30,
postback_url="https://example.com/postback",
success_url="https://example.com/success"
)<?php
function createInvoice(
string $currency,
string $label,
float $amount,
int $expiresTime,
string $postbackUrl = null,
string $successUrl = null
): array {
$url = "https://api.nord-pay.com/invoice/create";
$payload = [
"currency" => $currency,
"label" => $label,
"amount" => $amount,
"expires_time" => $expiresTime
];
if ($postbackUrl) $payload["postback_url"] = $postbackUrl;
if ($successUrl) $payload["success_url"] = $successUrl;
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode($payload),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: YOUR_API_KEY"
],
]);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response, true);
}
// usage:
$invoice = createInvoice(
"USDTBEP20",
"Order #123",
"200 USD",
30,
"https://example.com/postback",
"https://example.com/success"
);async function createInvoice({
currency,
label,
amount,
expires_time,
postback_url,
success_url
}) {
const response = await fetch("https://api.nord-pay.com/invoice/create", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-KEY": "YOUR_API_KEY"
},
body: JSON.stringify({
currency,
label,
amount,
expires_time,
...(postback_url && { postback_url }),
...(success_url && { success_url })
})
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
return response.json();
}
// usage:
createInvoice({
currency: "USDTBEP20",
label: "Order #123",
amount: "200 USD",
expires_time: 30,
postback_url: "https://example.com/postback",
success_url: "https://example.com/success"
}).then(invoice => {
// work with invoice
});const axios = require('axios');
async function createInvoice({
currency,
label,
amount,
expires_time,
postback_url,
success_url
}) {
const { data } = await axios.post(
"https://api.nord-pay.com/invoice/create",
{
currency,
label,
amount,
expires_time,
...(postback_url && { postback_url }),
...(success_url && { success_url })
},
{
headers: {
"Content-Type": "application/json",
"X-API-KEY": "YOUR_API_KEY"
}
}
);
return data;
}
// usage:
createInvoice({
currency: "USDTBEP20",
label: "Order #123",
amount: "200 USD",
expires_time: 30,
postback_url: "https://example.com/postback",
success_url: "https://example.com/success"
}).then(invoice => {
// work with invoice
});Last updated