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"
}'await hisarpay.invoices.simulate(invoice.id, { outcome: 'paid' });$hisarpay->invoices->simulate($invoice['id'], ['outcome' => 'paid']);client.invoices.simulate(invoice["id"], {"outcome": "paid"})| outcome | Amount sent | Result |
|---|---|---|
paid | Everything still due | invoice.paid |
partial | Half of what is due, or your amount (must be below it) | invoice.partial |
overpaid | 10% more than is due, or your amount (must be above it) | invoice.overpaid |
expired | No payment; the invoice expires now | invoice.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,partialorexpiredinvoices can be simulated; anything else returns409 conflict. - Calling it with a live key returns
403 live_key. Simulated payments are markedpayment.simulated: truein webhooks.
Scenarios to try
- Full payment: with
paid, check that the order is fulfilled exactly once. - Partial payment, then the rest: send
partial, thenpaid. Show the customer what is still due after the first event and fulfil after the second. - Overpayment: with
overpaid, check that you readoverpaid_amountand still fulfil the order. - Expiry: with
expired, test that stock and carts are released. - Late payment: send
expired, thenpaid. The payment is accepted and flaggedpayment.late: true. - 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"
}'await hisarpay.invoices.simulate(invoice.id, { outcome: 'partial', amount: '20' });$hisarpay->invoices->simulate($invoice['id'], ['outcome' => 'partial', 'amount' => '20']);client.invoices.simulate(invoice["id"], {"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.pingevent. 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$header = \HisarPay\Webhook::generateTestHeader($payload, $secret);from hisarpay import webhooks
header = webhooks.generate_test_header(payload, secret)