PHP code example of jasara / laravel-selling-partner-api

1. Go to this page and download the library: Download jasara/laravel-selling-partner-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/ */

    

jasara / laravel-selling-partner-api example snippets


return [
    'marketplace_id' => env('AMZN_SPA_MARKETPLACE_ID'),
    'application_id' => env('AMZN_SPA_APPLICATION_ID'),
    'redirect_url' => env('AMZN_SPA_REDIRECT_URL'),
    'use_test_endpoints' => env('AMZN_SPA_USE_TEST_ENDPOINTS'),
    'aws_access_key' => env('AMZN_SPA_AWS_ACCESS_KEY'),
    'aws_secret_key' => env('AMZN_SPA_AWS_SECRET_KEY'),
    'lwa_client_id' => env('AMZN_SPA_LWA_CLIENT_ID'),
    'lwa_client_secret' => env('AMZN_SPA_LWA_CLIENT_SECRET'),
];

$amzn = new \Jasara\LaravelAmznSPA\LaravelAmznSPA(
    tokens: new \Jasara\AmznSPA\DataTransferObjects\AuthTokensDTO(
        access_token: $access_token, // optional if there is a refresh token
        expires_at: $expires_at, // optional, instance of CarbonImmutable
        refresh_token: $refresh_token, // optional if there is an access token, Passing in the refresh token will automatically generate a new access token when needed
    ),
    http: $http, // instance of Illuminate\Http\Client\Factory - if you would like to stub tests, you can pass in a faked HTTP instance
    grantless_token: new \Jasara\AmznSPA\DataTransferObjects\GrantlessTokenDTO(
        access_token: $access_token, // optional, a new token will be automatically generated if not passed in
        expires_at: $expires_at, // optional, instance of CarbonImmutable
    ),
    marketplace_id: $marketplace_id, // e.g. ATVPDKIKX0DER
);

$amzn->notifications->getDestinations();
$destination_id = $response->payload[0]->destination_id;