Git Product home page Git Product logo

shopee-php's Introduction

shopee-php

tests Latest Stable Version Latest Unstable Version composer.lock

This is a Shopee OpenAPI 1.0 Client for PHP.

⚠️ The Shopee Open API v.1.0 will be completely deprecated after 26 December 2022.

Requirements

Installation

Execute the following command to get the package:

$ composer require minchao/shopee-php

Usage

Create an instance of the Shopee client, then use to access the Shopee Partner API.

<?php

use Shopee\Client;

require __DIR__ . '/vendor/autoload.php';

$client = new Client([
    'secret' => getenv('SHOPEE_PARTNER_KEY'),
    'partner_id' => getenv('SHOPEE_PARTNER_ID'),
    'shopid' => getenv('SHOPEE_SHOP_ID'),
]);

Examples

Get detail of item

$response = $client->item->getItemDetail(['item_id' => 1978]);

Alternatively, you can also use the parameter model within request.

$parameters = (new \Shopee\Nodes\Item\Parameters\GetItemDetail())
    ->setItemId(1978);
$response = $client->item->getItemDetail($parameters);

Webhook

Use webhook to receive incoming push notifications:

<?php

/**
 * Push Mechanism (WebHook)
 *
 * @see  https://open.shopee.com/documents?module=63&type=2&id=55
 */

use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Shopee\SignatureGenerator;
use Shopee\SignatureValidator;
use Slim\Factory\AppFactory;

require __DIR__ . '/vendor/autoload.php';

$app = AppFactory::create();
$signatureGenerator = new SignatureGenerator(getenv('PARTNER_KEY'));
$signatureValidator = new SignatureValidator($signatureGenerator);

$app->post('/webhook', function (Request $request, Response $response) use ($signatureValidator) {
    // Verify push content
    if (!$signatureValidator->isValid($request)) {
        error_log('Invalid authorization signature');
        return $response;
    }

    // TODO here to handle your business logic

    // HTTP response must with status code 2xx and empty body
    return $response;
});

$app->run();

License

See the LICENSE file for license rights and limitations (BSD 3-Clause).

shopee-php's People

Contributors

ahmedalahmed avatar ahmedqaid avatar cloudsthere avatar dependabot-preview[bot] avatar dependabot[bot] avatar faizalluthfi avatar igun997 avatar minchao avatar phongphanmage avatar weikenchoo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

shopee-php's Issues

Push Mechanism(WebHook) Application

Hello,
The first thanks for share this library.
I have one question when i try verify for webhook at shopee i can not, so in this library have support?
or can you help me make one simple php code for that ?
Thanks!

Install this package error on Laravel 7 & 8

I am tried install this package, but i has error message

Installation request for guzzlehttp/guzzle (locked at 7.2.0, required as ^6.3.1|^7.0.1) -> satisfiable by guzzlehttp/guzzle[7.2.0]

How to resolved this error. Thanks

no partner_id error param

anyone can help me ?
if i try to request to shopee api i will get response
Array ( [request_id] => 7c29cdd15d984a27e2b0548b749bb3cf [msg] => no partner_id [error] => error_param ) )

and i make new partner id in app list, i got same error again

Get an orders with status "pickup_pending"

Currently I use orders.GetOrdersByStatus with order status READY_TO_SHIP but the results is mixed between orders that has tracking number and no, in shopee seller center we can see orders that still need to be processed in /portal/sale?shipping_center_status=pickup_pending&sort_type=0&type=toship

Can I use the API to get an orders with status pickup_pending without check it one by one using orders.GetOrderDetails ?

missing magic method other than item

Hi, in client.php I think something is missing.
/**

under constructor

    $this->nodes['item'] = new Nodes\Item\Item($this);
    $this->nodes['logistics'] = new Nodes\Logistics\Logistics($this);
    $this->nodes['order'] = new Nodes\Order\Order($this);
    $this->nodes['returns'] = new Nodes\Returns\Returns($this);
    $this->nodes['shop'] = new Nodes\Shop\Shop($this);

Multiple Shop

Hi @minchao ,

How can I integrate more than 1 shop ?
Thanks.

I'm sorry, it's no issue. Just add parameter for shop_id. Issue closed.

Issue Item Update Img

Steps to reproduce:

$params = (new \Shopee\Nodes\Item\Parameters\UpdateItemImg([
                        'item_id' => (int) $shopeeProductId,
                        'images' => [$urlImage]
                    ]));
$client->item->updateItemImage($params);

Errors:
[msg] => type of images is invalid, should be string [request_id] => 8d80c8c0bcb2dce8d12f01ed53c45177 [error] => error_param
@minchao : Can you help to check this ? Shopee team said that it's working by their end.

Webhook signature didnt work

Hi Thanks to make great lib, i had following issue that authorization not passed

// generate from library
[2022-02-14 13:39:24] local.INFO: signature:generator 6eb20be8ea9f711605a66713abec76a4225eb60ab159b7682e97f01233f1d126

// the data i was log from request
[2022-02-14 13:39:24] local.INFO: webhook:forbidden {"authorization":"7b4471f2f78b383d7a53326854b833707fc7aaa1b25192884918634f5a039817","uri":"https://url","content":"{\"code\":0,\"data\":{\"verify_info\":\"This is a Verification message.Please respond in the certain format."}}"}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.