Skip to main content
The official Node.js / TypeScript library for the Yativo Fiat API. It sends your API key on every request, adds idempotency keys to writes, retries temporary failures safely, raises typed errors and verifies webhooks.

Package

@yativo/fiat-sdk

Requires

Node.js 18 or newer (works with TypeScript, ES modules and CommonJS)

Source

Yativo/yativo-fiat-node

Install

Configure

You need an API key with your server’s IP address on its IP whitelist. Put the key and secret in environment variables, never in code:
.env
Node.js 20.6+ can load the file for you: node --env-file=.env app.mjs. On older versions, use the dotenv package or export the variables in your shell. The client reads these variables automatically. You can also pass them yourself:
Use the SDK on your server only. A browser or mobile app would expose your API secret.

Make your first request

first-request.mjs
You should see Key check: pass and your balances. pass means the key works from this server.

Accept a payment

A deposit gives your customer a hosted page to pay with a local method. You’re credited in the wallet you choose.
1

Find a payment method

List the methods for your customer’s country (three-letter code) and currency. The method’s id is the deposit’s gateway.
2

Create the deposit

amount is in the method’s currency. currency is the wallet you’re credited in: one of the method’s base_currency values. Send your order ID as the idempotency key so a retry never creates a second deposit.
3

Confirm before you fulfil

When the customer comes back, or a deposit.updated webhook arrives, read the deposit from the API. A redirect back to your site isn’t proof of payment.
A deposit’s status is pending, processing, success, failed, cancelled or expired.

Handle webhooks

Register your URL once and store the secret it returns as YATIVO_WEBHOOK_SECRET. Your account has one webhook URL.
The SDK checks the Signature header against the raw body and routes each event to your code. It answers 200 when your code succeeds, 401 for a bad signature and 500 when your code fails, so Yativo retries.
Other frameworks:
Answer within 3 seconds and do slow work in the background. The same event can arrive more than once, so skip ones you’ve already handled. See Webhooks for every event.

Card Checkout

Card Checkout gives your buyer a hosted page to pay by card, Apple Pay or Google Pay. Your account needs Card Checkout access, and the selling customer needs an approved card_checkout endorsement.
Treat the order as paid only after the card_checkout.order.paid webhook, confirmed by reading the order. The link works for 60 minutes.

Send a payout

Progress arrives through the payout.updated webhook. See Payouts.

Everyday tasks

Every endpoint is wrapped. The full method list is in docs/REFERENCE.md. To call an endpoint the SDK doesn’t wrap yet, with the same authentication and retries:

Errors

BadRequestError (400), AuthenticationError (401), PermissionDeniedError (403), NotFoundError (404), ConflictError (409), ValidationError (422), RateLimitError (429), APIError (5xx) and APIConnectionError (no answer). They all extend YativoError and have status, code, message and fields. Network errors, 429 and 5xx are retried twice with backoff, using the same idempotency key. Other errors are never retried. See Troubleshooting for what each common error means.

Pagination

Options

Test in sandbox

Use sandbox keys with YATIVO_ENVIRONMENT=sandbox. No real money moves. Card Checkout test cards: 4242 4242 4242 4242 succeeds and 4000 0000 0000 0002 is declined, with any future expiry and any CVC. Send yourself sample webhooks:

More

Runnable examples

A quick start, a complete checkout server with webhooks, and card payments.

Every method

All endpoints as Node.js / TypeScript calls.