/** * Manages the 'return' and 'cancel' replies */ function complete() { $this->extend("EwayPayment_Handler_completion_start"); if (isset($_REQUEST['code']) && ($code = $_REQUEST['code'])) { $params = explode('-', $code); if (count($params) == 2) { $payment = EwayPayment::get()->byID(intval($params[0])); if ($payment && $payment->AuthorisationCode == $params[1]) { if (isset($_REQUEST['AccessPaymentCode'])) { $url = $payment->EwayConfirmationURL($_REQUEST['AccessPaymentCode']); $response = file_get_contents($url); if ($response) { $response = Convert::xml2array($response); if (isset($response['ResponseCode']) && $response['ResponseCode'] == '00') { $payment->Status = 'Success'; } else { $payment->Status = 'Failure'; } } else { $payment->Status = 'Failure'; } $payment->write(); $payment->redirectToOrder(); } } } } }
function eway_capture($params) { if ($params['testmode']) { $url = "https://www.eway.com.au/gateway/xmltest/testpage.asp"; } else { if ($params['beagle'] && $params['cccvv']) { $url = "https://www.eway.com.au/gateway_cvn/xmlbeagle.asp"; } else { $url = "https://www.eway.com.au/gateway/xmlpayment.asp"; } } $eway = new EwayPayment($params['customerid'], $url); $eway->setCustomerFirstname($params['clientdetails']['firstname']); $eway->setCustomerLastname($params['clientdetails']['lastname']); $eway->setCustomerEmail($params['clientdetails']['email']); $eway->setCustomerAddress($params['clientdetails']['address1'] . ", " . $params['clientdetails']['city'] . ", " . $params['clientdetails']['state']); $eway->setCustomerPostcode($params['clientdetails']['postcode']); $eway->setCustomerCountry($params['clientdetails']['country']); $eway->setCustomerInvoiceDescription($params['description']); $eway->setCustomerInvoiceRef($params['invoiceid']); $eway->setCardHoldersName($params['clientdetails']['firstname'] . " " . $params['clientdetails']['lastname']); $eway->setCardNumber($params['cardnum']); $eway->setCardExpiryMonth(substr($params['cardexp'], 0, 2)); $eway->setCardExpiryYear(substr($params['cardexp'], 2, 2)); $eway->setCardCVN($params['cccvv']); $eway->setTrxnNumber($params['invoiceid']); $eway->setTotalAmount(round($params['amount'] * 100, 2)); $desc = "Action => Capture\nClient => " . $params['clientdetails']['firstname'] . " " . $params['clientdetails']['lastname'] . "\n"; $result = $eway->doPayment(); foreach ($eway->xmlData as $key => $value) { $desc .= "" . $key . " => " . $value . "\n"; } if ($result == EWAY_TRANSACTION_OK) { return array("status" => "success", "transid" => $eway->getTrxnNumber(), "rawdata" => $desc); } return array("status" => "declined", "rawdata" => $desc); }
function process_payment($order_number, $order_total, &$d) { global $vendor_name, $VM_LANG, $vmLogger; $auth = $_SESSION['auth']; /*** Get the Configuration File for eway ***/ require_once CLASSPATH . "payment/" . $this->classname . ".cfg.php"; /* eWAY Gateway Location (URI) */ if (EWAY_TEST_REQUEST == "FALSE") { define("GATEWAY_URL", "https://www.eway.com.au/gateway_cvn/xmlpayment.asp"); } else { define("GATEWAY_URL", "https://www.eway.com.au/gateway_cvn/xmltest/testpage.asp"); } // Get user billing information $db = new ps_DB(); $qt = "SELECT * FROM #__users WHERE id='" . $auth["user_id"] . "' AND address_type='BT'"; $db->query($qt); $db->next_record(); // WE need the $order_total in cents! $order_total = $order_total * 100; // We need to show the year with two digits only $year = substr($_SESSION['ccdata']['order_payment_expire_year'], 2, 2); $my_trxn_number = uniqid("eway_"); $payer_name_is = $_SESSION['ccdata']['order_payment_name']; $eway = new EwayPayment(EWAY_CUSTID, GATEWAY_URL); $eway->setCustomerFirstname($db->f("first_name")); $eway->setCustomerLastname($db->f("last_name")); $eway->setCustomerEmail($db->f("email")); $eway->setCustomerAddress($db->f("address_1")); $eway->setCustomerPostcode($db->f("zip")); $eway->setCustomerInvoiceDescription($vendor_name . " Order"); $eway->setCustomerInvoiceRef($order_number); $eway->setCardHoldersName($payer_name_is + ''); $eway->setCardNumber($_SESSION['ccdata']['order_payment_number']); $eway->setCardExpiryMonth($_SESSION['ccdata']['order_payment_expire_month']); $eway->setCardExpiryYear($year + ''); $eway->setCardCVN($_SESSION['ccdata']['credit_card_code']); $eway->setTrxnNumber($my_trxn_number); $eway->setTotalAmount($order_total); if ($eway->doPayment() == EWAY_TRANSACTION_OK) { $d["order_payment_log"] = $VM_LANG->_('PHPSHOP_PAYMENT_TRANSACTION_SUCCESS'); //Catch Transaction ID $d["order_payment_trans_id"] = $eway->getTrxnNumber(); //$d["error"] = ""; return true; } else { $vmLogger->err($VM_LANG->_('PHPSHOP_PAYMENT_ERROR', false) . ": " . $eway->getErrorMessage()); //Catch Transaction ID $d["order_payment_trans_id"] = $eway->getTrxnNumber(); return false; } }