Package Exports
- razcrypto-node
- razcrypto-node/src/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (razcrypto-node) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
RazCrypto Node.js SDK
Accept cryptocurrency payments (USDT, USDC, DAI) on BSC and Ethereum chains with ease using the official RazCrypto Node.js SDK.
Installation
npm install razcrypto-node
Quick Start
1. Initialize the API
JavaScript
const RazCrypto = require('razcrypto-node');
const razcrypto = new RazCrypto("YOUR_GATEWAY_ID", "YOUR_SECRET_KEY");
2. Create a Payment
JavaScript
async function createOrder() {
try {
const payment = await razcrypto.payment.create({
amount: 10.50,
currency: 'USDT',
chain: 'BSC',
email: 'customer@example.com',
callback_url: '[https://yourwebsite.com/webhook](https://yourwebsite.com/webhook)',
custom_data: {
order_id: 'ORD-12345'
}
});
console.log("Checkout URL:", payment.checkout_page);
// Redirect your user to this URL
} catch (error) {
console.error("Error:", error.message);
}
}
3. Verify Webhook (Express.js Example)
Always verify the webhook signature to ensure security.
JavaScript
const express = require('express');
const app = express();
// Note: Use express.raw() or express.text() if you need the raw body for signature matching
app.use(express.json());
app.post('/webhook', (req, res) => {
const signature = req.headers['x-razcrypto-signature'];
const rawPayload = JSON.stringify(req.body); // Ensure this matches raw incoming payload
const secretKey = "YOUR_SECRET_KEY";
const isValid = RazCrypto.Webhook.verifySignature(rawPayload, signature, secretKey);
if (isValid) {
const data = req.body;
if (data.event === 'payment.completed') {
const orderId = data.custom_data.order_id;
// TODO: Mark order as paid in database
}
res.status(200).send({ status: 'ok' });
} else {
res.status(401).send({ error: 'Invalid Signature' });
}
});