Approve/decline commissions by Order ID

This is a sample code of how to approve or 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.

Please note, that you can not use this script to decline approved transaction, or approve declined transaction. This script works and change the status of pending transactions only!
If you want to change already approved or declined transaction, you need to use this API.
$papURL = "http://URL_TO_PostAffiliatePro"; //URL of your Post Affiliate Pro installation without any trailing slash
$merchantUsername = ""; //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");   

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

$transaction = new Pap_Api_Transaction($session);


$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();

NOTE: These functions are available since version