Webhooks

Paybin calls your server in two situations: when a deposit to one of your customers' addresses is confirmed (the deposit callback), and — if enabled for your account — before a withdrawal is created (the withdraw confirmation callback). This page describes both payloads, how to verify them and how to respond.

POSTyour CallbackUrl

Deposit callback

Paybin sends the deposit callback as an HTTP POST with a JSON body (Content-Type: application/json) to the CallbackUrl stored on the receiving address. The URL comes from Create a deposit address or the hosted deposit page; if none was given, your account's default callback URL is used.

The callback is sent when:

  • the transaction has reached the number of confirmations required for its network, and
  • the amount is at or above the minimum deposit amount configured for your account. Deposits below the minimum get status 5 (InsufficientAmount), no callback is sent, and they are visible in the Paybin dashboard.

Unlike the API responses, the callback payload uses PascalCase field names.

Payload

  • Name
    Address
    Type
    string
    Description

    The deposit address that received the funds. EVM addresses are lowercase.

  • Name
    UniqueId
    Type
    string
    Description

    Blockchain transaction hash (transaction signature on Solana). Used to compute Signature.

  • Name
    Amount
    Type
    decimal
    Description

    Amount received, in units of Symbol (not in fiat). Can have up to 18 decimals.

  • Name
    Symbol
    Type
    string
    Description

    Symbol of the deposit, for example BSC-USD. See Supported symbols.

  • Name
    ReferenceId
    Type
    string
    Description

    The customer's ReferenceId you used when creating the address.

  • Name
    Price
    Type
    object
    Description

    Fiat value of the whole deposit (Amount × unit price) in USD, GBP, EUR, TRY, JPY and BRL.

  • Name
    OrderId
    Type
    integer
    Description

    Distinguishes multiple deposits inside the same blockchain transaction (for example a batch transfer that pays several of your addresses).

  • Name
    Signature
    Type
    string
    Description

    Uppercase hex MD5 of SecretKey + UniqueId. See Verifying the signature.

  • Name
    Hash
    Type
    string
    Description

    Opaque identifier of the event. It cannot be recomputed on your side and its letter case is not guaranteed — do not use it for verification.

Deposit callback payload

{
  "Address": "0x5b1f3e0c9a8d4f2e7c6b1a0d9e8f7c6b5a4d3e2f",
  "UniqueId": "0x9f2c4b7e1d0a3c5e8b6f4a2d1c0e9b8a7f6e5d4c3b2a1f0e9d8c7b6a5f4e3d2c",
  "Amount": 250.0,
  "Symbol": "BSC-USD",
  "ReferenceId": "customer-1001",
  "Price": {
    "USD": 249.85,
    "GBP": 197.4,
    "EUR": 229.9,
    "TRY": 8521.3,
    "JPY": 37790.0,
    "BRL": 1399.2
  },
  "Signature": "954B9296E380F3BBBA765BFE58956E2B",
  "OrderId": 0,
  "Hash": "5B0AAA0CF6835D7512E66C4B0BA4345A"
}

The example Signature is computed with the secret key my-secret-key, so you can use it to test your implementation.


Verifying the signature

Anyone can send a request to your callback URL, so verify every callback before crediting a customer:

  1. Read UniqueId and Signature from the JSON body.
  2. Compute MD5(SecretKey + UniqueId) over the UTF-8 bytes and encode it as hex.
  3. Compare it with Signature case-insensitively and in constant time. Reject the request if they differ.

The signature proves the callback was produced with your secret key, but it does not cover the amount or address. For large amounts, additionally confirm the deposit with Verify a deposit or Get a deposit before crediting.

Verify a deposit callback

import crypto from 'node:crypto'
import express from 'express'
import { parse } from 'lossless-json'

const app = express()

function isValidSignature(payload, secretKey) {
  if (typeof payload?.UniqueId !== 'string' || typeof payload?.Signature !== 'string') {
    return false
  }
  const expected = Buffer.from(
    crypto
      .createHash('md5')
      .update(secretKey + payload.UniqueId, 'utf8')
      .digest('hex')
      .toUpperCase(),
    'utf8',
  )
  // Compare byte lengths: timingSafeEqual throws when they differ
  const received = Buffer.from(payload.Signature.toUpperCase(), 'utf8')
  return received.length === expected.length && crypto.timingSafeEqual(received, expected)
}

// Read the body as text: express.json() would round Amount to a float
app.post('/paybin/callback', express.text({ type: 'application/json' }), async (req, res) => {
  let payload
  try {
    payload = parse(req.body) // lossless-json keeps every digit of Amount
  } catch {
    return res.status(400).json({ error: 'invalid JSON' })
  }
  if (!isValidSignature(payload, process.env.PAYBIN_SECRET_KEY)) {
    return res.status(401).json({ error: 'invalid signature' })
  }

  const depositKey = `${payload.UniqueId}:${payload.OrderId}:${payload.Address}`
  const amount = payload.Amount.toString() // exact decimal string, e.g. '250.123456789012345678'
  await creditDepositOnce(depositKey, amount, payload) // your idempotent business logic

  res.status(200).json({ TransactionId: depositKey })
})

