Nice Paydocs API version 2026-12-01 OpenAPI

TypeScript and PHP SDKs

Both SDKs are thin: their types and methods are generated from our OpenAPI document; signing, idempotency, retries and webhook verification are written by hand and tested against the same test vectors as our server. Neither has third-party dependencies.

TypeScript @nicepay/sdk-tsPHP nicepay/sdk-php
Runs onNode 20.3+, Bun, DenoPHP 8.1+ with ext-curl, ext-json, ext-sodium
SigningHMAC-SHA256 and Ed25519HMAC-SHA256 and Ed25519 (libsodium)
Idempotencya key per money call unless you pass one; reused on retriessame
Retriesat most 3, back-off with jitter, only where safe (table)same
WebhooksconstructEvent(rawBody, header), keys cached, rotation handledsame, with an optional cache_file
Safe credithandlePayinEvent(event, creditOnce)handlePayinEvent($event, $creditOnce)
Moneydecimal strings; Money helper on bigintdecimal strings; Money helper on int (no bcmath needed)
StreamWebSocket client with token refresh and resumenot included
ErrorsNicePayError (code, requestId, retryable), NicePayConnectionError (outcomeUnknown)ApiException (errorCode, requestId, retryable), ConnectionException (outcomeUnknown)

Every API operation is a method named after its operation id in the reference: createPayin, getPayin, listPayins, createPayout, listEvents, …

TypeScript

TypeScript
import { NicePay } from "@nicepay/sdk-ts";

const nicepay = new NicePay({
  keyId: process.env["NICEPAY_KEY_ID"] ?? "",
  secret: process.env["NICEPAY_KEY_SECRET"] ?? "", // or privateKey for an Ed25519 key
});
const payin = await nicepay.createPayin({ merchant_order_id: "DEP-1", amount: "100.00", currency: "INR", method: "upi", customer: { ref: "p1" } }, { idempotencyKey: "DEP-1" });

Options: baseUrl (default the production API — test and live use the same host), maxRetries (3), timeoutMs (30,000 per attempt), apiVersion, fetch. Per call: idempotencyKey, maxRetries, timeoutMs, signal.

PHP

PHP
$nicepay = new NicePay\Client([
    'key_id' => getenv('NICEPAY_KEY_ID'),
    'secret' => getenv('NICEPAY_KEY_SECRET'), // or 'private_key' for an Ed25519 key
]);
$payin = $nicepay->createPayin(['merchant_order_id' => 'DEP-1', 'amount' => '100.00', 'currency' => 'INR', 'method' => 'upi', 'customer' => ['ref' => 'p1']], ['idempotency_key' => 'DEP-1']);

Objects come back as associative arrays, exactly as the JSON; money stays a string. Options: base_url, max_retries, timeout_ms, api_version, transport (your own HTTP stack). A float anywhere in the parameters is refused before anything is sent.

Money helper

TypeScript
import { Money } from "@nicepay/sdk-ts";
const total = Money.of("0.10", "INR").add(Money.of("0.20", "INR")); // "0.30", exactly
const usdt = Money.of("25.500000", "USDT"); // six decimal places; usdt.minor === 25500000n
PHP
$minor = NicePay\Money::toMinor('10000.50'); // 1000050 (INR unless you name the currency)
$total = NicePay\Money::of('0.10', 'INR')->add(NicePay\Money::of('0.20', 'INR')); // "0.30"
$usdt = NicePay\Money::toMinor('25.500000', 'USDT'); // 25500000: USDT has six decimal places

The helper knows each currency's decimal places (INR two, USDT six). Always pass the object's own currency: an amount with more places than its currency has is refused, never rounded.

No SDK

Any language with HTTPS, SHA-256 and HMAC-SHA256 (or Ed25519) can call the API: see signing by hand and check your code against the test vectors.

Versions

The SDKs follow semantic versioning. A release names the API version it was generated from; it never contains a default host other than our production API, and never logs request bodies.