예제 #1
0
파일: wxpay.php 프로젝트: shiruolin/hzzshop
 /**
  * 接受通知处理订单。
  * @param undefined $log_id
  * 20141125
  */
 function respond()
 {
     $notify = new Notify_pub();
     //存储微信的回调
     $xml = $GLOBALS['HTTP_RAW_POST_DATA'];
     $notify->saveData($xml);
     if ($notify->checkSign() == FALSE) {
         $notify->setReturnParameter("return_code", "FAIL");
         //返回状态码
         $notify->setReturnParameter("return_msg", "签名失败");
         //返回信息
     } else {
         $notify->setReturnParameter("return_code", "SUCCESS");
         //设置返回码
     }
     $returnXml = $notify->returnXml();
     echo $returnXml;
     $log_ = new Log_();
     $log_name = ROOT_PATH . "wxpay/demo/notify_url.log";
     //log文件路径
     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 {
             $order = $notify->getData();
             $log_id = $order["out_trade_no"];
             order_paid($log_id);
             //$wxpay = new wxpay();
             //$wxpay->respond($order["out_trade_no"]);
             //此处应该更新一下订单状态,商户自行增删操作
             $log_->log_result($log_name, "【支付成功】:\n" . $order["out_trade_no"] . "\n");
         }
     }
 }
예제 #2
0
}
$returnXml = $notify->returnXml();
echo $returnXml;
//==商户根据实际情况设置相应的处理流程,此处仅作举例=======
//以log文件形式记录回调信息
$log_ = new Log_();
$log_name = "./notify_url.log";
//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 {
        $order = $notify->getData();
        $orsn = $order["out_trade_no"];
        $odid = get_order_id_by_sn($orsn);
        order_paid($odid);
        //$wxpay = new wxpay();
        //$wxpay->respond();
        //此处应该更新一下订单状态,商户自行增删操作
        $log_->log_result($log_name, "【支付成功】:\n" . $order["out_trade_no"] . "\n");
    }
    //商户自行增加处理流程,
    //例如:更新订单状态
    //例如:数据库操作
    //例如:推送支付完成信息
}
예제 #3
0
파일: notify.php 프로젝트: aspnmy/weizan
 * [WeiZan System] Copyright (c) 2014 012wz.com
 * WeiZan is  a free software, it under the license terms, visited http://www.012wz.com/ for more details.
 */
