Dev tools

NerezPay CLI and Live Explorer

nerezpay-cli tails webhooks without a public tunnel. The Live Explorer in these docs fires requests right from the page.

Two tools to spin up a local integration in a minute: nerezpay-cli tails webhooks without a public tunnel, Live Explorer fires requests straight from the docs page.

Live Explorer (on this page)

The ▶ Run button in any endpoint header opens a popup with a pre-filled request. Enter your sk_test_… key once — it\u2019s cached in browser localStorage. Then click Run and see a real API response.

  • You can edit the request body inline: amount = 100099 to get insufficient_funds; 100050 for the 3DS flow; and so on (see the Sandbox section).
  • The response shows HTTP status, time and pretty-printed body. A "copy" button sits nearby.
  • On sk_live_… we\u2019ll ask for confirmation: the request goes to the real bank, so an accidental Run in production mode isn\u2019t possible.

nerezpay-cli — webhooks without ngrok

A local helper that listens to merchant events via SSE and forwards them as POSTs to localhost. Equivalent to stripe-cli listen: your dev server receives real webhooks without exposing a public URL.

Install

go install github.com/nerezpay/cli/nerezpay@latest

# or download a release binary for your OS:
# https://github.com/nerezpay/cli/releases

Login: nerezpay login

Save the key once into ~/.nerezpay/config.json. From then on nerezpay listen, nerezpay trigger and other commands pick it up on their own.

$ nerezpay login
nerezpay API key (sk_test_… or sk_live_…): sk_test_xxxxxx_yyyy
✓ profile "default" saved to ~/.nerezpay/config.json
  key: sk_test_xxx••••••yyyy
  url: https://api.nerezpay.ru

# Multiple profiles:
$ nerezpay login --profile staging --base-url https://api.staging.nerezpay.ru
$ nerezpay status
Profiles:
* default      sk_test_xxx••••••yyyy  https://api.nerezpay.ru
  staging      sk_test_aaa••••••bbbb  https://api.staging.nerezpay.ru
$ nerezpay use staging
$ nerezpay logout --profile staging

File mode 0600, plus a test GET before saving — invalid keys are rejected at the login step.

Trigger events: nerezpay trigger

To drive your webhook handler through the main scenarios without crafting amounts by hand:

$ nerezpay trigger payment.succeeded
✓ payment 5a331a39-…, status=succeeded, mode=test

$ nerezpay trigger payment.failed
✓ payment 8c7f12ab-…, status=failed, mode=test

$ nerezpay trigger payment.refunded
→ payment 9b2c1f8a-… created, waiting for succeeded…
✓ refund 4d11e3c4-…, status=succeeded, amount=10000

$ nerezpay trigger payment.cancelled
✓ payment 7e8aa4dd-… cancelled

$ nerezpay trigger payout.failed
✓ payout f47ac10b-…, status=failed, mode=test

Under the hood — regular POSTs to the public API with the right simulator triggers (see the Sandbox section). When nerezpay listen is running, webhooks immediately reach your dev server.

Using listen

# Auto credentials from login:
nerezpay listen --forward-to http://localhost:3000/nerezpay/hook

# Or ad-hoc via ENV:
export PSP_API_KEY=sk_test_xxxxxx
nerezpay listen --forward-to http://localhost:3000/nerezpay/hook

What happens on start:

  1. CLI opens an SSE stream at /v1/public/cli/listen using your key.
  2. The server issues a one-time webhook secret for this session. CLI prints it on the first line: cli_a3f9e7…. Put it in PSP_WEBHOOK_SECRET on your dev server.
  3. Every merchant event (payment, payout, refund) is wrapped in the standard webhook envelope, signed with HMAC-SHA256, and POSTed to the --forward-to URL.
nerezpay-cli: connected, forward → http://localhost:3000/nerezpay/hook
nerezpay-cli: webhook secret for this session: cli_a3f9e7…
nerezpay-cli: put it into PSP_WEBHOOK_SECRET on your dev environment
             so verifyWebhook passes.

  14:01:23 [payment.succeeded     ] evt_8f9a… → http://localhost:3000/nerezpay/hook 200 (12ms)
  14:01:24 [payment.refunded      ] evt_a23b… → http://localhost:3000/nerezpay/hook 200 (8ms)
Headers and body are exactly the same as the production webhook worker emits. The code you write for the production handler doesn\u2019t need adapting for local: verifyWebhook(rawBody, signature, secret) works the same way.

Auto-reconnect

If the connection drops (Wi-Fi, server restart), CLI sleeps 3 seconds and reconnects. Events delivered mid-drop are lost for the CLI — this is a dev mode. For guarantees, use a regular webhook endpoint in the dashboard with a fixed URL: retries up to ~3.5 days.

Flags

FlagValue
--forward-torequired. Local URL to POST webhooks to.
--api-keyAPI key. Defaults to env PSP_API_KEY.
--base-urloverride base URL (for staging / local backend).