Skip to main content

Retrieve an affiliate by code

Retrieve an affiliate by code

Last updated: 27-Sep-2021
Rate this article:

Overview

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

Request Parameters

Parameters Required Type/Description
AffiliateCode Required String. Unique code which represents an affiliate.

Request Example

<?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.
                                        ListName Name of the affiliate commission list.
                                        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.
                                         FirstName Affiliate first name.
                                         LastName Affiliate last name.
                                        Phone Affiliate phone number.
                                        Email Affiliate email.
                                        Country Country of the affiliate.

Response Example

{  
   "AffiliateCode":"TFTF76455ee4YFCFCT6545465",
   "Status":"Active",
   "Affiliate Name":"STIC Soft E-Solutions Private Limited",
   "Website":"https://debasis.2checkout.com",
   "CommissionList":  {  
         "ListName":"CommissionList1",
         "CommissionRate":"25%"
    },
   "RequestDate":"2018-10-05",
   "Categories":["PC security","Mobile security","Tablet security"],
   "TCStatus":"Accepted",
   "AffiliateContact":{  
      "FirstName":"FN",
      "LastName":"LN",
      "Phone":"0040723483987",
      "Email":"FN.LN@2AFFLT.COM",
      "Country":"Spain"
   }
}

 

Rate this article:
Logo of Verifone