PHP code example of laz-vn / logistics-api

1. Go to this page and download the library: Download laz-vn/logistics-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

laz-vn / logistics-api example snippets


use LazApi\LogisticsService;

$api_key = getenv('LAZADA_API_KEY');
$api_secret = getenv('LAZADA_API_SECRET');
$api_url = getenv('LAZADA_API_URL');

$logistics = new LogisticsService($api_key, $api_secret, $api_url);

$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 = $logistics->mappingSellerAccount($parameters);

$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 = $logistics->createWarehouse($parameters);

$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 = $logistics->getDeliveryOptions($parameters);

$parameters = [
    "externalSellerId" => "your_seller_id(partner input)",
    ...
    // get full parameters from https://open.lazada.com/apps/doc/api?path=%2Flogistics%2Fepis%2Festimate_shipping_fee
];
$response = $logistics->estimateShippingFee($parameters);

$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' => '[email protected]'
    ],
    "destination" => [
        'address' => [
            'details' => 'Phường Mai dịch',
            'id' => 'R80199163',
            'type' => 'home'
        ],
        'phone' => '0366452565',
        'name' => 'huy huy',
        'email' => '[email protected]'
    ],
    "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
];

$response = $logistics->createPackage($parameters);

    $parameters = [
        "dangerousGood"= "false",
        // get full parameters from https://open.lazada.com/apps/doc/api?path=%2Flogistics%2Fepis%2Fpackages%2Fconsign
    ]
    $response = $logistics->consignPackage($parameters);

    $parameters = [
        "trackingNumber"= "tracking_number pack",
    ]
    $response = $logistics->rtsPackage($parameters);

$parameters = [
    "packageCode" => "your_package_code(partner input)",
    "type"=>"pdf",
];

$response = $logistics->printAwb($parameters);

$parameters = [
    "packageCodes" => "your_package_code(partner input)",
    "trackingNumbers" => "your_tracking_number(partner input)",
    "type"=>"pdf",
];
$response = $logistics->printAwbV2($parameters);

$parameters = [
    "packageCode" => "your_package_code(partner input)",
    "reason"=>"your_reason(partner input)",
];

$response = $logistics->cancelPackage($parameters);

$parameters = [
    "externalSellerId" => "your_seller_id(partner input)",
    "platformName"= "your_platform_name(lazada provided)",
    "trackingNumber"= "your_tracking_number(partner input)",
];
$response = $logistics->getShippingFee($parameters);


Version 1.0.0