PHPackages                             laraditz/shopee - 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/shopee

ActiveLibrary[API Development](/categories/api)

laraditz/shopee
===============

A simple laravel package for Shopee

1.1.7(1mo ago)15419—0%10MITPHPPHP ^8.1CI failing

Since Oct 27Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/laraditz/shopee)[ Packagist](https://packagist.org/packages/laraditz/shopee)[ Docs](https://github.com/laraditz/shopee)[ Fund](https://www.buymeacoffee.com/raditzfarhan)[ GitHub Sponsors](https://github.com/raditzfarhan)[ RSS](/packages/laraditz-shopee/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (8)Versions (11)Used By (0)

Laravel Shopee
==============

[](#laravel-shopee)

[![Latest Version on Packagist](https://camo.githubusercontent.com/e22f65ec2742e328934cfca6b0953f801f50fa7faec96f8cb490eb5bd22f3d07/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c6172616469747a2f73686f7065652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/laraditz/shopee)[![Total Downloads](https://camo.githubusercontent.com/a96719acaa4881bee2ca3ccf23d6b00e7b06ba83ad6f3a25732b8be57a23a497/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c6172616469747a2f73686f7065652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/laraditz/shopee)[![License](https://camo.githubusercontent.com/04bf2b8a5ddeddb8a6144133c3fa580520fa51e4e09877d96de0c2e0928ab9d4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6c6172616469747a2f73686f7065653f7374796c653d666c61742d737175617265)](./LICENSE.md)[![GitHub Tests Action Status](https://camo.githubusercontent.com/4cb3b980d690f18ca8665435ad8488a48ad506f16308c1a22938769c066a34b8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6c6172616469747a2f73686f7065652f6d61696e2e796d6c3f6272616e63683d6d6173746572266c6162656c3d5465737473)](https://github.com/laraditz/shopee/actions?query=workflow%3ATests+branch%3Amaster)

A comprehensive Laravel package for seamlessly integrating with the Shopee Open Platform API. This package provides an elegant, fluent interface for managing shops, products, orders, and payments on Shopee's marketplace.

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

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

[](#installation)

You can install the package via composer:

```
composer require laraditz/shopee
```

Before Starting
---------------

[](#before-starting)

Configure your Shopee API credentials in your `.env` file (recommended) or publish and modify the config file.

```
SHOPEE_SANDBOX_MODE=true # Set to false for production
SHOPEE_PARTNER_ID=
SHOPEE_PARTNER_KEY=
SHOPEE_SHOP_ID=
SHOPEE_REDIRECT_URL= # Optional — see Authorization Flow
```

(Optional) You can publish the config file via this command:

```
php artisan vendor:publish --provider="Laraditz\Shopee\ShopeeServiceProvider" --tag="config"
```

Run the migration command to create the necessary database tables for storing shop data, access tokens, and API request logs.

```
php artisan migrate
```

Authorization Flow
------------------

[](#authorization-flow)

To authorize a Shopee shop with your app:

1. Visit [Shopee Open Platform Console](https://open.shopee.com/).
2. On your App List, click `Authorize` link next to the `Test/Live Partner_id`. Alternatively, you can generate the authorization URL using the `generateAuthorizationURL()` method.
3. Make sure the domain for authorized redirect URL already been whitelisted beforehand.
4. Enter `https://your-app-url/shopee/shops/authorized` as the Redirect URL and click Next.
5. Proceed to login using the seller account that you want to authorized to be use for the app.
6. Shopee redirects back to `https://your-app-url/shopee/shops/authorized`.
7. Package automatically handles the authorization code exchange and token storage.
8. Shop is now ready for API calls.

### Custom Redirect After Authorization

[](#custom-redirect-after-authorization)

By default, the package renders a built-in success page after authorization. To redirect to your own URL instead, set `SHOPEE_REDIRECT_URL` in your `.env`:

```
SHOPEE_REDIRECT_URL=https://your-app-url/shopee/callback
```

On success, the package redirects to your URL with the following query parameters:

ParameterDescription`shop_id`Shopee shop ID`shop_name`Shop display name`region`Shop region (e.g. `MY`, `SG`)`access_token`OAuth access token`refresh_token`OAuth refresh token`expires_at`Token expiry (ISO 8601)On failure (e.g. token exchange error), the redirect includes:

ParameterValue`error``token_failed``shop_id`Shopee shop ID> **Security:** `SHOPEE_REDIRECT_URL` must be an exact absolute URL without query strings. Only requests carrying this exact value are honoured — any other value is silently discarded, preventing open redirect attacks. Use HTTPS in production as tokens are passed in the URL.

Available Services &amp; Methods
--------------------------------

[](#available-services--methods)

Below is a list of all available methods in this SDK. For detailed usage, please refer to the [Developer’s Guide](https://open.shopee.com/developer-guide/4) and the [API Reference](https://open.shopee.com/documents/v2/v2.product.get_category?module=89&type=1). This package organizes Shopee API endpoints into logical services. Each method name corresponds to its respective API endpoint (converted from `snake_case` → `camelCase`), and all parameters follow the exact definitions provided in the API reference.

> **Note:** All method parameters must be passed as named arguments, not positional arguments.

### 🔐 Authorization and Authentication Service `auth()`

[](#-authorization-and-authentication-service-auth)

Handles OAuth 2.0 authentication flow and token management.

MethodDescriptionParameters`accessToken()`Generate access token from authorization code`entity_id`, EntityType `entity_type``refreshToken()`Refresh access token before expiration (4 hours)ShopeeAccessToken `shopeeAccessToken`### 🏪 Shop Service `shop()`

[](#-shop-service-shop)

Manages shop information and authorization processes.

MethodDescription`generateAuthorizationURL()`Generate authorization URL for shop authorization`getShopInfo()`Retrieve comprehensive shop information and status### 📦 Product Service `product()`

[](#-product-service-product)

Comprehensive product and inventory management capabilities.

MethodDescriptionParameters`getItemList()`Retrieve paginated list of shop items with filters`offset`, `page_size`, `item_status`, `update_time_from`, `update_time_to``getItemBaseInfo()`Get basic product information including pricing and status`item_id_list`, `need_tax_info`, `need_complaint_policy``getItemExtraInfo()`Get extended product details like dimensions and attributes`item_id_list``getModelList()`Retrieve all variants/models for a specific product`item_id``searchItem()`Search products by name, SKU, or status with pagination`item_name`, `item_sku`, `item_status`, `offset`, `page_size` and more`updateStock()`Update inventory levels for product variants in bulk`item_id`, `stock_list``addItem()`Create a new product listing on ShopeeRefer to [Shopee API Reference](https://open.shopee.com/documents/v2/v2.product.add_item?module=89&type=1)`updateItem()`Update an existing product listing`item_id` and any fields to update - refer to [Shopee API Reference](https://open.shopee.com/documents/v2/v2.product.update_item?module=89&type=1)`deleteItem()`Delete a product listing`item_id`### 🛒 Order Service `order()`

[](#-order-service-order)

Handles order management and retrieval with detailed tracking information.

MethodDescriptionParameters`getOrderList()`Retrieve paginated orders within specified date range`time_range_field`, `time_from`, `time_to`, `page_size`, `cursor` and more`getOrderDetail()`Get comprehensive order details by order serial number`order_sn_list`, `request_order_status_pending`, `response_optional_fields`### 💰 Payment Service `payment()`

[](#-payment-service-payment)

Manages payment and financial transaction details.

MethodDescriptionParameters`getEscrowDetail()`Retrieve detailed escrow and payment information for orders`order_sn`Usage Examples
--------------

[](#usage-examples)

The package provides a fluent, chainable API interface. Access services by chaining the service name before calling the method.

### Basic Usage

[](#basic-usage)

```
use Laraditz\Shopee\Facades\Shopee;

// Get order details
$orderDetails = Shopee::order()->getOrderDetail(
    order_sn_list: '211020BNFYMXXX,211020BNFYXXX2'
);

// Get shop information
$shopInfo = Shopee::shop()->getShopInfo();

// Search products
$products = Shopee::product()->searchItem(
    item_name: 'smartphone',
    page_size: 20,
    offset: 0
);

// Add a new product
$newProduct = Shopee::product()->addItem(
    item_name: 'My Product',
    description: 'Product description',
    original_price: 29.90,
    normal_stock: 100,
    weight: 0.5,
    item_sku: 'SKU-001',
    category_id: 100001,
    // ... refer to Shopee API Reference for full parameter list
);

// Update an existing product
Shopee::product()->updateItem(
    item_id: 123456789,
    item_name: 'Updated Product Name',
    original_price: 24.90,
);

// Delete a product
Shopee::product()->deleteItem(item_id: 123456789);

// Alternative: using service container
$orders = app('shopee')->order()->getOrderList(
    time_range_field: 'create_time',
    time_from: strtotime('-30 days'),
    time_to: time(),
    page_size: 50
);
```

### Multi-Shop Support

[](#multi-shop-support)

By default, the package uses `SHOPEE_SHOP_ID` from your `.env` file. For multi-shop applications, specify the shop ID per request:

```
use Laraditz\Shopee\Facades\Shopee;

// Method 1: Using make() with shop_id
$products = Shopee::make(shop_id: '2257XXXXX')
    ->product()
    ->getItemList(
        offset: 0,
        page_size: 10,
        item_status: 'NORMAL'
    );

// Method 2: Using shopId() method
$orders = Shopee::shopId('2257XXXXX')
    ->order()
    ->getOrderList(
        time_range_field: 'create_time',
        time_from: strtotime('-7 days'),
        time_to: time()
    );
```

### Error Handling

[](#error-handling)

```
use Laraditz\Shopee\Facades\Shopee;
use Illuminate\Http\Client\RequestException;

try {
    $result = Shopee::product()->updateStock(
        item_id: 123456789,
        stock_list: [
            [
                'model_id' => 123123123,
                'seller_stock' => [
                    [
                        'location_id' => 'MYZ',
                        'stock' => 100,
                    ]
                ],
            ]
        ]
    );
} catch (RequestException $e) {
    // Handle HTTP/network errors
    logger()->error('Request failed: ' . $e->getMessage());
}
```

Webhook Integration
-------------------

[](#webhook-integration)

This package provides comprehensive webhook support for real-time notifications from Shopee. Refer to [Push Mecahnism](https://open.shopee.com/push-mechanism/5) documentation for more details.

### Event Handling

[](#event-handling)

Create listeners for webhook events to automatically process updates from Shopee:

EventDescription`Laraditz\Shopee\Events\WebhookReceived`Triggered when receiving push notifications from Shopee### Setting Up Webhooks

[](#setting-up-webhooks)

**Configure Webhook URL**: In your Shopee Open Platform dashboard, set the webhook URL to:

```
https://your-app-url/shopee/webhooks

```

**Create Event Listeners to Handle Webhook Data**: Create a listener to process incoming data:

```
