Home > Post Affiliate Pro > Programmers documentation > API > Examples > Change status of a transaction

Change status of a transaction

This example shows how to change the status of a transaction via API. 


//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 Gpf_Api_Session("URL_to_PAP/scripts/server.php");

if(!$session->login("merchant@example.com","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 ("<br>Loading of transaction failed!<br>".$sale->getMessage());
// reading the status of a transaction
$status = $sale->getStatus();
echo "<br>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)
$sale->setStatus('A');  //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 "<br>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:

Quality Unit's products


LiveAgent integrates live chat software and help desk software features into a single customer support solution.

Try it free

Post Affiliate Pro

Post Affiliate Pro is a full featured affiliate tracking software ready to power your own affiliate program.

Buy Now