Skip to content

Latest commit

 

History

History
142 lines (121 loc) · 4.01 KB

README_en-US.md

File metadata and controls

142 lines (121 loc) · 4.01 KB

giaohangnhanh

VI | EN

Open source library to support delivery management with giaohangnhanh (ghn).

Documentation from Ghn: https://api.ghn.vn/home/docs/detail

Installation

Install giaohangnhanh with npm:

npm install giaohangnhanh

Install giaohangnhanh with yarn:

yarn add giaohangnhanh

Install giaohangnhanh with pnpm:

pnpm install giaohangnhanh

Usage

Initialize

import { Ghn } from 'giaohangnhanh';

const ghn = new Ghn({
    token: 'YOUR_GHN_TOKEN', // Replace with your token
    shopId: 123456, // Replace with your shopId
    host: 'https://dev-online-gateway.ghn.vn',
    trackingHost: 'https://tracking.ghn.dev/',
    testMode: true, // Enable test mode to override host to sandbox environment
});

Methods

Instances Methods Description Status
address getProvinces() Get provinces data
getDistricts() Get districts data
getWards() Get wards data
calculateFee getServiceList() Get list of available services from district pick up items and to district drop off items
calculateShippingFee() Get the shipping fee and provide to buyer before create shipping order
order calculateExpectedDeliveryTime() Calculate the expected delivery time
pickShift() Get Pick shift in order
previewOrder() Helps preview order information without creating an order
createOrder() Create order
orderInfo() Get all information of a order
cancelOrder() Cancel order
getTrackingUrl() Get tracking url of an order

Note:

  • The ✅ icon indicates that the task has been completed.
  • The 📝 icon indicates that the task is todo.
  • The ❗ icon indicates that the task needs help.

Sample working code: Click here!

Contribution