For the complete documentation index, see llms.txt. This page is also available as Markdown.

Retrieve an affiliate by code

Use the getAffiliate method to extract details about an affiliate by code.

Request parameters

Parameters
Type / Description

AffiliateCode

Required (string)

Unique code which represents an affiliate.

Request sample

<?php

function callRPC($Request, $hostUrl, $Debug = true)
{
    $curl = curl_init($hostUrl);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($curl, CURLOPT_SSLVERSION, 0);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        'Content-Type: application/json',
        'Accept: application/json',
        'Cookie: XDEBUG_SESSION=PHPSTORM',
    ));
    $RequestString = json_encode($Request);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $RequestString);


    if ($Debug) {
        var_dump($RequestString);
    }
    $ResponseString = curl_exec($curl);
    if ($Debug) {
        var_dump($ResponseString);
    }

    if (!empty($ResponseString)) {
//        var_dump($ResponseString);
        $Response = json_decode($ResponseString);
        if (isset($Response->result)) {
            return $Response->result;
        }
        var_dump($Response);

        if (!is_null($Response->error)) {
            var_dump($Request->method, $Response->error);
        }
    } else {
        return null;
    }
}


$apiVersion = '6.0';
$host = "http://api.sandbox34.avangate.local/rpc/" . $apiVersion . "/";

$merchantCode = "lucian";
$key = "SECRET_KEY";

$date = gmdate('Y-m-d H:i:s');

$string = strlen($merchantCode) . $merchantCode . strlen($date) . $date;
$hash = hash_hmac('md5', $string, $key);

$i = 1; // counter for api calls
// call login
$jsonRpcRequest = new stdClass();
$jsonRpcRequest->jsonrpc = '2.0';
$jsonRpcRequest->method = 'login';
$jsonRpcRequest->params = array($merchantCode, $date, $hash);
$jsonRpcRequest->id = $i++;

$sessionID = callRPC($jsonRpcRequest, $host);
var_dump($sessionID);

$affiliateId = "79396127BA";
// Active:
// 1295 - 964CF2AF42
// 11541 - E4B69882C2
// 12951 - E8A1DB473C
// 12950 - 44857BFE94

// Pending:
// 13639 - F56BCF1E2E

// Rejected
// 65602 - 79396127BA

$jsonRpcRequest = new stdClass();
$jsonRpcRequest->jsonrpc = '2.0';
$jsonRpcRequest->method = 'getAffiliate';
$jsonRpcRequest->params = array($sessionID, $affiliateId);
$jsonRpcRequest->id = $i++;
echo "\nRESPONSE: \n\n";
$getAffiliate = callRPC($jsonRpcRequest, $host, false);

print_r(json_encode($getAffiliate));

Response parameters

Parameters
Description

AffiliateCode

Unique, system-generated identifying code of the affiliate.

Status

Merchant Affiliate relationship status.

AffiliateName

Name of the affiliate.

Website

Website of the affiliate.

CommissionList

Affiliate commission list.

CommissionList.ListName

Name of the affiliate commission list.

CommissionList.CommissionRate

Value of the commission rate (in %).

RequestDate

Categories

Product category of the affiliate.

NotifyUpdates

Boolean

Value can be TRUE or FALSE.

TCSStatus

AffiliateContact

Affiliate contact details.

AffiliateContact.FirstName

Affiliate first name.

AffiliateContact.LastName

Affiliate last name.

AffiliateContact.Phone

Affiliate phone number.

AffiliateContact.Email

Affiliate email.

AffiliateContact.Country

Country of the affiliate.

Response sample

Last updated

Was this helpful?