PayNode

Developer guide

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.

Which way is right for you?

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.

Quick answer

  • I can't edit codeWay 1
  • My site runs on PHP (cPanel scripts, WordPress-style sites)Way 2, PHP kit
  • My site runs on Node.js (Express, Next.js)Way 2, Node.js kit
  • Another language, or I want everything inside my own pagesWay 3

1. No code: payment link or pay button

About 5 minutes. For shops, freelancers, invoices and donations.

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.

2. Starter kit: ready files

15 to 30 minutes. For sites built in PHP or Node.js, where you or a developer can edit a few lines.

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.

The Node.js kit works with Express, Next.js or plain Node.

3. Build it yourself: the API

A few hours. For experienced developers in any language (Python, Go, Ruby, Java, PHP frameworks), or sites that want deposits and withdrawals inside their own pages.

Use the endpoints and webhooks in the sections that follow. You control every screen and step.

Optionalpaynode.phppaynode.jsWebhook helpers

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.

Quick start

Base URL https://paynode.space. Every request uses your key: Authorization: Bearer YOUR_KEY

How a deposit works

  1. Your user presses Deposit on your siteYour server asks PayNode to create a payment and gets back a checkout_url.
  2. You send the user to that pageThey see the amount, network and address, and pay.
  3. PayNode tells your serverA signed webhook arrives. On invoice.settled you confirm it and credit the user once.
  4. The user comes backTo your success_url.

Set up in your PayNode dashboard

1. Add your wallet

Settings. Customer payments are sent straight there.

2. Add your domain

Website integration. Return links only work to these domains.

3. Webhook and secret

Website integration. Your https address, then create the secret.

4. Create an API key

Website integration. Keep it on your server only.

Keep keys on your server. Never put a key or the webhook secret in a browser, a mobile app or a public repository.

Create a payment

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"}'

What you send

FieldNeededWhat it is
assetYesThe coin. See supported coins (open "For developers" on a coin).
amount_displayYesThe price in normal units, as text, e.g. "25".
order_idNoYour own reference. Same order id, coin and amount while still open gives you the same payment back, so retries are safe.
descriptionNoShown on the payment page.
success_url, cancel_urlNoWhere the user goes after. Must be on a domain you added. We add ?invoice_id=...&order_id=....

What you get back

Among other fields: id, checkout_url, address, fee_display, net_display, status. A payment page stays open for 6 hours.

Get told when it is paid

PayNode sends a POST to your webhook address each time a payment changes.

Easiest way - starter kit: download paynode-kit.zip for PHP (setup guide) or paynode-kit-node.zip for Node.js (setup guide). Each has a ready deposit page, an automatic withdraw page and the webhook. Add the folder, paste your keys into the settings file, and connect three marked lines to your users and balances. It works in demo mode straight away so you can test first.
Only need the webhook? download paynode.php or paynode.js. Put it on your server, paste your webhook secret and API key, and fill in the two parts marked REPLACE THIS. It already checks signatures, refuses replays and ignores repeats.

Write your own

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

Events

EventMeaning
invoice.confirmingMoney seen, waiting for network confirmations.
invoice.underpaidLess than the price arrived. Compare amount_received with amount_expected.
invoice.confirmedConfirmed on the network.
invoice.settlingBeing forwarded to the merchant wallet.
invoice.settledDone. This is the one to credit on.
invoice.expired, invoice.failedNot paid in time, or failed. Credit nothing.
payout.confirmed, payout.failedA 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.

Retries: no 2xx answer means we try again after 30 seconds, 2 minutes, 10 minutes, 1 hour, 6 hours and 24 hours. Your dashboard shows every delivery with a Resend button. Make your handler safe to run twice.

Confirm, then credit once

Never credit because a user reached your success page - anyone can open that link. And do not trust the webhook signature alone: if your secret ever leaks, someone could sign a fake message.

Before crediting, ask PayNode directly

GET /api/invoices/INVOICE_ID with your key, and check all of these:

status is settled
live is true

And sandbox is not true (not a practice payment).

Same order_id

As the one you created.

Same coin and amount

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 refused

Your website keeps each user's balance. PayNode never does.

Pay your users (withdrawals)

Winnings, rewards, refunds, withdrawals - sent from your own PayNode wallet.

  1. Create your PayNode walletDashboard, press Deposit funds. We make a wallet for you.
  2. Fill itSend it the coins to pay out, plus a little BNB for network fees. How much?
  3. Create a payout keySettings. It starts with sk_payout_ and is the only key that can move money.
  4. Call the payout endpointWe sign and send, and tell your webhook when it arrives.
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();
Always send 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.
payout.confirmed

It arrived. Mark it done.

payout.failed

Nothing left your wallet. Put the amount back in your user's balance.

Set limits

Payouts tab: cap one payout and a 24-hour total per coin, or approve each by hand.

All endpoints

RequestWhat it doesKey
GET /api/assetsCoins you can useAny
POST /api/invoicesCreate a paymentAPI key
GET /api/invoices/IDOne payment's status and amountsAPI key
GET /api/invoicesYour paymentsAPI key
GET /api/ledgerYour ledger entriesAPI key
POST /api/payoutsPay a walletPayout key
GET /api/payoutsYour payouts, newest firstAPI key
GET /api/payouts/IDOne payoutAPI key
GET /api/floatYour PayNode wallet, balances and gas warningAPI key
POST /api/refundsRefund part or all of a settled paymentDashboard

Changing wallets, keys, limits or the webhook secret is only possible while logged in to the dashboard, never with an API key.

Test it on yourself first

  1. Create a small paymentA payment link or an API payment of 1 or 2 USDT.
  2. Pay it from your own walletWatch the page update and say "Payment received".
  3. Check your serverYour dashboard shows the webhook delivery and your server's answer.
  4. Check your walletThe money arrives, minus the fee.
Keep your own records. Save each deposit and payout in your database as webhooks arrive, instead of asking us on every page load. Use GET /api/invoices and GET /api/payouts to reconcile.