Files
bobsleighphotos.com/production/modules/gateway/Nochex_APC/transfer.inc.php
2017-03-02 20:30:40 -06:00

163 lines
7.4 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
+--------------------------------------------------------------------------
| transfer.inc.php
| ========================================
| Core functions for the Nochex Gateway
+--------------------------------------------------------------------------
*/
function repeatVars() {
return false;
}
function fixedVars() {
global $module, $cc_session, $orderSum, $config;
$hiddenVars = "";
$hiddenVars.= "<input type='hidden' name='description' value='Payment for order #".$orderSum['cart_order_id']."' />";
$hiddenVars.= "<input type='hidden' name='amount' value='".$orderSum['prod_total']."' />";
switch($module['accType']){
case "seller":
$hiddenVars.= "<input type='hidden' name='firstname' value='".$cc_session->ccUserData['firstName']."' />";
$hiddenVars.= "<input type='hidden' name='lastname' value='".$cc_session->ccUserData['lastName']."' />";
$hiddenVars.= "<input type='hidden' name='firstline' value='".$orderSum['add_1']."' />";
$hiddenVars.= "<input type='hidden' name='town' value='".$orderSum['town']."' />";
$hiddenVars.= "<input type='hidden' name='county' value='".$orderSum['county']."' />";
$hiddenVars.= "<input type='hidden' name='postcode' value='".$orderSum['postcode']."' />";
$hiddenVars.= "<input type='hidden' name='email_address_sender' value='".$orderSum['email']."' />";
$hiddenVars.= "<input type='hidden' name='email' value='".$module['email']."' />";
$hiddenVars.= "<input type='hidden' name='ordernumber' value='".$orderSum['cart_order_id']."' />";
$hiddenVars.= "<input type='hidden' name='returnurl' value='".$GLOBALS['storeURL']."/index.php?_g=rm&type=gateway&cmd=process&module=Nochex_APC' />";
$hiddenVars.= "<input type='hidden' name='cancelurl' value='".$GLOBALS['storeURL']."/index.php?_g=rm&type=gateway&cmd=process&module=Nochex_APC' />";
$hiddenVars.= "<input type='hidden' name='responderurl' value='".$GLOBALS['storeURL']."/index.php?_g=rm&type=gateway&cmd=call&module=Nochex_APC' />";
if ($module['testMode']) {
$hiddenVars.= "<input type='hidden' name='status' value='test' />";
}
break;
case "merchant":
$billing_address = array();
if (strlen($orderSum['add_1'])>0) $billing_address[] = $orderSum['add_1'];
if (strlen($orderSum['add_2'])>0) $billing_address[] = $orderSum['add_2'];
if (strlen($orderSum['town'])>0) $billing_address[] = $orderSum['town'];
if (strlen($orderSum['county'])>0) $billing_address[] = $orderSum['county'];
$merchant_id = (strlen($module['merchant_id'])>0) ? $module['merchant_id'] : $module['email'];
$hiddenVars.= "<input type='hidden' name='postage' value='0.00' />";
$hiddenVars.= "<input type='hidden' name='billing_fullname' value='".$orderSum['name']."' />";
$hiddenVars.= "<input type='hidden' name='billing_address' value='".implode("\r\n", $billing_address)."' />";
$hiddenVars.= "<input type='hidden' name='billing_postcode' value='".$orderSum['postcode']."' />";
$hiddenVars.= "<input type='hidden' name='customer_phone_number' value='".$orderSum['phone']."' />";
$hiddenVars.= "<input type='hidden' name='email_address' value='".$orderSum['email']."' />";
$hiddenVars.= "<input type='hidden' name='order_id' value='".$orderSum['cart_order_id']."' />";
$hiddenVars.= "<input type='hidden' name='merchant_id' value='".$merchant_id."' />";
$hiddenVars.= "<input type='hidden' name='success_url' value='".$GLOBALS['storeURL']."/index.php?_g=co&amp;_a=confirmed&amp;s=2' />";
$hiddenVars.= "<input type='hidden' name='test_success_url' value='".$GLOBALS['storeURL']."/index.php?_g=co&amp;_a=confirmed&amp;s=2' />";
$hiddenVars.= "<input type='hidden' name='cancel_url' value='".$GLOBALS['storeURL']."/index.php?_g=co&amp;_a=confirmed&amp;s=1' />";
$hiddenVars.= "<input type='hidden' name='declined_url' value='".$GLOBALS['storeURL']."/index.php?_g=co&amp;_a=confirmed&amp;s=1' />";
$hiddenVars.= "<input type='hidden' name='callback_url' value='".$GLOBALS['storeURL']."/index.php?_g=rm&amp;type=gateway&amp;cmd=call&amp;module=Nochex_APC' />";
if ($module['passTemplate']) {
$template_html = nochex_get_template_html();
$hiddenVars.= "<input type='hidden' name='header_html' value='".$template_html[0]."' />";
$hiddenVars.= "<input type='hidden' name='footer_html' value='".$template_html[1]."' />";
}
if ($module['testMode']) {
$hiddenVars.= "<input type='hidden' name='test_transaction' value='100' />";
}
break;
}
return $hiddenVars;
}
function nochex_get_template_html() {
global $module, $cc_session, $config;
global $db, $glob, $config, $lang;
ob_start();
$body = new XTemplate ("skins/".$config['skinDir']."/styleTemplates/global/cart.tpl",'',null,'main',true,$skipPath=TRUE);
$body->assign("SEARCHSTR","");
$body->assign("CURRENCY_VER", $currencyVer);
$body->assign("VAL_ISO", $charsetIso);
$body->assign("VAL_SKIN", $config['skinDir']);
$body->assign("PAGE_CONTENT", "<!-- EXPLODER -->");
include("includes/boxes/searchForm.inc.php");
$body->assign("SEARCH_FORM", $box_content);
include("includes/boxes/session.inc.php");
$body->assign("SESSION", $box_content);
include("includes/boxes/siteDocs.inc.php");
$body->assign("SITE_DOCS", $box_content);
include("includes/boxes/cartNavi.inc.php");
$body->assign("CART_NAVI", $box_content);
$body->parse("body");
$body->out("body");
$body = ob_get_contents();
ob_end_clean();
$body = str_replace(array("<html>", "<head>", "</head>", "<body>"), "", $body);
$body = array_shift(explode("</body>", $body));
//die("<pre>".print_r($GLOBALS, true)."</pre>");
$body = nochex_insert_absolute_urls($body, array("src", "href"));
$body = explode("<!-- EXPLODER -->", $body);
$header_html = "<center>".$body[0];
$header_html.= "<div><img src=\"" . $GLOBALS['storeURL'] . "/modules/gateway/Nochex_APC/header.gif\" border=\"0\" alt=\"\" ></a></div>";
$footer_html = $body[1]."</center>";
return array(htmlspecialchars($header_html), htmlspecialchars($footer_html));
}
function nochex_insert_absolute_urls($markup, $attribs = array()) {
foreach($attribs as $attrib) {
$offset = 0;
while($pos = strpos($markup, $attrib."=", $offset)) {
if ($pos===false) break;
if (substr($markup, $pos + strlen($attrib) + 1, 1)=="\"" || substr($markup, $pos + strlen($attrib) + 1, 1)=="'") {
$pos++;
}
if (substr($markup, $pos + strlen($attrib) + 1, 7)!="http://" && substr($markup, $pos + strlen($attrib) + 1, 8)!="https://") {
$markup = substr($markup, 0, $pos + strlen($attrib) + 1) . $GLOBALS['storeURL'] . "/" . substr($markup, $pos + strlen($attrib) + 1);
}
$offset = $pos;
}
}
return $markup;
}
$formAction = "https://secure.nochex.com/";
$formMethod = "post";
$formTarget = "_self";
$transfer = "auto";
?>