<?php

session_start();
require 'PxPay_Curl.inc.php';
require '../secret.php';
//create an instance of the PxPay class
$pxpay = new PxPay_Curl('https://sec.paymentexpress.com/pxpay/pxaccess.aspx', PXPAY_USER, PXPAY_KEY);
//convert the response into something we can use
$response = $pxpay->getResponse($_GET['result']);
//was the transaction successfull
if ($response->getSuccess() == 1) {
    //update the database order to say paid
    echo "<pre>";
    print_r($response);
    //email the client
    //email the website owner
    //clear the cart
}
 public function makeCheckRequest($request, $data)
 {
     $this->onBeforeMakeRequest();
     $pxpay = new PxPay_Curl($this->pxPayUrl, $this->pxPayUserID, $this->pxPayKey);
     return $pxpay->makeRequest($request);
 }
<?php

// Start session
session_start();
// Require the config file
require '../assets/config.php';
// Obtain the resullt from the address bar
$result = $_GET['result'];
// Require the PxPay library
require 'app/PxPay_Curl.inc.php';
// Create an instance of the library
$pxpay = new PxPay_Curl('https://sec.paymentexpress.com/pxpay/pxaccess.aspx', $PxPay_Userid, $PxPay_Key);
// Get the response from payment express
$response = $pxpay->getResponse($result);
// FOR TESTING
echo '<pre>';
print_r($response);
// Connect to the database
$dbc = new mysqli('localhost', 'root', '', 'payment_gateway');
// If the transaction was a success
if ($response->getSuccess()) {
    // Success!
    // Extract the data
    $customerName = $response->getTxnData1();
    $customerAddress = $response->getTxnData2();
    // Mix them together
    // \n\n means new line, it'll take the customers name, create a space and add the customer's address.
    $contact = $customerName . "\n\n" . $customerAddress;
    // Filter the contact info
    $contact = $dbc->real_escape_string($contact);
    // Create a new order
<?php

// Start the session
session_start();
//get the config file
require '../config.php';
require 'app/PxPay_Curl.inc.php';
//create an instance of the library
$pxpay = new PxPay_Curl('https://sec.paymentexpress.com/pxpay/pxaccess.aspx', $PxPay_Userid, $PxPay_Key);
//Create a new request object
$request = new PxPayRequest();
//prepare the url to come back to once payment has been complete
$http_host = getenv('HTTP_HOST');
//localhost. if online than domain name
$folders = getenv('SCRIPT_NAME');
$urlToComeBackTo = 'http://' . $http_host . $folders;
//loopthrough cart and calculate the grand total
$grandTotal = 0;
foreach ($_SESSION['cart'] as $cartItem) {
    $grandTotal += $cartItem['quantity'] * $cartItem['price'];
}
//prepare data for PxPay
$request->setAmountInput($grandTotal);
$request->setTxnType('Purchase');
//transaction type
$request->setCurrencyInput('NZD');
$request->setUrlFail(PROJECT_ROOT . 'payment-response.php');
$request->setUrlSuccess(PROJECT_ROOT . 'payment-response.php');
$request->setTxnData1('Nehal Patel');
$request->setTxnData2('20 Kent Terrace, Wellington, NZ');
$request->setTxnData3('Somthing else');