Node SDK

Developers · Hashry Pay

Hashry Pay Node SDK

@hashrytech/pay-node calls the Hashry Pay API from your server. It needs Node 22.12 or newer and has no dependencies. Never import it from browser code.

The Next.js, Express + React and SvelteKit pages already use it. Read this page to use it on another Node server, or to see what it does for you.

Install

Terminal
npm install @hashrytech/pay-node

What the SDK does for you

  • Gets an access token with POST /auth/token. It caches the token, gets a new one before it expires, and tries once more after a 401.
  • Sends your idempotency key. Every create takes { idempotencyKey }, and it is required. The SDK never makes one up.
  • Retries network errors, 5xx and 429 answers twice, with a growing wait. It retries only reads and calls with an idempotency key.
  • Checks webhook signatures on the raw bytes with verifyWebhook (see Webhooks).
  • Refuses a key in the wrong place, for example a test key with environment: "live", or the webhook secret as the client secret.
The token request it makes
POST https://api.hashrytech.com/auth/token
Content-Type: application/json

{ "grant_type": "client_credentials", "client_id": "...", "client_secret": "hsk_test_..." }

200 OK
{ "access_token": "...", "expires_in": 3600, "token_type": "Bearer", "scope": "..." }

How to use it

  • Create one client with new Hashry(...) and share it. environment is required: "sandbox" or "live".
  • The payment calls are hashry.paymentIntents.create, .createAttempt, .retrieve, .refresh, .cancel and .list. The client also has paymentLinks, paymentMethods, subscriptionIntents, subscriptions and channel.self().
  • Request fields and results use the API's own names, such as external_reference and embed_url. Results are the API's JSON as it is, with types from the API schema (PaymentIntent and others).
  • Amounts are strings with 2 decimal places, such as "2500.00". Never a number.
  • Never log a result whole. A payment holds embed_url and status_token. The SDK's own errors and logs never hold them.
  • Leave baseUrl unset. It accepts only Hashry's API or localhost, so a wrong setting can't send your key to another server.
  • The full list of endpoints is in the API reference.

Next: build it for your stack

Back to top

© 2026 Hashry Solutions Limited. All rights reserved.