@meru.app/checkout-node
v0.1.0
Published
Server-side SDK for Meru Checkout — create and retrieve crypto checkout sessions with your secret key.
Maintainers
Readme
@meru.app/checkout-node
Server-side SDK for Meru Checkout. Create and retrieve crypto checkout sessions (crypto exchanges + QR Bolivia) with your secret key.
Use this only on your backend — it holds
sk_live_…. The customer-facing part (@meru.app/checkout-react) only ever receives the session id/url.
Install
npm install @meru.app/checkout-node
# Node 18+ (uses global fetch)Create a session
import { MeruCheckout } from '@meru.app/checkout-node';
const meru = new MeruCheckout(process.env.MERU_SECRET_KEY); // sk_live_…
const session = await meru.checkouts.create({
amountFiat: 50,
fiatCurrency: 'USD',
paymentMethod: 'qr-bolivia', // or 'crypto-exchanges', or omit to let the customer choose
reference: 'order_123',
successUrl: 'https://your-site.com/thanks',
cancelUrl: 'https://your-site.com/cart',
});
// Redirect the customer to session.url, or pass session.id to the React SDK.
console.log(session.id, session.url);Express example
app.post('/checkout', async (req, res) => {
const session = await meru.checkouts.create({
amountFiat: req.body.amount,
reference: req.body.orderId,
});
res.json({ id: session.id, url: session.url });
});Idempotency
Pass an idempotency key so a retried create (network blips, retries) returns the same session instead of creating a duplicate — scoped to your account:
const session = await meru.checkouts.create(
{ amountFiat: 50, reference: 'order_123' },
{ idempotencyKey: 'order_123' }, // any stable unique string per logical request
);Reconcile status
const checkout = await meru.checkouts.retrieve(session.id);
if (checkout.status === 'succeeded') {
// fulfill the order — this is the authoritative check
}
// 'created' | 'pending' | 'processing' | 'succeeded' | 'failed' | 'expired'Configuration
new MeruCheckout({
apiKey: process.env.MERU_SECRET_KEY, // or the first positional arg
baseUrl: 'https://checkout-api.meru.com', // default; override for sandbox/self-host
timeoutMs: 20000,
// fetch: customFetch, // optional (defaults to global fetch)
});Errors
Non-2xx responses throw MeruApiError with .status and .body:
import { MeruApiError } from '@meru.app/checkout-node';
try {
await meru.checkouts.create({ amountFiat: 50 });
} catch (e) {
if (e instanceof MeruApiError) {
console.error(e.status, e.body);
}
}API
| Method | Calls | Returns |
| --- | --- | --- |
| meru.checkouts.create(params) | POST /v1/checkouts | CheckoutSession (with url) |
| meru.checkouts.retrieve(id) | GET /checkouts/:id | CheckoutSession |
CreateCheckoutParams: amountFiat?, fiatCurrency?, paymentMethod?
('crypto-exchanges' | 'qr-bolivia'), token? ('USDC' | 'USDT'), description?,
reference?, clientReference?, successUrl?, cancelUrl?, metadata?.
