Open source library to support delivery management with giaohangnhanh (ghn).
Documentation from Ghn: https://api.ghn.vn/home/docs/detail
Install giaohangnhanh
with npm
:
npm install giaohangnhanh
Install giaohangnhanh
with yarn
:
yarn add giaohangnhanh
Install giaohangnhanh
with pnpm
:
pnpm install giaohangnhanh
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
});
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.