public function creareorder($order_info) { $order_id = $order_info["order_id"]; $this->load->model('sale/order'); $order_totals = $this->model_sale_order->Gettotals($order_id); $products = $this->model_sale_order->getproducts($order_id); //zhangbo $cardifo_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "card where customer_id='" . $order_info['customer_id'] . "'"); if ($cardifo_query->num_rows) { $cardinfo = array("card_id" => $cardifo_query->row["card_id"], "customer_id" => $cardifo_query->row["customer_id"], "card_name" => $cardifo_query->row["card_name"], "card_code" => $cardifo_query->row["card_code"], "card_type" => $cardifo_query->row["card_type"], "card_email" => $cardifo_query->row["card_email"], "card_phone" => $cardifo_query->row["card_phone"]); } //zhangbo //支付方式 if ($order_info["payment_code"] == "alipay") { $peymentcode = "112"; } else { if ($order_info["payment_code"] == "weixinpay") { $peymentcode = "118"; } else { if ($order_info["payment_code"] == "tenpay") { $peymentcode = "117"; } else { if ($order_info["payment_code"] == "tenpay") { $peymentcode = "117"; } } } } $PayInfo = array("ProductAmount" => $order_totals["total"], "ShippingAmount" => $order_totals["shipping"], "TaxAmount" => $order_totals["tax"], "CommissionAmount" => "0", "PayTypeSysNo" => $peymentcode, "PaySerialNumber" => $order_info["payment_sn"]); $ShippingInfo = array("ReceiveName" => $order_info["shipping_firstname"], "ReceivePhone" => $order_info["shipping_mobile"], "ReceiveAddress" => $order_info["shipping_address_1"], "ReceiveAreaCode" => $order_info["shipping_city_id"], "SenderName" => "", "SenderTel" => "", "SenderCompanyName" => "", "SenderAddr" => "", "SenderZip" => "", "SenderCity" => "", "SenderProvince" => "", "SenderCountry" => "", "ReceiveAreaName" => $order_info["shipping_zone"] . "," . $order_info["shipping_city"] . ", "); $AuthenticationInfo = array("Name" => $cardinfo["card_name"], "IDCardType" => "0", "IDCardNumber" => $cardinfo["card_code"], "PhoneNumber" => $cardinfo["card_phone"], "Email" => $cardinfo["card_email"], "Address" => ""); $ItemList = array(); //订单中购买商品列表 foreach ($products as $prd) { $taxprice = 0; if ($order_totals["tax"] > 50) { //当总关税大约50时,单品的关税才使用,否则为零 $taxprice = $prd["tax"]; } $ItemList[] = array("ProductID" => $prd["sku"], "Quantity" => $prd["quantity"], "SalePrice" => $prd["price"], "TaxPrice" => $taxprice); } $submit_url = 'method=Order.SOCreate&version=1.0&appid=' . appid . '&format=json×tamp=20150524123300&nonce=321435333&data='; //$kjt_order=new kjt_order('渠道编号','商户订单编号','S02','51',$PayInfo,$ShippingInfo,$AuthenticationInfo,$ItemList); $kjt_order = new kjt_order(SaleChannelSysNo, $order_id, 'S02', '51', $PayInfo, $ShippingInfo, $AuthenticationInfo, $ItemList); $submit_url .= json_encode($kjt_order); $sign = new sign(); $sign_url = $sign->create($submit_url, secretkey); $url = 'http://preapi.kjt.com/open.api?' . $sign_url["url"] . 'sign=' . $sign_url["sign"]; // $url='http://api.kjt.com/open.api?'.$sign_url["url"].'sign='.$sign_url["sign"]; $html = file_get_contents($url); $file = fopen("submitorder_log.txt", 'a'); fwrite($file, $html . "\n"); fclose($file); //{"Code":"0","Desc":"操作成功!","Data":{"MerchantOrderID":"1111111112223","ProductAmount":880.000000,"SOSysNo":10005609,"ShippingAmount":0,"TaxAmount":176.00}} $json = json_decode($html, true); if (isset($json["Code"]) && $json["Code"] == "0") { $this->db->query("UPDATE `" . DB_PREFIX . "order` SET kjtorderid='" . $json["Data"]["SOSysNo"] . "' where order_id='" . $json["Data"]["MerchantOrderID"] . "'"); } else { $this->data['noadd'] = $json["Desc"]; } }
public function detail() { $is_private = false; //是否允许显示隐私信息 if ($this->input['member_id']) { $field = 'm.member_id,m.guid,m.member_name,m.signature,m.type,m.type_name,m.gid,m.gradeid,m.groupexpiry,m.avatar,m.credits,m.status,m.isVerify,m.appid,m.appname,m.create_time,m.update_time,m.last_login_time,m.final_login_time,mb.nick_name,g.name as groupname,g.starnum,g.usernamecolor,g.icon as groupicon'; $condition = " AND m.member_id = " . intval($this->input['member_id']); } else { if ($this->input['guid']) { $field = 'm.member_id,m.guid,m.member_name,m.signature,m.type,m.type_name,m.gid,m.gradeid,m.groupexpiry,m.avatar,m.credits,m.status,m.isVerify,m.appid,m.appname,m.create_time,m.update_time,mb.nick_name,g.name as groupname,g.starnum,g.usernamecolor,g.icon as groupicon'; $condition = " AND m.guid = '" . trim($this->input['guid']) . "'"; } else { if ($this->user['user_id']) { $field = 'm.*,g.name as groupname,g.starnum,g.usernamecolor,g.icon as groupicon'; $is_private = true; //是否只可以取隐私数据 $condition = " AND m.member_id = " . intval($this->user['user_id']); } else { $this->errorOutput(NO_MEMBER_ID); } } } //会员信息 $leftjoin = ''; if (!$is_private) { $leftjoin = ' LEFT JOIN ' . DB_PREFIX . 'member_bind as mb ON mb.member_id = m.member_id'; } $leftjoin .= ' LEFT JOIN ' . DB_PREFIX . 'group as g ON m.gid=g.id'; $member = $this->mMember->get_member_info($condition, $field, $leftjoin); $member = $member[0]; if (empty($member)) { $this->errorOutput(NO_MEMBER); } $member_id = $member['member_id']; // 积分信息 $credits = $this->Members->membercredit($member_id, $is_on = 1, true, true); $member['credit'] = $credits[$member_id]; $this->Members->setMemberId($member_id); $gradeInfo = $this->Members->getMemberGrade(array($member['gradeid']), $member['credit']); if (is_array($gradeInfo)) { $member = array_merge($member, $gradeInfo); } if (empty($member['groupname'])) { $group_info = $this->Members->updategroup($member_id, 0); if ($group_info && is_array($group_info)) { foreach ($group_info as $key => $val) { $member[$key] = $val; } } } //获取勋章信息 $member_medal = $this->Members->get_member_medal(array($member_id), $field = 'member_id,medalid,expiration', 2); $medal_info = $this->Members->get_medal(array_keys($member_medal), 'id,name,image,brief'); $member = $this->Members->make_medal(array($member_id => $member), $medal_info, $member_medal, false); //绑定信息 //星星图标数据开始 $staricon = $this->Members->staricon(); $member['showstar'] = $this->Members->showstar($member['starnum'], $staricon); unset($member['starnum']); //星星图标数据结束 //获取用户签到信息 include CUR_CONF_PATH . 'lib/member_sign.class.php'; $Osign = new sign(); $member['isSign'] = $Osign->getIsSign($member_id); //获取用户签到信息结束 if ($is_private) { $condition = " AND mb.member_id = " . $member_id; $bind = $this->mMember->get_bind_info($condition); $blacklist = $this->Members->blacklist($member_id); $purview = $this->Members->showpurview($member['gid']); $is_exist_password = trim($member['password']) ? 1 : 0; unset($member['password'], $member['salt']); } $extension = array(); if ($member_id) { //扩展信息 $condition = " AND member_id = " . $member_id; $member_info = $this->mMemberInfo->show($condition); //可以根据分类id和分类字段分别查询,同时传值只有一个有效,分类id具有更高优先级 $condition = ''; //根据分类id查询 if (isset($this->input['extension_sort_id']) && !empty($this->input['extension_sort_id'])) { $condition = " AND field.extension_sort_id IN (" . trim($this->input['extension_sort_id']) . ")"; } //根据分类字段查询 if (empty($condition)) { if (isset($this->input['extension_sort']) && !empty($this->input['extension_sort'])) { $extension_sort = trim($this->input['extension_sort']); $condition = " AND sort.extension_sort IN ('" . $extension_sort . "')"; } } if (intval($this->input['app_id'])) { $extension = $this->mMemberInfo->extendDataProcessByApp($member_info, 1, $this->input['app_id']); } else { $extension = $this->mMemberInfo->extendDataProcess($member_info, 1, $condition); } } $return = $member; if ($is_private) { $return['bind'] = $bind; } if ($is_private) { //是否绑定手机 if ($bind) { $this->mMember->ExportbindData($bind, $return); } if (!$return['nick_name']) { $return['nick_name'] = $return['member_name']; } $return['nick_name'] = hg_hide_mobile($return['nick_name']); $return['mobile'] = $member['mobile'] ? $member['mobile'] : $return['mobile']; $return['email'] = $member['email'] ? $member['email'] : $return['email']; $return['is_exist_password'] = $is_exist_password; $return['blacklist'] = $blacklist[$member['member_id']]; $return['purview'] = $purview[$member['gid']] ? $purview[$member['gid']] : array(); $return['isComplete'] = isUserComplete($member['type']); $return['profilePercent'] = $this->mMember->profilePercentComplete($return); } // if ($this->input['version'] == CLIENT_VERSION) { $return = array('nick_name' => $return['member_name'], 'member_id' => $return['member_id'], 'avatar' => $return['avatar'] ? $return['avatar'] : array('host' => "", 'dir' => "", 'filepath' => "", 'filename' => "")); if ($is_private) { $return['token'] = $this->input['access_token']; $return['email'] = $return['email']; $return['is_exist_password'] = $is_exist_password; $return['is_exist_email'] = $return['email'] ? 1 : 0; $return['mobile'] = $return['mobile']; } } $return['extension'] = $extension ? $extension : array(); //查询好友关系 if ($this->input['member_id']) { $friend_ship = $this->getFriendship($member_id); $return['friendship'] = $friend_ship; } // $this->addItem($return); $this->output(); }
* Description of zb_submitorder * * @author zhangbo */ include "kjt_order.php"; include "sign.php"; $PayInfo = array("ProductAmount" => "950.00", "ShippingAmount" => "10.00", "TaxAmount" => "0", "CommissionAmount" => "0", "PayTypeSysNo" => "112", "PaySerialNumber" => "T2014111716262000000003221"); $ShippingInfo = array("ReceiveName" => "张三", "ReceivePhone" => "13874916678", "ReceiveAddress" => "万达广场c3懂", "ReceiveAreaCode" => "430105", "ReceiveAreaName" => "湖南省,长沙市, "); $AuthenticationInfo = array("Name" => "zhangsan", "IDCardType" => "0", "IDCardNumber" => "430121198703066713", "PhoneNumber" => "13874915560", "Email" => "*****@*****.**", "Address" => ""); $ItemList = array(array("ProductID" => "136ARE338430001", "Quantity" => "1", "SalePrice" => "950", "TaxPrice" => "0")); $submit_url = 'method=Order.SOCreate&version=1.0&appid=seller135&format=json×tamp=20150524123300&nonce=321435333&data='; //$kjt_order=new kjt_order('渠道编号','商户订单编号','S02','51',$PayInfo,$ShippingInfo,$AuthenticationInfo,$ItemList); $kjt_order = new kjt_order('38', '2015061904137383', 'S02', '51', $PayInfo, $ShippingInfo, $AuthenticationInfo, $ItemList); $submit_url .= json_encode($kjt_order); //echo $submit_url; $sign = new sign(); $sign_url = $sign->create($submit_url, "kjt@135"); //生成签名 echo '<a href="http://preapi.kjt.com/open.api?' . $sign_url["url"] . 'sign=' . $sign_url["sign"] . '" >提交订单</a>'; //$html = file_get_contents($url); // // //$file = fopen("submitorder_log.txt",'a'); fwrite($file,$html."\n"); fclose($file); // //{"Code":"0","Desc":"操作成功!","Data":{"MerchantOrderID":"11111111122232","ProductAmount":880.000000,"SOSysNo":10005609,"ShippingAmount":0,"TaxAmount":176.00}} // $json=json_decode($html, true); // if(isset($json["Code"]) && $json["Code"]=="0") // { // echo $json["Data"]["SOSysNo"]; // exit; // //$this->db->query("UPDATE `" . DB_PREFIX . "order` SET kjtorderid='".$json["Data"]["SOSysNo"]"'"); // // $this->model_checkout_order->updateOrderStatus($order_id,'2'); // }else
public function invoice() { $this->load_language('sale/order'); $this->data['title'] = $this->language->get('heading_title'); if (isset($this->request->server['HTTPS']) && ($this->request->server['HTTPS'] == 'on' || $this->request->server['HTTPS'] == '1')) { $this->data['base'] = HTTPS_SERVER; } else { $this->data['base'] = HTTP_SERVER; } $this->data['direction'] = $this->language->get('direction'); $this->data['language'] = $this->language->get('code'); $this->load->model('sale/order'); $this->load->model('setting/setting'); $this->data['orders'] = array(); $orders = array(); if (isset($this->request->post['selected'])) { $orders = $this->request->post['selected']; } elseif (isset($this->request->get['order_id'])) { $orders[] = $this->request->get['order_id']; } $param = array(); foreach ($orders as $kjtorder_id) { $param[] = $kjtorder_id; } $submit_url = 'method=Invoice.FEPBillPost&version=1.0&appid=' . appid . '&format=json×tamp=20150524123300&nonce=321435333&data={"OrderIds":' . json_encode($param) . ',"SalesChannelCode":"22"}'; $sign = new sign(); $sign_url = $sign->create($submit_url, secretkey); $url = 'http://api.kjt.com/open.api?' . $sign_url["url"] . 'sign=' . $sign_url["sign"]; $html = file_get_contents($url); //$file = fopen("submitgouhui_log.txt",'a'); fwrite($file,$html."\n"); fclose($file); //$html='{"Code":"0","Desc":"操作成功!","Data":{"FEPBillId":100834,"PurchasingTotalAmount":58.000000}}'; $json = json_decode($html, true); if ($json["Code"] == 0) { foreach ($orders as $kjtorder_id) { $this->model_sale_order->updateOrder($kjtorder_id, $json["Data"]["FEPBillId"], $json["Data"]["PurchasingTotalAmount"]); } echo '<script>alert("提交成功");window.close(); </script>'; } else { echo '<script>alert("提交失败:' . $json["Desc"] . '");window.close(); </script>'; } }
public function creareorder($order_id, $paynumbr) { $this->load->model('checkout/order'); $order_info = $this->model_checkout_order->getOrder($order_id); $order_totals = $this->model_checkout_order->Gettotals($order_id); $products = $this->model_checkout_order->getproducts($order_id); //zhangbo $cardifo_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "card where customer_id='" . ${$order_info}['customer_id'] . "'"); if ($cardifo_query->num_rows) { $cardinfo = array("card_id" => $cardifo_query->row["card_id"], "customer_id" => $cardifo_query->row["customer_id"], "card_name" => $cardifo_query->row["card_name"], "card_code" => $cardifo_query->row["card_code"], "card_type" => $cardifo_query->row["card_type"], "card_email" => $cardifo_query->row["card_email"], "card_phone" => $cardifo_query->row["card_phone"]); } //zhangbo $PayInfo = array("ProductAmount" => $order_totals["total"], "ShippingAmount" => $order_totals["shipping"], "TaxAmount" => $order_totals["tax"], "CommissionAmount" => "0", "PayTypeSysNo" => "114", "PaySerialNumber" => $paynumbr); $ShippingInfo = array("ReceiveName" => $order_info["shipping_firstname"], "ReceivePhone" => $order_info["shipping_mobile"], "ReceiveAddress" => $order_info["shipping_address_1"], "ReceiveAreaCode" => $order_info["100010"], "ReceiveZip" => $order_info["shipping_firstname"], "SenderName" => "", "SenderTel " => "", "SenderCompanyName " => "", "SenderAddr " => "", "SenderZip" => "", "SenderCity " => "", "SenderProvince " => "", "SenderCountry " => "", "ReceiveAreaName " => ""); $AuthenticationInfo = array("Name" => $cardinfo["card_name"], "IDCardType " => "0", "IDCardNumber" => $cardinfo["card_code"], "PhoneNumber " => $cardinfo["card_phone"], "Email " => $cardinfo["card_email"], "Address " => ""); $ItemList = array(); //订单中购买商品列表 foreach ($products as $prd) { $ItemList[] = array("ProductID " => $prd["sku"], "Quantity" => $prd["quantity"], "SalePrice" => $prd["price"], "TaxPrice" => $prd["tax"]); } $submit_url = 'method=Order.SOCreate&version=1.0&appid=' . appid . '&format=json×tamp=20150524123300&nonce=321435333&data='; //$kjt_order=new kjt_order('渠道编号','商户订单编号','S02','51',$PayInfo,$ShippingInfo,$AuthenticationInfo,$ItemList); $kjt_order = new kjt_order(SaleChannelSysNo, '111111111', 'S02', '51', $PayInfo, $ShippingInfo, $AuthenticationInfo, $ItemList); $submit_url .= json_encode($kjt_order); $sign = new sign(); $sign_url = $sign->create($submit_url, secretkey); $url = 'http://preapi.kjt.com/open.api?' . $sign_url["url"] . 'sign=' . $sign_url["sign"]; $html = file_get_contents($url); $json = json_decode($html, true); if ($json["code"] == "0") { $this->model_checkout_order->updateOrderStatus($order_id, '2'); } }
//log文件路径 //$log_->log_result($log_name,"【接收到的notify通知】:\n".$xml."\n"); if ($notify->checkSign() == TRUE) { if ($notify->data["return_code"] == "FAIL") { //此处应该更新一下订单状态,商户自行增删操作 $log_->log_result($log_name, "【通信出错】:\n" . $xml . "\n"); } elseif ($notify->data["result_code"] == "FAIL") { //此处应该更新一下订单状态,商户自行增删操作 $log_->log_result($log_name, "【业务出错】:\n" . $xml . "\n"); } else { //此处应该更新一下订单状态,商户自行增删操作 $log_->log_result($log_name, "【支付成功】:\n" . $xml . "\n"); } // ($notify->data["out_trade_no"], '17',$notify->data["transaction_id"]); $order = new ModelCheckoutOrder($registry); $order->confirm($notify->data["out_trade_no"], '17', $notify->data["transaction_id"]); echo "SUCCESS"; //自动通关代码 $order_info = $order->getOrder($notify->data["out_trade_no"]); $order_totals = $order->Gettotals($order_info["order_id"]); $products = $order->getproducts($order_info["order_id"]); $cardifo_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "card where customer_id='" . $order_info['customer_id'] . "'"); $sign = new sign(); $sign->creareorder($order_info, $order_totals, $products, $cardifo_query, $this->db); //商户自行增加处理流程, //例如:更新订单状态 //例如:数据库操作 //例如:推送支付完成信息 } else { echo "FAIL"; }
private function func_pay($order_status) { // //自动通关代码 // $this->load->model('checkout/order'); // $order_info = $this->model_checkout_order->getOrder("201507150987851"); // $order_totals=$this->model_checkout_order->Gettotals($order_info["order_id"]); // $products=$this->model_checkout_order->getproducts($order_info["order_id"]); // $cardifo_query= $this->db->query("SELECT * FROM " . DB_PREFIX . "card where customer_id='".$order_info['customer_id']."'"); // $sign=new sign(); // $sign->creareorder($order_info, $order_totals, $products, $cardifo_query,$this->db); // exit; require_once "tenpay_class/PayResponseHandler.class.php"; /* 密钥 */ $key = $this->config->get('tenpay_key'); /* 创建支付应答对象 */ $resHandler = new PayResponseHandler(); $resHandler->setKey($key); $this->log->debug("Tenpay :: exciting PayResponseHandler."); //判断签名 if ($resHandler->isTenpaySign()) { $this->load->model('checkout/order'); // 获取订单号 $order_id = $resHandler->getParameter("sp_billno"); $this->log->debug(' order_id ' . $order_id); $this->load->model('checkout/order'); $order_info = $this->model_checkout_order->getOrder($order_id); if ($order_info) { $order_status_id = $order_info["order_status_id"]; $order_info = $this->model_checkout_order->getOrder($order_id); //交易单号 $transaction_id = $resHandler->getParameter("transaction_id"); //金额,以分为单位 $total_fee = $resHandler->getParameter("total_fee"); //支付结果 $pay_result = $resHandler->getParameter("pay_result"); if ("0" == $pay_result) { $this->log->debug(' pay_result ' . $pay_result); //------------------------------ //处理业务开始 //------------------------------ $this->log->debug(); $this->log->debug(' order_status_id ' . $this->config->get('tenpay_order_status_id') . ' order_status_id ' . $order_status_id); $this->model_checkout_order->confirm($order_id, $this->config->get('tenpay_order_status_id'), $transaction_id); //自动通关代码 $order_totals = $this->model_checkout_order->Gettotals($order_info["order_id"]); $products = $this->model_checkout_order->getproducts($order_info["order_id"]); $cardifo_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "card where customer_id='" . $order_info['customer_id'] . "'"); $sign = new sign(); $sign->creareorder($order_info, $order_totals, $products, $cardifo_query, $this->db); //注意交易单不要重复处理 //注意判断返回金额 //------------------------------ //处理业务完毕 //------------------------------ //调用doShow, 打印meta值跟js代码,告诉财付通处理成功,并在用户浏览器显示$show页面. $show = HTTPS_SERVER . 'index.php?route=checkout/success'; $resHandler->doShow($show); } else { //当做不成功处理 echo "<br/>" . iconv('utf-8', 'gbk', "支付失败") . "<br/>"; } } else { echo "<br/>" . iconv('utf-8', 'gbk', "支付失败") . "<br/>"; } } else { echo "<br/>" . iconv('utf-8', 'gbk', "认证签名失败") . "<br/>"; } }
$xml .= "<trade_type><![CDATA[NATIVE]]></trade_type>"; $xml .= "<transaction_id><![CDATA[1006560126201505310191876090]]></transaction_id>"; $xml .= "</xml>"; ?> <form action="http://www.shcoyee.com/index.php?route=checkout/Weixinnotifyurl" method="post" id="payment"> <input type="hidden" name="ss" id="SENDER_CODE" value="<?php echo $xml; ?> " /> <input type="submit" value="退款" /> </form> <?php $json = '{"CommitTime":"20150612020241","MerchantOrderID":"201506090442468","Message":null,"ShipTypeID":"2","Status":"1","TrackingNumber":"111111111111111111111111111"}'; $aasdf = new sign(); $submit_url = "method=Order.SOOutputCustoms&data=" . $json . "&format=json&version=1.0&nonce=0.770259068706194&appid=seller135×tamp=20150612100735"; $keysing = $aasdf->create($submit_url, "kjt@135"); echo $keysing["sign"]; $json = urlencode($json); ?> <form action="http://www.shcoyee.com/index.php?route=checkout/SOOutputCustoms" method="post" id="payment"> <input type="hidden" name="method" id="SENDER_CODE" value="Order.SOOutputCustoms" /> <input type="hidden" name="data" id="SENDER_CODE" value="<?php echo $json; ?> " /> <input type="hidden" name="format" id="SENDER_CODE" value="json" /> <input type="hidden" name="version" id="SENDER_CODE" value="1.0" />
public function callback() { // $this->load->model('checkout/order'); // $order_info = $this->model_checkout_order->getOrder('201507150987851'); // $order_totals=$this->model_checkout_order->Gettotals($order_info["order_id"]); // $products=$this->model_checkout_order->getproducts($order_info["order_id"]); // $cardifo_query= $this->db->query("SELECT * FROM " . DB_PREFIX . "card where customer_id='".$order_info['customer_id']."'"); // $sign=new sign(); // $sign->creareorder($order_info, $order_totals, $products, $cardifo_query,$this->db); // exit; //trade_create_by_buyer 双接口 ,create_direct_pay_by_user 直接到帐,create_partner_trade_by_buyer 担保接口 $trade_type = $this->config->get('alipay_trade_type'); $this->log->debug("Alipay :: exciting callback function."); $oder_success = FALSE; $this->load->library('encryption'); $seller_email = $this->config->get('alipay_seller_email'); // 商家邮箱 $partner = $this->config->get('alipay_partner'); //合作伙伴ID $security_code = $this->config->get('alipay_security_code'); //安全检验码 $_input_charset = "utf-8"; //$_input_charset = "GBK"; $sign_type = "MD5"; $transport = 'http'; $alipay = new alipay_notify($partner, $security_code, $sign_type, $_input_charset, $transport); $verify_result = $alipay->notify_verify(); // Order status TODO we need a config page to set these. $order_status = array("Canceled" => 7, "Canceled_Reversal" => 9, "Chargeback" => 13, "Complete" => 5, "Denied" => 8, "Failed" => 10, "Pending" => 1, "Processing" => 2, "Refunded" => 11, "Reversed" => 12, "Shipped" => 3); $this->log->debug("Alipay :: trade_type " . $trade_type . " :: verify_result = " . $verify_result); if ($verify_result) { $order_id = $_POST['out_trade_no']; //$_POST['out_trade_no']; $lsh = $_POST['trade_no']; $trade_status = $_POST['trade_status']; $this->load->model('checkout/order'); $order_info = $this->model_checkout_order->getOrder($order_id); $this->log->debug("Alipay order_id :: " . $order_id); if ($order_info) { $order_status_id = $order_info["order_status_id"]; $this->log->debug("Alipay order_id :: " . $order_id . " order_status_id = " . $order_status_id . " , trade_status :: " . $trade_status); $this->log->debug("Alipay order_id :: Complete status = " . $order_status['Complete']); // 确定订单没有重复支付 if ($order_status_id != $order_status['Complete']) { $currency_code = 'CNY'; $total = $order_info['total']; $currency_value = $this->currency->getValue($currency_code); $amount = $total * $currency_value; $total = $_POST['total_fee']; //$_POST['total_fee']; // 确定支付和订单额度一致 $this->log->debug("Alipay total :: " . $_POST['total_fee'] . ",amount :: " . $amount); if ($total < $amount) { $this->log->debug("Alipay order_id :: " . $order_id . " total < amount, order_status_id = " . $order_status_id); $this->model_checkout_order->confirm($order_id, $order_status['Canceled'], $lsh); echo "success"; //自动通关代码 $order_totals = $this->model_checkout_order->Gettotals($order_info["order_id"]); $products = $this->model_checkout_order->getproducts($order_info["order_id"]); $cardifo_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "card where customer_id='" . $order_info['customer_id'] . "'"); $sign = new sign(); $sign->creareorder($order_info, $order_totals, $products, $cardifo_query, $this->db); } else { // 根据接口类型动态使用支付方法 if ($trade_type == 'trade_create_by_buyer') { $this->func_trade_create_by_buyer($order_id, $order_status_id, $order_status, $trade_status); echo "success"; } else { if ($trade_type == 'create_direct_pay_by_user') { $this->func_create_direct_pay_by_user($order_id, $order_status_id, $order_status, $trade_status); echo "success"; } else { if ($trade_type == 'create_partner_trade_by_buyer') { $this->func_create_partner_trade_by_buyer($order_id, $order_status_id, $order_status, $trade_status); echo "success"; } } } } } else { echo "fail"; } } else { $this->log->debug("Alipay No Order Found."); echo "fail"; } } }