# 11. Security practices

## Credentials

- [ ] Call the API from your server only. The secret key never reaches a browser, an app or a URL users can see.
- [ ] Keep keys in a secret store or environment variables, not in code.
- [ ] Pay-in status requests carry the keys in the query string: redact them from your request logs.
- [ ] Rotate the secret key (merchant portal → **Rotate keys**) if it may have leaked, and periodically. The old secret stops at once.
- [ ] Everything is HTTPS. Plain HTTP is refused.

## Webhooks

- [ ] Your `webhookUrl` and `callbackUrl` are HTTPS, public, and answer 2xx within 8 seconds.
- [ ] Every webhook's **signature is checked** over the raw body, and timestamps older than 5 minutes are refused.
- [ ] Duplicate deliveries are harmless: credit once per `transactionId`, only on `approved`.
- [ ] Before crediting, `orderId`, `userId` and `amount` match the pay-in you created.

## Pay-ins

- [ ] Each deposit has its own `orderId`. A timed-out create call is retried with the same `orderId`.
- [ ] Both your `orderId` and Royal Pay's `transactionId` are stored.
- [ ] The customer is redirected to `paymentUrl` in the browser they pay from, and nothing opens it first.
- [ ] Pay-ins still `progress` or `pending` after an hour are checked with [4. Get transaction status](https://docs.royalpe.site/payin/transaction-status).

## Payouts

- [ ] Only whitelisted servers (IPs registered with Royal Pay) can call payout endpoints.
- [ ] Payouts go through your own approval process before you call the API: each call moves real money.
- [ ] Payouts are followed by webhook or status until `completed`, and a `reversed` after `completed` is handled.

---

Source: https://docs.royalpe.site/notes/security · All docs: https://docs.royalpe.site/llms-full.txt · Updated 2026-11-30
