PHPackages                             laraditz/lazada - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. laraditz/lazada

ActiveLibrary[API Development](/categories/api)

laraditz/lazada
===============

Laravel package for interacting with Lazada API.

1.1.6(1mo ago)1975MITPHPPHP ^8.2CI passing

Since Nov 28Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/laraditz/lazada)[ Packagist](https://packagist.org/packages/laraditz/lazada)[ Docs](https://github.com/laraditz/lazada)[ RSS](/packages/laraditz-lazada/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (1)Dependencies (8)Versions (11)Used By (0)

Laravel Lazada
==============

[](#laravel-lazada)

[![Latest Version on Packagist](https://camo.githubusercontent.com/bca0ec169bb071da07c68e82a3ff371eccdcd6b3f022a00fa160b5463b3ef3dc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c6172616469747a2f6c617a6164612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/laraditz/lazada)[![Total Downloads](https://camo.githubusercontent.com/a2c0e759e0657ff07e0077edb1446549d65a465e143967511f3072357d80b02d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c6172616469747a2f6c617a6164612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/laraditz/lazada)[![License](https://camo.githubusercontent.com/5896c8f5ed587bf78f34278f4bf8bdc334ae752a7d5c8c982f8fb77b483db8e8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6c6172616469747a2f6c617a6164613f7374796c653d666c61742d737175617265)](./LICENSE.md)[![GitHub Actions](https://github.com/laraditz/lazada/actions/workflows/main.yml/badge.svg)](https://github.com/laraditz/lazada/actions/workflows/main.yml/badge.svg)

A comprehensive Laravel package for seamless integration with the Lazada Open Platform API. This package provides a clean, intuitive interface for managing Lazada sellers, handling authentication, processing orders, managing products, and receiving webhooks.

[![Buy Me A Coffee](https://camo.githubusercontent.com/0cf29a542375e1a46e84d8bf5805a4e5c0a6ee98b6547ccdc0c55eed49d99c69/68747470733a2f2f63646e2e6275796d6561636f666665652e636f6d2f627574746f6e732f76322f64656661756c742d79656c6c6f772e706e67)](https://www.buymeacoffee.com/raditzfarhan)

Features
--------

[](#features)

- 🔐 **Complete Authentication Flow** - Automatic token management with refresh capabilities
- 🏪 **Multi-Seller Support** - Manage multiple Lazada sellers within a single application
- 📦 **Product Management** - Retrieve products and update sellable stock quantities
- 🛒 **Order Processing** - Comprehensive order management and document retrieval
- 💰 **Finance &amp; Transactions** - Query payout status, account transactions, and finance details
- 📡 **Webhook Integration** - Real-time push event handling with built-in endpoints
- 🗄️ **Database Logging** - Automatic request/response logging for debugging and monitoring
- 🔄 **Auto Token Refresh** - Scheduled token refresh to maintain API connectivity

Requirements
------------

[](#requirements)

- PHP 8.2 and above.
- Laravel 10 and above.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require laraditz/lazada
```

Quick Start
-----------

[](#quick-start)

### 1. Lazada App Setup

[](#1-lazada-app-setup)

Before using this package, you need a Lazada Open Platform app:

1. Visit [Lazada Open Platform](https://open.lazada.com/)
2. Create a new app or use an existing one
3. Note your `App Key` and `App Secret`
4. Configure the App Callback URL: `https://your-app-url.com/lazada/seller/authorized`

### 2. Environment Configuration

[](#2-environment-configuration)

Add your Lazada credentials to your `.env` file:

```
LAZADA_APP_KEY=your_app_key_here
LAZADA_APP_SECRET=your_app_secret_here
LAZADA_SELLER_SHORT_CODE=MYXXXXXXXX   # Optional: default seller short code (also called Seller ID in the console)
```

### 3. Publish Migration

[](#3-publish-migration)

```
php artisan vendor:publish --provider="Laraditz\Lazada\LazadaServiceProvider" --tag="migrations"
```

### 4. Run Migration

[](#4-run-migration)

```
php artisan migrate
```

### 5. Configuration (Optional)

[](#5-configuration-optional)

```
php artisan vendor:publish --provider="Laraditz\Lazada\LazadaServiceProvider" --tag="config"
```

### 6. Authorization Flow

[](#6-authorization-flow)

To authorize a seller:

1. Generate and share the authorization URL with the seller:

```
$url = Lazada::auth()->authorizationUrl();
// Redirect the seller to this URL
```

2. The seller logs in and authorizes your app
3. Lazada redirects to `https://your-app-url.com/lazada/seller/authorized`
4. The package automatically handles the token exchange and storage
5. The seller is now ready for API calls

Available Methods
-----------------

[](#available-methods)

Here's the full list of methods available in this package. Parameters follow the [Lazada Open Platform Documentation](https://open.lazada.com/apps/doc/api) exactly. Common parameters like `app_key`, `sign`, `timestamp`, and `access_token` are added automatically.

### Authentication Service `auth()`

[](#authentication-service-auth)

MethodDescription`authorizationUrl()`Get the authorization URL to share with the seller.`accessToken()`Exchange an authorization code for an access token.`refreshToken()`Refresh an access token before it expires.`accessTokenWithOpenId()`Generate an access token using an OpenID.### Seller Service `seller()`

[](#seller-service-seller)

MethodDescription`get()`Fetch seller information from Lazada API and sync to DB.`info()`Return the resolved `LazadaSeller` model for the current context.`pickUpStoreList()`Return the list of pick-up store information for the seller.### Order Service `order()`

[](#order-service-order)

MethodDescription`list()`Get an order list from a specified date range.`get()`Get single order detail by order ID.`items()`Get the item information of an order.`document()`Retrieve order-related documents (invoices, shipping labels).### Finance Service `finance()`

[](#finance-service-finance)

MethodDescription`payoutStatus()`Get transaction statements created after the provided date.`accountTransactions()`Query account transactions.`logisticsFeeDetail()`Query logistics fee details.`transactionDetail()`Query seller transaction details within a specific date range.### Product Service `product()`

[](#product-service-product)

MethodDescription`get()`Get the product list for the seller.`item()`Get a single product item by item ID.`updateSellableQuantity()`Update sellable stock quantity for a SKU.Usage Examples
--------------

[](#usage-examples)

### Basic Usage

[](#basic-usage)

```
use Laraditz\Lazada\Facades\Lazada;

// Using facade (recommended)
Lazada::order()->list(created_after: '2023-11-17T00:00:00+08:00');

// Using service container
app('lazada')->order()->list(created_after: '2023-11-17T00:00:00+08:00');
```

### Authentication

[](#authentication)

```
use Laraditz\Lazada\Facades\Lazada;
use Laraditz\Lazada\Exceptions\LazadaAPIError;

// Step 1: Get the authorization URL and redirect the seller to it
$url = Lazada::auth()->authorizationUrl();

// Step 2: After the seller authorizes, exchange the code for a token
// (The package handles this automatically via the built-in callback route)
// If using a custom callback, call this manually:
try {
    $token = Lazada::auth()->accessToken(code: '0_123456_XxxXXXXxxXXxxXXXXxxxxxxXXXXxx');
} catch (LazadaAPIError $e) {
    logger()->error('Lazada token error', [
        'message' => $e->getMessage(),
        'code'    => $e->getMessageCode(),
        'request' => $e->getRequestId(),
    ]);
}
```

### Working with Orders

[](#working-with-orders)

```
// Get orders created after a date
$orders = Lazada::order()->list(created_after: '2023-11-17T00:00:00+08:00');

// Get a specific order
$order = Lazada::order()->get(order_id: '16090');

// Get items in an order
$items = Lazada::order()->items(order_id: '16090');

// Get order documents (invoice, shipping label)
$document = Lazada::order()->document(
    order_item_ids: [1234567, 1234568],
    doc_type: 'invoice',
);
```

### Working with Products

[](#working-with-products)

```
// Get product list
$products = Lazada::product()->get(
    filter: 'live',
    offset: 0,
    limit: 50,
);

// Get a specific product item
$item = Lazada::product()->item(item_id: 123456789);

// Update sellable stock quantity for a SKU
Lazada::product()->updateSellableQuantity(
    payload: json_encode([
        'skuId' => 'your-sku-id',
        'sellableQuantity' => 100,
    ])
);
```

### Working with Finance

[](#working-with-finance)

```
// Get payout status
$payout = Lazada::finance()->payoutStatus(
    created_after: '2023-01-01T00:00:00+08:00',
);

// Query account transactions
$transactions = Lazada::finance()->accountTransactions(
    start_time: '2023-11-01T00:00:00+08:00',
    end_time: '2023-11-30T23:59:59+08:00',
);

// Query transaction details
$details = Lazada::finance()->transactionDetail(
    trans_type: 3,
    start_time: '2023-11-01T00:00:00+08:00',
    end_time: '2023-11-30T23:59:59+08:00',
);
```

### Working with Sellers

[](#working-with-sellers)

```
// Sync seller info from Lazada API to DB
Lazada::seller()->get();

// Get the resolved seller model (no API call)
$seller = Lazada::seller()->info();
echo $seller->name;
echo $seller->short_code;

// Get pick-up store list
$stores = Lazada::seller()->pickUpStoreList();
```

### Multi-Seller Support

[](#multi-seller-support)

By default the package uses `LAZADA_SELLER_SHORT_CODE` from your `.env`. For multi-seller applications, specify the seller per request:

```
// Method 1: Using make() — reuse the same instance for multiple calls
$lazada = Lazada::make(seller_id: 'MYXXXXXXXX');
$orders   = $lazada->order()->list(created_after: '2023-11-17T00:00:00+08:00');
$products = $lazada->product()->get(filter: 'live', offset: 0, limit: 50);

// Method 2: Pass seller_id on any service call to switch sellers inline
Lazada::order(seller_id: 'MYXXXXXXXX')->list(created_after: '2023-11-17T00:00:00+08:00');
```

### Error Handling

[](#error-handling)

```
use Laraditz\Lazada\Facades\Lazada;
use Laraditz\Lazada\Exceptions\LazadaAPIError;

try {
    $orders = Lazada::order()->list(created_after: '2023-11-17T00:00:00+08:00');
} catch (LazadaAPIError $e) {
    // Handle Lazada API errors
    logger()->error('Lazada API Error', [
        'message'    => $e->getMessage(),
        'code'       => $e->getMessageCode(),
        'request_id' => $e->getRequestId(),
        'result'     => $e->getResult(), // raw response
    ]);
} catch (\Throwable $th) {
    throw $th;
}
```

Events &amp; Webhooks
---------------------

[](#events--webhooks)

### Webhook URL

[](#webhook-url)

Configure this URL in your Lazada Open Platform App Management under the **Push Mechanism** section so Lazada pushes content updates to your app:

```
https://your-app-url.com/lazada/webhooks

```

### Available Events

[](#available-events)

EventDescription`Laraditz\Lazada\Events\WebPushReceived`Triggered when Lazada sends a web push.### Creating Event Listeners

[](#creating-event-listeners)

```
// app/Listeners/LazadaWebPushListener.php

namespace App\Listeners;

use Laraditz\Lazada\Events\WebPushReceived;

class LazadaWebPushListener
{
    public function handle(WebPushReceived $event): void
    {
        $pushType = $event->pushType;
        $data     = $event->data;

        // Handle the push content based on type
    }
}
```

Register the listener in your `EventServiceProvider` (Laravel 10 and below):

```
// app/Providers/EventServiceProvider.php

protected $listen = [
    \Laraditz\Lazada\Events\WebPushReceived::class => [
        \App\Listeners\LazadaWebPushListener::class,
    ],
];
```

Read more about the Lazada Push Mechanism (LPM) in the [official documentation](https://open.lazada.com/apps/doc/doc?nodeId=29526&docId=120168).

Token Management
----------------

[](#token-management)

### Artisan Commands

[](#artisan-commands)

```
# Refresh existing access tokens before they expire
php artisan lazada:refresh-token

# Remove expired access tokens from the database
php artisan lazada:flush-expired-token
```

### Automated Token Refresh

[](#automated-token-refresh)

Set up scheduled token refresh in your `app/Console/Kernel.php`:

```
protected function schedule(Schedule $schedule)
{
    // Refresh tokens daily (live access tokens expire in 30 days)
    $schedule->command('lazada:refresh-token')
             ->daily()
             ->withoutOverlapping();

    // Clean up expired tokens weekly
    $schedule->command('lazada:flush-expired-token')
             ->weekly();
}
```

### Token Lifecycle

[](#token-lifecycle)

EnvironmentToken TypeDuration**Live**Access Token30 days**Live**Refresh Token180 days**Testing**Access Token7 days**Testing**Refresh Token30 days> **Important:** If both tokens expire, the seller must re-authorize your app to generate a new token pair.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information about recent changes.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security vulnerabilities, please email  instead of using the issue tracker.

Support
-------

[](#support)

- 📖 [Lazada Open Platform Documentation](https://open.lazada.com/apps/doc/api)
- 🐛 [Issue Tracker](https://github.com/laraditz/lazada/issues)

Credits
-------

[](#credits)

- [Raditz Farhan](https://github.com/laraditz) - Creator and maintainer
- [All Contributors](../../contributors) - Thank you for your contributions!

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance90

Actively maintained with recent releases

Popularity16

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 96.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~111 days

Recently: every ~11 days

Total

9

Last Release

46d ago

PHP version history (2 changes)1.0.0PHP ^8.1

1.1.0PHP ^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1203676?v=4)[Raditz Farhan](/maintainers/raditzfarhan)[@raditzfarhan](https://github.com/raditzfarhan)

---

Top Contributors

[![raditzfarhan](https://avatars.githubusercontent.com/u/1203676?v=4)](https://github.com/raditzfarhan "raditzfarhan (62 commits)")[![csfwn](https://avatars.githubusercontent.com/u/23299636?v=4)](https://github.com/csfwn "csfwn (2 commits)")

---

Tags

laravellaraditzLazada

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/laraditz-lazada/health.svg)

```
[![Health](https://phpackages.com/badges/laraditz-lazada/health.svg)](https://phpackages.com/packages/laraditz-lazada)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

815320.5k3](/packages/defstudio-telegraph)[resend/resend-laravel

Resend for Laravel

1212.2M8](/packages/resend-resend-laravel)[essa/api-tool-kit

set of tools to build an api with laravel

53386.5k](/packages/essa-api-tool-kit)[simplestats-io/laravel-client

Analytics for Laravel. Track visitors, registrations, and payments. Discover which channels actually drive revenue, not just traffic. Server-side, GDPR compliant, ad-blocker proof.

5019.3k](/packages/simplestats-io-laravel-client)[joggapp/laravel-aws-sns

Laravel package for the SNS events by AWS

3175.9k](/packages/joggapp-laravel-aws-sns)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
