<?php /** * 异步处理 * @author abei<*****@*****.**> */ require_once(dirname(dirname(dirname(__FILE__))) . '/app.php'); import('qalipay'); $alipayNotify = new QAlipayNotify($INI['qalipay']); $verify_result = $alipayNotify->verifyNotify(); if($verify_result) { //$notify_data = $alipayNotify->decrypt($_POST['notify_data']); $doc = new DOMDocument(); $doc->loadXML($_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; DB::Insert('alipay_log',array('value'=>$total_fee.$out_trade_no.$trade_no.$trade_status)); if($trade_status == 'TRADE_FINISHED') { @list($_, $order_id, $city_id, $_) = explode('-', $out_trade_no, 4); if (Table::Fetch('pay', $out_trade_no)) die('success'); $currency = 'CNY'; $service = 'alipay'; $bank = '支付宝'; $order = Table::Fetch('order',$order_id);
<?php require_once(dirname(dirname(dirname(__FILE__))) . '/app.php'); import('qalipay'); $alipayNotify = new QAlipayNotify($INI['qalipay']); $verify_result = $alipayNotify->verifyReturn(); if($verify_result) { $out_trade_no = $_GET['out_trade_no']; $trade_no = $_GET['trade_no']; $result = $_GET['result']; @list($_, $order_id, $city_id, $_) = explode('-', $out_trade_no, 4); if (Table::Fetch('pay', $out_trade_no)){ redirect("../order.php?id={$order_id}" ); //die('成功啦!'); }