cevara-node
v1.0.1
Published
Official Node.js SDK for the Cevara USDT payment gateway (TRC20, BEP20, ERC20, BASE)
Downloads
41
Maintainers
Readme
cevara-node
Official Node.js SDK for the Cevara USDT payment gateway (TRC20, BEP20, ERC20, BASE).
npm install cevara-nodeUsage
import Cevara, { verifyWebhook, CevaraApiError } from "cevara-node";
const cevara = new Cevara(process.env.CEVARA_SECRET_KEY!);
// Create an invoice
const invoice = await cevara.invoices.create({
chain: "TRC20",
amount: "49.00",
order_id: "ORD-12345",
callback_url: "https://shop.example.com/webhooks/cevara",
});
// Retrieve / list
await cevara.invoices.retrieve(invoice.id);
await cevara.invoices.list({ limit: 20, status: "paid" });
// Balance
await cevara.balances.retrieve();
// Payout
await cevara.payouts.create({ chain: "TRC20", to: "T...", amount: "10.00" });Idempotency
const c = new Cevara(KEY, { idempotencyKey: "ord-12345-attempt-1" });
await c.invoices.create({ chain: "TRC20", amount: "10.00" });Verifying webhooks
import express from "express";
import { verifyWebhook } from "cevara-node";
app.post(
"/webhooks/cevara",
express.raw({ type: "application/json" }),
(req, res) => {
const ok = verifyWebhook(
req.body,
req.header("X-Cevara-Signature") ?? "",
process.env.CEVARA_WEBHOOK_SECRET!,
);
if (!ok) return res.status(401).end();
const event = JSON.parse(req.body.toString());
// ...
res.json({ received: true });
},
);Changelog
1.0.1
- Fix:
verifyWebhookno longer throwsDynamic require of "crypto" is not supportedwhen imported from an ESM project. Switched to a top-levelnode:cryptoimport. - Dual ESM/CJS build via
tsup. - More resilient response parsing (handles empty / non-JSON bodies).
1.0.0
- Initial release.
