API documentation

API integration guide

Three endpoints are all you need: create an invoice, receive the callback, check the status. Parameter names match FPayment, so most storefront scripts just change the domain and paste their keys.

1

The customer clicks top up

Your site calls /api/AddInvoice, gets url_payment back and redirects the customer there.

2

The customer sends USDT

They pick a network and send the exact amount with its unique decimals. The money lands straight in your wallet.

3

Payfjord calls you back

Once the chain has enough confirmations, we call your callback_url so you can credit the customer.

Create a payment invoice

POST or GET · https://payfjord.com/api/AddInvoice

Accepts JSON, form-urlencoded and multipart/form-data — PHP's cURL sample sends multipart, so it works unchanged.

Parameters

merchant_idRequiredStore ID. Never expose it publicly.
api_keyRequiredThe store's API key. Never expose it publicly.
nameRequiredInvoice name, shown to the customer.
amountRequiredThe amount to collect, in USD. The customer transfers this plus the identifying decimals.
request_idRequiredYour own order ID. Re-sending the same request_id returns the existing invoice instead of creating a new one.
descriptionDescription, usually the customer's username or email.
callback_urlURL that receives the transaction result. Leave it empty and this invoice gets no callback.
success_urlRedirect used when the customer clicks Back to website after paying.
cancel_urlRedirect used when the invoice expires.
tao-hoa-don.php
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => "https://payfjord.com/api/AddInvoice",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array(
      'merchant_id'  => "MERCHANT_ID_CUA_BAN",
      'api_key'      => "API_KEY_CUA_BAN",
      'name'         => 'Nap tien vao website abc.xyz',
      'description'  => 'Username hoac email cua khach',
      'amount'       => '12',                       // amount in USD
      'request_id'   => 'don_hang_48127',           // your own order ID, for reconciliation
      'callback_url' => 'https://website-cua-ban.com/payfjord-callback',
      'success_url'  => 'https://website-cua-ban.com/thanh-cong',
      'cancel_url'   => 'https://website-cua-ban.com/that-bai'
  ),
));
$response = curl_exec($curl);
curl_close($curl);
$result = json_decode($response, true);

if ($result['status'] == 'success') {
    $trans_id    = $result['data']['trans_id'];     // Payfjord transaction code
    $url_payment = $result['data']['url_payment'];  // redirect the customer here

    // SAVE trans_id to your database before redirecting, so you can check the status later
    // ...

    header("Location: " . $url_payment);
    exit;
} else {
    echo "Error: " . $result['msg'];
}
tao-hoa-don.js
const res = await fetch("https://payfjord.com/api/AddInvoice", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    merchant_id: "MERCHANT_ID_CUA_BAN",
    api_key: "API_KEY_CUA_BAN",
    name: "Top up on abc.xyz",
    description: "Customer's username or email",
    amount: "12",
    request_id: "don_hang_48127",
    callback_url: "https://website-cua-ban.com/payfjord-callback",
    success_url: "https://website-cua-ban.com/thanh-cong",
    cancel_url: "https://website-cua-ban.com/that-bai",
  }),
});

const result = await res.json();

if (result.status === "success") {
  // Save trans_id to your database before redirecting, so you can check the status later
  redirect(result.data.url_payment);
}

Response

response.json
{
  "data": {
    "trans_id": "TX8170250689345912",
    "amount": "12.04",              // what you asked for PLUS the identifying decimals — store this to reconcile against
    "status": "waiting",
    "url_payment": "https://payfjord.com/payment/TX8170250689345912"
  },
  "status": "success",
  "msg": "Invoice creation successful!"
}

Networks that use a coin other than USDT

Nothing extra to do, and no extra fields to read. Whichever network the customer picks, the API takes and returns the amount in USD — Bitcoin and Litecoin included. Just credit amount to the customer as usual.

The amount in the network's own coin appears only on the checkout page, because that is the figure the customer types into their wallet.

Ready to accept USDT on your website?

Create an account, add a wallet, and try an invoice in minutes.

Get started

Payfjord