PHP code example of incenteev / async-amazon-incentives

1. Go to this page and download the library: Download incenteev/async-amazon-incentives 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/ */

    

incenteev / async-amazon-incentives example snippets


use AsyncAws\Core\Configuration;
use Incenteev\AsyncAmazonIncentives\AmazonIncentivesClient;
use Incenteev\AsyncAmazonIncentives\Enum\CurrencyCode;
use Incenteev\AsyncAmazonIncentives\Exception\SystemTemporarilyUnavailableException;
use Incenteev\AsyncAmazonIncentives\Region;
use Incenteev\AsyncAmazonIncentives\ValueObject\MoneyAmount;

// Get your credentials in the Amazon Incentives portal
$accessKey = '';
$secretKey = '';
$partnerId = '';

// Choose the region corresponding to your partnership, with either the sandbox or production one.
$region = Region::EUROPE_AND_ASIA_SANDBOX;

$client = new AmazonIncentivesClient([
    Configuration::OPTION_ACCESS_KEY_ID => $accessKey,
    Configuration::OPTION_SECRET_ACCESS_KEY => $secretKey,
    Configuration::OPTION_REGION => $region,
]);

try {
    $result = $client->createGiftCard([
        'partnerId' => $partnerId,
        'creationRequestId' => '', // Create the proper request id
        'value' => new MoneyAmount(['amount' => 10, 'currencyCode' => CurrencyCode::EUR]),
    ]);

    $code = $result->getGcClaimCode();
} catch (SystemTemporarilyUnavailableException $e) {
    // TODO handle temporary failures according to the Amazon Incentives best practices
}