npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

fakepe-sdk

v1.0.1

Published

Official Node.js SDK for FakePE Payment Gateway - A Razorpay-inspired mock payment system

Downloads

11

Readme

fakepe-sdk

Official Node.js SDK for FakePE Payment Gateway - A Razorpay-inspired mock payment system for testing and development.

npm version npm downloads license

🚀 Installation

npm install fakepe-sdk

📦 Quick Start

const FakePE = require('fakepe-sdk');

const fakepe = new FakePE({
  key_id: 'your_key_id',
  key_secret: 'your_key_secret',
  baseUrl: 'http://localhost:4000' // Optional
});

// Create a payment
const payment = await fakepe.payments.create({
  merchantId: 'mer_123',
  amount: 50000, // Amount in paise (₹500)
  orderId: 'order_001',
  callbackUrl: 'https://yoursite.com/webhook'
});

console.log(payment.paymentId);
console.log(payment.paymentUrl);

📚 API Reference

Initialize SDK

const fakepe = new FakePE({
  key_id: 'your_key_id',        // Required
  key_secret: 'your_key_secret', // Required
  baseUrl: 'http://localhost:4000' // Optional
});

Payments

Create Payment

const payment = await fakepe.payments.create({
  merchantId: 'mer_123',
  amount: 50000, // in paise
  orderId: 'order_001',
  callbackUrl: 'https://yoursite.com/webhook',
  metadata: { // optional
    customer_name: 'John Doe',
    customer_email: '[email protected]'
  }
});

Fetch Payment

const payment = await fakepe.payments.fetch('pay_xyz789');

List Payments

const payments = await fakepe.payments.list({
  merchantId: 'mer_123',
  status: 'COMPLETED',
  limit: 10,
  offset: 0
});

Refund Payment

await fakepe.payments.refund('pay_xyz789', {
  amount: 25000, // partial refund
  reason: 'Customer request'
});

UPI

Create VPA

await fakepe.upi.createVpa({
  userId: 'usr_123',
  vpa: 'user@fakepe'
});

Get User VPAs

const vpas = await fakepe.upi.getVpas('usr_123');

Generate QR Code

const qr = await fakepe.upi.generateQr('pay_xyz789');
console.log(qr.upiIntent); // upi://pay?...
console.log(qr.qrCodeData); // base64 QR code image

Initiate Payment

const txn = await fakepe.upi.initiate({
  paymentId: 'pay_xyz789',
  payerVpa: 'user@fakepe'
});

Confirm Payment

const result = await fakepe.upi.confirm({
  txnId: txn.txnId,
  pin: '1234' // Mock PIN
});

Get Transaction

const txn = await fakepe.upi.getTransaction('UPI2024011512345678');

Get Transaction History

const history = await fakepe.upi.getHistory('usr_123', {
  limit: 20,
  offset: 0
});

Wallets

Get Balance

const wallet = await fakepe.wallets.getBalance('usr_123');
console.log(wallet.balance); // in paise

Top Up

await fakepe.wallets.topup({
  userId: 'usr_123',
  amount: 100000 // ₹1000
});

Transfer

await fakepe.wallets.transfer({
  from: 'usr_123',
  to: 'usr_456',
  amount: 50000
});

Webhooks

Verify Signature

app.post('/webhook', (req, res) => {
  const signature = req.headers['x-fakepe-signature'];
  
  // Verify webhook signature
  if (!fakepe.webhooks.verify(req.body, signature)) {
    return res.status(400).send('Invalid signature');
  }
  
  // Process webhook
  const { event, data } = req.body;
  
  switch(event) {
    case 'payment.completed':
      console.log('Payment completed:', data.paymentId);
      break;
    case 'payment.failed':
      console.log('Payment failed:', data.paymentId);
      break;
  }
  
  res.status(200).send('OK');
});

Generate Signature (for testing)

const signature = fakepe.webhooks.generateSignature(payload);

📋 Examples

Check the examples/ directory for complete working examples:

  • basic-payment.js - Simple payment creation
  • upi-payment.js - Complete UPI payment flow
  • webhook-server.js - Webhook handling with signature verification

🔧 Error Handling

try {
  const payment = await fakepe.payments.create({
    merchantId: 'mer_123',
    amount: 50000,
    orderId: 'order_001'
  });
} catch (error) {
  console.error('Payment creation failed:', error.message);
  console.error('Error code:', error.response?.status);
  console.error('Error details:', error.response?.data);
}

💡 Best Practices

  1. Store credentials securely - Never commit API keys
  2. Use environment variables - process.env.FAKEPE_KEY_ID
  3. Handle errors gracefully - Wrap API calls in try-catch
  4. Verify webhooks - Always verify signature before processing
  5. Use idempotency - Pass Idempotency-Key header for safe retries

🔗 Related Projects

⚠️ Disclaimer

This is a MOCK payment system for testing and development only. All transactions use fake money and are not real financial transactions.

For production use, integrate with real payment providers like:

📄 License

MIT License - see LICENSE file

👨‍💻 Author

Mihir Rabari


⭐ Star the repo if you find it useful!