Skip to main content
@orsunpay/node 0.1.0 is a server-side TypeScript/Node client with no runtime dependencies. It supports ESM and CommonJS and requires Node 20 or newer. Its types are generated from the merchant OpenAPI document. Install the supplied package in your server application:

Configure the client

There is no default server: baseUrl is required and must be HTTPS (plain HTTP is allowed only for localhost and 127.0.0.1). Redirects are refused so the API key cannot follow a redirect to another host. merchantId is set once on the client, not per call. Keep the SDK and your keys on the server.

Operations

Use payments.iterate and refunds.iterate to read successive pages as an async iterator. For usage billing, use the HTTP API. Every call resolves to { data, idempotencyKey?, replayed, requestId? }.

Create a sale

amount must be a string; a number is a TypeScript error and throws TypeError before any request. An accepted payment can still be pending or declined: inspect data.transaction. A replayed creation returns the original snapshot; use payments.retrieve(id) for the current status.

Idempotency and retries

If you omit idempotencyKey, the SDK generates a UUID and reuses it for its own retries. Supply and persist your own key so that retries after a process restart are also safe. The SDK retries GETs and keyed writes after network errors or timeouts, HTTP 502/503/504, 429, and 409 IDEMPOTENCY_IN_PROGRESS, with full-jitter backoff (500 ms base, 8 s cap), honouring Retry-After. A Retry-After above 60 seconds stops automatic retries. Other 4xx responses, paymentLinks.deactivate and cashier mutations are not retried.

Errors

Verify webhooks

verifyWebhook({ rawBody, signatureHeader, secrets, toleranceSeconds?, now? }) checks the HMAC-SHA256 signature with a constant-time comparison and a ±300-second default tolerance, then parses the JSON object. It does not validate the event schema: check the event type, merchant, order, livemode and amounts in your code. Reject requests with more than one OrsunPay-Signature header line. See webhooks.