承接 tims/laravel-flipkart-seller-api 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tims/laravel-flipkart-seller-api

Composer 安装命令:

composer require tims/laravel-flipkart-seller-api

包简介

Laravel integration for the Flipkart Seller API PHP SDK (tims/flipkart-seller-api-php)

README 文档

README

Laravel integration for the Flipkart Seller API PHP SDK (tims/flipkart-seller-api-php).

Why this package?

tims/flipkart-seller-api-php is the API client. This package adds the Laravel layer around it:

  • Config and environment-based credentials
  • Single-seller and multi-seller credential storage
  • Access-token caching via Laravel Cache
  • OAuth helpers for third-party authorization-code flow
  • HTTP retries for 429 and transient 5xx responses
  • Service-container bindings and a FlipkartSellerApi facade
  • Test fakes via FlipkartSellerFake

You continue to call official Flipkart\SellerApi\Api\... classes (or FlipkartSellerClient); this package configures and supports them in Laravel.

Requirements

  • PHP 8.3+
  • Laravel 10, 11, or 12

Installation

composer require tims/laravel-flipkart-seller-api

Publish the config:

php artisan vendor:publish --tag=flipkart-seller-api-config

Configuration

Add these to your .env:

FLIPKART_SELLER_INSTALLATION_TYPE=single

FLIPKART_SELLER_CLIENT_ID=
FLIPKART_SELLER_CLIENT_SECRET=

# PROD or SANDBOX
FLIPKART_SELLER_ENVIRONMENT=SANDBOX

# Optional (third-party OAuth)
FLIPKART_SELLER_REDIRECT_URI=https://your-app.test/flipkart/callback

# Token cache (enabled by default)
FLIPKART_SELLER_TOKEN_CACHE=true

# Retries for 429 / 5xx (enabled by default)
FLIPKART_SELLER_RETRY_ENABLED=true
FLIPKART_SELLER_RETRY_MAX_ATTEMPTS=3
FLIPKART_SELLER_RETRY_BASE_DELAY_MS=500

Single-seller mode

Type-hint FlipkartSellerManager or use the facade:

use Flipkart\SellerApi\Api\ListingsCommonV3Api;
use Tims\FlipkartSellerApi\Facades\FlipkartSellerApi;
use Tims\FlipkartSellerApi\FlipkartSellerManager;

public function index(FlipkartSellerManager $flipkart)
{
    $client = $flipkart->client();
    $listings = $client->listingsCommonV3()->getListings('SKU1,SKU2');

    return response()->json($listings);
}

// Or build an official API class directly:
$api = FlipkartSellerApi::make(ListingsCommonV3Api::class);
$result = $api->getListings('SKU1,SKU2');

In single-seller mode you can also resolve Flipkart\SellerApi\FlipkartSellerClient and Flipkart\SellerApi\ApiClient from the container.

Multi-seller mode

  1. Set FLIPKART_SELLER_INSTALLATION_TYPE=multi (or installation_type in config).
  2. Publish and run migrations:
php artisan vendor:publish --tag=flipkart-seller-api-multi-seller
php artisan migrate
  1. Store sellers and credentials:
use Tims\FlipkartSellerApi\Models\Credentials;
use Tims\FlipkartSellerApi\Models\Seller;

$seller = Seller::create(['name' => 'My Seller']);

$credentials = Credentials::create([
    'seller_id' => $seller->id,
    'environment' => 'SANDBOX',
    // Optional when using shared app credentials from .env
    'client_id' => null,
    'client_secret' => null,
    // Or store a token from OAuth (preferred for third-party apps)
    'access_token' => '',
    'access_token_expires_at' => now()->addSeconds(5184000),
]);
  1. Build clients from a credentials row:
use Flipkart\SellerApi\Api\OrdersV2Api;

$api = $credentials->make(OrdersV2Api::class);
$result = $api->searchOrderItemRequest([/* … */]);

// Or the high-level client:
$client = $credentials->client();
$shipments = $client->shipmentV3()->searchPreDispatchShipmentGet();

client_id / client_secret fall back to the single-seller env values when left null. Secrets and access tokens are stored encrypted.

OAuth (third-party apps)

use Tims\FlipkartSellerApi\OAuth;

$oauth = OAuth::fromConfig();

$authorizeUrl = $oauth->getAuthorizationUri(state: $state);

// After Flipkart redirects back with code + state:
$payload = $oauth->getAccessToken(
    authorizationCode: $request->query('code'),
    state: $request->query('state'),
);

// Store $payload['access_token'] (and expires_in) on Credentials

Retries

HTTP retries for 429 / 5xx / connection errors are enabled by default. Disable globally via config or per client:

$api = FlipkartSellerApi::make(ListingsCommonV3Api::class, options: ['retry' => false]);

Testing

use Flipkart\SellerApi\Api\ListingsCommonV3Api;
use Tims\FlipkartSellerApi\Facades\FlipkartSellerApi;
use Tims\FlipkartSellerApi\Testing\FlipkartSellerFake;

$fake = FlipkartSellerFake::start();
$fake->mock(ListingsCommonV3Api::class, function ($api) {
    $api->shouldReceive('getListings')->andReturn(['items' => []]);
});

$result = FlipkartSellerApi::make(ListingsCommonV3Api::class)->getListings('SKU1');

License

MIT

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-07-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固