* This code sample shows a very based approach
* on handling data that is posted to a script running
* a merchant's server after a transaction is processed
* through their BluePay gateway account.
*/
include "BluePayPayment_BP20Post.php";
$secretKey = '';
// get POST parameters
$transID = isset($_REQUEST['trans_id']) ? $_REQUEST['trans_id'] : null;
$transStatus = isset($_REQUEST['trans_status']) ? $_REQUEST['trans_status'] : null;
$transType = isset($_REQUEST['trans_type']) ? $_REQUEST['trans_type'] : null;
$amount = isset($_REQUEST['amount']) ? $_REQUEST['amount'] : null;
$batchID = isset($_REQUEST['batch_id']) ? $_REQUEST['batch_id'] : null;
$batchStatus = isset($_REQUEST['batch_status']) ? $_REQUEST['batch_status'] : null;
$totalCount = isset($_REQUEST['total_count']) ? $_REQUEST['total_count'] : null;
$totalAmount = isset($_REQUEST['total_amount']) ? $REQUEST['total_amount'] : null;
$batchUploadID = isset($_REQUEST['bupload_id']) ? $REQUEST['bupload_id'] : null;
$rebillID = isset($_REQUEST['rebill_id']) ? $_REQUEST['rebill_id'] : null;
$rebillAmount = isset($_REQUEST['reb_amount']) ? $_REQUEST['reb_amount'] : null;
$rebillStatus = isset($_REQUEST['status']) ? $_REQUEST['status'] : null;
// calculate expected bp_stamp
$bpStamp = BluePayPayment_BP20Post::calcTransNotifyTPS($secretKey, $transID, $transStatus, $transType, $amount, $batchID, $batchStatus, $totalCount, $totalAmount, $batchUploadID, $rebillID, $rebillAmount, $rebillStatus);
// check if expected bp_stamp = actual bp_stamp
if (isset($_REQUEST['bp_stamp'])) {
    if ($bpStamp == $_REQUEST['bp_stamp']) {
        // Read response from BluePay
        echo 'Transaction ID: ' . $transID . '<br />' . 'Transaction Status: ' . $transStatus . '<br />' . 'Transaction Type: ' . $transType . '<br />' . 'Transaction Amount: ' . $amount . '<br />' . 'Rebill ID: ' . $rebillID . '<br />' . 'Rebill Amount: ' . $rebillAmount . '<br />' . 'Rebill Status: ' . $rebillStatus . '<br />';
    }
} else {
    echo 'ERROR IN RECEIVING DATA FROM BLUEPAY';
}
<?php

/**
* BluePay PHP Sample code.
*
* This code sample runs a report that grabs a single transaction 
* from the BluePay gateway based on certain criteria. 
* See comments below on the details of the report.
* If using TEST mode, only TEST transactions will be returned.
*/
include "BluePayPayment_BP20Post.php";
$accountID = "MERCHANT'S ACCOUNT ID HERE";
$secretKey = "MERCHANT'S SECRET KEY HERE";
$mode = "TEST";
// Merchant's Account ID
// Merchant's Secret Key
// Transaction Mode: TEST (can also be LIVE)
$query = new BluePayPayment_BP20Post($accountID, $secretKey, $mode);
/* RUN A SINGLE TRANSACTION QUERY */
// Report Start Date: Jan. 1, 2013
// Report End Date: Jan. 15, 2013
// Do not include errored transactions? Yes
$query->getSingleTransQuery('2013-01-01', '2013-01-15', '1');
// Query by a specific Transaction ID
$query->queryByTransactionID('100122319414');
$query->process();
# Read response from BluePay
echo 'Response: ' . $query->getResponse() . '<br />' . 'First Name: ' . $query->getName1() . '<br />' . 'Last Name:  ' . $query->getName2() . '<br />' . 'Transaction ID: ' . $query->getID() . '<br />' . 'Payment Type ' . $query->getPaymentType() . '<br />' . 'Transaction Type: ' . $query->getTransType() . '<br />' . 'Amount: ' . $query->getAmount() . '<br />';