robuxpay
v1.0.1
Published
Official RobuxPAY SDK for Node.js - Accept Robux payments in your applications
Maintainers
Readme
RobuxPAY SDK
Official Node.js SDK for RobuxPAY - Accept Robux payments in your applications.
Installation
npm install robuxpayQuick Start
import RobuxPAY from 'robuxpay';
// Initialize client
const robuxpay = new RobuxPAY({
apiKey: 'rpay_your_api_key_here'
});
// List products
const products = await robuxpay.products.list();
console.log(products);
// Create a payment
const payment = await robuxpay.payments.create({
productId: 'prod_123',
userId: '568128963'
});
console.log('Payment URL:', payment.paymentUrl);
// Verify a payment
const verified = await robuxpay.payments.verify('pay_abc123');
console.log('Payment status:', verified.status);API Reference
Initialize Client
const robuxpay = new RobuxPAY({
apiKey: 'rpay_xxx', // Required: Your API key
baseUrl: 'https://...' // Optional: Custom API URL
});Products
List all products
const products = await robuxpay.products.list();Get a specific product
const product = await robuxpay.products.get('prod_123');Payments
Create a payment
const payment = await robuxpay.payments.create({
productId: 'prod_123',
userId: '568128963',
metadata: { orderId: '12345' } // Optional
});Verify a payment
const payment = await robuxpay.payments.verify('pay_abc123');List all payments
const payments = await robuxpay.payments.list();Webhooks
Verify webhook signatures to ensure requests are from RobuxPAY:
import express from 'express';
app.post('/webhook', express.raw({ type: 'application/json' }), (req, res) => {
const signature = req.headers['x-robuxpay-signature'];
const payload = req.body.toString();
const isValid = robuxpay.verifyWebhook(
payload,
signature,
'your_webhook_secret'
);
if (!isValid) {
return res.status(401).send('Invalid signature');
}
const event = JSON.parse(payload);
if (event.type === 'payment.completed') {
console.log('Payment completed:', event.data);
// Handle successful payment
}
res.send('OK');
});TypeScript Support
This SDK is written in TypeScript and includes type definitions:
import RobuxPAY, { Product, Payment } from 'robuxpay';
const robuxpay = new RobuxPAY({ apiKey: 'rpay_xxx' });
const products: Product[] = await robuxpay.products.list();
const payment: Payment = await robuxpay.payments.verify('pay_123');Error Handling
try {
const payment = await robuxpay.payments.create({
productId: 'prod_123',
userId: '568128963'
});
} catch (error) {
if (error.response) {
console.error('API Error:', error.response.data);
} else {
console.error('Network Error:', error.message);
}
}License
MIT
