RazCrypto RazCrypto Docs
Dashboard Get API Keys
Docs Node.js SDK

Node.js SDK

Official Node.js SDK for RazCrypto. Accept USDT, USDC, DAI on BSC and Ethereum chains.

Installation

npm
npm install razcrypto-node

Initialize

JavaScript
const RazCrypto = require('razcrypto-node');
const razcrypto = new RazCrypto("YOUR_GATEWAY_ID", "YOUR_SECRET_KEY");

Create Payment

JavaScript
async function createOrder() {
    try {
        const payment = await razcrypto.payment.create({
            amount: 10.50,
            currency: 'USDT',
            chain: 'BSC',
            email: '[email protected]',
            callback_url: 'https://yourwebsite.com/webhook',
            custom_data: {
                order_id: 'ORD-12345',
                user_id: 'USER_123'
            }
        });

        console.log("Checkout URL:", payment.checkout_page);
        // Redirect your user to payment.checkout_page
    } catch (error) {
        console.error("Error:", error.message);
    }
}

Verify Webhook (Express.js)

JavaScript
const express = require('express');
const app = express();

app.post('/webhook', express.raw({ type: 'application/json' }), (req, res) => {
    const signature = req.headers['x-razcrypto-signature'];
    const rawPayload = req.body.toString('utf8');
    const secretKey = process.env.RAZ_WEBHOOK_SECRET;

    const isValid = RazCrypto.Webhook.verifySignature(rawPayload, signature, secretKey);

    if (!isValid) {
        return res.status(401).json({ error: 'Invalid Signature' });
    }

    const data = JSON.parse(rawPayload);

    if (data.event === 'payment.completed') {
        const orderId = data.custom_data?.order_id;
        console.log('Payment completed for order:', orderId);
        // TODO: Mark order as paid in database
    }

    res.status(200).json({ status: 'ok' });
});

app.listen(3000);
Important: Use express.raw() middleware for webhook routes so you get the raw request body needed for signature verification.

Links