Sale (action) tracking request data description

Sale/action tracking request

 
This request is sent from sale tracker to Post Affiliate Pro server:
 
http://my_pap_url/scripts/track.php?visitorId=b910a79d013c8856a01393511GPTWP0s&accountId=&url=H_localhost%2Ftests%2Fapi%2Fme%2Fsale.php&referrer=&tracking=1&getParams=&ip=127.0.0.1&sale=%5B%7B%22ac%22%3A%22%22%2C%22t%22%3A%22100%22%2C%22f%22%3A%22%22%2C%22o%22%3A%22oid%22%2C%22p%22%3A%22pid%22%2C%22d1%22%3A%22data1value%22%2C%22d2%22%3A%22data2value%22%2C%22d3%22%3A%22data3value%22%2C%22d4%22%3A%22data4value%22%2C%22d5%22%3A%22data5value%22%2C%22a%22%3A%22testaff%22%2C%22c%22%3A%2255a22310%22%2C%22b%22%3A%22%22%2C%22ch%22%3A%22channelid%22%2C%22cc%22%3A%22%22%2C%22s%22%3A%22A%22%2C%22cr%22%3A%22Eur%22%2C%22cp%22%3A%22couponcode%22%2C%22ts%22%3A%22%22%7D%5D
The base of it is same as in a click request, since it contains the following  parameters (they are common in both click request and sale tracking request): visitorIdaccountIdurl,referrertrackingipuseragent.
 
The difference is that getParams is empty and the new sale parameter contains all the information about the created sale:
 

Sale data parameters:

 
ac: action code, if you want to register an action commission (so not a 'sale' type of action); for simple sale tracking keep it empty
- t: total cost
- f: fixed cost
- o: order id
- p: product id
- d1: extra data1
- d2: extra data2
- d3: extra data3
- d4: extra data4
- d5: extra data5
- a: affiliate id or referral id (if should be recognized from cookie, let it empty)
- c: campaign id  (if should be recognized from cookie, let it empty)
- b: banner id  (if should be recognized from cookie, let it empty)
ch: channel id
cc: custom commission
s: status, force to set this status, possible values 'A', 'P', 'D' for approved, pending, declined
cr: currency of sale
cp: coupon code
 
Sale parameters are in JSON format and url encoded.
 

Response

 
Response works the same way as for click tracking request, if cookie is empty the response returns a value to be saved in cookie, otherwise the response is empty (blank).

Example

 
A simple example how to compose such a sale tracking request in php:
 
<?php

$saleData = array(array(
    "ac"=>"",
    "t"=>"100",
    "f"=>"",
    "o"=>"myorderid",
    "p"=>"myproductid",
    "d1"=>"data1value",
    "d2"=>"data2value",
    "d3"=>"data3value",
    "d4"=>"data4value",
    "d5"=>"data5value",
    "a"=>"",
    "c"=>"",
    "b"=>"",
    "ch"=>"",
    "cc"=>"",
    "s"=>"",
    "cr"=>"",
    "cp"=>"couponcode",
    "ts"=>""
));

$accountId = '';
$visitorid = @$_COOKIE['PAPVisitorId'];

$ip = $_SERVER['REMOTE_ADDR'];
$referer = encodeUrlParam($_SERVER['HTTP_REFERER']);
$urlParam = encodeUrlParam('http://'.$_SERVER["SERVER_NAME"].$_SERVER['SCRIPT_NAME']);

$url ='http://your_postaffiliatepro_url/scripts/track.php?visitorId='.$visitorid. '&accountId='.$accountId.'&url='.$urlParam.'&referrer='.$referer.'&tracking=1&getParams=&ip='.$ip;

$encodedSaleData = 'sale=' . urlencode(json_encode($saleData));

$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $encodedSaleData);

$json_response = curl_exec($curl);

curl_close($curl);
echo ($json_response);

function encodeUrlParam($url) {
	$url = str_replace('http://', 'H_', $url);
	$url = str_replace('https://', 'S_', $url);
	return $url;
}

?>