1.0.0 • Published 4 years ago

@npay/vnptpay v1.0.0

Weekly downloads
1
License
-
Repository
-
Last release
4 years ago

Vnptpay APIs NodejS Client

Client library for using Vnptpay APIs

Cài đặt

npm install @pay/vnptpay

Vnptpay Client

const Client = require('@pay/vnptpay')

const client = new Client({
    serviceID: 6901,
    apiKey: 'acf392daf78c3cbeeb9705dab9a63219',
    secretKey:: '36e3c5b5a6d53fce2a2cc23d46ee5988',
    dev: true // Options, true nếu dùng để dev
})

Khởi tạo giao dịch

const paymentLink = async client.createTransaction({
    order_id: 'OID-009', // Mã đơn hàng cần thanh toán
    amount: 69000,
    currency_code: 'VND',
    payment_method: 'VNPTPAY',
    description: 'Mô tả yêu cầu thanh toán',
    create_date: '20200222022222',
    client_ip: '127.0.0.1'
    locale: 'vi-VN'
})

Truy vấn giao dịch

const transaction = async client.queryTransaction({
    order_id: 'OID-009',
    create_time: '20200222022222'
})

Giao dịch trả về gồm các thông tin.

{
    order_id: 'OID-009',
    transaction_id: '',
    amount: 69000,
    locale: 'vi-VN',
    currency_code: 'VND',
    payment_method: 'VNPTPAY',
    pay_date: '20200222022222',
    transaction_status: '',
    description: 'Mô tả giao dịch'
}