Row object - class representing one transaction (commission) record. You can use it to retrieve, edit and manually add commissions.

 

Methods:

load() - loads record with given transaction id. You have to set transaction id before calling this method.

save() - save changes in given record (record must be loaded first).

add() - inserts new record

refund($note = '', $fee = 0, $refundMultiTier = false, $refundValue = 0) - makes refund of transaction with optional note and fee that is substracted from commission, set $refundMultiTier to true if you want to refund all tiers. Set $refundValue to the refunded value if this was a partial refund only.
chargeback($note = '', $fee = 0, $refundMultiTier = false, $refundValue = 0) - makes chargeback of transaction with optional note and fee that is substracted from commission. Set $refundValue to the refunded value if this was a partial refund only.

refundByOrderId($note = '', $fee = 0, $refundValue = 0), chargeBackByOrderId($note = '', $fee = 0, $refundValue = 0) - here you can see example how to use it: https://support.qualityunit.com/715772-Refund-of-Transaction

 

getMessage() - returns error message in case of error

 

the following methods get/set the corresponding fields.

getTransid(), setTransid($value)

getParentTransactionId(), setParentTransactionId($value) – ID of parent transaction if the transaction is higher tier or refund type

getType(),setType($value) – transaction type, allowed values: I – CPM commission, C – per click commission, S – sale, A – action, B – signup bonus, U – recurring commission, F – referral commission, R – refund, H – chargeback, E – extra bonus

 

getStatus(),setStatus($value) – allowed values: A – approved, P – pending, D - declined

 

getMultiTierCreation(), setMultiTierCreation($value) – sets if you want to create also sub-tier commissions depending on this commission. Allowed values: Y – yes, N – no.

 

getUserid(),setUserid($value)

getBannerid(),setBannerid($value)

getParentBannerid(),setParentBannerid($value)

getCampaignid(),setCampaignid($value)

getCountryCode(),setCountryCode($value)

getDateInserted(),setDateInserted($value)

getDateApproved(),setDateApproved($value)

getPayoutStatus(),setPayoutStatus($value)  – allowed values: P – paid, U – unpaid (you can set paid only if multi tier creation is disabled)

getPayoutHistoryId(),setPayoutHistoryId($value)

getRefererUrl(),setRefererUrl($value)

getIp(),setIp($value)

getBrowser(),setBrowser($value)

getCommission(),setCommission($value)

getOrderId(),setOrderId($value)

getProductId(),setProductId($value)

getTotalCost(),setTotalCost($value)

getTier(),setTier($value)

getChannel(),setChannel($value)

getCommTypeId(),setCommTypeId($value)

getMerchantNote(),setMerchantNote($value)

getSystemNote(),setSystemNote($value)

getData($index),setData($index, $value)

getRecurringCommid(),setRecurringCommid($value)

 

getTrackMethod(),setTrackMethod($value) – tracking method used, available values: U – unknown, 3 – 3rd party cookie, 1 - 1st party cookie, F – Flash cookie, R – forced parameter, I – IP address, D – default (nor referred) affiliate, M – manual commission, L – lifetime referral, O – recurring commission

 

If the system uses multiple currencies, it stores the original currency (passed by tracking script) in the following fields:

getOriginalCurrencyId(),setOriginalCurrencyId($value)

getOriginalCurrencyValue(),setOriginalCurrencyValue($value)

getOriginalCurrencyRate(),setOriginalCurrencyRate($value)

 

 

Every transaction contains also information about the first and last click that let to this transaction:

getFirstClickTime(),setFirstClickTime($value)

getFirstClickReferer(),setFirstClickReferer($value)

getFirstClickIp(),setFirstClickIp($value)

getFirstClickData1(),setFirstClickData1($value)

getFirstClickData2(),setFirstClickData2($value)

getLastClickTime(),setLastClickTime($value)

getLastClickReferer(),setLastClickReferer($value)

getLastClickIp(),setLastClickIp($value)

getLastClickData1(),setLastClickData1($value)

getLastClickData2(),setLastClickData2($value)

getClickCount(),setClickCount($value)

approveByOrderId($note = ''),declineByOrderId($note = '') - https://support.qualityunit.com/650825-Approvedecline-commissions-by-Order-ID

Complete source code for the example:

How to create one commision for affiliate, and automaticaly generate multi-tier commisions for its parents:

 

<?php
include 'PapApi.class.php';

//----------------------------------------------
// login (as merchant)

$session = new Pap_Api_Session("https://exampleurl.com/server/scripts/server.php");

if(!$session->login("login@email.com","password")) {
  die("Cannot login. Message: ".$session->getMessage());
}
//Create new transaction:
$transaction = new Pap_Api_Transaction($session);

//Fill custom data:
$transaction->setDateInserted("2010-07-15 14:25:59");
$transaction->setDateApproved("2010-07-15 14:25:59");
$transaction->setCampaignid("99079a08");
$transaction->setTotalCost("10");
$transaction->setCommTypeId("525d71d2"); //Can be found in Merchant panel: Campaigns -> Campaign manager -> edit campaign (pencil icon) -> Commission settings
$transaction->setStatus("A"); 
$transaction->setUserid("bdff507a");

//This will automatomaticaly count multi-tier commissions for parent affiliates
$transaction->setMultiTierCreation("Y");

//Adding transaction
if ($transaction->add()) {
  echo 'ok ';
  echo 'ID of created transaction: ' . $transaction->getTransId() . ', ';
} else {
  echo 'error ';
}

//OPTIONAL - To view status (success/error) of added transaction
echo $transaction->getMessage() . "\n"; 
?>

 

 

Here you can find example how to get commissiontypeid manually or using API code.
 
Deleting transaction is not as simple. While refunds are preferable, sometimes you need to delete the transactions. For that you need to use Gpf_Rpc_FormRequest. Here is how:
 
// Create request to delete.
$request = new Gpf_Rpc_FormRequest("Pap_Merchants_Transaction_TransactionsForm", "deleteRows", $session);

// Id needs to be the coupon you try to test
$request->addParam('ids',new Gpf_Rpc_Array(array('809cd8a5')));
// you can delete more rows with one call.. just put more ids in the array.

// send request
try {
 $request->sendNow();
} catch(Exception $e) {
 die("API call error: ".$e->getMessage());
}
×