PHP code example of tims / laravel-flipkart-seller-api

1. Go to this page and download the library: Download tims/laravel-flipkart-seller-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/ */

    

tims / laravel-flipkart-seller-api example snippets


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');

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),
]);

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();

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

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

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');
bash
php artisan vendor:publish --tag=flipkart-seller-api-config
bash
php artisan vendor:publish --tag=flipkart-seller-api-multi-seller
php artisan migrate