Пример #1
0
 public function index()
 {
     $alipay_config = alipay_config();
     require_once "application/third_party/alipay/lib/alipay_notify.class.php";
     $alipayNotify = new AlipayNotify($alipay_config);
     $verify_result = $alipayNotify->verifyNotify();
     $result = false;
     if ($verify_result) {
         $out_trade_no = $_POST['out_trade_no'];
         $trade_no = $_POST['trade_no'];
         $trade_status = $_POST['trade_status'];
         if ($_POST['trade_status'] == 'TRADE_FINISHED') {
             $result = $this->Morder->updatePaymentStatus($out_trade_no);
             if (!$result) {
                 logResult('update payment error:' . $out_trade_no . "\\n");
             }
             logResult($out_trade_no . " " . $trade_no . " " . $trade_status . "\\n");
         } else {
             if ($_POST['trade_status'] == 'TRADE_SUCCESS') {
                 $result = $this->Morder->updatePaymentStatus($out_trade_no);
                 if (!$result) {
                     logResult('update payment error:' . $out_trade_no . "\\n");
                 }
                 logResult($out_trade_no . " " . $trade_no . " " . $trade_status . "\\n");
             }
         }
         if ($result) {
             echo "success";
         } else {
             echo 'fail';
         }
     } else {
         echo "fail";
         logResult("notify fail out_trade_no:" . $_POST['out_trade_no'] . ' trade_no:' . $_POST['trade_no'] . ' trade_status:' . $_POST['trade_status']);
         //if($_POST['trade_status'] == 'TRADE_SUCCESS')
         //    logPayError();
     }
 }
Пример #2
0
 public function return_alipay()
 {
     require_once "application/third_party/alipay/lib/alipay_notify.class.php";
     $alipay_config = alipay_config();
     $alipayNotify = new AlipayNotify($alipay_config);
     $verify_result = $alipayNotify->verifyReturn();
     if ($verify_result) {
         $out_trade_no = $_GET['out_trade_no'];
         $trade_no = $_GET['trade_no'];
         $trade_status = $_GET['trade_status'];
         if ($_GET['trade_status'] == 'TRADE_FINISHED' || $_GET['trade_status'] == 'TRADE_SUCCESS') {
             $result = $this->Morder->updatePaymentStatus($out_trade_no);
             if ($result) {
                 echo "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\"></head>";
                 echo "验证成功<br />";
                 echo "<script>alert('支付成功!请等待管理员审核完成实物交易。');</script>";
                 echo "<script>window.location.href=\"" . base_url() . "order/listpage\";</script>";
                 echo "</html>";
             } else {
                 echo "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\"></head>";
                 echo "<script>alert('你的支付信息将同步到系统!请等待管理员审核完成实物交易。');</script>";
                 echo "<script>window.location.href=\"" . base_url() . "order/listpage\";</script>";
                 echo "验证失败";
                 echo "</html>";
             }
         } else {
             echo "trade_status=" . $_GET['trade_status'];
         }
     } else {
         echo "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\"></head>";
         echo "<script>alert('你的支付信息将同步到系统!请等待管理员审核完成实物交易。');</script>";
         echo "<script>window.location.href=\"" . base_url() . "order/listpage\";</script>";
         echo "验证失败";
         echo "</html>";
     }
 }