Responding to callbacks

How you answer decides the deposit's status in Paybin:

Your responseResult
HTTP 200 with an empty body or a JSON objectDelivered. The deposit moves to status 4 (Ok) and no further callbacks are sent for it.
Any other HTTP status code (including 201, 204, 4xx, 5xx)Not delivered. The deposit moves to status 3 (NotOk).
HTTP 200 with a body that is not a JSON object (for example plain text OK), a timeout or a connection errorNot recorded as delivered. The deposit stays in status 2 (Confirmed).

In both failure cases Paybin attempts the callback again on later processing runs, for a limited time after the deposit was detected.

Recommendations:

  • Return exactly 200 with a JSON object such as {} once you have stored the deposit. Do the heavy processing asynchronously so the response is fast.
  • Optionally return your own ID: a JSON body like { "TransactionId": "your-internal-id" } stores that value as the deposit's merchant transaction ID in Paybin, which makes reconciliation in the dashboard easier.
  • Be idempotent. Because unacknowledged callbacks are attempted again, the same callback can arrive more than once — including after your server already processed it but the response was lost. Use UniqueId + OrderId (+ Address) as a unique key and credit each deposit only once.
  • Do not depend on redelivery. Repeated attempts only happen for a limited time after the deposit is detected. Reconcile regularly with List deposits, for example by querying deposits in status 2 or 3.
  • Parse Amount precisely. Token amounts can have up to 18 decimals, which a double-precision float cannot hold. Use a decimal type when you credit balances.

POSTyour withdraw verification URL

Withdraw confirmation callback

This optional callback lets your server approve every withdrawal before Paybin creates it — a safety net against withdrawals you did not initiate. It is enabled when a withdraw verification URL is configured on your Paybin account; contact Paybin to set it up. When it is not configured, withdrawals are created without this check.

When a withdraw request arrives, Paybin first sends an HTTP POST with this PascalCase JSON body to your URL:

Payload

  • Name
    ReferenceId
    Type
    string
    Description

    The customer ReferenceId from the withdraw request.

  • Name
    MerchantTransactionId
    Type
    string
    Description

    Your unique ID of the withdrawal.

  • Name
    Amount
    Type
    decimal
    Description

    Amount to withdraw, in units of Symbol.

  • Name
    Symbol
    Type
    string
    Description

    Symbol of the withdrawal.

  • Name
    NetworkId
    Type
    integer
    Description

    NetworkId as sent in the withdraw request (0 if you omitted it).

  • Name
    Address
    Type
    string
    Description

    Destination address.

  • Name
    Signature
    Type
    string
    Description

    Reserved. Currently always NotIntegrated — it is not a verifiable signature.

Your response

  • To approve, return a 2xx status with a body that contains true, for example true or { "approved": true }.
  • To reject, return a non-2xx status, or a body that does not contain the text true anywhere (for example false). Paybin only checks whether the body contains true, so do not include that word in rejection bodies.

Errors, timeouts and rejections all stop the withdrawal, and the withdraw request fails with Z505.

Withdraw confirmation payload

{
  "ReferenceId": "customer-1001",
  "MerchantTransactionId": "WD-2026-000187",
  "Amount": 120.5,
  "Symbol": "TRX-USD",
  "NetworkId": 0,
  "Address": "TQrY8tryqsYVCYS3MFbtffiPp2ccyn4STm",
  "Signature": "NotIntegrated"
}

Node.js handler

app.post('/paybin/withdraw-confirmation', async (req, res) => {
  const p = req.body
  const pending = await findPendingWithdrawal(p.MerchantTransactionId)

  const approved =
    pending &&
    !pending.confirmedByPaybin &&
    pending.symbol === p.Symbol &&
    pending.address === p.Address &&
    amountsEqual(pending.amount, p.Amount) // compare as decimals, not floats

  if (!approved) return res.status(403).send('false')

  await markConfirmedByPaybin(pending.id)
  res.status(200).json({ approved: true })
})

Testing callbacks

  • Use the sandbox environment (https://sandbox.paybin.io) and check which symbols are available there in Sandbox vs production.
  • Your callback URL must be reachable from the public internet. During development, expose your local server through an HTTPS tunnel and pass the tunnel URL as CallbackUrl when you create a deposit address.
  • Test your signature check with the example payload above and the secret key my-secret-key before going live.
  • Log the raw body of every callback you receive. It makes it much easier to investigate a deposit with Paybin support.

Was this page helpful?