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

paystation-sdk

v1.0.2

Published

PayStation Bangladesh Backend SDK for Node.js

Downloads

44

Readme

PayStation SDK

A production-ready Node.js backend SDK for integrating the PayStation Bangladesh payment gateway.

Supports Express, Next.js, Nuxt, Hono, Fastify, Serverless environments.


✨ Features

  • 💳 Initiate payment (Hosted Checkout)
  • 🔍 Check transaction status
  • 🔁 Transaction status via trxId
  • 🔔 Callback handling support
  • 🌐 Sandbox & Live environment
  • ⚙️ Works with all Node.js frameworks
  • 🔐 Backend-only (secure)

📦 Installation

npm install paystation-sdk

⚙️ Configuration

import { PayStation } from "paystation-sdk";

const paystation = new PayStation({
  environment: "sandbox" // "sandbox" | "live"
});

🔐 Default Credentials (Sandbox)

merchantId: "104-1653730183"
password: "gamecoderstorepass"

⚠️ For production, always use your own credentials.


🌍 Environments

| Mode | Base URL | | ------- | --------------------------------- | | Sandbox | https://sandbox.paystation.com.bd | | Live | https://api.paystation.com.bd |


💳 Initiate Payment

Example

const response = await paystation.initiatePayment({
  invoice_number: "INV_" + Date.now(),
  currency: "BDT",
  payment_amount: 10,
  reference: "Test Payment",
  cust_name: "Shohel",
  cust_phone: "01700000000",
  cust_email: "[email protected]",
  callback_url: "https://yourdomain.com/callback",
  checkout_items: "Test Product"
});

✅ Success Response

{
  "status_code": "200",
  "status": "success",
  "message": "Payment Link Created Successfully.",
  "payment_amount": "10",
  "invoice_number": "INV_123456",
  "payment_url": "https://api.paystation.com.bd/checkout/XXXX"
}

❌ Failed Response

{
  "status_code": "1008",
  "status": "failed",
  "message": "Duplicate invoice number."
}

📌 As documented by PayStation


🔍 Transaction Status

Example

const status = await paystation.transactionStatus("INV_123456");

✅ Success Response

{
  "status_code": "200",
  "status": "success",
  "message": "Transaction found.",
  "data": {
    "invoice_number": "INV_123456",
    "trx_status": "Success",
    "trx_id": "10XB9900",
    "payment_amount": "120",
    "order_date_time": "2022-12-25 10:25:30",
    "payer_mobile_no": "01700000001",
    "payment_method": "bkash",
    "reference": "Test Payment",
    "checkout_items": "Test Product"
  }
}

❌ Failed Transaction

{
  "status_code": "200",
  "status": "success",
  "data": {
    "trx_status": "Failed"
  }
}

🔎 Transaction Status (by trxId)

const status = await paystation.transactionStatusByTrxId("TRX_ID");

Response Example

{
  "status_code": "200",
  "status": "success",
  "data": {
    "invoice_number": "59734251219",
    "trx_status": "success",
    "trx_id": "CG20D8AYB4121",
    "trx_amount": 2,
    "trx_date": "2025-07-02",
    "payment_amount": "2.00",
    "payment_method": "bKash"
  }
}

🔔 Callback Handling

After payment, PayStation redirects:

https://yourdomain.com/callback?status=Successful&invoice_number=123&trx_id=ABC123

Example (Express)

app.get("/callback", (req, res) => {
  const { status, invoice_number, trx_id } = req.query;

  if (status === "Successful") {
    return res.redirect(`/success?invoice=${invoice_number}&trx=${trx_id}`);
  }

  return res.redirect(`/failed?invoice=${invoice_number}`);
});

✅ Success Route

app.get("/success", (req, res) => {
  res.send("Payment Successful");
});

❌ Failed Route

app.get("/failed", (req, res) => {
  res.send("Payment Failed");
});

🧪 Full Express Example

import express from "express";
import { PayStation } from "paystation-sdk";

const app = express();
app.use(express.json());

const ps = new PayStation({ environment: "sandbox" });

app.post("/pay", async (req, res) => {
  const data = await ps.initiatePayment({
    invoice_number: "INV_" + Date.now(),
    currency: "BDT",
    payment_amount: 10,
    cust_name: "Shohel",
    cust_phone: "01700000000",
    cust_email: "[email protected]",
    callback_url: "http://localhost:3000/callback"
  });

  res.json(data);
});

app.listen(3000);

🔐 Security Best Practices

  • Never expose credentials in frontend
  • Always verify payment using transactionStatus
  • Do not trust callback alone
  • Use .env for production credentials

📁 Project Structure

src/
  core/
    PayStation.ts
  types/
    index.ts

📦 Publish

npm publish --access public

🔁 Version Update

npm version patch
npm publish

📄 License

MIT License © Shohel Hossain


👨‍💻 Author

Shohel Hossain https://github.com/developershohel


⭐ Support

If this SDK helps you, please ⭐ the repo!