Files
2017-03-02 20:30:40 -06:00

127 lines
3.6 KiB
PHP

<?php
/*
+--------------------------------------------------------------------------
| CubeCart v3.0.15
| ========================================
| by Alistair Brookbanks
| CubeCart is a Trade Mark of Devellion Limited
| Copyright Devellion Limited 2005 - 2006. All rights reserved.
| Devellion Limited,
| 22 Thomas Heskin Court,
| Station Road,
| Bishops Stortford,
| HERTFORDSHIRE.
| CM23 3EE
| UNITED KINGDOM
| http://www.devellion.com
| UK Private Limited Company No. 5323904
| ========================================
| Web: http://www.cubecart.com
| Date: Thursday, 4th January 2007
| Email: sales (at) cubecart (dot) com
| License Type: CubeCart is NOT Open Source Software and Limitations Apply
| Licence Info: http://www.cubecart.com/site/faq/license.php
+--------------------------------------------------------------------------
| call.inc.php
| ========================================
| APC for the Nochex Gateway
+--------------------------------------------------------------------------
*/
// read the POST data and compile request string for validation call
$params = array();
foreach ($_POST as $key => $value){
$value = urlencode(stripslashes($value));
$params[] = "$key=$value";
}
$params = implode("&", $params);
$validation_url = "www.nochex.com";
// post back to Nochex server to validate
$header .= "POST /nochex.dll/apc/apc HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($params) . "\r\n\r\n";
$fp = fsockopen ($validation_url, 80, $errno, $errstr, 30);
if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $params);
while (!feof($fp)){
$res = fgets ($fp, 1024);
if (strcmp ($res, "AUTHORISED") == 0){
$fail = FALSE;
$cleared = TRUE;
$summary = $db->select("SELECT prod_total, comments FROM ".$glob['dbprefix']."CubeCart_order_sum WHERE cart_order_id = ".$db->mySQLsafe($_POST['order_id']));
// check that the transaction has not been previously processed
$txn_id = $db->select("SELECT * FROM ".$glob['dbprefix']."CubeCart_order_sum WHERE sec_order_id = ".$db->mySQLsafe($_POST['transaction_id']));
if($txn_id == TRUE) {
$fail = TRUE;
}
/*
else
{
//$updateOrderTxn['sec_order_id'] = $db->mySQLSafe($_POST['transaction_id']);
//$update = $db->update($glob['dbprefix']."CubeCart_order_sum", $updateOrderTxn,"cart_order_id=".$db->mySQLSafe($_POST['order_id']));
}
*/
// check that the transaction status is correct and mark test transactions
if(strtolower($_POST['status'])=="test"){
if($module['testMode']==0){
$fail = TRUE;
} else {
$cleared = FALSE;
}
}
// check that to_email is your Nochex email address
if(strtolower($_POST['to_email'])!==strtolower(trim($module['email']))) {
$fail = TRUE;
}
// make sure amount paid is same as in database
if($_POST['amount']!=$summary[0]['prod_total']){
$fail = TRUE;
}
// process payment
if($fail==FALSE)
{
if($cleared==TRUE){
$order->orderStatus(3,$_POST['order_id']);
}
/*
else
{
//$updateOrderStatus['status'] = $db->mySQLSafe(7);
//$update = $db->update($glob['dbprefix']."CubeCart_order_sum", $updateOrderStatus,"cart_order_id=".$db->mySQLSafe($_POST['order_id']));
}
*/
}
}
/*
elseif (strcmp ($res, "DECLINED") == 0)
{
// mark order as declined
//$updateOrderStatus['status'] = $db->mySQLSafe(4);
//$update = $db->update($glob['dbprefix']."CubeCart_order_sum", $updateOrderStatus,"cart_order_id=".$db->mySQLSafe($_POST['order_id']));
}
*/
}
fclose ($fp);
}
?>