Implementation of automatic commission evaluation

Implementation of automatic commission evaluation

Approving and rejecting commissions can also be done using the API. You can modify your own system so that when the status of the order changes, or when another action is taken that defines in your system that the order was successfully completed (paid, recieved, not returned) you run a PHP code that also approves (or rejects) corresponding commission also in our affiliate system.

How to do it:

For APIs it is necessary to download PapApi.class.php. For the latest version go to https://login.dognet.sk/api/download.php.

Enter your login data to the Dognet system and in the orderID parameter you set the insertion of the order ID.

<?php
$papURL = "https://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 the PapApi.class.php is in the same dir as this script

$session = new Pap_Api_Session($papURL."/scripts/server.php");   
//$session->setDebug(); 

//login as merchant
if(!@$session->login($merchantUsername, $merchantPassword)) { 
  die ("Cannot login. Message: ".$session->getMessage());
}

$transaction = new Pap_Api_Transaction($session);

$transaction->setOrderId('ORD_12345'); // PAP will try to change status of commission with order ID exactly ORD_12345 and if not found then of all commissions like ORD_12345(%), so of all per product commissions for given order ID.

$result = $transaction->approveByOrderId('note message'); //note message for affiliate is optional, can be empty
//use declineByOrderId() if you want to decline pending commissions by order ID
//$result = $transaction->declineByOrderId('note message');

if ($result->isError()) {
  echo 'Error: '.$result->getErrorMessage();
} else {
  echo 'Ok: '.$result->getInfoMessage();
}

?>

You can approve commission $transaction->approveByOrderId(); or decline $transaction->declineByOrderId();. You need to IF based on the order status what action will be taken. Then, you must set the call of this function, for example, every time the order status changes. You can run the code on every order. It doesn’t matter if the given order ID is not in our system.

You can also create 2 different PHP codes, where one code will be for approval and the other for rejection, and you will call them based on the status of the order.

Example of if-ifing:

if($your_internal_order_status==’OK’) { $transaction->approveByOrderId(); }

if($your_internal_order_status==’CANCELED’) { $transaction->declineByOrderId(); }

 

Katka Novotná

Viac ako dva roky som pracovala na pozícií e-commerce marketér a zvyšovala som obraty rôznym eshopom. Niektoré z nich sa vyšplhali až na Shop Roku (ocenenie od Heureka.sk). Mám skúsenosti s PPC Adwords aj Facebook. Analytics mi je veľmi blízky. Pre reklamnú agentúru Wiktor Leo Burnett som pomáhala s UX/UI webových projektov a aplikácií pre veľkých klientov. Vo voľnom čase tvorím webové stránky založené prevažne na WordPresse.

More articles that might interest you

Which campaigns are available in our network?