Pap_Api_AffiliateSignup

Object for affiliates signup, it doesn't require merchant's credentials or session.


Methods:

add() - inserts new record

setLanguage('en-US') – notification signup email will be sent in 'en-US' language instead of default language, this function is for adding affiliate.

setUserid($value)

setRefid($value)

setParentUserId($value) - signup would fail if incorrect $value is passed. If you want to ignore incorrect value and not fail the process use also setField('parentUserIdValidate', 'N')

setUsername($value)

setPassword($value)

setFirstname($value)

setLastname($value)

setIp($value)

setNotificationEmail($value)

setPayoutOptionId($value)

setPayoutOptionField($code, $value)

 

There are another three special methods related to the way PAP handles affiliate information.

Every affiliate has up to 25 custom fields named data1, data2, ... data25. These fields are configurable, and you can use them to store any information about affiliate.

For example data1 can be Street, data2 = City, etc.

You can edit these assignments in

merchant panel -> Configuration -> Affiliate signup -> Fields.

 

Special methods:

setData($index, $value) – sets data value given in $index variable

getDataName($index) – returns assigned name of the data in given index (index can be: 1 to 25), for example “Street” for data1. It returns empty string for undefined field. (merchant's session is required)

getDataStatus($index) – returns status of data field in given index (index can be: 1 to 25), available values: M – mandatory, O – optional, U - hidden/readonly (merchant's session is required)

setVisitorId($value) – set visitor cookie value, if you want to recognize parent affiliate from cookie value

 

Example of using the affiliate signup object:

<?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->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());
}
?>
×