Grid object - this class handles requests to the list of payouts. You can use it to search and filter in merchant payouts.
Note: This api is for merchant only.
Methods:
- all methods are inherited from Gpf_Rpc_GridRequest class, check it's documentation.
- addAllAffiliatesToPay() - this adds all affiliates loaded to payouts grid to payout process
- addAffiliateToPay(affiliateid) - this adds affiliate with id affiliateid to payout process
- payAffiliates(paymentNote, affiliateNote, send_payment_to_affiliate, send_generated_invoices_to_merchant, send_generated_invoices_to_affiliates) - this launches the payout process. Payment note is note for merchant, affiliateNote is note for affiliate. set send_payment_to_affiliate = Y if you want to affiliate recieve notification mail about this payment. Set send_generated_invoices_to_merchant = Y if you want to PAP generate invoice for this payment and deliver it to merchant. Set send_generated_invoices_to_affiliates = Y if you want PAP generate invoice for this payment and deliver it to affiliate
Possible filters you can use:
- methods - list of id's of payout methods ids separated by comma
- reachedMinPayout - Y or N
- dateinserted - date value
- rstatus - list of statuses separated by comma
- campaignid - id of campaign
Example of retrieving the list of all commissions to be paid (all payouts to be done):
include '../api/PapApi.class.php'; $session = new Pap_Api_Session("https://yourserver.com/scripts/server.php"); if(!$session->login("your_merchant_name", "merchant_password")) { die('Failed authentication'); } $payoutRequest = new Pap_Api_PayoutsGrid($session); $payoutRequest->addParam('columns', new Gpf_Rpc_Array(array(array('id'), array('userid'), array('username'), array('firstname'), array('lastname'), array('commission'), array('payoutMethod'), array('payoutData'), array('pendingAmount'), array('declinedAmount'), array('rstatus'), array('campaignid'), array('accountuserid')))); $payoutRequest->addFilter('dateinserted',Gpf_Data_Filter::DATERANGE_IS,Gpf_Data_Filter::RANGE_LAST_7_DAYS); $payoutRequest->addFilter('campaignid',Gpf_Data_Filter::EQUALS,'cid123'); $payoutRequest->addFilter('reachedMinPayout',Gpf_Data_Filter::EQUALS,'Y'); //... $payoutRequest->sendNow(); $payoutGrid = $payoutRequest->getGrid(); $recordset = $payoutGrid->getRecordset(); //print list of transactions to pay affiliates foreach($recordset as $rec) { echo $rec->get('id') . ';' . $rec->get('firstname') . ';' . $rec->get('lastname') . ';' . $rec->get('username') .';' . $rec->get('amounttopay') . '</br>'; }
Possible values you can get from grid (default):
- username
- firstname
- lastname
- userid
- commission
- minimumpayout
- payoutMethod
Other values you can get, if you use param 'columns' with column names from example above: "$payoutRequest->addParam('columns', ...":
- pendingAmount
- declinedAmount
- campaignid
- rstatus
- accountuserid
//and now pay them $payoutRequest->addAllAffiliatesToPay(); //adds all loaded affiliates to payout process $payoutRequest->payAffiliates(); //pay them
Or we can add only specified affiliate and pay him:
$payoutRequest->addAffiliateToPay('aff123'); //adds affiliate aff123 to payout process $payoutRequest->payAffiliates(); //pay him