Quickstart
Create a test payment, pay it, and receive its webhook in a few minutes.
This guide takes you from sign-up to a paid test payment and a verified webhook. No real money moves.
Sign up
Create an account at pay.piti.id/dashboard (Daftar). Your account can use test mode at once: the switch at the top right of the dashboard shows Mode uji.
Create a test API key
Open Developer in the dashboard. Every account starts with one app. Choose Buat kunci (create key) on your app.
The key starts with lbp_test_ and is shown once: copy it into your server's environment, for example as PITI_API_KEY. Keep it on your server only, never in a web page or a mobile app.
Create a payment
Call POST /v1/payments from your server. It needs an Idempotency-Key header, so a retry never makes a second payment (see Idempotency).
curl https://pay.piti.id/v1/payments \
-H "Authorization: Bearer lbp_test_xxxxxxxx" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-1042-1" \
-d '{
"amount": 150000,
"reference": "INV-1042",
"method": "qris",
"description": "Order 1042",
"return_url": "https://shop.example/orders/1042"
}'The answer is 201 with the payment. Shortened:
{
"id": "pay_8Fq2...",
"object": "payment",
"mode": "test",
"reference": "INV-1042",
"method": "qris",
"status": "pending",
"currency": "IDR",
"amount": 150000,
"total": 150000,
"checkout_url": "https://pay.piti.id/pay/pay_8Fq2...",
"qris": { "content": "...", "expires_at": "2026-12-01T03:05:00Z" },
"va": null,
"expires_at": "2026-12-02T03:00:00Z",
"paid_at": null
}Save id with your order. The full object is in the API reference.
Open the payment page
Open checkout_url in a browser. This is the page your customer sees. In test mode it carries the banner Mode uji · Tidak ada uang sungguhan (test mode, no real money). The test QR is not a real QRIS code: a bank app cannot pay it.
Set your webhook URL
On the Developer page, set your app's webhook URL. It must be reachable from the internet (http is allowed in test mode; a localhost address is not, so use a tunnel while you develop). We show the signing secret (whsec_...) once and send a webhook.test event to the URL at once: answer it with any 2xx.
Simulate the payment
In test mode you pay a payment yourself, in any of three ways:
- the Simulasikan pembayaran button on the payment page;
- Simulasikan dibayar on the payment's detail in the dashboard;
- the API:
curl -X POST https://pay.piti.id/v1/payments/pay_8Fq2.../simulate \
-H "Authorization: Bearer lbp_test_xxxxxxxx"The payment becomes paid through the same checks as a real payment, and we send payment.paid to your webhook URL.
Receive and verify the webhook
Each event is a POST with a JSON body and a LayerbeatPay-Signature: t=<unix time>,v1=<hex> header. v1 is the HMAC-SHA256 of t + "." + body, keyed with your signing secret. Check it against the raw body, refuse it if t is more than 5 minutes old, then answer 2xx.
import crypto from 'node:crypto';
import express from 'express';
function verify(rawBody, header, secret) {
const parts = Object.fromEntries((header ?? '').split(',').map((kv) => kv.trim().split('=')));
const t = Number(parts.t);
if (!parts.v1 || !Number.isInteger(t)) return false;
if (Math.abs(Date.now() / 1000 - t) > 300) return false; // older than 5 minutes
const expected = crypto.createHmac('sha256', secret).update(`${parts.t}.`).update(rawBody).digest('hex');
const a = Buffer.from(parts.v1, 'hex');
const b = Buffer.from(expected, 'hex');
return a.length === b.length && crypto.timingSafeEqual(a, b);
}
const app = express();
app.post('/webhooks/piti', express.raw({ type: 'application/json' }), (req, res) => {
if (!verify(req.body, req.get('LayerbeatPay-Signature'), process.env.PITI_WEBHOOK_SECRET)) {
return res.sendStatus(400);
}
const event = JSON.parse(req.body);
if (event.type === 'payment.paid') {
// Look up your order by event.data.reference or event.data.id,
// skip it if you already handled event.id, then fulfil the order.
}
res.sendStatus(200);
});
app.listen(3000);The body looks like this:
{
"id": "evt_3G5g...",
"object": "event",
"type": "payment.paid",
"mode": "test",
"created_at": "2026-12-01T03:01:12Z",
"data": { "id": "pay_8Fq2...", "object": "payment", "status": "paid", "reference": "INV-1042", "amount": 150000 }
}An event can arrive more than once: use its id to skip repeats. Retries, all event types and more languages are in Webhooks.
Next
- Read a payment any time with
GET /v1/payments/{id}. - Try a virtual account or let the customer choose.
- What test mode can and cannot do: Testing.
- To take real money, submit your business verification (Verifikasi bisnis in the dashboard); once it is approved, create a live key. See API keys & modes.