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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@gatepaybd/core

v0.0.1

Published

Official JavaScript/TypeScript SDK for GatePay payment gateway supporting bKash, Nagad, Rocket and other Bangladesh payment methods

Downloads

24

Readme

GatePay SDK for JavaScript/TypeScript

Official JavaScript/TypeScript SDK for the GatePay payment gateway. Supports Node.js, React, Vue, Angular, and all modern JavaScript environments.

Installation

npm install gatepay
# or
yarn add gatepay

Quick Start

import { PayflowSDK, PaymentMethod } from 'payflow-sdk';

// Initialize the SDK
const payflow = new PayflowSDK({
  apiKey: 'your-api-key',
  environment: 'sandbox' // or 'production'
});

// Create a payment
const payment = await payflow.payments.create({
  amount: 1000, // Amount in smallest currency unit (e.g., paisa for BDT)
  currency: 'BDT',
  paymentMethod: PaymentMethod.BKASH,
  customerInfo: {
    name: 'John Doe',
    email: '[email protected]',
    phone: '+8801234567890'
  },
  returnUrl: 'https://yoursite.com/success',
  cancelUrl: 'https://yoursite.com/cancel'
});

console.log('Payment created:', payment);

API Reference

Configuration

interface PayflowConfig {
  apiKey: string;
  environment?: 'sandbox' | 'production';
  baseUrl?: string; // Custom API base URL
  timeout?: number; // Request timeout in milliseconds
}

Payment Methods

Create a payment:

const payment = await payflow.payments.create({
  amount: 1000,
  currency: 'BDT',
  paymentMethod: PaymentMethod.BKASH,
  customerInfo: {
    name: 'Customer Name',
    email: '[email protected]',
    phone: '+8801234567890'
  }
});

Get payment status:

const payment = await payflow.payments.get('payment-id');

List transactions:

const transactions = await payflow.payments.list({
  page: 1,
  limit: 20,
  status: PaymentStatus.COMPLETED,
  startDate: new Date('2024-01-01'),
  endDate: new Date('2024-12-31')
});

Process/Execute payment:

const result = await payflow.payments.execute('payment-id');

Refund payment:

const refund = await payflow.payments.refund({
  transactionId: 'payment-id',
  amount: 500, // Partial refund (optional)
  reason: 'Customer request'
});

Supported Payment Methods

enum PaymentMethod {
  BKASH = 'BKASH',
  NAGAD = 'NAGAD',
  ROCKET = 'ROCKET',
  UPAY = 'UPAY',
  MCASH = 'MCASH',
  VISA = 'VISA',
  MASTERCARD = 'MASTERCARD',
  AMEX = 'AMEX',
  INTERNET_BANKING = 'INTERNET_BANKING',
}

Error Handling

import { PayflowSDKError, PayflowValidationError, PayflowNetworkError } from 'payflow-sdk';

try {
  const payment = await payflow.payments.create(paymentData);
} catch (error) {
  if (error instanceof PayflowSDKError) {
    console.error('API Error:', error.code, error.message);
  } else if (error instanceof PayflowValidationError) {
    console.error('Validation Error:', error.message);
  } else if (error instanceof PayflowNetworkError) {
    console.error('Network Error:', error.message);
  }
}

Framework Examples

React

import React, { useState } from 'react';
import { PayflowSDK, PaymentMethod } from 'payflow-sdk';

const payflow = new PayflowSDK({
  apiKey: process.env.REACT_APP_PAYFLOW_API_KEY!,
  environment: 'sandbox'
});

function PaymentButton() {
  const [loading, setLoading] = useState(false);
  
  const handlePayment = async () => {
    setLoading(true);
    try {
      const payment = await payflow.payments.create({
        amount: 1000,
        currency: 'BDT',
        paymentMethod: PaymentMethod.BKASH,
      });
      
      // Redirect to payment URL
      window.location.href = payment.paymentUrl!;
    } catch (error) {
      console.error('Payment failed:', error);
    } finally {
      setLoading(false);
    }
  };
  
  return (
    <button onClick={handlePayment} disabled={loading}>
      {loading ? 'Processing...' : 'Pay with bKash'}
    </button>
  );
}

Node.js

const { PayflowSDK, PaymentMethod } = require('payflow-sdk');

const payflow = new PayflowSDK({
  apiKey: process.env.PAYFLOW_API_KEY,
  environment: 'production'
});

// Express.js route example
app.post('/create-payment', async (req, res) => {
  try {
    const payment = await payflow.payments.create({
      amount: req.body.amount,
      currency: 'BDT',
      paymentMethod: req.body.paymentMethod,
      customerInfo: req.body.customerInfo
    });
    
    res.json({ success: true, payment });
  } catch (error) {
    res.status(400).json({ success: false, error: error.message });
  }
});

License

MIT