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

vnpay

v2.4.4

Published

An open-source nodejs library support to payment with VNPay

Readme

📦 vnpayjs

🇻🇳 Tiếng Việt | 🇺🇸 English

NPM Version Package License NPM Downloads GitHub Stars GitHub Issues

🚀 Thư viện Node.js hiện đại cho tích hợp cổng thanh toán VNPay vào ứng dụng của bạn.

Hỗ trợ TypeScript • Tree-shaking • Modular imports • Minimal dependencies


✨ Tính năng nổi bật

| 🎯 Dễ sử dụng | 🧩 Modular | 📘 TypeScript | ⚡ Tối ưu | | :----------------------: | :----------------: | :---------------: | :----------------: | | API đơn giản & trực quan | Import theo module | Full type support | Tree-shaking ready |

🆕 Mới trong v2.4.0

  • 📦 Import theo module - Giảm kích thước bundle lên đến 80%
  • 🎯 Types-only imports - 0KB runtime cho TypeScript projects
  • Tối ưu build - Code splitting và tree-shaking
  • 🔧 Flexible endpoints - Custom API endpoints

📚 Tài liệu

| 📖 Tài liệu | 🔗 Link | 📝 Mô tả | | :------------------ | :--------------------------------------------------------------------- | :-------------------------- | | Docs chính thức | vnpay.js.org | Tài liệu chi tiết với ví dụ | | VNPay API | sandbox.vnpayment.vn/apis | Tài liệu chính thức VNPay | | GitHub | github.com/lehuygiang28/vnpay | Source code & Issues |


🚀 Cài đặt

[!TIP] NestJS users: Sử dụng nestjs-vnpay - wrapper tích hợp sẵn cho NestJS.

# NPM
npm install vnpay

# Yarn
yarn add vnpay

# PNPM
pnpm install vnpay

📦 Import Options (v2.4.0+)

🏆 Import toàn bộ (Backward Compatible)

import { VNPay, HashAlgorithm, ProductCode } from 'vnpay';

🦩 Import theo module (Recommended)

import { VNPay } from 'vnpay/vnpay';
import { HashAlgorithm, ProductCode } from 'vnpay/enums';
import { VNP_VERSION, PAYMENT_ENDPOINT } from 'vnpay/constants';
import { resolveUrlString, dateFormat } from 'vnpay/utils';

📘 Types-only (TypeScript)

import type { VNPayConfig, BuildPaymentUrl, Bank } from 'vnpay/types-only';

[!WARNING] ⚠️ QUAN TRỌNG: Sử dụng trên Client-side (Frontend)

Thư viện VNPay chỉ dành cho Node.js backend vì sử dụng các module như fs, crypto và các API chỉ có trên server.

❌ KHÔNG làm thế này trong React/Vue/Angular components:

import { VNPay } from 'vnpay'; // Error: Module not found: Can't resolve 'fs'

✅ SỬ DỤNG như thế này cho frontend:

import type { VNPayConfig, BuildPaymentUrl, Bank, VerifyReturnUrl } from 'vnpay/types-only';
  • Backend (Node.js): Sử dụng import bình thường để xử lý thanh toán
  • Frontend (React/Vue/Angular): Chỉ import types để type checking
  • API calls: Gọi backend APIs từ frontend thay vì import trực tiếp

💡 Cách sử dụng

🔧 Khởi tạo VNPay

import { VNPay, ignoreLogger } from 'vnpay';

const vnpay = new VNPay({
    // ⚡ Cấu hình bắt buộc
    tmnCode: '2QXUI4B4',
    secureSecret: 'your-secret-key',
    vnpayHost: 'https://sandbox.vnpayment.vn',

    // 🔧 Cấu hình tùy chọn
    testMode: true, // Chế độ test
    hashAlgorithm: 'SHA512', // Thuật toán mã hóa
    enableLog: true, // Bật/tắt log
    loggerFn: ignoreLogger, // Custom logger

    // 🔧 Custom endpoints
    endpoints: {
        paymentEndpoint: 'paymentv2/vpcpay.html',
        queryDrRefundEndpoint: 'merchant_webapi/api/transaction',
        getBankListEndpoint: 'qrpayauth/api/merchant/get_bank_list',
    },
});

💳 Tạo URL thanh toán

const paymentUrl = vnpay.buildPaymentUrl({
    vnp_Amount: 100000, // 100,000 VND
    vnp_IpAddr: '192.168.1.1',
    vnp_ReturnUrl: 'https://yourapp.com/return',
    vnp_TxnRef: 'ORDER_123',
    vnp_OrderInfo: 'Thanh toán đơn hàng #123',
});

console.log('Payment URL:', paymentUrl);

Xác thực thanh toán

// Xác thực URL return
const verify = vnpay.verifyReturnUrl(req.query);
if (verify.isSuccess) {
    console.log('✅ Thanh toán thành công!', verify.message);
} else {
    console.log('❌ Thanh toán thất bại:', verify.message);
}

Sponsored by GitAds


🤝 Hỗ trợ & Đóng góp

🎉 vnpayjs là dự án mã nguồn mở và hoàn toàn miễn phí!

Nếu thư viện giúp ích cho bạn, hãy tặng cho project này một ⭐ hoặc mời một ly cà phê ☕ và nhấn vào các quảng cáo trên để mình nhận được 1 khoản tiền nhỏ để duy trì project

GitHub Stars

🛠️ Tham gia đóng góp

| 📋 Bước | 🔗 Hành động | | :---------: | :------------------------------------------------------------------------------ | | 1 | Đọc Hướng dẫn đóng góp | | 2 | Fork repo và tạo Pull Request | | 3 | Tham gia thảo luận trong Issues |

👥 Contributors

Cảm ơn tất cả những người đã đóng góp cho dự án:

Contributors


📄 Giấy phép

MIT License © Lê Huy Giang

Made with ❤️ in Vietnam