WebToPay integration
The faster way to send and receive money all over the world.
This integration method uses integration with WebToPay API. More info about this payment gateway can be found here:
https://www.webtopay.com/index.php?2595448377
The integration method is divided into two main sections:
- Passing the visitor ID (cookie value) to the webtopay gateway
- Reading the response from webtopay
Getting the cookie value
First thing is to get the cookie value, e.g. using standard PHP methods, or you can use our script that reads it from cookies:
writeCookieToCustomField OR writeCookieToLink
<script id="pap_x2s6df8d" src="https://URL_TO_PostAffiliatePro/scripts/trackjs.js" type="text/javascript"></script>
<script type="text/javascript">
PostAffTracker.writeCookieToCustomField('fullCookieInfoId');
PostAffTracker.writeCookieToLink('affCookieLinkId', 'papCookie');
</script>
Based on the method you used, you can get the cookie value from GET or POST parameter.
Passing the visitor ID into the gateway
Now, when you have the value, you have to attach it to callbackurl, BEFORE using the function WebToPay::buildRequest($request).
E.g. if your callbackurl parameter was set like this:
$request[‘callbackurl’] = $request_url;
append the cookie value, sent in GET parameter like this:
...
$request['callbackurl'] = $request_url."?papCookie=".$_GET['papCookie'];
...
This will send get parameter “papCookie” to the gateway. This is needed so we can use Post Affiliate Pro API when parsing response from webtopay… otherwise the sale would be unreferred.
Parsing the response
After calling the function WebToPay::checkResponse() in your callbackurl, in a place where you are sure everything is correct, you can call our API to register a commission.
Do not forget to set correct path to your PapApi.class.php file (in api/ directory of Post Affiliate Pro):
// Post Affiliate Pro integration snippet --------------------------
if (isset($_GET['papCookie']) && (strlen($_GET['papCookie']) > 20)) {
require_once "path_to_PAP/api/PapApi.class.php"; // set correct path to API file here
$saleTracker = new Pap_Api_SaleTracker('https://URL_TO_PostAffiliatePro/scripts/sale.php');
$saleTracker->setAccountId('default1');
$saleTracker->setVisitorId(substr($_GET['papCookie'], -32)); // returns only visitor ID, no "default1" prefix
$total = $response['amount']/100; // need to get rid of hundreds
$sale = $saleTracker->createSale();
$sale->setTotalCost($total);
$sale->setOrderID($response['orderid']);
$saleTracker->register();
}
// /Post Affiliate Pro integration snippet -------------------------
This is all you need to track a sale commission.
More info can be found here:
https://www.webtopay.com/index.php?683722975