PayunitWallet &
payment gateway
Developers

Connect Payunit.
In hours.

A REST API, signed alerts and test keys. Documented in Arabic and English.

  1. 1Copy a test keyIt identifies your system.
  2. 2Set your alert URLTo get a signed alert with every payment.
  3. 3Send a test alertAnd check your system got it.
  4. 4Go liveSame URL, a live key.

Features

  • Ready examples

    An example for every request and reply.

  • Plugins and a PHP library

    They save you build time.

  • Safe keys

    A key shows once, and you revoke it anytime.

  • Refund in one call

    Straight from your system.

The API

Accept payments on your website, or with no website at all.

A REST API for your website, ready plugins for popular platforms, payment links and invoices you share as a link, and a QR code for your shop.

  1. Create an invoiceOne POST request with the amount and your order number.
  2. Send the customer to the payment pageThe payment page link comes back in checkout_url: a ready page with the Payunit wallet, USDT and cards, as you enable them.
  3. Receive the invoice.paid eventA webhook signed in the Payunit-Signature header. Verify it, then fulfil the order.

A test mode before you go live. Try everything with pay_test_ keys before going live with pay_live_ keys.

curl -X POST https://payunit.co/api/v1/invoices \
  -H "Authorization: Bearer pay_live_••••.••••" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": "25.00",
    "currency": "USD",
    "external_ref": "ORDER-1001",
    "description": "Order #1001",
    "expires_in": 3600,
    "success_url": "https://yourstore.com/thanks",
    "cancel_url": "https://yourstore.com/cart",
    "metadata": { "customer_id": "4821" }
  }'
// 201 Created
{
  "id": "inv_8F2kQ…",
  "status": "pending",
  "amount": "25.00",
  "currency": "USD",
  "fee": "…",
  "net": "…",
  "external_ref": "ORDER-1001",
  "checkout_url": "https://payunit.co/invoice/inv_8F2kQ…"
}
POST /webhooks/payunit
Payunit-Event-Id: evt_3Hq9…
Payunit-Timestamp: 1761300000
Payunit-Signature: v1=5f1c9a…

{
  "id": "evt_3Hq9…",
  "event": "invoice.paid",
  "created_at": "2025-10-24T10:00:00+00:00",
  "data": {
    "invoice_id": "inv_8F2kQ…",
    "status": "paid",
    "amount": "25.00",
    "currency": "USD",
    "external_ref": "ORDER-1001",
    "metadata": { "customer_id": "4821" }
  }
}

The fee and net amounts depend on the payment method and show before every payment. Other events: payment.refunded · refund.review · invoice.reversed · invoice.captured · invoice.voided

Ready plugins

Connect your existing store without writing code.

  • WooCommerce
  • WHMCS
  • OpenCart 3
  • OpenCart 4
  • PrestaShop
  • Magento 2
  • Easy Digital Downloads
  • FOSSBilling
  • PHP SDK
API examples

For shops: a QR code

A fixed code at the till, or an invoice for an exact amount. With daily, weekly and monthly reports.

REST · JSON

Ready-to-copy examples

Real requests to the Payunit API. Change the key and amount and try them.

Base URLhttps://payunit.co/api/v1

Send the amount and your order number, and get the payment page link for your customer.

POST /invoicescurl

curl -X POST https://payunit.co/api/v1/invoices \
  -H "Authorization: Bearer pay_live_3f9a….SECRET" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": "120.00",
    "currency": "USD",
    "external_ref": "order-1024",
    "success_url": "https://shop.example/thanks"
  }'

201 CreatedResponse

{
  "id": "inv_8Kq2Xz4LmT7pRw1c",
  "status": "pending",
  "amount": "120.00",
  "checkout_url": "https://payunit.co/invoice/inv_8Kq2…"
}

See whether the invoice is paid and how much you got after fees.

GET /invoices/{id}curl

curl https://payunit.co/api/v1/invoices/inv_8Kq2Xz4LmT7pRw1c \
  -H "Authorization: Bearer pay_live_3f9a….SECRET"

200 OKResponse

{
  "status": "paid",
  "amount": "120.00",
  "fee": "1.50",
  "net": "118.50",
  "paid_at": "2026-09-30T10:24:11Z"
}

Refund all or part of a payment. The idempotency key stops a double refund.

POST /payments/{id}/refundscurl

curl -X POST https://payunit.co/api/v1/payments/48213095517260/refunds \
  -H "Authorization: Bearer pay_live_3f9a….SECRET" \
  -H "Idempotency-Key: refund-1024-1" \
  -d '{ "amount": "40.00", "reason": "Returned item" }'

201 CreatedResponse

{
  "status": "completed",
  "amount": "40.00"
}

With a pay_test_ key every request works the same on fully separate test data. Pay or fail a test invoice and receive signed events just like live ones, without moving any money.

POST /invoices/{id}/simulatecurl

# Test key: same address, same requests, no money moves
curl -X POST https://payunit.co/api/v1/invoices/inv_test_8Kq2Xz4LmT7p/simulate \
  -H "Authorization: Bearer pay_test_7c1d….SECRET" \
  -d '{ "result": "paid" }'

200 OKResponse

{
  "id": "inv_test_8Kq2Xz4LmT7p",
  "status": "paid",
  "environment": "test"
}

Make sure the notification is from Payunit before you update the order in your system.

webhook.phpphp

// Verify the signature before trusting the event
$body      = file_get_contents('php://input');
$timestamp = $_SERVER['HTTP_PAYUNIT_TIMESTAMP'];
$signature = $_SERVER['HTTP_PAYUNIT_SIGNATURE'];

$expected = 'v1=' . hash_hmac('sha256', $timestamp . '.' . $body, $secret);

if (!hash_equals($expected, $signature)) {
    http_response_code(400); exit;
}
$event = json_decode($body, true);   // $event['event'] === 'invoice.paid'
The full reference is inside your business account.

Start today. For free.

A personal or a business account, with every fee in sight before you confirm.