Getting started example

We'll make a short example of making a simple request that will retrieve a list of affiliates. You will get more detailed documentation about the classes and methods in the documentation for each class. To start using the API, you have to include file _PapApi.class.php_ into your PHP code. This file contains all the necessary classes. You can download the _PapApi.class.php_ file from the merchant panel: _Tools > Integration > API Integration > Download PAP API_ include 'P...

How to approve affiliate sale tracking code

In this example you can see how to approve existing affiliate sale tracking code (https://support.qualityunit.com/573712-Affiliate-Sale-Tracking-Codes) via API. Creating of new affiliate sale tracking code via API is described here (https://support.qualityunit.com/608230-How-to-create-affiliate-sale-tracking-code). <?php //the PapApi.class.php can be downloaded from the merchant panel at Tools > Integration > API Integration > Download PAP API include 'PapApi.class.php'; //this inc...

How to create affiliate sale tracking code

In this example you can see how to create new affiliate sale tracking code (https://support.qualityunit.com/573712-Affiliate-Sale-Tracking-Codes) for a specific affiliate and specific campaign via API. By default each sale tracking code is created as Pending and merchant need to approve it. How to approve existing affiliate sale tracking code via API is described here (https://support.qualityunit.com/909884-How-to-approve-affiliate-sale-tracking-code). <?php //the PapApi.class.php can be do...

Import lifetime relationships

Sometimes, when you are using the lifetime commissions (https://support.qualityunit.com/541587-Lifetime-commissions) feature (and you have a lot of new affiliates with their own customers), you may want to import all their relationships to PAP at once. In this case, we made the following script which imports relationships from a CSV file. The CSV file has to be in this exact format (below you can download an example). In the API script you have to replace PAP URL, merchant's username an...

Logging in the merchant and affiliate

Here is an example of one click login for merchant and affiliate using API. You can redirect automatically logged in affiliate to his/her panel. Logging in as merchant: include_once('PapApi.class.php'); $session = new Pap_Api_Session("http://demo.postaffiliatepro.com/scripts/server.php"); if(!@$session->login("merchant@example.com", "demo")) { die("Cannot login. Message: ".$session->getMessage()); } If you want to redirect user (merchant/affiliate) to his panel after Pap_Api_Session...

Approve/decline commissions by Order ID

This is a sample code of how to approve/decline pending transactions by Order ID, it will approve all pending transactions with inserted Order ID (all tiers and all products), also transactions which are not processed by cron. <?php $papURL = "http://URL_TO_PostAffiliatePro"; //URL of your Post Affiliate Pro installation without any trailing slash $merchantUsername = "merchant@example.com"; //merchant username $merchantPassword = "123456"; //merchant password //your PapApi.class.php file...

Send password reset email to affiliate

If you have created external login forms for your affiliates you might also need an API solution to send out a password reset email to the affiliate. Below is the code with explanations in the comments which you might use to do just that. Important parts are highlighted. <?php //your PapApi.class.php file can be downloaded in the merchant panel: Tools>Integration>API Integration>Download PAP API include_once ("PapApi.class.php"); //this include assumes the PapApi.class.php is i...

Allow affiliates to add sale manually from the affiliate panel

Sometimes, you may need to give your affiliates an option to add sales manually. You can achieve it by creating a custom page (http://support.qualityunit.com/023779-How-to-create-Custom-PageURL-Page)in their affiliate panel and in that page include a simple php script (file) of yours via iframe. The steps to follow are: * create a new PHP file (in this example we call it affaddsale.php) and insert this code into the file: <html><head><title> Add your sale here </title&...

Get (retrieve) banner codes via API (only for affiliates)

If some affiliates wish to obtain their banner codes via API so that they add all their banners to their page(s) dynamically and the fastest way possible, then the following php API example will come in handy. <?php define('URL_TO_PAP','http://URL_To_PostAffiliatePro'); //URL to Post Affiliate Pro (network) without any trailing slash define('AFFILIATE_USERNAME','affiliate@example.com'); //affiliate username define('AFFILIATE_PASSWORD','demo'); //affiliate password define('API_FILE','Pa...

Get the Top Affiliates report via API

The following sample script shows how to get the Top Affiliates report data via API. <?php // the PapApi.class.php file can be downloaded from the merchant panel at: // Tools > Integration > API Integration > Download PAP API // This include assumes the PapApi.class.php file is in the same directory as this particular script. include 'PapApi.class.php'; $papURL = "http://URL_TO_PostAffiliatePro"; //URL to Post Affiliate Pro without any trailing slash $merchantUsername = "merchan...

Load banner/campaign categories tree

This is a sample code of how to load all campaigns categories: <?php $papURL = "http://URL_TO_PostAffiliatePro"; //URL of your Post Affiliate Pro installation without any trailing slash $merchantUsername = "merchant@example.com"; //merchant username $merchantPassword = "123456"; //merchant password //your PapApi.class.php file can be downloaded in the merchant panel: //Tools>Integration>API Integration>Download PAP API include_once ("PapApi.class.php"); //this include assumes th...

Add a Replicated site banner via API

This is a sample code of how to create a Replicated site banner via API. <?php $papURL = "http://URL_TO_PostAffiliatePro"; //URL of your Post Affiliate Pro installation without any trailing slash $merchantUsername = "merchant@example.com"; //merchant username $merchantPassword = "123456"; //merchant password //your PapApi.class.php file can be downloaded in the merchant panel: //Tools>Integration>API Integration>Download PAP API include_once ("PapApi.class.php"); //this inclu...

Get the list of affiliates invited to any private campaign

This sample script shows the same result as the "Campaigns > Affiliates in campaigns" grid in the merchant panel. More exactly, it lists the affiliates and names of private (public with manual approval) campaigns the affiliates belong to. <?php // the PapApi.class.php file can be downloaded from the merchant panel at: // Tools > Integration > API Integration > Download PAP API // This include assumes the PapApi.class.php file is in the same directory as this particular script. ...

Add commission group to a campaign via API

The following sample code shows how to add a commission group to a campaign. It behaves the same way as if you added a commission group to a campaign through the merchant panel, so the commission types that you already have in a campaign will be automatically created within the freshly added/created commission group. <?php //the PapApi.class.php can be downloaded from the merchant panel at Tools > Integration > API Integration > Download PAP API include 'PapApi.class.php'; //th...

Display affiliates of a private campaign via API

The following sample code shows how to display the list of affiliates invited to a particular private campaign. <?php //the PapApi.class.php can be downloaded from the merchant panel: //Tools > Integration > API Integratoin > Download PAP API include_once 'PapApi.class.php'; //campaign ID (http://support.qualityunit.com/425816-How-do-I-find-a-campaign-ID-) of the particular private campaign $campaignID = '9e394454'; $session = new Pap_Api_Session("http://URL_TO_PAP/scripts/serv...

Create (import) coupons via API

The following 2 examples will show how to create (import) coupons via php API. 1. Created (imported) coupons will have to be assigned manually to affiliates <?php //your PapApi.class.php file can be downloaded in the merchant panel: Tools>Integration>API Integration>Download PAP API include ("PapApi.class.php"); //this include assumes the PapApi.class.php is in the same dir as this script //change localhost/pap to the path of your Post Affiliate Pro installation $session = new...

Add DirectLink URL via API

Here is an example how to add a DirectLink URL via API using merchant login credentials. NOTE: You will need to know the exact userid of the affiliate to whom the DirectLink URL should be assigned. You can get the userid of an affiliate via the following API: http://support.qualityunit.com/608550-Pap_Api_AffiliatesGrid while you can filter the affiliate via his/her username (e-mail address). <?php // the PapApi.class.php file can be downloaded from the merchant panel at: // Tools...

Add product ID to existing campaign via API

The following code is an example how to add product id(s) to an existing campaign. NOTE: it will replace the existing product IDs. If you wish to keep the existing product IDs, then first you have to load the campaign (http://support.qualityunit.com/295078-Loading-campaigns) and its product IDs and add them again along with the new product ids. <?php $papURL = "http://URL_TO_PAP"; //URL to PAP/PAN without trailing slash $merchantUsername = "merchant@username.com"; //replace with your usern...

Delete merchant via API

The following example shows how to delete a merchant via API, while we filter the merchant via his/her username (e-mail address) <?php //the PapApi.class.php can be downloaded from the merchant panel: //Tools > Integration > API Integratoin > Download PAP API include 'PapApi.class.php'; //---------------------------------------------- // login as main merchant or network-owner in case of PAN $session = new Pap_Api_Session("http://URL_TO_PAP/scripts/server.php"); if(!@$session-&g...

Change the status of recurring regulations via API

If you ever wanted to change the status of existing recurring regulations found at Transactions > Recurring commissions via API, then the following sample script might come in handy: <?php include_once 'PapApi.class.php'; $papURL = "URL_TO_PostAffiliatePro"; //URL to Post Affliate Pro including protocol, but without any trailing slash $merchantUsername = "merchant@example.com"; //merchant username $merchantPassword = "123456"; //merchant password $session = new Pap_Api_Session($papUR...

Get the list of recurring regulations (recurring commissions)

The following API example shows how to obtain the unique IDs (or other details) of recurring regulations that you see in the merchant panel at Transactions > Recurring commissions. <?php include_once ("PapApi.class.php"); //this include assumes the PapApi.class.php is in the same dir as this script //change localhost/pap to the path of your Post Affiliate Pro installation $session = new Pap_Api_Session("http://URL_TO_PAP/scripts/server.php"); //login as merchant if(!$session->login...

Get the list of Raw Clicks

The following example shows how to obtain the list of Raw Clicks via API. <?php // PapApi.class.php can be downloaded from the merchant panel at Tools > Integration > API Integration include '../pap/api/PapApi.class.php'; $papURL="http://URL_TO_PAP"; //URL leading to PAP/PAN without trailing slash $merchantUsername = "merchant@user.com"; $merchantPassword = "merchantpassword"; //------------------------------------------------------------------ // login (as merchant) $session = new...

Add channel via API

Sample code to add channel via API. NOTE: It requires affiliate login credentials. <?php $desiredChannelName = "MyTestChannel"; //up to 255 characters $desiredChannelCode = "MTC"; //up to 255 characters $papURL = "http://localhost/pap"; //URL to PAP without trailing slash $affiliateUsername = "affiliate@username.com"; $affiliatePassword = "password"; //the PapApi.class.php can be found at the PAP installation folder, in the 'api' directory //or downloaded from the merchant panel includ...

How to update URL links of images

If the URL address of your installation of Post Affiliate Pro has changed (e.g. the installation has been moved to another domain or directory) and if you are using full URLs in your banner images, campaign logos, application logo, you can update these links by this script: <?php include 'PapApi.class.php'; $session = new Pap_Api_Session('url_to_your_pap_installation/scripts/server.php'); if(!@$session->login('merchant_username', 'merchant_password')) { die("Cannot login. Message: ". $...

Display online users (merchants, affiliates) via API

The following script publishes the merchants, affiliates being logged in. <?php //---------------------------------------------- // PapApi.class.php can be downloaded from the merchant panel at: // Tools > Integration > API Integration > Download PAP API // This include assumes the PapApi.class.php file is in the same directory as this particular script include 'api/PapApi.class.php'; //---------------------------------------------- // login (as merchant) $session = new Pap_Api_...

Display or update affiliate payout options via API

The following php API example shows how to update the payout option information of a particular affiliate. <?php //your PapApi.class.php file can be downloaded in the merchant panel: Tools>Integration>API Integration>Download PAP API include ("PapApi.class.php"); //this include assumes the PapApi.class.php is in the same dir as this script $papURL = "http://localhost/pap"; //URL leading to your Post Affiliate Pro (or Network) without trailing slash $merchantUsername = "test@merc...

PAN: change merchant password via API

The following script enables the network owner to change the password of any merchant belonging to his Post Affiliate Network via php API. <?php //your PapApi.class.php file can be downloaded in the merchant panel: //Tools > Integration > API Integration > Download PAP API //this include assumes the PapApi.class.php is in the same dir as this script include ("PapApi.class.php"); $panURL ="http://yoursite.com/PostAffiliateNetwork"; //URL to PAN without trailing slash // change it...

Delete banners via API

If you wish to delete banners via php API, you need to know the IDs of the particular banners. <?php include 'PapApi.class.php'; $session = new Pap_Api_Session("http://URL_TO_PAP/scripts/server.php"); if(!$session->login("merchant@example.com","demo")) { die("Cannot login. Message: ". $session->getMessage()); } $bannerIDs = array('38a9d2c8','bb1723b8','e6c99e22'); //delete banners identified by those banner IDs $request = new Gpf_Rpc_FormRequest("Pap_Merchants_Banner_BannerForm", "...

Load sent mail templates via API

As you may have noticed, if you send some custom e-mail from Post Affiliate Pro 4 merchant panel via _Emails > Send message_, then the particular template gets saved and you can load it anytime by clicking the "Load email from template ..." link But what if you wish to load such a saved custom e-mail template via API? Here is a sample script that loads all the saved custom templates: <?php //the PapApi.class.php can be downloaded from the merchant panel: // Tools > Integrati...

Get the list of PAN Accounts via API

The following sample code shows how a network-owner can get the list of Accounts of his/her Post Affiliate Network via API <?php //your PapApi.class.php file can be downloaded in the merchant panel: Tools>Integration>API Integration>Download PAP API include ("PapApi.class.php"); //this include assumes the PapApi.class.php is in the same dir as this script $session = new Pap_Api_Session("http://URL_TO_PAN/scripts/server.php"); //login as merchant if(!$session->login("network-o...

Display campaigns, commission groups and commission settings of an affiliate via API

This is a complete sample code that shows the campaigns, commission groups and commission settings of the commission group in which a particular affiliate is involved. <?php //Download PapApi.class.php from the merchant panel: // Tools > Integration > API Integration > Download PAP API // the include_once below assumes the PapApi.class.php is in the same folder as this script include_once 'PapApi.class.php'; $papURL = "http://yoursite.com/pap"; //change it for the real URL of yo...

Configuring campaign commissions via API

After you add a campaign via API (http://support.qualityunit.com/468152-Add-campaign-through-API) it is essential to configure its commissions. Here is a sample script how to configure a campaign's commission structure (the default commission group) -- Sale or Click commission. If you wish to add an action commission (http://support.qualityunit.com/131732-Action-Commissions) to a campaign via API then check the notes below this sample code or click here (#actionCommission). <?php //you...

Add banner via API

<?php // the PapApi.class.php file can be downloaded from the merchant panel at: // Tools > Integration > API Integration > Download PAP API // This include assumes the PapApi.class.php file is in the same directory as this particular script. include 'PapApi.class.php'; $session = new Pap_Api_Session("http://URL_TO_PAP/scripts/server.php"); //user your merchant username and password below if(!$session->login("Merchant Username","Merchant Password")) { die("Cannot login. Message: "...

How to load coupon details

If you want to get informations about coupon and affiliate from coupon code, you can use class _Pap_Features_Coupon_OfflineSaleForm_. <?php include 'PapApi.class.php'; //the PapApi.class.php can be found at the PAP installation folder, in the 'api' directory $session = new Pap_Api_Session("http://your_pap_url/scripts/server.php"); if(!$session->login("merchant login","password")) { die("Cannot login. Message: ". $session->getMessage()); } $couponCode = 'xxxxxx'; $request = ne...

How to load (display) coupons via php API?

The following code shows, how you can load valid and assigned coupons via php API. <?php //your PapApi.class.php file can be downloaded in the merchant panel at: //Tools>Integration>API Integration>Download PAP API //this include below assumes the PapApi.class.php is in the same dir as this script include ("PapApi.class.php"); //change localhost/pap to the path of your Post Affiliate Pro installation $session = new Pap_Api_Session("http://localhost/pap/scripts/server.php"); //login...

How to assign coupon

Examples how to assign coupon using API you can read in Coupons feature description: How to assign coupon using API (http://support.qualityunit.com/531726-How-to-assign-coupon-using-API)

How to Update API file

This example shows how to check version of API file and how to update it. In return command of first function write right url of your PAP. <?php //base url of your pap function getPapUrl() { return 'http://www.yoursite.com/affiliate/'; } //name of api file (with path if it is not in the same directory as this script) function getApiFilename() { return 'PapApi.class.php'; } function getVersionFromPap() { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, getPapUrl().'api/version.php'); cu...

Loading campaigns

If you want to load campaigns grid, you can use this example: <?php include 'PapApi.class.php'; //the PapApi.class.php can be downloaded from Tools->Integration->API->Download PapApi.class.php $session = new Pap_Api_Session("http://your_pap_url/scripts/server.php"); if(!$session->login("merchant login","password")) { die("Cannot login. Message: ". $session->getMessage()); } $request = new Gpf_Rpc_GridRequest("Pap_Merchants_Campaign_CampaignsGrid", "getRows", $session); $r...

How to load channel stats for affiliate

If you want to load channel stats report for affiliate, you can send grid request to class _Pap_Affiliates_Reports_ChannelStatsGrid_. Notice that you need to use affiliate login details for api login, because channel stats report is from affiliate panel. <?php include 'PapApi.class.php'; //the PapApi.class.php can be found at the PAP installation folder, in the 'api' directory $session = new Pap_Api_Session("http://your_pap_url/scripts/server.php"); if(!$session->login("affiliate@...

How to load statistics data

If you want to get statistics data which are used in Traffic stats widget or in reports (Quick, Trends), you can use class _Pap_Merchants_Reports_TrafficStatsData_. In case you wish to load the data for a particular affiliate, then you can log in as an affiliate via api (http://support.qualityunit.com/367540-Logging-in-the-merchant-and-affiliate) or use 'userid' filter: $filters[] = array("userid", Gpf_Data_Filter::EQUALS, '11111111'); Loading traffic stats data: <?php ...

How to load affiliate manager information

Here is example how can affiliate load affiliate manager information. <?php include 'PapApi.class.php'; //the PapApi.class.php can be found at the PAP installation folder, in the 'api' directory $session = new Pap_Api_Session("http://your_pap_url/scripts/server.php"); if(!$session->login("affiliate login","password", Pap_Api_Session::AFFILIATE)) { die("Cannot login. Message: ". $session->getMessage()); } $request = new Gpf_Rpc_FormRequest("Pap_Affiliates_MerchantInfo", "load", $...

How to recompute transaction

This examples show how to recompute commission of transaction. If you know campaignid, userid, commissiontypeid you can compute commission so: <?php include 'PapApi.class.php'; //the PapApi.class.php can be found at the PAP installation folder, in the 'api' directory //---------------------------------------------- // login (as merchant) $session = new Pap_Api_Session("URL_to_PAP/scripts/server.php"); if(!$session->login("merchant@example.com","merchant_password")) { die("Cannot...

Get affiliate ID based on the visitor ID

Many times you will need to use affiliate ID but you only have visitor ID value from cookies. Use this example to help you to get the affiliate ID (or any other value) based on the visitor ID. <?php include 'PapApi.class.php'; //Download PapApi.class.php from the merchant panel $session = new Pap_Api_Session('http://www.yoursite.com/pap4/scripts/server.php'); if(!@$session->login("merchant@test.com","merchantpassword")) { die("Cannot login. Message: ". $session->getMessage());...

Add affiliate

This example shows how to create new affiliate, more about class Pap_Api_Affiliate you can read here (http://support.qualityunit.com/961744-Pap_Api_Affiliate) or about class Pap_Api_AffiliateSignup you can read here (http://support.qualityunit.com/397716-Pap_Api_AffiliateSignup). <?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_pas...

PAN: Edit merchant info via API

The following sample script shows how to change the password of a network merchant via API. NOTE: it requires network-owner login credentials OR if another merchant would like to use it, he/she would have to have 'network owner privileges (http://support.qualityunit.com/067568-How-to-create-merchant-with-network-owner-privileges)'. <?php //your PapApi.class.php file can be downloaded in the merchant panel: //Tools>Integration>API Integration>Download PAP API include ("PapApi.c...

PAN: Add merchant account

This example shows how to add merchant account in Post Affiliate Network. <?php include 'PapApi.class.php'; //the PapApi.class.php can be downloaded from the merchant panel: Tools > Integration > API Integration > Download PAP API $session = new Pap_Api_Session("URL_to_PAP/scripts/server.php"); //---------------------------------------------- // login (as merchant / network owner) is not required, as this request is same as signup merchant account // but if you use captcha fo...

How to remove affiliates

If you want to remove affiliates, you can use method _deleteRows _in class _Pap_Merchants_User_AffiliateForm_. <?php include 'PapApi.class.php'; //the PapApi.class.php can be found at the PAP installation folder, in the 'api' directory $session = new Pap_Api_Session("http://your_pap_url/scripts/server.php"); if(!$session->login("merchant login","password")) { die("Cannot login. Message: ". $session->getMessage()); } $userIds = array('11111111','6f4936c8'); //delete affiliats w...

How to display dates in the correct timezone

All dates which you receive and send through API are in the server's timezone (Post Affiliate Pro uses by default the 'America/Los_Angeles' timezone), but dates displayed in the merchant/affiliate panel are displayed in the client timezone (PC regional settings). Here you can see some examples how to set the dates by API to be displayed in the desired timezone. First, you need to know your local timezone (find it out here (http://www.timezoneconverter.com/cgi-bin/findzone.tzc)), since it is...

Refund of Transaction

Example code that loads transactions (even tier commissions) with the defined order ID and refunds them, which means that another transaction with the same order ID, total cost, but negative commission and with type of 'refund' will be created. <?php //----------------------------------------------------------------------- // PapApi.class.php can be downloaded from the merchant panel at: // Tools > Integration > API Integration > Download PAP API require_once 'PapApi.class.php'...

Change status of a transaction

This example shows how to change the status of a transaction via API. Commission is found by trans action ID. If you want to only approve pending commissions by Order ID read this article: http://support.qualityunit.com/650825-Approvedecline-commissions-by-Order-ID <?php //the PapApi.class.php can be downloaded from the merchant panel of Post Affiliate Pro //at Start --> Tools > Integration > API Integration > Download PAP API include 'PapApi.class.php'; //----------------------...

Add campaign through API

Here is an example code which you can use to create campaign in your Post Affiliate Pro through API: <?php include 'PapApi.class.php'; //this include assumes the PapApi.class.php is in the same directory as this api script itself $session = new Pap_Api_Session("http://URL_TO_YOUR_PAP_INSTALLATION/scripts/server.php"); //log in as merchant if(!@$session->login("merchant username","merchant password")) { die("Cannot login. Message: ". $session->getMessage()); } $request = new Gpf_Rp...

Add action commission to a campaign via API

Here is an example how you can add an action commission to a campaign via API: <?php //PapApi.class.php can be downloaded from the merchant panel: //Start > Tools > Integration > API Integration > Download PAP API // or can be found in the 'api' folder of your installation of Post Affiliate Pro include 'PapApi.class.php'; //log in as merchant $session = new Pap_Api_Session("http://yoursite.com/PostAffiliatePro/scripts/server.php"); if(!$session->login("merchant@username.c...

Integration with Joomla 1.5.X and lower

Task - when user signs up to Joomla, sign them up also to the affiliate system. For this example we'll use Joomla 1.5.8, and we'll develop a simple Joomla plugin that will call PAP4 API upon user registration in Joomla. To develop a new plugin in Joomla we need to create two files: pap4.xml <?xml version="1.0" encoding="utf-8"?> <install version="1.5" type="plugin" group="user" method="upgrade"> <name>User - PAP4 Register</name> <author>Maros Fric</author>...

Integration with Joomla 2.5.X

The plugin will handle synchronization of user signup with your Post Affiliate Pro 4 installation. To develop a new plugin in Joomla we need to create two files: pap4.xml <?xml version="1.0" encoding="utf-8"?> <extension version="2.5" type="plugin" group="user"> <name>User - Post Affiliat Pro signup synchro</name> <author>Martin Pullmann with Brendon Hatcher</author> <creationDate>June 2012</creationDate> <copyright>(C) 2012 Quality Un...

Integration with Joomla 3

The plugin will handle synchronization of user signup with your Post Affiliate Pro 4 installation. To develop a new plugin in Joomla we have to create these two main files: pap4.xml <?xml version="1.0" encoding="utf-8"?> <extension version="3" type="plugin" group="user"> <name>plg_user_pap4</name> <author>Martin Pullmann</author> <creationDate>January 2013</creationDate> <copyright>(C) 2012 Quality Unit</copyright> <license>...

Add WHMCS clients as affiliates to PAP via API

The following script has to be saved into the 'includes/hooks' directory of your WHMCS installation and it will be executed upon adding a new client. Make sure, that the signup page fields of Post Affiliate Pro are set to optional at Configuration > Affiliate signup > Fields (tab) NOTE: if you wish to recognize the referring affiliate and set him as parent of the new affiliate you must add a client custom field (http://docs.whmcs.com/Custom_Fields#Client_Custom_Fields) into the regis...

Redirect visitor to affiliate's replicated page

If you want to redirect visitor to affiliate's replicated based on the information from cookie you can use following API code: <?php include_once('PapApi.class.php'); $session = new Pap_Api_Session("URL_TO_PAP/scripts/server.php"); // register click $clickTracker = new Pap_Api_ClickTracker($session); try { $clickTracker->track(); $clickTracker->save3rdPartyCookiesOnly(); } catch (Exception $e) { } $refid = 'testaff'; // default affiliate if ($clickTracker->getAffiliate() != null) {...

How to get commissiontypeid for campaign and commissiontype

This example shows how to get commissiontypeid for certain campaign and commissiontype. When you create transaction using class Pap_Api_Transaction, you need know commissiontypeid. You can find it manually in Merchant panel: Start -> Campaigns manager -> Edit -> Commissions settings <?php include 'PapApi.class.php'; //the PapApi.class.php can be found at the PAP installation folder, in the 'api' directory //---------------------------------------------- // login (as mercha...

Approve affiliate with API

Following example shows, how you can approve pending affiliate using Post Affiliate Pro API. Include API: include_once('PapApi.class.php'); Login as merchant to get rights manipulating with Affiliate rows: $session = new Pap_Api_Session("http://demo.qualityunit.com/pax4/scripts/server.php"); if(!$session->login("merchant@example.com", "demo")) { die("Cannot login. Message: ".$session->getMessage()); } Load affiliate data: // loading affiliate by his ID $affiliate = new Pap_Ap...

Adding affiliate to commission group

Here is an example how to add affiliate to commission group. This example assumes that you already know the desired affiliate id, campaign id and commission group id. <?php include 'affiliate/api/PapApi.class.php'; $session = new Pap_Api_Session("http://localhost/affiliate/scripts/server.php"); if(!$session->login("merchant@example.com", "demo")) { die("Cannot login. Message: ".$session->getMessage()); }else{ echo "Success"; } $request = new Gpf_Rpc_FormRequest("Pap_Features_Commission...

How to get commission group id

Here is example how to retrieve the commission groupId for a campaign: <?php include 'PapApi.class.php'; //the PapApi.class.php can be found at the PAP installation folder, in the 'api' directory $session = new Pap_Api_Session("http://your_pap_url/scripts/server.php"); if(!$session->login("merchant login","pass")) { die("Cannot login. Message: ". $session->getMessage()); } $request = new Gpf_Rpc_Request("Pap_Merchants_Campaign_CommissionGroups","loadCommissionGroups",$session); ...

WHMCS Integration

Create a file (name it e.g. pap.php) in the /includes/hooks/ directory of your installation of WHMCS and use the following code there. NOTE: Do not forget to follow the instructions in the code below (see them after the double slash // ) in the first few lines. <?php include_once '/PATH_TO_PAP/api/PapApi.class.php'; // Change to correct path add_hook("AfterShoppingCartCheckout",20,"pap_Track",""); add_hook("InvoicePaid",0,"pap_InvoicePaid",""); add_hook("InvoiceUnpaid",0,"pap_InvoiceD...