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

$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 5.4.0.1