require_once("alipay.config.php");
require_once("lib/alipay_notify.class.php");
$alipayNotify = new AlipayNotify($alipay_config);
$verify_result = $alipayNotify->verifyNotify();
if($verify_result) {//驗證成功
$notify_data = $alipayNotify->decrypt($_POST[‘notify_data‘]);
$doc = new DOMDocument();
$doc->loadXML($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($_POST[‘trade_status‘] == ‘TRADE_FINISHED‘ || $_POST[‘trade_status‘] == ‘TRADE_SUCCESS‘) {
//以下是數據庫操作代碼
require_once(‘../Connections/coon.php‘);
mysql_select_db($database_coon, $coon);
mysql_query("UPDATE shop_orders SET ZT=‘payed‘ WHERE DDH=‘$out_trade_no‘");
mysql_close($coon);
//數據庫操作結束
echo "success";
}
}
}
else {
echo "fail";
}
?>
操作數據庫的代碼沒有執行,查過支付寶可以正常訪問這個頁面。問題出現在解密或者解析XML上,請問高手們這個哪里有問題?我是采用RSA加密方式。
你這是官方文檔應用的 這個文檔是有錯誤的!!低級錯誤!!!$_POST[‘trade_status‘]改成$trade_status寫日志調試!!!
追問:
非常感謝您!改了之后就成功了!感謝無私的奉獻!
追答:
官方給的實例問題!!!不客氣!!
原文:http://www.cnblogs.com/phpxuetang/p/4857154.html