Skip to content
HisarPay

Getting started

Test mode and simulation

In test mode, invoices and payment links behave exactly as in live mode; only no money moves. Simulate payments to try your integration in every scenario.

How test mode works

Requests made with a key that starts with hp_test_ run in test mode:

  • Invoices go through the real state machine and webhooks are sent in the same format as live ones.
  • Nothing touches the blockchain, no transfer is made and your balance does not change.
  • Test data shows up in the dashboard when test mode is on; it never mixes with live reports or balances.
  • Test keys cannot withdraw; that needs a live key.

Simulating payments

POST /v1/invoices/{id}/simulate behaves as if a payment arrived for a test invoice. The outcome field decides what happens:

curl -X POST https://hisarpay.com/v1/invoices/0b6a3f52-3c1d-4a7e-8f4b-1d2c3e4f5a6b/simulate \
  -H "Authorization: Bearer $HISARPAY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "outcome": "paid"
  }'
outcomeAmount sentResult
paidEverything still dueinvoice.paid
partialHalf of what is due, or your amount (must be below it)invoice.partial
overpaid10% more than is due, or your amount (must be above it)invoice.overpaid
expiredNo payment; the invoice expires nowinvoice.expired
  • If the customer has not picked a coin yet, the simulation picks USDT when it is allowed. USDT needs no exchange rate, so amounts are always predictable.
  • Only pending, partial or expired invoices can be simulated; anything else returns 409 conflict.
  • Calling it with a live key returns 403 live_key. Simulated payments are marked payment.simulated: true in webhooks.

Scenarios to try

  1. Full payment: with paid, check that the order is fulfilled exactly once.
  2. Partial payment, then the rest: send partial, then paid. Show the customer what is still due after the first event and fulfil after the second.
  3. Overpayment: with overpaid, check that you read overpaid_amount and still fulfil the order.
  4. Expiry: with expired, test that stock and carts are released.
  5. Late payment: send expired, then paid. The payment is accepted and flagged payment.late: true.
  6. Repeated event: resend the same event from the dashboard and check that the order is not processed twice.
curl -X POST https://hisarpay.com/v1/invoices/0b6a3f52-3c1d-4a7e-8f4b-1d2c3e4f5a6b/simulate \
  -H "Authorization: Bearer $HISARPAY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "outcome": "partial",
    "amount": "20"
  }'

Receiving webhooks locally

HisarPay only delivers events to public addresses; localhost and private network addresses are refused. During development, expose your local server through a tunnel (for example Cloudflare Tunnel) and add the resulting HTTPS address as a webhook endpoint.

  • The Send test button next to an endpoint in the dashboard sends one test.ping event. It is never retried.
  • In unit tests, use the SDKs’ test header helpers to produce a valid signature without any network:
const payload = JSON.stringify({
  id: 'evt_test',
  type: 'test.ping',
  livemode: false,
  created_at: new Date().toISOString(),
  data: {},
});
const header = HisarPay.webhooks.generateTestHeader({ payload, secret });
// POST payload to your handler with X-HisarPay-Signature: header