Socket
Socket
Sign inDemoInstall

@gat-solutions/top-up

Package Overview
Dependencies
9
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @gat-solutions/top-up

Đây là một thư viện hỗ trợ gọi API TopUp từ bên thứ 3 (Hiện tại là ViHAT). Thư viện bao gồm 1 service gọi API đi kèm những định nghĩa type dành cho typescript. # Installation ```bash $ npm i @gat-solutions/top-up ``` # Usage ## Khởi tạo service ```typescr


Version published
Maintainers
2
Install size
2.13 MB
Created

Readme

Source

Introduction

Đây là một thư viện hỗ trợ gọi API TopUp từ bên thứ 3 (Hiện tại là ViHAT). Thư viện bao gồm 1 service gọi API đi kèm những định nghĩa type dành cho typescript.

Installation

$ npm i @gat-solutions/top-up

Usage

Khởi tạo service

import { TopUpService } from '@gat-solutions/top-up';

const email = 'email@gmail.com';
const password = 'veryStringPassword';

const topUpService = new TopUpService(email, password);
FieldsDescription
emailEmail này được bên thứ 3 cung cấp
passwordPassword được cung cấp kèm theo email

Login

const topUpService = new TopUpService(email, password);

const data = await topUpService.login();
Dữ liệu trả về
{
    "resultCode": "100",
    "data": {
        "token": "MYAWH3P-CE3MWPD-H2F7SVW-91GGHGF",
        "expiry": "2023-08-30T03:46:01.000Z"
    }
}

Get Balance

const topUpService = new TopUpService(email, password);

const data = await topUpService.getBalance();
Dữ liệu trả về
{
    "resultCode": 100,
    "message": "Success",
    "data": {
        "email": "email@gmail.com",
        "balance": 40000
    }
}

Get all transactions

const topUpService = new TopUpService(email, password);

const dto: GetAllTransactionDto = {
    from: "2023/01/01",
    to: "2023/12/31",
    type: TransactionType.TOP_UP
};

const data = await topUpService.getAllTransactions(dto);
FieldsDescription
fromTừ ngày theo format (YYYY/MM/DD)
toĐến ngày theo format (YYYY/MM/DD)
typeLoại giao dịch: TopUp hoặc CardCode (Mua card)
Dữ liệu trả về
{
    "resultCode": 100,
    "message": "Thành công",
    "data": {
        "logs": [
            {
                "_id": "xxxxxxxxxxxxxxx",
                "requestid": "xxxxxxxxxxxxxxx",
                "typeid": 1,
                "phonenumber": "xxxxxxxxxxxxxxx",
                "requestip": "xxx.xxx.xxx.xx",
                "price": 10000,
                "referenceid": "xxxxxxxxxxxxxxx",
                "result": "true",
                "createDate": "2023-08-28T02:56:25.801Z"
            }
        ]
    }
}

Get detail a transaction

const topUpService = new TopUpService(email, password);

const dto: GetDetailTransactionDto = {
    referenceId: "xxxxxxxxx"
};

const data = await topUpService.getDetailTransaction(dto);
FieldsDescription
referenceIdMã mà user truyền lên khi user thực hiện giao dịch
Dữ liệu trả về
{
    "resultCode": 100,
    "message": "Success",
    "logs": [
        {
            "referenceId": "xxxxxxxxx",
            "result": 0
        }
    ]
}

Top Up (nạp tiền điện thoại)

const topUpService = new TopUpService(email, password);

const dto: TopUpDto = {
    phonenumber: "0xxxxxxxxx",
    price: 10000,
    requestId: "random",
    callbackurl: "http://localhost:3000",
    sandbox: Env.SANDBOX
};

const data = await topUpService.topUp(dto);
FieldsDescription
phonenumberSố điện thoại cần nạp tiền
priceMệnh giá
requestIdMã user tự tạo và truyền lên (recommend dùng uuid)
callbackurlURL để ViHAT bắn webhook về
sandboxMôi trường: Sandbox hoặc Production
Dữ liệu trả về (Sandbox):
{
    "resultCode": 200,
    "message": "Test OK",
    "userid": "64db55440dcdb000307a1a73"
}

Buy Card (nạp tiền điện thoại)

const topUpService = new TopUpService(email, password);

const dto: BuyCardDto ={
    network: CardNetwork.VINAPHONE,
    price: 10000,
    sandbox: Env.SANDBOX
};

const data = await topUpService.buyCard(dto);
FieldsDescription
networkMã nhà mạng
priceMệnh giá
sandboxMôi trường: Sandbox hoặc Production
Dữ liệu trả về (Sandbox):
{
    "resultCode": 200,
    "message": "Test OK"
}

FAQs

Last updated on 29 Aug 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc