Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lazada - Open Platform

Library package to integrate Lazada Open Platform

Prerequisites

  • Nodejs >= 10
  • npm >= 6

Installing

Make sure you have the correct Nodejs version and npm installed. Then you can add the package from the command line:

 npm install laz-logistics-api

Or you can add directly to the package.json file and then run the command npm update:

require {
    "laz-logistics-api":"*"
}

Documention

https://open.lazada.com/ - official documentation for Lazada Open Platform

Environment Variables - .env

LAZADA_API_KEY=your_api_key #your api key from lazada open platform
LAZADA_API_SECRET=your_api_secret #your api secret from lazada open platform
LAZADA_API_URL=your_api_url #staging:https://api.lazada.vn/rest -  production:https://api.lazada.vn/rest

Usage

const { LogisticsService } = require("laz-logistics-api");

const api_key = process.env.LAZADA_API_KEY;
const api_secret = process.env.LAZADA_API_SECRET;
const api_url = process.env.LAZADA_API_URL;

const logistics = new LogisticsService(api_key, api_secret, api_url);
const parameters = {
  platformName: "your_platform_name(lazada provided)",
  sellerId: "your_seller_id(partner input)",
  otp: "your_otp(partner get from seller account https://logistics.lazada.vn)",
};

$response = await logistics.mappingSellerAccount(parameters);
const parameters = {
  warehouseCode: "your_warehouse_code(partner input)",
  platformName: "your_platform_name(lazada provided)",
  // get full parameters from https://open.lazada.com/apps/doc/api?path=%2Flogistics%2Fepis%2Fcustomers%2Fwarehouses
};
$response = await logistics.createWarehouse(parameters);
const parameters = {
  externalOrderId: "your_order_id(partner input)",
  // get full parameters from https://open.lazada.com/apps/doc/api?path=%2Flogistics%2Fepis%2Fservice%2Fdelivery_options
};
response = await logistics.getDeliveryOptions(parameters);
const parameters = {
    "externalSellerId" : "your_seller_id(partner input)",
    ...
    // get full parameters from https://open.lazada.com/apps/doc/api?path=%2Flogistics%2Fepis%2Festimate_shipping_fee
};
const response = await logistics.estimateShippingFee(parameters);
const parameters = {
     "dangerousGood" : "false",
    "shipper" : {
        'externalSellerId' : 'your_seller_id(partner input)',
        'externalWarehouseCode' : 'your_warehouse_code(partner input)',
    },
    "dimWeight" : {
        'length' : '10',
        'width' : '10',
        'weight' : '100',
        'height' : '5'
    },
    "origin" : {
        'address' : {
            'details' : 'Test quận 2',
            'id' : 'R7346817'
        },
        'phone' : '1111111111',
        'name' : 'Kho mặc định',
        'email' : 'teat@gmail.com'
    },
    "destination" : {
        'address' : {
            'details' : 'Phường Mai dịch',
            'id' : 'R80199163',
            'type' : 'home'
        },
        'phone' : '0366452565',
        'name' : 'huy huy',
        'email' : 'teat@gmail.com'
    },
    "payment" : {
        'totalAmount' : '234535',
        'currency' : 'VND',
        'paymentType' : 'COD'
    },
    "externalOrderId" : "your_order_id(partner input)",
    "platformOrderCreationTime" : "timestamp of order creation(partner input)",
    "packageType" : "Sales_order|Return_order",
    "deliveryOption" : "standard",
    "items" : {
        {
            'unitPrice' : '200000',
            'quantity' : '1',
            'name' : 'Áo thun nam thời trang',
            'id' : '10887094399',
            'sku' : 'SP701',
            'paidPrice' : '200000'
        },
    },
    "options" : {
        "directReturnToMerchant" : "false"
    },
    // get full parameters from https://open.lazada.com/apps/doc/api?path=%2Flogistics%2Fepis%2Fpackages
};

const response = await logistics.createPackage($parameters);
const parameters = {
    "packageCode" : "your_package_code(partner input)",
    "type"=>"pdf",
};

const response = await logistics.printAwb($parameters);
const parameters = {
  packageCode: "your_package_code(partner input)",
  reason: "your_reason(partner input)",
};

const response = await logistics.cancelPackage($parameters);

Error List

  • otp expired: please check your otp and get new one from seller account
{
  "type": "ISV",
  "code": "IllegalAccessToken",
  "message": "The specified access token is invalid or expired",
  "request_id": "2101567a17104988838493654"
}
  • invalid signature: please check your api key and api secret
{
  "type": "ISV",
  "code": "IncompleteSignature",
  "message": "The request signature does not conform to platform standards",
  "request_id": "210131d117090244906601493"
}
  • ip not allowed: please provide your ip to lazada open platform to whitelist
<a
  id="a-link"
  \r\n
  href="https://bixi.alicdn.com/punish/punish:resource:template:lazadaSpace:exefqahalk_33139279.html?qrcode=JLsKMoCLzMuA8mmIk6N75g|ZfWc8Q|MWrYXQ_0&uuid=24bb0a32808bcccb80f2698893a37be6&action=deny&origin=https%3A%2F%2Fapi-pre.lazada.vn%3A443%2Frest%2Flogistics%2Fepis%2Fpackages"
></a
>\r\n
<script>
  \r\n
  var host = location.host;\r\n
  var parts = host.split('.');\r\n
  if (parts.length > 2){\r\n
    host = parts.pop();\r\n
    host = "." + parts.pop() + "." + host;\r\n
  }\r\n
  var exp = new Date();\r\n
  var maxAge = -100;\r\n
  exp.setTime(exp.getTime() + maxAge);\r\n
  var cookie = "x5secdata=;maxAge=" + maxAge + ";expires=" + exp.toUTCString() + ";path=/;domain=" + host + ";";\r\n
  document.cookie = cookie;\r\n
  document.cookie = cookie + 'Secure;SameSite=None';\r\n
  document.getElementById("a-link").click();\r\n
  window._config_ = {\r\n
     "action": "deny",\r\n
     "url": "https://bixi.alicdn.com/punish/punish:resource:template:lazadaSpace:exefqahalk_33139279.html?qrcode=JLsKMoCLzMuA8mmIk6N75g|ZfWc8Q|MWrYXQ_0&uuid=24bb0a32808bcccb80f2698893a37be6&action=deny&origin=https%3A%2F%2Fapi-pre.lazada.vn%3A443%2Frest%2Flogistics%2Fepis%2Fpackages"\r\n
  };\r\n
</script>

Languages

  • js

Versioning


Version 1.0.0

License

(c) Lazada Vietnam

Support

=======





About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages