cruisecontrol2010 Posted February 2, 2013 Posted February 2, 2013 Ive tried to no avail! can someone pls quickly recode this to work with oscommerce? <?php /* Moneybrace online payment * * @version 2.1 * @[member='date'] 08/30/2012 */ class moneybrace{ var $code, $title, $description, $enabled,$sort_order,$order_id; var $order_pending_status = 1; var $order_status = DEFAULT_ORDERS_STATUS_ID; function moneybrace () { global $order; $this->code="moneybrace"; $this->title=MODULE_PAYMENT_MONEYBRACE_TEXT_ADMIN_TITLE; $this->description=MODULE_PAYMENT_MONEYBRACE_TEXT_DESCRIPTION; $this->sort_order=MODULE_PAYMENT_MONEYBRACE_SORT_ORDER; $this->enabled = ((MODULE_PAYMENT_MONEYBRACE_STATUS == 'True') ? true : false); if ((int)MODULE_PAYMENT_MONEYBRACE_ORDER_STATUS_ID > 0) { $this->order_status = MODULE_PAYMENT_MONEYBRACE_ORDER_STATUS_ID; } if(is_object($order)) { $this->update_status(); } if(MODULE_PAYMENT_MONEYBRACE_HANDLER == 'Live') { $this->form_action_url='https://payment.moneybrace.com/payment/paypage.aspx'; if (MODULE_PAYMENT_MONEYBRACE_URL != '') { $this->form_action_url=MODULE_PAYMENT_MONEYBRACE_URL; } } elseif (MODULE_PAYMENT_MONEYBRACE_HANDLER == 'Test') { $this->form_action_url='https://payment.moneybrace.com/payment/paypage.aspx'; } } function update_status() { global $db,$order; if(($this->enabled==true)&&((int)MODULE_PAYMENT_MONEYBRACE_ZONE > 0)) { $check_flag=false; $check_query=$db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_MONEYBRACE_ZONE . "' and zone_country_id = '" . $order->billing['country']['id'] . "' order by zone_id"); while(!$check_query->EOF) { if($check_query->fields['zone_id'] < 1) { $check_flag=true; break; } elseif ($check_query->fields['zone_id'] == $order->billing['zone_id']) { $check_flag=true; break; } $check_query->MoveNext(); } if($check_flag==false) { $this->enabled=false; } } } function javascript_validation() { return false; } function selection() { return array( 'id' => $this->code, 'module'=> MODULE_PAYMENT_MONEYBRACE_TEXT_CATALOG_LOGO, 'icon' => MODULE_PAYMENT_MONEYBRACE_TEXT_CATALOG_LOGO ); } function pre_confirmation_check() { return false; } function confirmation() { return true; } function process_button() { global $db, $order, $currencies; require_once(DIR_WS_CLASSES . 'order.php'); //force zen cart to load existing order without creating dumplicate order if ( isset($_SESSION['order_id']) && ($_SESSION['cart']->cartID == $_SESSION['old_cart_id']) && ($_SESSION['old_cur'] == $_SESSION['currency'])) { $order_id = $_SESSION['order_id']; } else { if ( isset($_SESSION['order_id'])) { $order_id = $_SESSION['order_id']; $db->Execute('delete from ' . TABLE_ORDERS . ' where orders_id = "' . (int)$order_id . '"'); $db->Execute('delete from ' . TABLE_ORDERS_TOTAL . ' where orders_id = "' . (int)$order_id . '"'); $db->Execute('delete from ' . TABLE_ORDERS_STATUS_HISTORY . ' where orders_id = "' . (int)$order_id . '"'); $db->Execute('delete from ' . TABLE_ORDERS_PRODUCTS . ' where orders_id = "' . (int)$order_id . '"'); $db->Execute('delete from ' . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . ' where orders_id = "' . (int)$order_id . '"'); $db->Execute('delete from ' . TABLE_ORDERS_PRODUCTS_DOWNLOAD . ' where orders_id = "' . (int)$order_id . '"'); } $order = new order(); $order->info['order_status'] = $this->order_status;//init status,pending require_once(DIR_WS_CLASSES . 'order_total.php'); $order_total_modules = new order_total(); $order_totals = $order_total_modules->process(); $order_id = $order->create($order_totals); $order->create_add_products($order_id, 2); $_SESSION['order_id'] = $order_id; $_SESSION['old_cart_id'] = $_SESSION['cart']->cartID;//if customer add or remove item,update qty $_SESSION['old_cur'] = $_SESSION['currency']; //if the customer swich the currency } // generate order block end, to be compatible with previous version,we do dump data to moneybrace talbe(but not manditory) date_default_timezone_set(date_default_timezone_get()); $version='zencart v2.9.0'; $encoding='utf-8'; $datestr=date('YmdHis'); if ( defined('MODULE_PAYMENT_MONEYBRACE_ORDER_PREFIX') ) { $prefix = strtolower(MODULE_PAYMENT_MONEYBRACE_ORDER_PREFIX); } else { $prefix = strtolower(STORE_NAME); } $prefix = preg_replace('/[^a-z0-9]/i', '', $prefix); if (strlen($prefix)>10) { $prefix = substr($prefix, 0, 10);} $orderid= $prefix . date('mdHis') . '-' . $order_id; $orderid=$this->filter_code($orderid); //增加该行的转换,因为$prefix也许会包含特殊字符 $allowed_cur = array('USD', 'EUR', 'GBP', 'CAD', 'AUD', 'JPY'); $currency = $_SESSION['currency']; if ( !in_array($currency, $allowed_cur)) { $currency = 'USD'; } //due to zen cart bug,we should not do currency exchange with zen cart build in currency class,keep in mind $amount = zen_round($order->info['total'] * $currencies->currencies[$currency]['value'], $currencies->currencies[$currency]['decimal_places']); $strServerUrl = zen_href_link('moneybrace_main_handler.php','', 'SSL',false,false,true); $strBrowserurl= zen_href_link('moneybrace.php','', 'SSL',false,false,true); $strAccessurl = zen_href_link(FILENAME_CHECKOUT_CONFIRMATION); //this will be fixed to adapt to fake url //never to use zen cart defautl reutrn url,as we change its working process $this->write_log('BrowserURl is : '. $strBrowserurl); //en,de,fr,it,es,pt,jp // leave here as they will want to revert the language back to customer choice switch($_SESSION['languages_code']) { case 'de': $strlang='de-de'; break; case 'fr': $strlang='fr-fr'; break; case 'it': $strlang='it-it'; break; case 'es': $strlang='es-es'; break; case 'pt': $strlang='pt-pt'; break; case 'jp': $strlang='ja-jp'; break; default: $strlang='en-us'; } $shipfee='0.00'; if($order->info['shipping_cost']!=''&&$order->info['shipping_cost']!=0) { $shipfee =$order->info['shipping_cost']; } $billaddress = $this->filter_code($order->billing['street_address']); $billcountry = $this->filter_code($order->billing['country']['iso_code_2']); $billstate = $this->filter_code($order->billing['state']); $billcity = $this->filter_code($order->billing['city']); $billemail = $this->filter_code($order->customer['email_address']); $billphone = $this->filter_code($order->customer['telephone']); $billpost = $this->filter_code($order->billing['postcode']); $deliveryfirstname = $order->delivery['firstname'] != '' ? $order->delivery['firstname'] : $order->billing['firstname']; $deliverylastname = $order->delivery['lastname'] != '' ? $order->delivery['lastname'] : $order->billing['lastname']; $deliveryname = $this->filter_code($deliveryfirstname . $deliverylastname); $deliveryaddress = $this->filter_code($order->delivery['street_address']); $deliverycountry = $this->filter_code($order->delivery['country']['iso_code_2']); $deliverystate = $this->filter_code($order->delivery['state']); $deliverycity = $this->filter_code($order->delivery['city']); $deliveryemail = $this->filter_code($order->customer['email_address']); $deliveryphone = $this->filter_code($order->customer['telephone']); $deliverypost = $this->filter_code($order->delivery['postcode']); $strProduct = ''; //传输的字符串 $strProducts = ''; //加密的字符串 for ($i=0; $i<sizeof($order->products)&&$i<=50; $i++) { $pname = $order->products[$i]["name"]; // if ($pname == '') { $pname = 'Order ' . $orderid; break; } $psku = $order->products[$i]["id"]; $price_unit = zen_round($order->products[$i]['price'] * $currencies->currencies[$currency]['value'], $currencies->currencies[$currency]['decimal_places']); // $pname=$this->filter_code($pname); //修改 $psku=$this->filter_code($psku); //修改 if($pname==""||$pname==null) $pname='product'.$i; // $strProducts = $strProducts . $pname . $psku . $order->products[$i]["qty"] . $price_unit; $strProduct = $strProduct . '<input type="hidden" name="'. productname.($i+1) .'" value="'. $this->utf8_htmldecode($pname) .'" />'. '<input type="hidden" name="'. productsn.($i+1) .'" value="'. $this->utf8_htmldecode($psku) .'" />'. '<input type="hidden" name="'. quantity.($i+1) .'" value="'. $order->products[$i]["qty"] .'" />'. '<input type="hidden" name="'. unit.($i+1) .'" value="'. $price_unit .'" />'; //$strProducts = $this->filter_code($strProducts); //修改 } $remark1 = $order_id; $remark2 = 'zencart v2.9.0'; $remark3 = ''; $value=$version . $encoding . $strlang . MODULE_PAYMENT_MONEYBRACE_MERCHANTID . $orderid . $datestr . $currency . $amount . 'ic' . $strServerUrl . $strBrowserurl . $strAccessurl . $remark1 . $remark2 . $remark3 . $strProducts . $shipfee . $billaddress . $billcountry . $billstate . $billcity . $billemail . $billphone . $billpost . $deliveryname . $deliveryaddress . $deliverycountry . $deliverystate . $deliverycity . $deliveryemail . $deliveryphone . $deliverypost; //the source string to generate signature $value = MODULE_PAYMENT_MONEYBRACE_HASHKEY . $value; $signature = md5($value); $this->write_log('Md5 source string is ' . $value); $process_button_string = '<input type="hidden" name="version" value="' .$this->utf8_htmldecode($version). '" />'. '<input type="hidden" name="encoding" value="' .$this->utf8_htmldecode($encoding). '" />'. '<input type="hidden" name="language" value="' .$this->utf8_htmldecode($strlang). '" />'. '<input type="hidden" name="merchantid" value="' .MODULE_PAYMENT_MONEYBRACE_MERCHANTID . '" />'. '<input type="hidden" name="orderid" value="' .$this->utf8_htmldecode($orderid). '" />'. '<input type="hidden" name="orderdate" value="' .$this->utf8_htmldecode($datestr). '" />'. '<input type="hidden" name="currency" value="' .$this->utf8_htmldecode($currency). '" />'. '<input type="hidden" name="orderamount" value="' .$this->utf8_htmldecode($amount). '" />'. '<input type="hidden" name="transtype" value="' .$this->utf8_htmldecode(ic). '" />'. '<input type="hidden" name="callbackurl" value="' .$this->utf8_htmldecode($strServerUrl). '" />'. '<input type="hidden" name="browserbackurl" value="' .$this->utf8_htmldecode($strBrowserurl). '" />'. '<input type="hidden" name="accessurl" value="' .$this->utf8_htmldecode($strAccessurl). '" />'. '<input type="hidden" name="remark1" value="' .$this->utf8_htmldecode($remark1). '" />'. '<input type="hidden" name="remark2" value="' .$this->utf8_htmldecode($remark2). '" />'. '<input type="hidden" name="remark3" value="' .$this->utf8_htmldecode($remark3). '" />'. $strProduct . '<input type="hidden" name="shippingfee" value="' .$this->utf8_htmldecode($shipfee). '" />'. '<input type="hidden" name="billaddress" value="' .$this->utf8_htmldecode($billaddress). '" />'. '<input type="hidden" name="billcountry" value="' .$this->utf8_htmldecode($billcountry). '" />'. '<input type="hidden" name="billprovince" value="' .$this->utf8_htmldecode($billstate). '" />'. '<input type="hidden" name="billcity" value="' .$this->utf8_htmldecode($billcity). '" />'. '<input type="hidden" name="billemail" value="' .$this->utf8_htmldecode($billemail). '" />'. '<input type="hidden" name="billphone" value="' .$this->utf8_htmldecode($billphone). '" />'. '<input type="hidden" name="billpost" value="' .$this->utf8_htmldecode($billpost). '" />'. '<input type="hidden" name="deliveryname" value="' .$this->utf8_htmldecode($deliveryname). '" />'. '<input type="hidden" name="deliveryaddress" value="' .$this->utf8_htmldecode($deliveryaddress). '" />'. '<input type="hidden" name="deliverycountry" value="' .$this->utf8_htmldecode($deliverycountry). '" />'. '<input type="hidden" name="deliveryprovince" value="' .$this->utf8_htmldecode($deliverystate). '" />'. '<input type="hidden" name="deliverycity" value="' .$this->utf8_htmldecode($deliverycity). '" />'. '<input type="hidden" name="deliveryemail" value="' .$this->utf8_htmldecode($deliveryemail). '" />'. '<input type="hidden" name="deliveryphone" value="' .$this->utf8_htmldecode($deliveryphone). '" />'. '<input type="hidden" name="deliverypost" value="' .$this->utf8_htmldecode($deliverypost). '" />'. '<input type="hidden" name="signature" value="' .$this->utf8_htmldecode($signature). '" />'; $this->write_log('Request form to moneybrace is :' . $process_button_string); return $process_button_string; } function before_process() { //deprecated as we produce customer order before customer leave our store die();//george fix,no need method,should be clear } function after_process() { $this->write_log('Begin do after_process()'); global $insert_id, $db; $sql_data_array = array( 'orders_id' => (int)$insert_id, 'orders_status_id' => $this->status, 'date_added' => 'now()', 'comments' => 'Moneybrace OrderID:'. $this->moneybraceid. ' - PayCurrency: '. $this->paycurrency . ' - PayAmount: ' . $this->payamount ); zen_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array); $_SESSION['order_created'] = ''; return true; } function output_error() { return false; } function check() { global $db; if(!isset($this->_check)) { $check_query=$db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_MONEYBRACE_STATUS'"); $this->_check=$check_query->RecordCount(); } return $this->_check; } function install() { global $db, $language, $module_type; if (!defined('MODULE_PAYMENT_MONEYBRACE_TEXT_CONFIG_1_1')) { $lang_file = DIR_FS_CATALOG_LANGUAGES . $_SESSION['language'] . '/modules/' . $module_type . '/' . $this->code . '.php'; if ( file_exists($lang_file)) { include($lang_file); } else { //load default lang file include(DIR_FS_CATALOG_LANGUAGES . 'english' . '/modules/' . $module_type . '/' . $this->code . '.php'); } } $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('" . MODULE_PAYMENT_MONEYBRACE_TEXT_CONFIG_1_1 . "', 'MODULE_PAYMENT_MONEYBRACE_STATUS', 'True', '" . MODULE_PAYMENT_MONEYBRACE_TEXT_CONFIG_1_2 . "', '9', '1', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())"); $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('" . MODULE_PAYMENT_MONEYBRACE_TEXT_CONFIG_2_1 . "', 'MODULE_PAYMENT_MONEYBRACE_MERCHANTID', '', '" . MODULE_PAYMENT_MONEYBRACE_TEXT_CONFIG_2_2 . "', '9', '2', now())"); $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('" . MODULE_PAYMENT_MONEYBRACE_TEXT_CONFIG_3_1 . "', 'MODULE_PAYMENT_MONEYBRACE_HASHKEY', '', '" . MODULE_PAYMENT_MONEYBRACE_TEXT_CONFIG_3_2 . "', '9', '3', now())"); $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('" . MODULE_PAYMENT_MONEYBRACE_TEXT_CONFIG_4_1 . "', 'MODULE_PAYMENT_MONEYBRACE_ZONE', '0', '" . MODULE_PAYMENT_MONEYBRACE_TEXT_CONFIG_4_2 . "', '9', '4', 'zen_get_zone_class_title', 'zen_cfg_pull_down_zone_classes(', now())"); $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, use_function, date_added) values ('" . MODULE_PAYMENT_MONEYBRACE_TEXT_CONFIG_5_1 . "', 'MODULE_PAYMENT_MONEYBRACE_PROCESSING_STATUS_ID', '2', '" . MODULE_PAYMENT_MONEYBRACE_TEXT_CONFIG_5_2 . "', '9', '5', 'zen_cfg_pull_down_order_statuses(', 'zen_get_order_status_name', now())"); $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, use_function, date_added) values ('" . MODULE_PAYMENT_MONEYBRACE_TEXT_CONFIG_6_1 . "', 'MODULE_PAYMENT_MONEYBRACE_ORDER_STATUS_ID', '1', '" . MODULE_PAYMENT_MONEYBRACE_TEXT_CONFIG_6_2 . "', '9', '6', 'zen_cfg_pull_down_order_statuses(', 'zen_get_order_status_name', now())"); $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('" . MODULE_PAYMENT_MONEYBRACE_TEXT_CONFIG_7_1 . "', 'MODULE_PAYMENT_MONEYBRACE_SORT_ORDER', '0', '" . MODULE_PAYMENT_MONEYBRACE_TEXT_CONFIG_7_2 . "', '9', '7', now())"); $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('" . MODULE_PAYMENT_MONEYBRACE_TEXT_CONFIG_8_1 . "', 'MODULE_PAYMENT_MONEYBRACE_HANDLER', 'Live', '" . MODULE_PAYMENT_MONEYBRACE_TEXT_CONFIG_8_2 . "', '9', '8', 'zen_cfg_select_option(array(\'Live\', \'Test\'), ', now())"); $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('" . MODULE_PAYMENT_MONEYBRACE_TEXT_CONFIG_9_1 . "', 'MODULE_PAYMENT_MONEYBRACE_DEBUG', 'False', '" . MODULE_PAYMENT_MONEYBRACE_TEXT_CONFIG_9_2 . "', '9', '9', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())"); $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('" . MODULE_PAYMENT_MONEYBRACE_TEXT_CONFIG_10_1 . "', 'MODULE_PAYMENT_MONEYBRACE_ORDER_PREFIX', '', '" . MODULE_PAYMENT_MONEYBRACE_TEXT_CONFIG_10_2 . "', '9', '10', now())"); $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('" . MODULE_PAYMENT_MONEYBRACE_TEXT_CONFIG_12_1 . "', 'MODULE_PAYMENT_MONEYBRACE_URL', 'https://payment.moneybrace.com/payment/paypage.aspx', '" . MODULE_PAYMENT_MONEYBRACE_TEXT_CONFIG_12_2 . "', '9', '12', now())"); } function keys() { return array( 'MODULE_PAYMENT_MONEYBRACE_STATUS', 'MODULE_PAYMENT_MONEYBRACE_MERCHANTID', 'MODULE_PAYMENT_MONEYBRACE_HASHKEY', 'MODULE_PAYMENT_MONEYBRACE_ZONE', 'MODULE_PAYMENT_MONEYBRACE_PROCESSING_STATUS_ID', 'MODULE_PAYMENT_MONEYBRACE_ORDER_STATUS_ID', 'MODULE_PAYMENT_MONEYBRACE_SORT_ORDER', 'MODULE_PAYMENT_MONEYBRACE_HANDLER', 'MODULE_PAYMENT_MONEYBRACE_DEBUG', 'MODULE_PAYMENT_MONEYBRACE_ORDER_PREFIX', 'MODULE_PAYMENT_MONEYBRACE_URL' ); } function remove() { global $db; $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key LIKE 'MODULE_PAYMENT_MONEYBRACE%'"); $db->Execute("DROP TABLE IF EXISTS moneybrace"); $db->Execute("DROP TABLE IF EXISTS moneybrace_session"); } function write_log($msg) { if(MODULE_PAYMENT_MONEYBRACE_DEBUG==true) { error_log(date("[Y-m-d H:i:s]")."\t" .$msg ."\r\n", 3, 'cache/mb'.date("Y-m-d").'.log'); } return true; } function utf8_htmldecode($str){ $str=str_replace("&","&",$str); $str=str_replace("\"",""",$str); $str=str_replace("<","<",$str); $str=str_replace(">",">",$str); $str=str_replace("'","'",$str); return $str; } function filter_code($str){ //$str=mb_convert_encoding ( $str,"UTF-8","UTF-8"); //该方法需要确认php中php.ini里将; extension=php_mbstring.dll 前面的 ; 去掉 if($str==null||$str=="") return ""; // $str2=@iconv ("UTF-8","UTF-8", $str); // $len=0; if($str!=null&&$str!="") $len=strlen($str2); for($ii=0;$ii<strlen($str);$ii++){ if(ord($str[$ii])<32 || $ii>=$len && ord($str[$ii])>127) $str[$ii]='*'; } return $str; // //if($str==null||$str=="") //{ // for($ii=0;$ii<strlen($str);$ii++){ // if(ord($str[$ii])<32 || ord($str[$ii])>127) $str[$ii]='*'; // } // return $str; //} //else //{ // for($ii=0;$ii<strlen($str);$ii++){ // if(ord($str[$ii])<32) $str[$ii]='*'; // } // return $str; //} } //end of class } ?>
Guest Posted March 1, 2013 Posted March 1, 2013 · Hidden by burt, June 24, 2013 - spam Hidden by burt, June 24, 2013 - spam me too,my site:http://www.grand-jewelry.com any one can be slove?
Recommended Posts
Archived
This topic is now archived and is closed to further replies.