Connect any website to PayNode: take deposits, get told when they are paid, and pay your users. Works with any language that can make a web request.
There are three ways to connect PayNode. Pick the one that matches how comfortable you are with code - you can always move to another later.
Create a link or button in your dashboard, then paste it on your site or send it to a customer. Every payment shows in your dashboard.
Your website's own balances are not updated automatically.
Each kit has a deposit page, an automatic withdraw page and the webhook. Add the folder to your site, paste your keys into the settings file, then connect three marked lines to your users and balances. It starts in demo mode so you can test first.
Use the endpoints and webhooks in the sections that follow. You control every screen and step.
Whichever way you choose, set up the basics in your dashboard first: add your wallet, add your website's domain, and (for ways 2 and 3) set your webhook address, create the webhook secret and an API key. A payout key is needed only for automatic withdrawals.
Base URL https://paynode.space. Every request uses your key: Authorization: Bearer YOUR_KEY
checkout_url.invoice.settled you confirm it and credit the user once.success_url.Settings. Customer payments are sent straight there.
Website integration. Return links only work to these domains.
Website integration. Your https address, then create the secret.
Website integration. Keep it on your server only.
POST /api/invoices then send the user to checkout_url.
<?php
// The user pressed Deposit on your site.
$payload = json_encode([
"asset" => "eip155:56:0x55d398326f99059ff775485246999027b3197955", // USDT on BNB Chain
"amount_display" => "25",
"order_id" => "deposit-" . $depositId, // your own reference
"description" => "Deposit for user " . $userId,
"success_url" => "https://yourwebsite.com/deposit/done",
"cancel_url" => "https://yourwebsite.com/deposit/cancelled",
]);
$ch = curl_init("https://paynode.space/api/invoices");
curl_setopt_array($ch, [
CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => ["Authorization: Bearer " . getenv("PAYNODE_KEY"), "Content-Type: application/json"],
]);
$invoice = json_decode(curl_exec($ch), true);
header("Location: " . $invoice["checkout_url"]); // send the user to pay
exit;
// The user pressed Deposit on your site (Node 18+).
const r = await fetch("https://paynode.space/api/invoices", {
method: "POST",
headers: { "Authorization": "Bearer " + process.env.PAYNODE_KEY, "Content-Type": "application/json" },
body: JSON.stringify({
asset: "eip155:56:0x55d398326f99059ff775485246999027b3197955", // USDT on BNB Chain
amount_display: "25",
order_id: "deposit-" + depositId, // your own reference
description: "Deposit for user " + userId,
success_url: "https://yourwebsite.com/deposit/done",
cancel_url: "https://yourwebsite.com/deposit/cancelled",
}),
});
const invoice = await r.json();
res.redirect(invoice.checkout_url); // send the user to pay
# The user pressed Deposit on your site.
import os, requests
invoice = requests.post("https://paynode.space/api/invoices",
headers={"Authorization": "Bearer " + os.environ["PAYNODE_KEY"]},
json={
"asset": "eip155:56:0x55d398326f99059ff775485246999027b3197955", # USDT on BNB Chain
"amount_display": "25",
"order_id": f"deposit-{deposit_id}", # your own reference
"description": f"Deposit for user {user_id}",
"success_url": "https://yourwebsite.com/deposit/done",
"cancel_url": "https://yourwebsite.com/deposit/cancelled",
}, timeout=20).json()
return redirect(invoice["checkout_url"]) # send the user to pay
curl -X POST https://paynode.space/api/invoices \
-H "Authorization: Bearer YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"asset":"eip155:56:0x55d398326f99059ff775485246999027b3197955",
"amount_display":"25","order_id":"deposit-1001",
"success_url":"https://yourwebsite.com/deposit/done"}'| Field | Needed | What it is |
|---|---|---|
asset | Yes | The coin. See supported coins (open "For developers" on a coin). |
amount_display | Yes | The price in normal units, as text, e.g. "25". |
order_id | No | Your own reference. Same order id, coin and amount while still open gives you the same payment back, so retries are safe. |
description | No | Shown on the payment page. |
success_url, cancel_url | No | Where the user goes after. Must be on a domain you added. We add ?invoice_id=...&order_id=.... |
Among other fields: id, checkout_url, address, fee_display, net_display, status. A payment page stays open for 6 hours.
PayNode sends a POST to your webhook address each time a payment changes.
Headers: X-PayNode-Event, X-PayNode-Delivery, X-PayNode-Timestamp, X-PayNode-Signature. The signature is HMAC-SHA256 (hex) of timestamp + "." + raw body with your webhook secret. Refuse anything older than 5 minutes. Reply with any 2xx.
<?php
// PayNode calls this address (your webhook URL).
$raw = file_get_contents("php://input");
$ts = $_SERVER["HTTP_X_PAYNODE_TIMESTAMP"] ?? "";
$sig = $_SERVER["HTTP_X_PAYNODE_SIGNATURE"] ?? "";
$expected = hash_hmac("sha256", $ts . "." . $raw, getenv("PAYNODE_WEBHOOK_SECRET"));
if (!hash_equals($expected, $sig) || abs(time() - (int)$ts) > 300) { http_response_code(400); exit; }
$e = json_decode($raw, true);
if ($e["event"] === "invoice.settled") {
// 1. Confirm with PayNode (see "Confirm and credit").
// 2. Credit the user ONCE, keyed by $e["invoice_id"].
}
http_response_code(200);
const crypto = require("crypto");
app.post("/paynode-webhook", express.raw({ type: "*/*" }), (req, res) => {
const ts = req.header("X-PayNode-Timestamp") || "";
const sig = req.header("X-PayNode-Signature") || "";
const expected = crypto.createHmac("sha256", process.env.PAYNODE_WEBHOOK_SECRET)
.update(ts + "." + req.body.toString()).digest("hex");
const ok = expected.length === sig.length && crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(sig));
if (!ok || Math.abs(Date.now() / 1000 - Number(ts)) > 300) return res.sendStatus(400);
const e = JSON.parse(req.body.toString());
if (e.event === "invoice.settled") { /* confirm with PayNode, then credit once by e.invoice_id */ }
res.sendStatus(200);
});
import hmac, hashlib, json, os, time
@app.post("/paynode-webhook") # Flask
def paynode_webhook():
raw = request.get_data()
ts = request.headers.get("X-PayNode-Timestamp", "")
sig = request.headers.get("X-PayNode-Signature", "")
expected = hmac.new(os.environ["PAYNODE_WEBHOOK_SECRET"].encode(), ts.encode() + b"." + raw, hashlib.sha256).hexdigest()
if not hmac.compare_digest(expected, sig) or abs(time.time() - int(ts or 0)) > 300:
return "", 400
e = json.loads(raw)
if e["event"] == "invoice.settled":
pass # confirm with PayNode, then credit once by e["invoice_id"]
return "", 200| Event | Meaning |
|---|---|
invoice.confirming | Money seen, waiting for network confirmations. |
invoice.underpaid | Less than the price arrived. Compare amount_received with amount_expected. |
invoice.confirmed | Confirmed on the network. |
invoice.settling | Being forwarded to the merchant wallet. |
invoice.settled | Done. This is the one to credit on. |
invoice.expired, invoice.failed | Not paid in time, or failed. Credit nothing. |
payout.confirmed, payout.failed | A payout you asked for arrived, or failed. |
Each body has invoice_id, order_id, status, asset, decimals, amount_expected, amount_received, platform_fee, net_amount. Amounts are whole-number text in the coin's smallest unit: divide by 10 to the power of decimals.
GET /api/invoices/INVOICE_ID with your key, and check all of these:
status is settledlive is trueAnd sandbox is not true (not a practice payment).
order_idAs the one you created.
asset_key and expected_display.
$ch = curl_init("https://paynode.space/api/invoices/" . urlencode($e["invoice_id"]));
curl_setopt_array($ch, [CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer " . getenv("PAYNODE_KEY")]]);
$inv = json_decode(curl_exec($ch), true);
if ($inv["status"] === "settled" && $inv["live"] === true && empty($inv["sandbox"])
&& $inv["order_id"] === $myOrderId && $inv["expected_display"] == $myAmount) {
// Credit ONCE: save invoice_id in a column with a UNIQUE rule so a repeat is refused.
}
const r = await fetch("https://paynode.space/api/invoices/" + encodeURIComponent(e.invoice_id),
{ headers: { "Authorization": "Bearer " + process.env.PAYNODE_KEY } });
const inv = await r.json();
if (inv.status === "settled" && inv.live === true && !inv.sandbox
&& inv.order_id === myOrderId && Number(inv.expected_display) === myAmount) {
// Credit ONCE: save invoice_id in a column with a UNIQUE rule so a repeat is refused.
}
inv = requests.get("https://paynode.space/api/invoices/" + e["invoice_id"],
headers={"Authorization": "Bearer " + os.environ["PAYNODE_KEY"]}, timeout=20).json()
if (inv["status"] == "settled" and inv.get("live") is True and not inv.get("sandbox")
and inv["order_id"] == my_order_id and float(inv["expected_display"]) == my_amount):
pass # credit ONCE: save invoice_id with a UNIQUE rule so a repeat is refusedYour website keeps each user's balance. PayNode never does.
Winnings, rewards, refunds, withdrawals - sent from your own PayNode wallet.
sk_payout_ and is the only key that can move money.curl -X POST https://paynode.space/api/payouts \
-H "Authorization: Bearer sk_payout_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"asset":"eip155:56:0x55d398326f99059ff775485246999027b3197955",
"amount_display":"25","dest":"0xTHE_USERS_WALLET",
"reference":"withdrawal-1234","idem":"withdrawal-1234"}'
$ch = curl_init("https://paynode.space/api/payouts");
curl_setopt_array($ch, [CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer " . getenv("PAYNODE_PAYOUT_KEY"), "Content-Type: application/json"],
CURLOPT_POSTFIELDS => json_encode([
"asset" => "eip155:56:0x55d398326f99059ff775485246999027b3197955",
"amount_display" => "25", "dest" => $userWallet,
"reference" => "withdrawal-" . $wid, "idem" => "withdrawal-" . $wid,
])]);
$payout = json_decode(curl_exec($ch), true);
const r = await fetch("https://paynode.space/api/payouts", {
method: "POST",
headers: { "Authorization": "Bearer " + process.env.PAYNODE_PAYOUT_KEY, "Content-Type": "application/json" },
body: JSON.stringify({
asset: "eip155:56:0x55d398326f99059ff775485246999027b3197955",
amount_display: "25", dest: userWallet,
reference: "withdrawal-" + wid, idem: "withdrawal-" + wid,
}),
});
const payout = await r.json();idem - your own id for this payout. If your server retries after a timeout or a double click, we return the payout we already made instead of paying twice.It arrived. Mark it done.
Nothing left your wallet. Put the amount back in your user's balance.
Payouts tab: cap one payout and a 24-hour total per coin, or approve each by hand.
| Request | What it does | Key |
|---|---|---|
GET /api/assets | Coins you can use | Any |
POST /api/invoices | Create a payment | API key |
GET /api/invoices/ID | One payment's status and amounts | API key |
GET /api/invoices | Your payments | API key |
GET /api/ledger | Your ledger entries | API key |
POST /api/payouts | Pay a wallet | Payout key |
GET /api/payouts | Your payouts, newest first | API key |
GET /api/payouts/ID | One payout | API key |
GET /api/float | Your PayNode wallet, balances and gas warning | API key |
POST /api/refunds | Refund part or all of a settled payment | Dashboard |
Changing wallets, keys, limits or the webhook secret is only possible while logged in to the dashboard, never with an API key.
GET /api/invoices and GET /api/payouts to reconcile.