Change status of a transaction

This example shows how to change the status of a transaction via API. Commission is found by transaction ID. If you want to only approve pending commissions by Order ID read this article:
//the PapApi.class.php can be downloaded from the merchant panel of Post Affiliate Pro
//at Start --> Tools > Integration > API Integration > Download PAP API

include 'PapApi.class.php'; 

// login (as merchant)
$session = new Pap_Api_Session("URL_to_PAP/scripts/server.php");

if(!$session->login("","merchant_password")) {
    die("Cannot login. Message: ".$session->getMessage());
// loading a transaction with exact id e.g.:  e367f77a
$sale = new Pap_Api_Transaction($session);


if (!($sale->load())) { //loads the record with the given transaction id.
    die ("Loading of transaction failed!".$sale->getMessage());
// reading the status of a transaction
$status = $sale->getStatus();
echo "Getting status: " . $status;

// changing the status of a transaction
if ($status == 'P') { //if the status of the current transaction is Pending ('P' = pending; 'A' = Approved,  'D' = Declined)
	//then change its status to Approved. (If you change the 'A' for 'D' then it will change the status of the transaction to Declined)
    $sale->setMerchantNote('transaction verified'); //merchant note can be viewed by both merchant and affiliate
echo "Status of the transaction has been changed.";

More information on available transaction parameters can be found here.
As you may see in the example above, you must know the ID of the transaction in order to load it. The ID is not ORDER ID. But, you can use the following API to get the ID of a transaction based on ORDER ID: