PHP code example of itaccfarm / reseller-api-sdk

1. Go to this page and download the library: Download itaccfarm/reseller-api-sdk 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/ */

    

itaccfarm / reseller-api-sdk example snippets



// and/or
use ITAccfarm\ResellerSDK\ResellerSDK;

$api = new ResellerSDK();

$authData = $api->auth('[email protected]', 'pass');

if (empty($success)) {
    throw new Exception('Wrong credentials');
}

$bearerToken = $authData['bearerToken'];
$userSecret = $authData['userSecret'];

// Store $userSecret & $bearerToken
// ...

$categories = $api->categories();
$offers = $api->offers(['product_id' => 4]);
$user = $api->user();

$api = new ResellerSDK('token', 'secret'); 

$api = new \ITAccfarm\ResellerSDK\ResellerSDK($bearerToken, $userSecret);

$response = [
  'number' => 'order_number',
  'status' => 'status_id',
  'total' => 'price',
  'secret_key' => 'secret_key'           
  'download_link' - 'link' // if needed
];

function signCallbackData(string $secret, array $data)
{
    ksort($data);

    $string = '';

    foreach($data as $value) {
        if (in_array(gettype($value), ['array', 'object', 'NULL']) ){
            continue;
        }
        if(is_bool($value) && $value){
            $string .= 1;
        } else {
            $string .= $value;
        }
    }

    return hash_hmac('sha512', strtolower($string), $secret);
}

$json = file_get_contents('php://input');
$data = json_decode($json);
$headers = getallheaders();

$secret = 'my_secret';
$testSignature = signCallbackData($secret, $data);
$signature = $headers['Signature'];

if (!hash_equals($signature, $testSignature)) {
    // Error, wrong signature
    die;
}

// Process data
// ...