This example shows how to create a new affiliate, more about class Pap_Api_Affiliate you can read here or about class Pap_Api_AffiliateSignup you can read here.

 
<?php
include 'PapApi.class.php'; //Download PapApi.class.php from the merchant panel
$session = new Pap_Api_Session("URL_to_PAP/scripts/server.php");
if(!@$session->login("merchant@example.com","merchant_password")) {
  die("Cannot login. Message: ". $session->getMessage());
}

$affiliate = new Pap_Api_Affiliate($session);

$affiliate->setUsername("some@email.com");
$affiliate->setFirstname("John");
$affiliate->setLastname("Smith");
$affiliate->setData(3, "Affiliate City");
//$affiliate->setPassword("aff_password");

try {
  if ($affiliate->add()) {
    echo "Affiliate saved successfully";
  } else {
    die("Cannot save affiliate: ".$affiliate->getMessage());
  }
} catch (Exception $e) {
    die("Error while communicating with PAP: ".$e->getMessage());
}

?>
 

Use Pap_Api_AffiliateSignup for using the same way as affiliate signup form, you don't need to use merchant credentials:

 
<?php
include 'PapApi.class.php'; //Download PapApi.class.php from the merchant panel
$session = new Pap_Api_Session("URL_to_PAP/scripts/server.php");

$affiliate = new Pap_Api_AffiliateSignup($session);

$affiliate->setUsername("testaffiliate@email.com");
$affiliate->setParentUserId('testaff');
//$affiliate->setField('parentUserIdValidate', 'N'); - set to not fail the signup process if an incorrect parent user ID is passed above
$affiliate->setFirstname("test");
$affiliate->setLastname("affiliate");
$affiliate->setRefid('testaff10');
$affiliate->setData(1, "urlExample");
$affiliate->setData(2, "companyNameExample");
$affiliate->setData(3, "streetExample");
$affiliate->setData(4, "cityExample");
$affiliate->setData(5, "streetExample");
$affiliate->setData(6, "GB");

$affiliate->setPassword("affpassword"); // use it if you want to set password

try {
  if ($affiliate->add()) {
    echo "Affiliate saved successfully id: " . $affiliate->getUserid();
  } else {
    die("Cannot save affiliate: ".$affiliate->getMessage());
  }
} catch (Exception $e) {
    die("Error while communicating with PAP: ".$e->getMessage());
}
?>
 

To set also payout option with its fields you can use setPayoutOptionField() function. The first step would be to find out the 'code' of the needed payout option field(s). Navigate to your merchant panel Configuration> Payout Options and edit the payout option which you want to work with. Each field has its 'code':

 

In the example above, the payout option has two fields, so the API code for it would look like this:

$affiliate->setPayoutOptionField("pp_email", "paypal@email.com");
$affiliate->setPayoutOptionField("backup", "paypal2@email.com");
 

For some additional configuration like to "Do not sent notification email" use Low-level API, example:

<?php
include 'PapApi.class.php'; //Download PapApi.class.php from the merchant panel
$session = new Pap_Api_Session("URL_to_PAP/scripts/server.php");
if(!@$session->login("merchant@example.com","merchant_password")) {
  die("Cannot login. Message: ". $session->getMessage());
}

$request = new Gpf_Rpc_FormRequest('Pap_Merchants_User_AffiliateForm', 'add', $session);

$request->setField('username', 'some@email.com');
$request->setField('firstname', 'John');
$request->setField('lastname', 'Smith');
$request->setField('refid', 'MyRefId');
$request->setField('dontSendEmail', 'Y');

try {
  $request->sendNow();
}
catch(Exception $e) {
  die("API call error: ".$e->getMessage());
}

$response = $request->getStdResponse();
if ($response->success == 'Y') {
  echo 'Successful: ' . $response->message;
}
else {
  echo 'Unsuccessful: ' . $response->message;
}
?>
 

Possible params are there fields from signup form (Configuration -> Affiliate signup -> Fields tab). Mandatory fields are also mandatory in this request except the field password. Other possible params:

 
rpassword
photo - url or path to photo image
rstatus - A (approved), P (pending), D (declined)
note
dontSendEmail - Y or N
createSignupReferralComm - Y or N
×