JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 38
  • Score
    100M100P100Q94251F
  • License MIT

Official ZenoBank TypeScript SDK

Package Exports

  • @zenobank/sdk

Readme

@zenobank/sdk

Official TypeScript SDK for the Zeno Bank Crypto Payment Gateway API.

How it works

  1. Create a checkout with an amount and currency
  2. Redirect your customer to the checkoutUrl to complete the payment
  3. The customer pays with crypto
  4. Zeno Bank sends a webhook to your server when the checkout status changes (e.g. completed, expired)
  5. Verify the webhook signature and handle the event in your system

Installation

npm install @zenobank/sdk
# or
pnpm add @zenobank/sdk
# or
yarn add @zenobank/sdk

Quick Start

import { ZenoBankClient } from '@zenobank/sdk';

const zenoBank = new ZenoBankClient({
  apiKey: 'your-api-key',
});

// Create a checkout
const checkout = await zenoBank.checkouts.create({
  orderId: 'order-12345',
  priceAmount: '100',
  priceCurrency: 'USD',
  successRedirectUrl: 'https://example.com/success',
});

// Redirect your customer to this URL to complete the payment
console.log(checkout.checkoutUrl);
// => https://pay.zenobank.io/ch_0gJfH4a9B2Eg1jpES

checkouts.get(checkoutId)

Retrieve an existing checkout by ID.

const checkout = await zenoBank.checkouts.get('ch_0gJfH4a9B2Eg1jpES');

// checkout.id            — "ch_0gJfH4a9B2Eg1jpES" — Checkout ID
// checkout.orderId       — "order-12345" — Your order identifier
// checkout.priceCurrency — "USD" — Currency code
// checkout.priceAmount   — "100" — Amount requested in priceCurrency
// checkout.paidAmount    — "85.50" — Amount actually paid in priceCurrency
// checkout.status        — "OPEN" | "COMPLETED" | "EXPIRED" | "CANCELLED" | "PARTIALLY_PAID"

Webhooks

Receive notifications when a checkout status changes so you can handle it internally.

To start receiving webhooks, add your endpoint URL in the Zeno Bank Dashboard.

webhooks.isValid(params): boolean

Verify that a webhook request is authentic and was sent by Zeno Bank. Returns a boolean.

const isValid = zenoBank.webhooks.isValid({
  secret: 'whsec_your_webhook_secret',  // From the Dashboard
  rawBody: req.body,                      // Raw request body (string or Buffer)
  headers: req.headers,                   // Request headers
});

Full Example (Express)

import { ZenoBankClient } from '@zenobank/sdk';
import type { WebhookEvent } from '@zenobank/sdk';

const zenoBank = new ZenoBankClient({ apiKey: 'your-api-key' });

app.post('/webhooks/zenobank', express.raw({ type: 'application/json' }), (req, res) => {
  const isValid = zenoBank.webhooks.isValid({
    secret: 'whsec_your_webhook_secret',
    rawBody: req.body,
    headers: req.headers,
  });

  if (!isValid) {
    return res.status(400).send('Invalid signature');
  }

  const event: WebhookEvent = JSON.parse(req.body.toString());

  switch (event.type) {
    case 'checkout.completed':
      // Payment successful — fulfill the order
      break;
    case 'checkout.expired':
      // Checkout expired — notify the customer
      break;
    case 'checkout.partially_paid':
      // Partial payment received — decide how to handle
      break;
  }

  res.status(200).send('OK');
});

License

MIT