error_reporting(1);
define('IN_MOBILE', true);
define("MON_ORDER", "mon_orderform");
require '../../framework/bootstrap.inc.php';
require_once "WxPayPubHelper/WxPayPubHelper.php";
require_once "monUtil.class.php";
require_once "dbutil.class.php";
$input = file_get_contents('php://input');
WeUtility::logging('info', "通用订单异步通知数据" . $input);
//WeUtility::logging('info',"商户key数据".$kjsetting);
$notify = new Notify_pub();
$notify->saveData($input);
$data = $notify->getData();
$ordersetting = DBUtil::findUnique(DBUtil::$TABLE_ORDER_SETTING, array(":appid" => $data['appid']));
if (empty($data)) {
    $notify->setReturnParameter("return_code", "FAIL");
    $notify->setReturnParameter("return_msg", "通用订单参数格式校验错误");
    WeUtility::logging('info', "通用订单回复参数格式校验错误");
    exit($notify->createXml());
}
if ($data['result_code'] != 'SUCCESS' || $data['return_code'] != 'SUCCESS') {
    $notify->setReturnParameter("return_code", "FAIL");
    $notify->setReturnParameter("return_msg", "通用订单参数格式校验错误");
    WeUtility::logging('info', "通用订单回复参数格式校验错误");
    exit($notify->createXml());
}
//更新表订单信息
WeUtility::logging('info', "通知订单更新");
    public function notify()
    {
        include_once LIB_PATH . "ORG/Wpay/WxPayPubHelper.php";
        //存储微信的回调
        $xml = $GLOBALS['HTTP_RAW_POST_DATA'];
        Log::record('wxpay notify get:' . print_r($xml, true));
        Log::save();
        //使用通用通知接口
        $notify = new Notify_pub();
        $notify->saveData($xml);
        $bak_params = $notify->getData();
        try {
            $sql = 'SELECT `pay_config` 
				FROM `' . C('DB_PREFIX') . 'b2c_wxtrade`
				INNER JOIN `' . C('DB_PREFIX') . 'b2c_payment` ON (`' . C('DB_PREFIX') . 'b2c_wxtrade`.`token` = `' . C('DB_PREFIX') . 'b2c_payment`.`token` AND `pay_code` = \'wxpay\' AND `enabled` = 1)
				WHERE `order_sn` = \'' . $bak_params['out_trade_no'] . '\' AND `wecha_id` = \'' . $bak_params['openid'] . '\'';
            $model = new Model();
            $payment = $model->query($sql);
            $wxpay_config = unserialize($payment[0]['pay_config']);
            $notify->setAppkey($wxpay_config['APPKEY']);
        } catch (Exception $e) {
            Log::record('get wxpay configuration params error:' . print_r($e, true));
            Log::save();
            exit;
        }
        //验证签名,并回应微信。
        //对后台通知交互时,如果微信收到商户的应答不是成功或超时,微信认为通知失败,
        //微信会通过一定的策略(如30分钟共8次)定期重新发起通知,
        //尽可能提高通知的成功率,但微信不保证通知最终能成功。
        if ($notify->checkSign() == FALSE) {
            $notify->setReturnParameter("return_code", "FAIL");
            //返回状态码
            $notify->setReturnParameter("return_msg", "签名失败");
            //返回信息
        } else {
            $notify->setReturnParameter("return_code", "SUCCESS");
            //设置返回码
        }
        $returnXml = $notify->returnXml();
        Log::record('wxpay notify get:' . print_r($returnXml, true));
        Log::save();
        //==商户根据实际情况设置相应的处理流程,此处仅作举例=======
        if ($notify->checkSign() == TRUE) {
            if ($notify->data["return_code"] == "FAIL") {
                //此处应该更新一下订单状态,商户自行增删操作
                Log::record('【通信出错】:\\n' . $xml . '\\n');
                Log::save();
                echo 'fail';
                exit;
            } elseif ($notify->data["result_code"] == "FAIL") {
                //此处应该更新一下订单状态,商户自行增删操作
                Log::record('【通信出错】:\\n' . $xml . '\\n');
                Log::save();
                echo 'fail';
                exit;
            } else {
                $this->change_order($bak_params);
                Log::record('【支付成功】:\\n' . $xml . '\\n');
                Log::save();
            }
        }
    }
예제 #5
0
 public function notify()
 {
     vendor('Weixinpay.WxPayPubHelper');
     //使用通用通知接口
     $notify = new \Notify_pub();
     // 存储微信的回调
     $xml = $GLOBALS['HTTP_RAW_POST_DATA'];
     $notify->saveData($xml);
     // 验证签名,并回应微信。
     if ($notify->checkSign() == FALSE) {
         $notify->setReturnParameter("return_code", "FAIL");
         // 返回状态码
         $notify->setReturnParameter("return_msg", "签名失败");
         // 返回信息
     } else {
         $notify->setReturnParameter("return_code", "SUCCESS");
         // 设置返回码
     }
     $returnXml = $notify->returnXml();
     echo $returnXml;
     // ==商户根据实际情况设置相应的处理流程=======
     if ($notify->checkSign() == TRUE) {
         if ($notify->data["return_code"] == "FAIL") {
             // 此处应该更新一下订单状态,商户自行增删操作
         } elseif ($notify->data["result_code"] == "FAIL") {
             // 此处应该更新一下订单状态,商户自行增删操作
         } else {
             // 此处应该更新一下订单状态,商户自行增删操作
             $order = $notify->getData();
             // $out_trade_no = $order["out_trade_no"];
             $trade_no = $order["transaction_id"];
             $total_fee = $order["total_fee"];
             $pkey = $order["attach"];
             $pkeys = explode("@", $pkey);
             $userId = $pkeys[0];
             $out_trade_no = $pkeys[1];
             $pm = D('Mobile/Payments');
             // 商户订单号
             $obj = array();
             $obj["trade_no"] = $trade_no;
             $obj["out_trade_no"] = $out_trade_no;
             $obj["total_fee"] = $total_fee;
             $obj["userId"] = $userId;
             // 支付成功业务逻辑
             $pm->complatePay($obj);
         }
     }
 }
 public function notify()
 {
     // 使用通用通知接口
     $notify = new \Notify_pub();
     // 存储微信的回调
     $xml = $GLOBALS['HTTP_RAW_POST_DATA'];
     $notify->saveData($xml);
     // 验证签名,并回应微信。
     // 对后台通知交互时,如果微信收到商户的应答不是成功或超时,微信认为通知失败,
     // 微信会通过一定的策略(如30分钟共8次)定期重新发起通知,
     // 尽可能提高通知的成功率,但微信不保证通知最终能成功。
     if ($notify->checkSign() == FALSE) {
         $notify->setReturnParameter("return_code", "FAIL");
         // 返回状态码
         $notify->setReturnParameter("return_msg", "签名失败");
         // 返回信息
     } else {
         $notify->setReturnParameter("return_code", "SUCCESS");
         // 设置返回码
     }
     $returnXml = $notify->returnXml();
     echo $returnXml;
     // ==商户根据实际情况设置相应的处理流程,此处仅作举例=======
     if ($notify->checkSign() == TRUE) {
         if ($notify->data["return_code"] == "FAIL") {
             // 此处应该更新一下订单状态,商户自行增删操作
         } elseif ($notify->data["result_code"] == "FAIL") {
             // 此处应该更新一下订单状态,商户自行增删操作
         } else {
             // 此处应该更新一下订单状态,商户自行增删操作
             $order = $notify->getData();
             // $out_trade_no = $order["out_trade_no"];
             $trade_no = $order["transaction_id"];
             $total_fee = $order["total_fee"];
             $pkey = $order["attach"];
             $pkeys = explode("@", $pkey);
             $userId = $pkeys[0];
             $out_trade_no = $pkeys[1];
             $pm = D('Home/Payments');
             // 商户订单号
             $obj = array();
             $obj["trade_no"] = $trade_no;
             $obj["out_trade_no"] = $out_trade_no;
             $obj["total_fee"] = $total_fee;
             $obj["userId"] = $userId;
             // 支付成功业务逻辑
             $payments = $pm->complatePay($obj);
             S("{$out_trade_no}", $total_fee);
         }
     }
 }