Skip to content
HisarPay

A REST API for your own integration

Selling on a platform without a ready-made plugin? The API lets you do everything the dashboard does, in code. It speaks JSON, reports errors in one consistent shape, and its OpenAPI definition is public.

  • REST
  • OpenAPI 3.1
  • Webhooks

What it does

  • Endpoints for invoices, payment links, withdrawals, balances, reports and rates.
  • Safe retries with the Idempotency-Key header: the same request is never processed twice.
  • Multiple webhook endpoints with event filters; after a secret rotation the old secret stays valid for 24 hours.
  • A test mode that never touches the blockchain, plus a simulate endpoint to trigger payment scenarios.
  • A request ID and RateLimit-* headers on every response, and one error shape everywhere.
An API request and its response

Requirements

Base URL
https://hisarpay.com/v1
Authentication
Authorization: Bearer hp_live_… or hp_test_…
Format
JSON bodies, UTF-8; amounts as decimal strings
Rate limit
300 requests per minute per key

Setup

  1. Step 1

    Create an API key

    In the dashboard, open Developers → API keys and create a key. Keep it on your server only, and optionally restrict it to specific IP addresses.

  2. Step 2

    Create an invoice

    Send the price in USD; the customer picks TRX or USDT on the payment page. Reuse the same Idempotency-Key for the same order and retries after a network error are safe.

    cURL
    curl https://hisarpay.com/v1/invoices \
      -H "Authorization: Bearer $HISARPAY_API_KEY" \
      -H "Idempotency-Key: order_1001" \
      -H "Content-Type: application/json" \
      -d '{
        "price_usd": "49.90",
        "order_id": "order_1001",
        "success_url": "https://shop.example/thanks"
      }'
  3. Step 3

    Listen for webhooks

    Each notification carries a timestamp and an HMAC-SHA256 signature of the raw body. Verify the signature, drop duplicates by event ID and answer quickly with a 2xx.

    HTTP
    POST /webhooks/hisarpay HTTP/1.1
    Content-Type: application/json
    User-Agent: HisarPay-Webhook/1.0
    X-HisarPay-Event-Id: 5f0c6c1e-8a51-4c7e-9d0e-2b1f4f6a9c11
    X-HisarPay-Signature: t=1760000000,v1=5257a869e7ecebeda32affa6…
    
    {"id":"5f0c6c1e-…","type":"invoice.paid","livemode":true,"data":{"invoice":{…},"payment":{…}}}
  4. Step 4

    Try the scenarios in test mode

    On an invoice created with a test key, trigger the paid, underpaid, overpaid and expired cases with the simulate endpoint.

    cURL
    curl https://hisarpay.com/v1/invoices/$INVOICE_ID/simulate \
      -H "Authorization: Bearer $HISARPAY_TEST_KEY" \
      -H "Content-Type: application/json" \
      -d '{ "outcome": "partial", "amount": "20" }'

Headers

Headers used in requests and responses:

Authorization
Your API key, prefixed with Bearer.
Idempotency-Key
A unique key on POST requests. A repeat with the same key returns the first response.
RateLimit-Remaining
Requests left in the current minute. Sent with RateLimit-Limit and RateLimit-Reset.
X-HisarPay-Signature
The signature on webhook requests: t=<time>,v1=<hmac>.
X-HisarPay-Event-Id
The webhook event ID. Store it to drop duplicates.

Resources

Parameters and example responses for every endpoint are in the API reference in the docs.

EndpointWhat for
/v1/invoicesCreate, list, look up by order ID, cancel, and simulate in test mode.
/v1/payment-linksReusable payment links with a fixed or open amount.
/v1/withdrawalsSingle withdrawals.
/v1/balancesBalances and balance transactions.
/v1/webhook-endpointsEndpoints, event filters and secret rotation.
/v1/eventsEvent history and resending.
/v1/ratesCurrent TRX and USDT rates.

Frequently asked questions

Can I fulfil orders when the customer returns from the payment page?
We advise against it. Customers can close the return page or open the URL by hand. Fulfil on a verified invoice.paid webhook, or on the invoice status you read from the API.
What happens when a webhook fails?
HisarPay retries at growing intervals until it gets a 2xx. The dashboard shows the delivery history and lets you resend with one click, and /v1/events lets you fetch anything you missed.
What do error responses look like?
Every error has the shape { "error": { "code", "message", "request_id" } }. The code is stable and meant for machines; share the request_id when you ask support for help.
Where do I get the OpenAPI definition?
The API reference in the docs is generated from the OpenAPI 3.1 definition, and the file can be downloaded. Use it directly with Postman, Insomnia or client generators.

Official SDKs

Node.js, PHP and Python libraries with typings, automatic retries and webhook verification built in.

  • Node.js
  • PHP
  • Python

WooCommerce

Adds TRX and USDT to your checkout and updates the order by itself once the payment confirms.

  • WP 6+
  • WC 8+
  • PHP 7.4+
  • HPOS

WHMCS

Adds a crypto option to your server and domain invoices; the payment is entered on the WHMCS invoice by itself.

  • WHMCS 8
  • PHP 7.4+

Your first collection is an e-mail away

Sign-up is free; your test keys are ready the moment you confirm your e-mail.