public function notify_url() { require_once $this->base_path . 'lib/alipay_notify.class.php'; $_POST['notify_data'] = htmlspecialchars_decode($_POST['notify_data']); $from = htmlentities($_GET['from']); $alipayNotify = new AlipayNotify($this->alipay_config); $verify_result = $alipayNotify->verifyNotify(); if ($verify_result) { $doc = new DOMDocument(); if ($this->alipay_config['sign_type'] == 'MD5') { $doc->loadXML($_POST['notify_data']); } if ($this->alipay_config['sign_type'] == '0001') { $doc->loadXML($alipayNotify->decrypt($_POST['notify_data'])); } if (!empty($doc->getElementsByTagName('notify')->item(0)->nodeValue)) { $out_trade_no = $doc->getElementsByTagName('out_trade_no')->item(0)->nodeValue; $trade_no = $doc->getElementsByTagName('trade_no')->item(0)->nodeValue; $trade_status = $doc->getElementsByTagName('trade_status')->item(0)->nodeValue; if ($trade_status == 'TRADE_FINISHED') { echo 'success'; } else { if ($trade_status == 'TRADE_SUCCESS') { $payHandel = new payHandle($this->token, $from, 'alipay'); $orderInfo = $payHandel->beforePay($out_trade_no); if (empty($orderInfo['paid'])) { $orderInfo = $payHandel->afterPay($out_trade_no, $trade_no); $url = C('site_url') . '/index.php?g=Wap&m=' . $from . '&a=payReturn&token=' . $orderInfo['token'] . '&wecha_id=' . $orderInfo['wecha_id'] . '&rget=1&orderid=' . $out_trade_no; file_get_contents($url); } echo 'success'; } } } } else { echo 'fail'; } }
public function notify() { require_once ROOT . "/libs/alipay_lib/alipay_notify.class.php"; $alipayNotify = new AlipayNotify($this->alipay_config); $verify_result = $alipayNotify->verifyNotify(); $ret = array(); if ($verify_result) { $doc = new DOMDocument(); if ($this->alipay_config['sign_type'] == 'MD5') { $doc->loadXML($_POST['notify_data']); } if ($this->alipay_config['sign_type'] == '0001') { $doc->loadXML($alipayNotify->decrypt($_POST['notify_data'])); } if (!empty($doc->getElementsByTagName("notify")->item(0)->nodeValue)) { $out_trade_no = $doc->getElementsByTagName("out_trade_no")->item(0)->nodeValue; $trade_no = $doc->getElementsByTagName("trade_no")->item(0)->nodeValue; $trade_status = $doc->getElementsByTagName("trade_status")->item(0)->nodeValue; $ret["out_trade_no"] = $out_trade_no; $ret["trade_no"] = $trade_no; if ($trade_status == 'TRADE_SUCCESS' || $trade_status == 'TRADE_FINISHED') { $ret["result"] = "SUCCESS"; } else { $ret["result"] = "FAIL"; } } else { $ret["result"] = "FAIL"; } } else { $ret["result"] = "FAIL"; } return $ret; }
$out_trade_no = $_GET['out_trade_no']; //获取订单号 $money = number_format($total_fee, 2, '.', ''); $module = $this->pay_model->pay_success($out_trade_no, $money, '交易号:' . $trade_no); $this->pay_msg("支付成功", $module ? MEMBER_URL . 'index.php?s=' . $module . '&c=order&m=index' : MEMBER_URL . 'index.php?c=pay', 1); } else { $this->pay_msg('验证失败'); } } else { //计算得出通知验证结果 $alipayNotify = new AlipayNotify($alipay_config); $verify_result = $alipayNotify->verifyNotify(); if ($verify_result) { //验证成功 //解密(如果是RSA签名需要解密,如果是MD5签名则下面一行清注释掉) $notify_data = $alipayNotify->decrypt($_POST['notify_data']); //获取支付宝的通知返回参数,可参考技术文档中服务器异步通知参数列表 $doc = new DOMDocument(); $doc->loadXML($notify_data); if (!empty($doc->getElementsByTagName("notify")->item(0)->nodeValue)) { //验证成功 $trade_no = $doc->getElementsByTagName("trade_no")->item(0)->nodeValue; //获取支付宝交易号 $total_fee = $doc->getElementsByTagName("total_fee")->item(0)->nodeValu; //获取总价格 $out_trade_no = $doc->getElementsByTagName("out_trade_no")->item(0)->nodeValue; //获取订单号 $this->pay_model->pay_success($out_trade_no, number_format($total_fee, 2, '.', ''), '交易号:' . $trade_no); echo "success"; //请不要修改或删除 }
function notify_url() { require_once "walipay/alipay.config.php"; require_once "walipay/lib/alipay_notify.class.php"; $alipay_config_temp = $this->tickets->select('payment', array('name' => 'alipay')); $alipay_con = $alipay_config_temp[0]; $alipay_config['partner'] = $alipay_con->app_id; $alipay_config['key'] = $alipay_con->app_secret; //计算得出通知验证结果 $alipayNotify = new AlipayNotify($alipay_config); $verify_result = $alipayNotify->verifyNotify(); if ($verify_result) { //验证成功 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //请在这里加上商户的业务逻辑程序代 //——请根据您的业务逻辑来编写程序(以下代码仅作参考)—— //获取支付宝的通知返回参数,可参考技术文档中服务器异步通知参数列表 //解析notify_data //注意:该功能PHP5环境及以上支持,需开通curl、SSL等PHP配置环境。建议本地调试时使用PHP开发软件 $doc = new DOMDocument(); if ($alipay_config['sign_type'] == 'MD5') { $doc->loadXML($_POST['notify_data']); } if ($alipay_config['sign_type'] == '0001') { $doc->loadXML($alipayNotify->decrypt($_POST['notify_data'])); } if (!empty($doc->getElementsByTagName("notify")->item(0)->nodeValue)) { //商户订单号 $out_trade_no = $doc->getElementsByTagName("out_trade_no")->item(0)->nodeValue; //支付宝交易号 $trade_no = $doc->getElementsByTagName("trade_no")->item(0)->nodeValue; //交易状态 $trade_status = $doc->getElementsByTagName("trade_status")->item(0)->nodeValue; if ($trade_status == 'TRADE_FINISHED') { //判断该笔订单是否在商户网站中已经做过处理 //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序 //如果有做过处理,不执行商户的业务程序 //注意: //该种交易状态只在两种情况下出现 //1、开通了普通即时到账,买家付款成功后。 //2、开通了高级即时到账,从该笔交易成功时间算起,过了签约时的可退款时限(如:三个月以内可退款、一年以内可退款等)后。 //调试用,写文本函数记录程序运行情况是否正常 //logResult("这里写入想要调试的代码变量值,或其他运行的结果记录"); echo "success"; //请不要修改或删除 } else { if ($trade_status == 'TRADE_SUCCESS') { $this->_change_order_status($out_trade_no); //判断该笔订单是否在商户网站中已经做过处理 //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序 //如果有做过处理,不执行商户的业务程序 //注意: //该种交易状态只在一种情况下出现——开通了高级即时到账,买家付款成功后。 //调试用,写文本函数记录程序运行情况是否正常 //logResult("这里写入想要调试的代码变量值,或其他运行的结果记录"); echo "success"; //请不要修改或删除 } } } //——请根据您的业务逻辑来编写程序(以上代码仅作参考)—— ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// } else { //验证失败 echo "fail"; //调试用,写文本函数记录程序运行情况是否正常 //logResult("这里写入想要调试的代码变量值,或其他运行的结果记录"); } }
public function aliNotify() { require_once app_path() . "/Tool/alipay/alipay.config.php"; require_once app_path() . "/Tool/alipay/lib/alipay_notify.class.php"; //计算得出通知验证结果 $alipayNotify = new \AlipayNotify($alipay_config); $verify_result = $alipayNotify->verifyNotify(); if ($verify_result) { //验证成功 $doc = new \DOMDocument(); if ($alipay_config['sign_type'] == 'MD5') { $doc->loadXML($_POST['notify_data']); } if ($alipay_config['sign_type'] == '0001') { $doc->loadXML($alipayNotify->decrypt($_POST['notify_data'])); } if (!empty($doc->getElementsByTagName("notify")->item(0)->nodeValue)) { //商户订单号 $out_trade_no = $doc->getElementsByTagName("out_trade_no")->item(0)->nodeValue; //支付宝交易号 $trade_no = $doc->getElementsByTagName("trade_no")->item(0)->nodeValue; //交易状态 $trade_status = $doc->getElementsByTagName("trade_status")->item(0)->nodeValue; if ($trade_status == 'TRADE_FINISHED') { Log::info('支付完成'); echo "success"; //请不要修改或删除 } else { if ($trade_status == 'TRADE_SUCCESS') { // 修改用户的订单状态 Log::info('支付成功'); $order = Order::where('order_no', $out_trade_no)->first(); $order->status = 2; $order->save(); echo "success"; //请不要修改或删除 } } } } else { //验证失败 Log::info('支付验证失败'); echo "fail"; } }
public function wapalipay_notify_url() { include_once APP_PATH . 'Lib/ORG/Weixinpay2/Log_.php'; $log_ = new Log_(); $log_name = APP_PATH . "./../data/wapalipay_notify_url-" . date('Y-m-d', time()) . ".log"; //log文件路径 $log_->log_result($log_name, "【接收到的notify通知】:\r\n" . var_export($_POST, true) . "\r\n"); vendor('Malipay.alipay_notify', '', '.class.php'); $alipay_config = $this->wapalipay_config; $alipayNotify = new AlipayNotify($alipay_config); $verify_result = $alipayNotify->verifyNotify(); //解析notify_data //注意:该功能PHP5环境及以上支持,需开通curl、SSL等PHP配置环境。建议本地调试时使用PHP开发软件 $doc = new DOMDocument(); if ($alipay_config['sign_type'] == 'MD5') { $doc->loadXML($_POST['notify_data']); } if ($alipay_config['sign_type'] == '0001') { $doc->loadXML($alipayNotify->decrypt($_POST['notify_data'])); } if (!empty($doc->getElementsByTagName("notify")->item(0)->nodeValue)) { //商户订单号 $out_trade_no = $doc->getElementsByTagName("out_trade_no")->item(0)->nodeValue; //支付宝交易号 $trade_no = $doc->getElementsByTagName("trade_no")->item(0)->nodeValue; //交易状态 $trade_status = $doc->getElementsByTagName("trade_status")->item(0)->nodeValue; $total_fee = $doc->getElementsByTagName("total_fee")->item(0)->nodeValue; //交易金额 //if($verify_result) {//验证成功 $log_->log_result($log_name, "没有验证直接通过哈,以后再加上验证哈:" . $verify_result . "\r\n"); $order = $this->order_db->where(array('orderid' => $out_trade_no))->find(); $log_->log_result($log_name, "查找到的订单数据是:" . $this->order_db->getLastSql() . "\r\n" . var_export($order, true) . "\r\n"); //if($trade_status == 'TRADE_FINISHED' || $trade_status == 'TRADE_SUCCESS') { if ($order['paid'] == 0) { $data['paid'] = 1; $data['payment'] = 'wapalipay'; $this->order_db->where(array('orderid' => $out_trade_no))->save($data); $log_->log_result($log_name, "正在更改该订单的状态,运行的SQL语句为:" . $this->order_db->getLastSql() . "\r\n"); } else { $log_->log_result($log_name, "订单的paid值为:" . $order['paid'] . ",没有对订单数据进行处理\r\n"); } $log_->log_result($log_name, "向请求端输出了字符串:success\r\n"); echo "success"; //} //}else{ //$log_->log_result($log_name,"但是验证失败了喔!".$verify_result."\r\n"); //} } }
$alipayNotify = new AlipayNotify($alipay_config); $verify_result = $alipayNotify->verifyNotify(); if ($verify_result) { //验证成功 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //请在这里加上商户的业务逻辑程序代 //——请根据您的业务逻辑来编写程序(以下代码仅作参考)—— //获取支付宝的通知返回参数,可参考技术文档中服务器异步通知参数列表 //解析notify_data //注意:该功能PHP5环境及以上支持,需开通curl、SSL等PHP配置环境。建议本地调试时使用PHP开发软件 $doc = new DOMDocument(); if ($alipay_config['sign_type'] == 'MD5') { $doc->loadXML($_POST['notify_data']); } if ($alipay_config['sign_type'] == '0001') { $doc->loadXML($alipayNotify->decrypt($_POST['notify_data'])); } if (!empty($doc->getElementsByTagName("notify")->item(0)->nodeValue)) { //商户订单号 $out_trade_no = $doc->getElementsByTagName("out_trade_no")->item(0)->nodeValue; //支付宝交易号 $trade_no = $doc->getElementsByTagName("trade_no")->item(0)->nodeValue; //交易状态 $trade_status = $doc->getElementsByTagName("trade_status")->item(0)->nodeValue; $app->action('shopping', 'pay_successs_tatus2', array('order_sn' => $out_trade_no, 'status' => '1')); //修改支付状态 if ($trade_status == 'TRADE_FINISHED') { //判断该笔订单是否在商户网站中已经做过处理 //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序 //如果有做过处理,不执行商户的业务程序 //注意:
public function notify_url() { if (defined('MOBILE')) { //手机支付 require_once CSCMSPATH . "pay/alipay_wap/alipay.config.php"; require_once CSCMSPATH . "pay/alipay_wap/lib/alipay_notify.class.php"; $alipayNotify = new AlipayNotify($alipay_config); $verify_result = $alipayNotify->verifyNotify(); if ($verify_result) { $doc = new DOMDocument(); if ($alipay_config['sign_type'] == 'MD5') { $doc->loadXML($_POST['notify_data']); } if ($alipay_config['sign_type'] == '0001') { $doc->loadXML($alipayNotify->decrypt($_POST['notify_data'])); } if (!empty($doc->getElementsByTagName("notify")->item(0)->nodeValue)) { //商户订单号 $out_trade_no = $doc->getElementsByTagName("out_trade_no")->item(0)->nodeValue; //支付宝交易号 $trade_no = $doc->getElementsByTagName("trade_no")->item(0)->nodeValue; //交易状态 $trade_status = $doc->getElementsByTagName("trade_status")->item(0)->nodeValue; //获取订单记录 $row = $this->CsdjDB->get_row('pay', '*', $out_trade_no, 'dingdan'); if ($trade_status == 'TRADE_FINISHED' || $trade_status == 'TRADE_SUCCESS') { if ($row && $row->pid != 1) { //增加金钱 $this->db->query("update " . CS_SqlPrefix . "user set rmb=rmb+" . $row->rmb . " where id=" . $row->uid . ""); //改变状态 $this->db->query("update " . CS_SqlPrefix . "pay set pid=1 where id=" . $row->id . ""); //发送通知 $add['uida'] = $row->uid; $add['uidb'] = 0; $add['name'] = L('pay_11'); $add['neir'] = L('pay_12', array($row->rmb, $out_trade_no)); $add['addtime'] = time(); $this->CsdjDB->get_insert('msg', $add); } echo "success"; } } } else { echo "fail"; } } elseif (CS_Alipay_JK == 1) { //双功能 require_once CSCMSPATH . "pay/alipay_trade/alipay.config.php"; require_once CSCMSPATH . "pay/alipay_trade/lib/alipay_notify.class.php"; //计算得出通知验证结果 $alipayNotify = new AlipayNotify($alipay_config); $verify_result = $alipayNotify->verifyNotify(); if ($verify_result) { //验证成功 //商户订单号 $out_trade_no = $this->input->post('out_trade_no', true, true); //支付宝交易号 $trade_no = $this->input->post('trade_no', true, true); //交易状态 $trade_status = $this->input->post('trade_status', true, true); //获取订单记录 $row = $this->CsdjDB->get_row('pay', '*', $out_trade_no, 'dingdan'); if ($trade_status == 'WAIT_BUYER_PAY') { //产生了交易记录,但没有付款 echo "success"; } elseif ($trade_status == 'WAIT_SELLER_SEND_GOODS') { //等待发货 if ($row) { $this->db->query("update " . CS_SqlPrefix . "pay set pid=2 where id=" . $row->id . ""); //发送通知 $add['uida'] = $row->uid; $add['uidb'] = 0; $add['name'] = L('pay_13'); $add['neir'] = L('pay_14', array($row->rmb, $out_trade_no)); $add['addtime'] = time(); $this->CsdjDB->get_insert('msg', $add); } echo "success"; } elseif ($trade_status == 'WAIT_BUYER_CONFIRM_GOODS') { //已经发货 if ($row) { $this->db->query("update " . CS_SqlPrefix . "pay set pid=3 where id=" . $row->id . ""); //发送通知 $add['uida'] = $row->uid; $add['uidb'] = 0; $add['name'] = L('pay_15'); $add['neir'] = L('pay_16', array($out_trade_no)); $add['addtime'] = time(); $this->CsdjDB->get_insert('msg', $add); } echo "success"; } elseif ($trade_status == 'TRADE_FINISHED') { //确定收货 if ($row && $row->pid != 1) { //增加金钱 $this->db->query("update " . CS_SqlPrefix . "user set rmb=rmb+" . $row->rmb . " where id=" . $row->uid . ""); //改变状态 $this->db->query("update " . CS_SqlPrefix . "pay set pid=1 where id=" . $row->id . ""); //发送通知 $add['uida'] = $row->uid; $add['uidb'] = 0; $add['name'] = L('pay_11'); $add['neir'] = L('pay_12', array($row->rmb, $out_trade_no)); $add['addtime'] = time(); $this->CsdjDB->get_insert('msg', $add); } echo "success"; } else { echo "success"; } } else { echo "fail"; } } elseif (CS_Alipay_JK == 2) { //即时到账 require_once CSCMSPATH . "pay/alipay_direct/alipay.config.php"; require_once CSCMSPATH . "pay/alipay_direct/lib/alipay_notify.class.php"; $alipayNotify = new AlipayNotify($alipay_config); $verify_result = $alipayNotify->verifyReturn(); if ($verify_result) { //验证成功 //商户订单号 $out_trade_no = $this->input->post('out_trade_no', true, true); //支付宝交易号 $trade_no = $this->input->post('trade_no', true, true); //交易状态 $trade_status = $this->input->post('trade_status', true, true); //获取订单记录 $row = $this->CsdjDB->get_row('pay', '*', $out_trade_no, 'dingdan'); if ($trade_status == 'TRADE_FINISHED' || $trade_status == 'TRADE_SUCCESS') { if ($row && $row->pid != 1) { //增加金钱 $this->db->query("update " . CS_SqlPrefix . "user set rmb=rmb+" . $row->rmb . " where id=" . $row->uid . ""); //改变状态 $this->db->query("update " . CS_SqlPrefix . "pay set pid=1 where id=" . $row->id . ""); //发送通知 $add['uida'] = $row->uid; $add['uidb'] = 0; $add['name'] = L('pay_11'); $add['neir'] = L('pay_12', array($row->rmb, $out_trade_no)); $add['addtime'] = time(); $this->CsdjDB->get_insert('msg', $add); } echo "success"; } else { echo "success"; } } else { echo "fail"; } } }