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
npm install @hashrytech/pay-nodeWhat 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.
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.environmentis required:"sandbox"or"live". - The payment calls are
hashry.paymentIntents.create,.createAttempt,.retrieve,.refresh,.canceland.list. The client also haspaymentLinks,paymentMethods,subscriptionIntents,subscriptionsandchannel.self(). - Request fields and results use the API's own names, such as
external_referenceandembed_url. Results are the API's JSON as it is, with types from the API schema (PaymentIntentand others). - Amounts are strings with 2 decimal places, such as
"2500.00". Never a number. - Never log a result whole. A payment holds
embed_urlandstatus_token. The SDK's own errors and logs never hold them. - Leave
baseUrlunset. It accepts only Hashry's API orlocalhost, so a wrong setting can't send your key to another server. - The full list of endpoints is in the API reference.