Package Exports
- @zenobank/sdk
Readme
@zenobank/sdk
Official TypeScript SDK for the Zeno Bank Crypto Payment Gateway API.
- Dashboard - Create your account and get an API key
- Documentation - Full API documentation
- Checkout Demo
- Support
How it works
- Create a checkout with an amount and currency
- Redirect your customer to the
checkoutUrlto complete the payment - The customer pays with crypto
- Zeno Bank sends a webhook to your server when the checkout status changes (e.g. completed, expired)
- 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/sdkQuick 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_0gJfH4a9B2Eg1jpEScheckouts.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