verifyReturn() public method

针对return_url验证消息是否是支付宝发出的合法消息
public verifyReturn ( ) : 验证结果
return 验证结果
Esempio n. 1
0
    function respond() {
        
        ini_set("display_errors","On");
        $where = array('ologin_code'=>front::$get['ologin_code']);
        $ologins = ologin::getInstance()->getrows($where);
        $ologin = unserialize_config($ologins[0]['ologin_config']);

        //var_dump($ologin);
        
        $aliapy_config['partner'] = $ologin['alipaylogin_id'];
        $aliapy_config['key'] = $ologin['alipaylogin_key'];
        $aliapy_config['return_url'] = ologin::url(basename(__FILE__,'.php'));
        $aliapy_config['sign_type']    = 'MD5';
        $aliapy_config['input_charset']= 'utf-8';
        $aliapy_config['transport']    = 'http';
        $aliapy_config['cacert']    = getcwd().'/lib/plugins/alipayauth/cacert.pem';
        //var_dump($aliapy_config);
        unset($_GET['case']);unset($_GET['act']);unset($_GET['ologin_code']);unset($_GET['site']);
        require_once("alipayauth/alipay_notify.class.php");
        $alipayNotify = new AlipayNotify($aliapy_config);
        //var_dump($alipayNotify);
        $verify_result = $alipayNotify->verifyReturn();
        //var_dump($verify_result);
        if($verify_result) {//验证成功
            $user_id = front::$get['user_id'];
            $token = front::$get['token'];
            session::set('access_token',$token);
            session::set("openid",$user_id);
            return array('nickname'=>  front::get('real_name'));
        }
        else {
            echo "验证失败";exit;
        }
    }
Esempio n. 2
0
function verifyAlipayReturn(array $alipayConfig)
{
    $alipayConfig = getAlipayConfig($alipayConfig);
    $alipayNotify = new AlipayNotify($alipayConfig);
    $verifyResult = $alipayNotify->verifyReturn();
    return (bool) $verifyResult;
}
Esempio n. 3
0
 public function return_url()
 {
     import("@.ORG.Alipay.AlipayNotify");
     $alipayNotify = new AlipayNotify($this->setconfig());
     $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'] == 'WAIT_SELLER_SEND_GOODS') {
             $indent = M('Indent')->field('id,price')->where(array('index_id' => $out_trade_no))->find();
             if ($indent !== false) {
                 //$back=M('Users')->where(array('id'=>$indent['uid']))->setInc('money',$indent['price']);
                 $back = M('Indent')->where(array('id' => $indent['id']))->setField('status', 1);
                 if ($back != false) {
                     $this->success('充值成功', U('Home/Index/index'));
                 } else {
                     $this->error('充值失败,请在线客服,为您处理', U('Home/Index/index'));
                 }
             } else {
                 $this->error('订单不存在', U('Home/Index/index'));
             }
         } else {
             $this->error('请勿重复操作', U('Home/Index/index'));
         }
     } else {
         $this->error('充值失败 ,请在线客服,为您处理', U('Home/Index/index'));
     }
 }
Esempio n. 4
0
 function actionVerify()
 {
     unset($_GET['action']);
     unset($_GET['module']);
     unset($_GET['controller']);
     $root_dir = Q::ini('app_config/ROOT_DIR');
     require_once $root_dir . Q::ini('appini/alipay_dir') . "lib/alipay_notify.class.php";
     //计算得出通知验证结果
     $alipayNotify = new AlipayNotify(Q::ini('appini/payment/alipay'));
     $verify_result = $alipayNotify->verifyReturn();
     if ($verify_result) {
         $out_trade_no = $_GET['out_trade_no'];
         //获取订单号
         $trade_no = $_GET['trade_no'];
         //获取支付宝交易号
         $total_fee = $_GET['price'];
         //获取总价格
         $rs = Invoice::find('order_number = ?', $_GET['out_trade_no'])->getOne();
         if ($rs->id()) {
             #$rs->total_fee   = $total_fee;
             $rs->trade_time = time();
             $rs->trade_no = $trade_no;
             $rs->trade_status = $_GET['trade_status'];
             $rs->buyer_email = $_GET['buyer_email'];
             $rs->trade_ip = $_SERVER['REMOTE_ADDR'];
             $rs->save();
         }
         $msg = "付款成功!如果您选择的是即时到帐服务那么您的帐号已经生效。";
         return $this->msg($msg, url('default::service/index'));
     } else {
         #dump($_GET);
         return $this->msg('您好,为了保障数据有效性,我们采用异步通知收款,如果您的帐号未生效,请联系我们。', url('default::service/index'));
     }
 }
 public function actionAlipayOrderReturn()
 {
     require_once Yii::getAlias('@vendor') . "/payment/alipay/alipay.config.php";
     require_once Yii::getAlias('@vendor') . "/payment/alipay/lib/alipay_notify.class.php";
     $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'];
         $model = Order::findOne(['order_sn' => $out_trade_no]);
         if ($model) {
             if ($trade_status === 'TRADE_SUCCESS' || $trade_status === 'TRADE_FINISHED') {
                 if ($model->pay()) {
                     $this->_sendMsg($model);
                     Yii::info("订单支付成功!订单号:{$out_trade_no}");
                 } else {
                     Yii::error("订单支付失败!订单号:{$out_trade_no}");
                     Yii::$app->session->setFlash('danger', '订单支付失败!');
                 }
             } elseif ($trade_status === 'TRADE_CLOSED') {
                 Yii::$app->session->setFlash('warning', '订单未支付!');
             }
         }
     } else {
         throw new ForbiddenHttpException('参数非法。');
     }
     return $this->redirect(['/order/detail', 'order' => $model->order_sn]);
 }
Esempio n. 6
0
 public function verifyReturn()
 {
     require_once "alipay.config.php";
     require_once "lib/alipay_notify.class.php";
     $alipayNotify = new \AlipayNotify($alipay_config);
     return $alipayNotify->verifyReturn();
 }
Esempio n. 7
0
    /**
     * 支付宝即时即时跳转返回的结果
     * @param   string      &$msg   提示信息
     * @return  bool        返回处理成功与否
     */
    public static function paying_return(&$msg)
    {
        $alipay_config = AlipayConfig::config();
        //计算得出通知验证结果
        $alipayNotify = new AlipayNotify($alipay_config);
        $verify_result = $alipayNotify->verifyReturn();
        if (!$verify_result) {
            /* TODO 由于验证总是失败,这里将其提示信息显示得友好些
               $msg = '验证失败,请稍候查询余额';
               return false;
                */
            $msg = "系统正在处理,请稍候查询余额";
            return true;
        }
        //验证成功
        //商户订单号
        $out_trade_no = $_GET['out_trade_no'];
        //支付宝交易号
        $trade_no = $_GET['trade_no'];
        //交易状态
        $trade_status = $_GET['trade_status'];
        if (!in_array($_GET['trade_status'], array('TRADE_FINISHED', 'TRADE_SUCCESS'))) {
            $msg = "验证失败(trade_status:" . $_GET['trade_status'] . ')';
            return false;
        }
        //判断该笔订单是否在商户网站中已经做过处理
        //如果没有做过处理,根据订单号(out_trade_no)在商户网站的
        //订单系统中查到该笔订单的详细,并执行商户的业务程序
        //如果有做过处理,不执行商户的业务程序
        $db = Fn::db();
        $time = time();
        $row = TransactionRecordModel::transactionRecordInfoByTrNo($out_trade_no);
        if (!$row) {
            $msg = "查无未订单{$out_trade_no}";
            return false;
        }
        if ($row['tr_flag'] == 1) {
            $msg = '订单已更新';
            return true;
        }
        if (!$db->beginTransaction()) {
            $msg = "更新订单失败(事务启动失败)";
            return false;
        }
        $param = array('tr_flag' => 1, 'tr_finishtime' => $time);
        TransactionRecordModel::setTransactionRecordByTrNo($out_trade_no, $param);
        $sql = <<<EOT
UPDATE rd_student SET account = account + ({$row['tr_trade_amount']}) 
WHERE uid = {$row['tr_uid']}
EOT;
        $flag = $db->exec($sql);
        if (!$db->commit()) {
            $db->rollBack();
            $msg = "更新订单失败(事务执行失败)";
            return false;
        }
        $msg = "更新订单成功" . $_GET['trade_status'];
        return true;
    }
Esempio n. 8
0
 public function return_url()
 {
     import("@.ORG.Alipay.AlipayNotify");
     $alipayNotify = new AlipayNotify($this->setconfig());
     $verify_result = $alipayNotify->verifyReturn();
     if ($verify_result) {
         $out_trade_no = $this->_get('out_trade_no');
         $trade_no = $this->_get('trade_no');
         $trade_status = $this->_get('trade_status');
         if ($this->_get('trade_status') == 'TRADE_FINISHED' || $this->_get('trade_status') == 'TRADE_SUCCESS') {
             $product_cart_model = M('product_cart');
             $order = $product_cart_model->where(array('orderid' => $out_trade_no))->find();
             if (!$this->wecha_id) {
                 $this->wecha_id = $order['wecha_id'];
             }
             $sepOrder = 0;
             if (!$order) {
                 $order = $product_cart_model->where(array('id' => $out_trade_no))->find();
                 $sepOrder = 1;
             }
             if ($order) {
                 if ($order['paid'] == 1) {
                     exit('该订单已经支付,请勿重复操作');
                 }
                 if (!$sepOrder) {
                     $product_cart_model->where(array('orderid' => $out_trade_no))->setField('paid', 1);
                 } else {
                     $product_cart_model->where(array('id' => $out_trade_no))->setField('paid', 1);
                 }
                 $member_card_create_db = M('Member_card_create');
                 $userCard = $member_card_create_db->where(array('token' => $this->token, 'wecha_id' => $this->wecha_id))->find();
                 $member_card_set_db = M('Member_card_set');
                 $thisCard = $member_card_set_db->where(array('id' => intval($userCard['cardid'])))->find();
                 $set_exchange = M('Member_card_exchange')->where(array('cardid' => intval($thisCard['id'])))->find();
                 $arr['token'] = $this->token;
                 $arr['wecha_id'] = $this->wecha_id;
                 $arr['expense'] = $order['price'];
                 $arr['time'] = time();
                 $arr['cat'] = 99;
                 $arr['staffid'] = 0;
                 $arr['score'] = intval($set_exchange['reward']) * $order['price'];
                 M('Member_card_use_record')->add($arr);
                 $userinfo_db = M('Userinfo');
                 $thisUser = $userinfo_db->where(array('token' => $thisCard['token'], 'wecha_id' => $arr['wecha_id']))->find();
                 $userArr = array();
                 $userArr['total_score'] = $thisUser['total_score'] + $arr['score'];
                 $userArr['expensetotal'] = $thisUser['expensetotal'] + $arr['expense'];
                 $userinfo_db->where(array('token' => $thisCard['token'], 'wecha_id' => $arr['wecha_id']))->save($userArr);
                 $this->redirect(U('Product/my', array('token' => $order['token'], 'wecha_id' => $order['wecha_id'], 'success' => 1)));
             } else {
                 exit('订单不存在:' . $out_trade_no);
             }
         } else {
             exit('付款失败');
         }
     } else {
         exit('不存在的订单');
     }
 }
Esempio n. 9
0
 function check($result)
 {
     require_once "alipay/config.php";
     require_once "alipay/lib/alipay_notify.class.php";
     $alipayNotify = new \AlipayNotify($alipay_config);
     $verify_result = $alipayNotify->verifyReturn($result);
     return $verify_result;
 }
Esempio n. 10
0
 public function returnVerify()
 {
     require_once "alipay/alipay_notify.class.php";
     $alipayNotify = new AlipayNotify($this->_config);
     $verify_result = $alipayNotify->verifyReturn();
     //验证
     if ($verify_result) {
         return $_GET;
     } else {
         return false;
     }
 }
Esempio n. 11
0
 public function callback()
 {
     es_session::start();
     $aliapy_config['partner'] = $this->api['config']['app_key'];
     $aliapy_config['key'] = $this->api['config']['app_secret'];
     $aliapy_config['return_url'] = SITE_DOMAIN . APP_ROOT . "/api_callback.php?c=Taobao";
     $aliapy_config['sign_type'] = 'MD5';
     $aliapy_config['input_charset'] = 'utf-8';
     $aliapy_config['transport'] = 'http';
     require_once APP_ROOT_PATH . "system/api_login/taobao/alipay_notify.class.php";
     unset($_GET['c']);
     $alipayNotify = new AlipayNotify($aliapy_config);
     $verify_result = $alipayNotify->verifyReturn();
     if ($verify_result) {
         //验证成功
         /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
         //请在这里加上商户的业务逻辑程序代码
         //——请根据您的业务逻辑来编写程序(以下代码仅作参考)——
         //获取支付宝的通知返回参数,可参考技术文档中页面跳转同步通知参数列表
         $user_id = $_GET['user_id'];
         //支付宝用户id
         $token = $_GET['token'];
         //授权令牌
         $real_name = $_GET['real_name'];
         //执行商户的业务程序
         $msg['id'] = $user_id;
         $msg['name'] = $real_name;
         $msg['field'] = 'taobao_id';
         es_session::set("api_user_info", $msg);
         $user_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where taobao_id = '" . $msg['id'] . "' and taobao_id <> ''");
         if ($user_data) {
             $user_current_group = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_group where id = " . intval($user_data['group_id']));
             $user_group = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_group where score <=" . intval($user_data['score']) . " order by score desc");
             if ($user_current_group['score'] < $user_group['score']) {
                 $user_data['group_id'] = intval($user_group['id']);
             }
             es_session::set("user_info", $user_data);
             $GLOBALS['db']->query("update " . DB_PREFIX . "user set login_ip = '" . CLIENT_IP . "',login_time= " . TIME_UTC . ",group_id=" . intval($user_data['group_id']) . " where id =" . $user_data['id']);
             //$GLOBALS['db']->query("update ".DB_PREFIX."deal_cart set user_id = ".intval($user_data['id'])." where session_id = '".es_session::id()."'");
             es_session::delete("api_user_info");
             app_recirect_preview();
         } else {
             app_redirect(url("shop", "user#api_login"));
         }
         //——请根据您的业务逻辑来编写程序(以上代码仅作参考)——
         /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     } else {
         //验证失败
         //如要调试,请看alipay_notify.php页面的return_verify函数,比对sign和mysign的值是否相等,或者检查$veryfy_result有没有返回true
         echo "验证失败";
     }
 }
Esempio n. 12
0
 public function callback()
 {
     es_session::start();
     $aliapy_config['partner'] = $this->api['config']['app_key'];
     $aliapy_config['key'] = $this->api['config']['app_secret'];
     $aliapy_config['return_url'] = get_domain() . APP_ROOT . "/api_callback.php?c=Taobao";
     $aliapy_config['sign_type'] = 'MD5';
     $aliapy_config['input_charset'] = 'utf-8';
     $aliapy_config['transport'] = 'http';
     require_once APP_ROOT_PATH . "system/api_login/taobao/alipay_notify.class.php";
     unset($_GET['c']);
     $alipayNotify = new AlipayNotify($aliapy_config);
     $verify_result = $alipayNotify->verifyReturn();
     if ($verify_result) {
         //验证成功
         /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
         //请在这里加上商户的业务逻辑程序代码
         //——请根据您的业务逻辑来编写程序(以下代码仅作参考)——
         //获取支付宝的通知返回参数,可参考技术文档中页面跳转同步通知参数列表
         $user_id = $_GET['user_id'];
         //支付宝用户id
         $token = $_GET['token'];
         //授权令牌
         $real_name = $_GET['real_name'];
         //执行商户的业务程序
         $msg['id'] = $user_id;
         $msg['name'] = $real_name;
         $msg['field'] = 'taobao_id';
         es_session::set("api_user_info", $msg);
         if (!$msg['name']) {
             app_redirect(url("index"));
         }
         $user_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where taobao_id = '" . $msg['id'] . "' and taobao_id <> ''");
         if ($user_data) {
             require_once APP_ROOT_PATH . "system/libs/user.php";
             auto_do_login_user($user_data['user_name'], $user_data['user_pwd'], $from_cookie = false);
             es_session::delete("api_user_info");
             app_recirect_preview();
         } else {
             $this->create_user();
             app_redirect(url("shop", "user#stepone"));
         }
         //——请根据您的业务逻辑来编写程序(以上代码仅作参考)——
         /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     } else {
         //验证失败
         //如要调试,请看alipay_notify.php页面的return_verify函数,比对sign和mysign的值是否相等,或者检查$veryfy_result有没有返回true
         echo "验证失败";
     }
 }
Esempio n. 13
0
function alipay_callback()
{
    require_once "alipay/wap/alipay.config.php";
    require_once "alipay/wap/lib/alipay_notify.class.php";
    $out_trade_no = $_GET['out_trade_no'];
    //商户订单号
    $trade_no = $_GET['trade_no'];
    //支付宝交易号
    $result = $_GET['result'];
    //交易状态
    $alipayNotify = new AlipayNotify($alipay_config);
    $verify_result = $alipayNotify->verifyReturn();
    if ($verify_result) {
        goto_app_callback(0, $out_trade_no);
    } else {
        //验证失败
        //echo "验证失败";
        goto_app_callback(1, $out_trade_no);
    }
}
Esempio n. 14
0
 public function callback()
 {
     require_once ROOT . '/libs/alipay_lib/alipay_notify.class.php';
     $alipayNotify = new AlipayNotify($this->alipay_config);
     $verify_result = $alipayNotify->verifyReturn();
     $ret = array();
     $ret["out_trade_no"] = $_REQUEST['out_trade_no'];
     $ret["trade_no"] = $_REQUEST['trade_no'];
     $trade_status = $_REQUEST['trade_status'];
     //$verify_result=true;
     if ($verify_result) {
         if ($trade_status == 'TRADE_SUCCESS' || $trade_status == 'TRADE_FINISHED') {
             $ret["result"] = "SUCCESS";
         } else {
             $ret["result"] = "FAIL";
         }
     } else {
         $ret["result"] = "FAIL";
     }
     return $ret;
 }
Esempio n. 15
0
 public function actionReturn()
 {
     //            $alipayconf=new AlipayConfig();
     //            $alipay_config=$alipayconf->getAlipayConfig();
     //计算得出通知验证结果
     $alipayNotify = new AlipayNotify($this->alipay_config);
     $verify_result = $alipayNotify->verifyReturn();
     $ret_status = "";
     $trade_status = "";
     if ($verify_result) {
         //验证成功
         //商户订单号
         $out_trade_no = $_GET['out_trade_no'];
         //支付宝交易号
         $trade_no = $_GET['trade_no'];
         //交易状态
         $trade_status = $_GET['trade_status'];
         //交易目前所处的状态。成功状态的值只有两个:
         //TRADE_FINISHED(普通即时到账的交易成功状态)
         //TRADE_SUCCESS(开通了高级即时到账或机票分销产品后的交易成功状态)
         if ($_GET['trade_status'] == 'TRADE_FINISHED' || $_GET['trade_status'] == 'TRADE_SUCCESS') {
             //判断该笔订单是否在商户网站中已经做过处理
             //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
             //如果有做过处理,不执行商户的业务程序
             //下单,返回页面,单元清单。。。
             $this->endTrade($out_trade_no, $trade_no, $trade_no);
             $ret_status = "正常返回,下单成功";
             //下单成功
         } else {
             //echo "trade_status=".$_GET['trade_status'];
             $ret_status = "非正常返回,验证成功。";
         }
     } else {
         //验证失败
         //如要调试,请看alipay_notify.php页面的verifyReturn函数
         $ret_status = "验证失败";
     }
     //var_dump($trade_status);exit;
     $this->render('return', array('trade_status' => $trade_status, 'ret_status' => $ret_status));
 }
Esempio n. 16
0
 public function return_url()
 {
     import('@.ORG.Alipay.AlipayNotify');
     $alipayNotify = new AlipayNotify($this->setconfig());
     $verify_result = $alipayNotify->verifyReturn();
     if ($verify_result) {
         $out_trade_no = $this->_get('out_trade_no');
         $trade_no = $this->_get('trade_no');
         $trade_status = $this->_get('trade_status');
         if ($this->_get('trade_status') == 'TRADE_FINISHED' || $this->_get('trade_status') == 'TRADE_SUCCESS') {
             $indent = M('Indent')->where(array('orderid' => $out_trade_no))->find();
             if ($indent != false) {
                 if ($indent['status'] == 1) {
                     $this->error('该订单已经处理过,请勿重复操作');
                 }
                 if (isset($_GET['discountpriceid'])) {
                     $thisPrice = M('Agent_price')->where(array('id' => intval($_GET['discountpriceid'])))->find();
                     $indent['amount'] = $thisPrice['maxaccount'] * $this->thisAgent['wxacountprice'];
                 }
                 M('Agent')->where(array('id' => $indent['agentid']))->setInc('money', intval($indent['amount']));
                 M('Agent')->where(array('id' => $indent['agentid']))->setInc('moneybalance', intval($indent['amount']));
                 $back = M('Agent_expenserecords')->where(array('id' => $indent['id']))->setField('status', 1);
                 if ($back != false) {
                     $this->success('充值成功', U('Agent/Basic/expenseRecords'));
                 } else {
                     $this->error('充值失败,请在线客服,为您处理', U('Agent/Basic/expenseRecords'));
                 }
             } else {
                 $this->error('订单不存在', U('Agent/Basic/expenseRecords'));
             }
         } else {
             $this->error('充值失败,请联系官方客户');
         }
     } else {
         $this->error('不存在的订单');
     }
 }
Esempio n. 17
0
 function callback()
 {
     //计算得出通知验证结果
     $alipayNotify = new AlipayNotify($this->alipay_config);
     $verify_result = $alipayNotify->verifyReturn();
     $this->log('deposit/return ' . 'verify:' . ($verify_result ? 'true' : 'false') . ' ' . json_encode($_GET, JSON_UNESCAPED_UNICODE));
     $result = array('err' => -1);
     if ($verify_result) {
         //验证成功
         //商户订单号
         $out_trade_no = $_GET['out_trade_no'];
         //支付宝交易号
         $trade_no = $_GET['trade_no'];
         //交易状态
         $trade_status = $_GET['trade_status'];
         $deposit_id = intval($out_trade_no);
         if (!$deposit_id) {
             $result['err'] = -2;
             return $result;
         }
         $record = DB::fetch_first('SELECT * FROM ' . DB::table('user_deposit') . ' WHERE ' . DB::implode(array('id' => $deposit_id)));
         if (!$record) {
             $result['err'] = -3;
             return $result;
         }
         $result['err'] = 0;
         $result['record'] = $record;
         $result['status'] = $trade_status;
         switch ($trade_status) {
             case 'WAIT_SELLER_SEND_GOODS':
                 break;
             case 'TRADE_FINISHED':
                 break;
         }
     }
     return $result;
 }
Esempio n. 18
0
 public function jump_old_return_url()
 {
     //这里获取参数试试吧
     require_once "application/config/alipay.config.php";
     require_once "application/libraries/oldalipay/alipay_notify.class.php";
     $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'] == 'WAIT_SELLER_SEND_GOODS') {
             //判断该笔订单是否在商户网站中已经做过处理
             //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
             //如果有做过处理,不执行商户的业务程序
         } else {
             echo "trade_status=" . $_GET['trade_status'];
         }
         echo "验证成功<br />";
         echo "trade_no=" . $trade_no;
         $this->charge_success($out_trade_no, true);
     } else {
         //验证失败
         //如要调试,请看alipay_notify.php页面的verifyReturn函数
         echo "验证失败";
         // $this->charge_success('1111111',false);
     }
     //$this->load->view('oldalipay/return_url');
 }
 public function m_alipay_return()
 {
     Log::record('m_return_url called. get:' . print_r($_GET, true) . ' post:' . print_r($_POST, true), Log::INFO);
     Log::save();
     $uid = session('uid');
     $agent_cfg;
     if (!empty($uid)) {
         $sql = "select ac.cfg_data, a.role from tp_users as u " . " LEFT JOIN tp_oem_cfg as ac on u.administrator = ac.agent_id " . " LEFT JOIN tp_user as a on u.administrator = a.id " . " where u.id = {$uid};";
         $Model = new Model();
         $cfg = $Model->query($sql);
         $agent_cfg = unserialize($cfg[0]['cfg_data']);
         if ($cfg != false && ($cfg[0]['role'] == 12 || $cfg[0]['role'] == 13)) {
             $default_agent_cfg = C('default_agent_info');
             //代理商用户和直销用户使用领众的支付信息
             $agent_cfg['alipay_seller_email'] = $default_agent_cfg['alipay_seller_email'];
             $agent_cfg['alipay_partner'] = $default_agent_cfg['alipay_partner'];
             $agent_cfg['alipay_key'] = $default_agent_cfg['alipay_key'];
             $agent_cfg['alipay_service'] = $default_agent_cfg['alipay_service'];
         }
     } else {
         Log::record("wrong request without uid");
         Log::record("record the returned info:" . print_r($_GET, true));
         Log::save();
         exit;
     }
     if (empty($agent_cfg['alipay_partner']) || empty($agent_cfg['alipay_key'])) {
         Log::record("wrong alipay cfg.");
         Log::record("record the returned info:" . print_r($_GET, true));
         Log::save();
         exit;
     }
     //载入支付宝支付配置信息
     $alipayConfig = C('alipay_config');
     $alipayConfig['partner'] = $agent_cfg['alipay_partner'];
     $alipayConfig['key'] = $agent_cfg['alipay_key'];
     import("@.ORG.Alipay.AlipayNotify");
     $alipayNotify = new AlipayNotify($alipayConfig);
     $verify_result = $alipayNotify->verifyReturn();
     if ($verify_result) {
         Log::record('m_return_url uid:' . session('uid') . ' ' . print_r($_GET, true), Log::INFO);
         //商户订单号
         $out_trade_no = $_GET['out_trade_no'];
         //支付宝交易号
         $data['ali_trade_no'] = $_GET['trade_no'];
         //交易状态
         $data['ali_trade_status'] = $_GET['trade_status'];
         $data['ali_notify_id'] = $_GET['notify_id'];
         $data['ali_notify_type'] = $_GET['notify_type'];
         $data['ali_total_fee'] = $_GET['total_fee'];
         $data['ali_is_success'] = $_GET['is_success'];
         $data['ali_buyer_email'] = $_GET['buyer_email'];
         $data['ali_buyer_id'] = $_GET['buyer_id'];
         $data['handler'] = 0;
         //return_url
         $data['finish_time'] = time();
         // 检查交易是否存在领众数据库
         $auditRecord = M('audit_merchant_purchase')->where(array('trade_no' => $out_trade_no))->find();
         if ($auditRecord == false || empty($auditRecord['user_id'])) {
             Log::record("record the returned info:" . print_r($_GET, true));
             $this->error('非法操作!', U('User/Index/purchase'));
         }
         $merchantPackages = C('MERCHANT_PACKAGES');
         // 如果订单不处于 提交 状态,则忽略
         if ($auditRecord['status'] != 1) {
             Log::record('m_return_url conflict. uid:' . $uid . ' ' . $out_trade_no);
             Log::save();
             $this->redirect(U('User/Index/purchase'));
             exit;
         }
         if ($data['ali_trade_status'] == 'TRADE_FINISHED' || $data['ali_trade_status'] == 'TRADE_SUCCESS') {
             $data['status'] = 2;
             M('audit_merchant_purchase')->where(array('trade_no' => $out_trade_no))->save($data);
             // 验证该请求来自支付宝
             require_once COMMON_PATH . '/AlipayNotifyVerifyHelper.php';
             $verifyStatus = AlipayNotifyVerifyHelper::ali_notify_verify($alipayConfig['partner'], $data['ali_notify_id']);
             if ($verifyStatus == false) {
                 Log::record('m_return_url fail ali_notify_verify' . $out_trade_no, Log::ERR);
                 Log::save();
                 M('audit_merchant_purchase')->where(array('trade_no' => $out_trade_no))->setField('status', 4);
                 $this->error('套餐购买失败!如果您已支付成功,请联系客服为您处理!', U('User/Index/purchase'));
             }
             Log::record('m_return_url finish ali_notify_verify. status=>5 ' . $out_trade_no, Log::INFO);
             M('audit_merchant_purchase')->where(array('trade_no' => $out_trade_no))->setField('status', 5);
             //需根据套餐类型设置payload参数:功能套餐设置成天数,短信包设置为条数
             $package_type = $merchantPackages[$auditRecord['package_id']]['type'];
             switch ($package_type) {
                 case 1:
                     // 套餐处理
                     $fgListStr = $merchantPackages[$auditRecord['package_id']]['function_groups'];
                     $durationInSecs = $auditRecord['package_duration'] * 31 * 24 * 60 * 60;
                     Log::record('m_return_url start open fg ' . $fgListStr . ' for ' . $durationInSecs . ' secs ' . $out_trade_no, Log::INFO);
                     $codeFgIdList = explode(",", $fgListStr);
                     $websiteUserFuncManager = new WebsiteUserFuncManager($auditRecord['user_id']);
                     $websiteUserFuncManager->extendFuncGroups($codeFgIdList, $durationInSecs);
                     Log::record('m_return_url finish open fg ' . $out_trade_no, Log::INFO);
                     Log::save();
                     break;
                 case 2:
                     //短信包
                     $volume = $auditRecord['package_duration'];
                     Log::record('m_return_url start sms ' . $volume . ' ' . $out_trade_no, Log::INFO);
                     $websiteUserFuncManager = new WebsiteUserFuncManager($auditRecord['user_id']);
                     $websiteUserFuncManager->extendSmsAccount($volume);
                     Log::record('m_return_url finish sms ' . $out_trade_no, Log::INFO);
                     Log::save();
                     break;
             }
             $this->redirect(U('User/Index/purchase'));
         } else {
             Log::record('m_return_url fail to pay ' . $out_trade_no, Log::ERR);
             Log::save();
             $data['status'] = 3;
             //支付失败
             M('audit_merchant_purchase')->where(array('trade_no' => $out_trade_no))->save($data);
             $this->error('套餐购买失败!如果您已支付成功,请联系客服为您处理!', U('User/Index/purchase'));
         }
     } else {
         $out_trade_no = $_GET['out_trade_no'];
         Log::record('m_return_url verify fail. uid:' . session('uid') . ' ' . $out_trade_no, Log::ERR);
         Log::save();
         $this->error('套餐购买失败 ,请联系在线客服,为您处理', U('User/Index/purchase'));
     }
 }
Esempio n. 20
0
 * 该页面可在本机电脑测试
 * 可放入HTML等美化页面的代码、商户业务逻辑程序代码
 * 该页面可以使用PHP开发工具调试,也可以使用写文本函数logResult,该函数已被默认关闭,见alipay_notify_class.php中的函数verifyReturn
 */
require_once "alipay.config.php";
require_once "lib/alipay_notify.class.php";
include_once 'DB.php';
?>
<!DOCTYPE HTML>
<html>
    <head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<?php 
//计算得出通知验证结果
$alipayNotify = new AlipayNotify($alipay_config);
$verify_result = $alipayNotify->verifyReturn();
if ($verify_result) {
    //验证成功
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //请在这里加上商户的业务逻辑程序代码
    //——请根据您的业务逻辑来编写程序(以下代码仅作参考)——
    //获取支付宝的通知返回参数,可参考技术文档中页面跳转同步通知参数列表
    //商户订单号
    $out_trade_no = $_GET['out_trade_no'];
    //支付宝交易号
    $trade_no = $_GET['trade_no'];
    //交易状态
    $result = $_GET['result'];
    //判断该笔订单是否在商户网站中已经做过处理
    //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
    //如果有做过处理,不执行商户的业务程序
 public function back()
 {
     \Common\Lib\Utils::log('alipay', 'back.log', $_GET);
     $alipay_config = C('ALIPAY_CONFIG');
     //计算得出通知验证结果
     $alipayNotify = new \AlipayNotify($alipay_config);
     $verify_result = $alipayNotify->verifyReturn();
     if ($verify_result) {
         //验证成功
         //请在这里加上商户的业务逻辑程序代码
         //——请根据您的业务逻辑来编写程序(以下代码仅作参考)——
         //获取支付宝的通知返回参数,可参考技术文档中页面跳转同步通知参数列表
         //商户订单号
         $out_trade_no = \Common\Lib\Idhandler::decode($_GET['out_trade_no']);
         //支付宝交易号
         $trade_no = $_GET['trade_no'];
         //交易状态
         $trade_status = $_GET['trade_status'];
         \Common\Lib\Utils::log('trade', 'alipay.log', $_GET);
         if ($_GET['trade_status'] == 'TRADE_FINISHED' || $_GET['trade_status'] == 'TRADE_SUCCESS') {
             $tradeMdl = D('Trade');
             $params = array('id' => $out_trade_no, 'status' => 'success', 'pay_from' => 'taobao', 'pay_no' => $trade_no, 'paid_at' => time(), 'updated_at' => time());
             \Common\Lib\Utils::log('trade', 'alipay.log', $params);
             $res = $tradeMdl->saveData($params);
             \Common\Lib\Utils::log('trade', 'alipay.log', $res);
             if ($res['status'] == 'success') {
                 $trade = $tradeMdl->getRow(array('id' => $out_trade_no));
                 \Common\Lib\Utils::log('trade', 'alipay.log', $trade);
                 //更新用户的due_at
                 $level = $trade['level'];
                 switch ($level) {
                     case '1':
                         $due_at = time() + 5 * 86400;
                         break;
                     case '2':
                         $due_at = time() + 30 * 86400;
                         break;
                     default:
                         break;
                 }
                 $userMdl = D('User');
                 $uparams['id'] = $trade['user_id'];
                 $uparams['due_at'] = $due_at;
                 \Common\Lib\Utils::log('trade', 'alipay.log', $uparams);
                 $res = $userMdl->saveData($uparams);
                 \Common\Lib\Utils::log('trade', 'alipay.log', $res);
                 //更新有效商品的时间
                 $sql = "update items set due_at = {$due_at} where user_id = {$trade['user_id']} and due_at > " . time();
                 \Common\Lib\Utils::log('trade', 'alipay.log', $sql);
                 $res = $tradeMdl->execute($sql);
                 \Common\Lib\Utils::log('trade', 'alipay.log', $res);
                 echo "<script>localtion.href='/home/pay/success'</script>";
                 exit;
             }
             //判断该笔订单是否在商户网站中已经做过处理
             //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
             //如果有做过处理,不执行商户的业务程序
         } else {
             echo "trade_status=" . $_GET['trade_status'];
         }
         echo "验证成功<br />";
         //——请根据您的业务逻辑来编写程序(以上代码仅作参考)——
         /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     } else {
         //验证失败
         //如要调试,请看alipay_notify.php页面的verifyReturn函数
         echo "验证失败";
     }
     exit;
 }
Esempio n. 22
0
 /**
  * 响应操作
  */
 function respond()
 {
     if (!empty($_POST)) {
         foreach ($_POST as $key => $data) {
             $_GET[$key] = $data;
         }
     }
     $payment = get_payment("alipay");
     $payment = unserialize_config($payment['pay_config']);
     $alipay_config = array();
     $alipay_config['partner'] = $payment['alipay_partner'];
     //安全检验码,以数字和字母组成的32位字符
     //如果签名方式设置为“MD5”时,请设置该参数
     $alipay_config['key'] = $payment['alipay_key'];
     //商户的私钥(后缀是.pen)文件相对路径
     //如果签名方式设置为“0001”时,请设置该参数
     $alipay_config['private_key_path'] = '';
     //$alipay_config['private_key_path']	= 'key/rsa_private_key.pem';
     //支付宝公钥(后缀是.pen)文件相对路径
     //如果签名方式设置为“0001”时,请设置该参数
     $alipay_config['ali_public_key_path'] = '';
     //$alipay_config['ali_public_key_path']= 'key/alipay_public_key.pem';
     //签名方式 不需修改
     $alipay_config['sign_type'] = 'MD5';
     //字符编码格式 目前支持 gbk 或 utf-8
     $alipay_config['input_charset'] = 'utf-8';
     //$alipay_config['cacert']    = ROOT_PATH .'mobile/includes/modules/cacert.pem';
     $alipay_config['cacert'] = '';
     //ca证书路径地址,用于curl中ssl校验
     //请保证cacert.pem文件在当前文件夹目录中
     //$alipay_config['cacert']    = getcwd().'\\cacert.pem';
     //访问模式,根据自己的服务器是否支持ssl访问,若支持请选择https;若不支持请选择http
     $alipay_config['transport'] = 'http';
     require_once ROOT_PATH . "includes/modules/lib/alipay_notify.class.php";
     $alipayNotify = new AlipayNotify($alipay_config);
     $verify_result = $alipayNotify->verifyReturn();
     if ($verify_result) {
         $out_trade_no = trim($_GET['out_trade_no']);
         $order_sn = trim(substr($out_trade_no, 0, 13));
         $log_id = get_order_id_by_sn($order_sn);
         order_paid($log_id);
         //$sql = "SELECT l.`log_id` FROM " . $GLOBALS['hhs']->table('order_info')." as info LEFT JOIN ". $GLOBALS['hhs']->table('pay_log') ." as l  ON l.order_id=info.order_id        WHERE info.order_sn = '$order_sn'";
         //$order_log_id = $GLOBALS['db']->getOne($sql);
         return true;
     } else {
         return false;
     }
 }
Esempio n. 23
0
 public function return_url()
 {
     import("@.ORG.Alipay.AlipayNotify");
     $alipayNotify = new AlipayNotify($this->setconfig());
     $verify_result = $alipayNotify->verifyReturn();
     //if($verify_result) {
     $out_trade_no = $this->_get('out_trade_no');
     //支付宝交易号
     $trade_no = $this->_get('trade_no');
     //交易状态
     $trade_status = $this->_get('trade_status');
     if ($this->_get('trade_status') == 'TRADE_FINISHED' || $this->_get('trade_status') == 'TRADE_SUCCESS') {
         //after
         $payHandel = new payHandle($_GET['token'], $_GET['from']);
         $orderInfo = $payHandel->afterPay($out_trade_no);
         $from = $payHandel->getFrom();
         $this->redirect('/index.php?g=Wap&m=' . $from . '&a=payReturn&token=' . $orderInfo['token'] . '&wecha_id=' . $orderInfo['wecha_id'] . '&orderid=' . $out_trade_no);
     } else {
         exit('付款失败');
     }
     //}else {
     //exit('不存在的订单');
     //}
 }
Esempio n. 24
0
 public function call_back_url()
 {
     $call_back = array();
     $call_back['out_trade_no'] = $this->_get('out_trade_no');
     $call_back['request_token'] = $this->_get('request_token');
     $call_back['result'] = $this->_get('result');
     $call_back['trade_no'] = $this->_get('trade_no');
     $call_back['sign'] = $this->_get('sign');
     $call_back['sign_type'] = $this->_get('sign_type');
     $alipay_config = $this->alipay_config;
     $alipayNotify = new AlipayNotify($alipay_config);
     $verify_result = $alipayNotify->verifyReturn();
     $out_trade_no = $call_back['out_trade_no'];
     //商户订单号
     $trade_no = $call_back['trade_no'];
     //支付宝交易号
     $result = $call_back['result'];
     //交易状态
     $order_db = M('Product_cart');
     $order = $order_db->where('sn = ' . $out_trade_no)->find();
     $order_token = $order['token'];
     $order_wecha_id = $order['wecha_id'];
     $back_url = U('Product/my', array('token' => $order_token, 'wecha_id' => $order_wecha_id));
     if ($verify_result && $result == "success") {
         if (!$this->checkorderstatus($out_trade_no)) {
             $order['paid'] = 1;
             $order_db->where('sn = ' . $out_trade_no)->save($order);
         }
         $res = $order_db->where('sn = ' . $out_trade_no)->find();
         $pcl = M('Product_cart_list')->where(array('token' => $res['token'], 'cartid' => $res['id']))->find();
         $pro = M('Product')->where(array('token' => $res['token'], 'id' => $pcl['productid']))->find();
         $content = "支付成功!产品名称:" . $pro['name'] . ",订单编号:" . $res['id'] . ",SN编码:" . $res['sn'] . ",姓名:" . $res['truename'] . ",电话:" . $res['tel'] . ",地址:" . $res['address'];
         $smsmesg = $res['id'] . "号订单已支付成功!产品名称:" . $pro['name'] . ",姓名:" . $res['truename'] . ",电话:" . $res['tel'];
         //短信+邮件
         $info = M('Wxuser')->where(array('token' => $res['token']))->find();
         $user = $info['sms_plat_user'];
         $pass = md5($info['sms_plat_pass']);
         $phone = $info['sms_plat_reply'];
         $if_sms = $info['sms_plat_status'];
         $sms_pay_feed = $info['sms_plat_pay_feed'];
         $if_smtp = $info['smtp_plat_status'];
         $smtp_pay_feed = $info['smtp_plat_pay_feed'];
         if ($if_sms == 1 && $sms_pay_feed == 1) {
             if (!empty($smsmesg)) {
                 $this->sendSMS($user, $pass, $phone, $smsmesg);
             }
         }
         $to = $info['smtp_plat_reply'];
         $name = $info['wxname'];
         $subject = '订单已支付!';
         $body = $content;
         $attachment = NULL;
         $config['SMTP_HOST'] = $info['smtp_plat_host'];
         $config['SMTP_PORT'] = $info['smtp_plat_port'];
         $config['SMTP_USER'] = $info['smtp_plat_send'];
         $config['SMTP_PASS'] = $info['smtp_plat_pass'];
         $config['FROM_EMAIL'] = $info['smtp_plat_send'];
         $config['FROM_NAME'] = $info['wxname'];
         $config['REPLY_EMAIL'] = $info['smtp_plat_reply'];
         $config['REPLY_NAME'] = $info['wxname'];
         $ssl = $info['smtp_plat_ssl'];
         if ($if_smtp == 1 && $smtp_pay_feed == 1) {
             if (!empty($content)) {
                 $this->sendEMAIL($to, $name, $subject, $body, $attachment, $config, $ssl);
             }
         }
         $mce = M('Member_card_exchange')->where(array('token' => $res['token']))->find();
         $exp = round($res['price']);
         $row['token'] = $res['token'];
         $row['wecha_id'] = $res['wecha_id'];
         $row['sign_time'] = time();
         $row['is_sign'] = 0;
         $row['score_type'] = 2;
         $row['sell_expense'] = $res['price'];
         if ($exp > 0 && $res['is_reward'] == 0 && $res['paid'] == 1) {
             $row['expense'] = $exp * $mce['reward'];
         } else {
             $row['expense'] = 0;
         }
         if ($res['is_reward'] == 0 && $res['paid'] == 1) {
             $expback = M('Member_card_sign')->where(array('token' => $res['token'], 'wecha_id' => $res['wecha_id']))->add($row);
             if ($expback) {
                 $order['is_reward'] = 1;
                 $order_db->where('sn = ' . $out_trade_no)->save($order);
                 M('Userinfo')->where(array('token' => $res['token'], 'wecha_id' => $res['wecha_id']))->setInc('expend_score', $row['expense']);
                 M('Userinfo')->where(array('token' => $res['token'], 'wecha_id' => $res['wecha_id']))->setInc('total_score', $row['expense']);
                 $userinfo['add_expend_time'] = $row['sign_time'];
                 $userinfo['add_expend'] = $row['expense'];
                 M('Userinfo')->where(array('token' => $res['token'], 'wecha_id' => $res['wecha_id']))->save($userinfo);
             }
         }
         $this->success('支付成功', $back_url);
     } else {
         $this->error('支付失败', $back_url);
     }
 }
Esempio n. 25
0
 public function alipayreturn()
 {
     header("Content-Type:text/html; charset=utf-8");
     import('@.Plugin.Dswjcmsalipay.Alipay.Notify');
     $online = M('online');
     $list = $online->where('`id`=1')->find();
     $alipay_config['partner'] = $list['pid'];
     $alipay_config['key'] = $list['checking'];
     $alipay_config['sign_type'] = strtoupper('MD5');
     //签名方式 不需修改
     $alipay_config['input_charset'] = strtolower('utf-8');
     //字符编码格式 目前支持 gbk 或 utf-8
     $alipay_config['transport'] = 'http';
     //访问模式,根据自己的服务器是否支持ssl访问,若支持请选择https;若不支持请选择http
     $alipayNotify = new AlipayNotify($alipay_config);
     $verify_result = $alipayNotify->verifyReturn();
     //获取充值
     $recharge = M('recharge');
     $rechar = $recharge->where('nid=' . $this->_get('out_trade_no'))->find();
     if ($verify_result) {
         //验证成功
         $recharge->where('nid=' . $this->_get('out_trade_no'))->save(array('type' => 2, 'audittime' => time(), 'date' => json_encode($_GET), 'handlers' => '第三方支付'));
         //获取用户资金
         $money = M('money');
         $mon = $money->field('total_money,available_funds,freeze_funds')->where(array('uid' => $rechar['uid']))->find();
         $array['total_money'] = $mon['total_money'] + $rechar['account_money'];
         $array['available_funds'] = $mon['available_funds'] + $rechar['account_money'];
         //记录添加点
         $money->where(array('uid' => $rechar['uid']))->save($array);
         $this->silSingle(array('title' => '充值成功', 'sid' => $rechar['uid'], 'msg' => '充值成功,帐户增加' . $rechar['account_money'] . '元'));
         //站内信
         $this->moneyLog(array(0, '充值成功', $rechar['money'], '平台', $array['total_money'] + $rechar['poundage'], $array['available_funds'] + $rechar['poundage'], $mon['freeze_funds'], $rechar['uid']));
         //资金记录
         $this->moneyLog(array(0, '充值手续费扣除', $rechar['poundage'], '平台', $array['total_money'], $array['available_funds'], $mon['freeze_funds'], $rechar['uid']));
         //资金记录
         $this->userLog('充值成功');
         //会员操作
         $this->success('充值成功', '__ROOT__/Center/fund/injectrecord.html');
     } else {
         $recharge->where('nid=' . $billno)->save(array('type' => 3, 'audittime' => time(), 'date' => json_encode($_GET), 'handlers' => '第三方支付'));
         //充值失败
         //记录添加点
         $this->error('充值失败!', '__ROOT__/Center/fund/injectrecord.html');
     }
 }
Esempio n. 26
0
 /**
  * 验证返回信息
  */
 private function _verify($type, $payment_config)
 {
     if (empty($payment_config)) {
         return false;
     }
     $alipay_config = array('partner' => $payment_config['alipay_partner'], 'key' => $payment_config['alipay_key'], 'private_key_path' => 'key/rsa_private_key.pem', 'ali_public_key_path' => 'key/alipay_public_key.pem', 'sign_type' => 'MD5', 'input_charset' => 'utf-8', 'cacert' => getcwd() . '\\cacert.pem', 'transport' => 'http');
     require_once BASE_PATH . DS . 'api/payment/alipay/lib/alipay_notify.class.php';
     //计算得出通知验证结果
     $alipayNotify = new AlipayNotify($alipay_config);
     switch ($type) {
         case 'notify':
             $verify_result = $alipayNotify->verifyNotify();
             break;
         case 'return':
             $verify_result = $alipayNotify->verifyReturn();
             break;
         default:
             $verify_result = false;
             break;
     }
     return $verify_result;
 }
Esempio n. 27
0
 public function aliResult()
 {
     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->verifyReturn();
     if ($verify_result) {
         //验证成功
         /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
         //请在这里加上商户的业务逻辑程序代码
         //——请根据您的业务逻辑来编写程序(以下代码仅作参考)——
         //获取支付宝的通知返回参数,可参考技术文档中页面跳转同步通知参数列表
         //商户订单号
         $out_trade_no = $_GET['out_trade_no'];
         //支付宝交易号
         $trade_no = $_GET['trade_no'];
         //交易状态
         $result = $_GET['result'];
         //判断该笔订单是否在商户网站中已经做过处理
         //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
         //如果有做过处理,不执行商户的业务程序
         return "验证成功";
         //——请根据您的业务逻辑来编写程序(以上代码仅作参考)——
         /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     } else {
         //验证失败
         //如要调试,请看alipay_notify.php页面的verifyReturn函数
         return "验证失败";
     }
 }
Esempio n. 28
0
 /**
  * 验证通知结果
  *
  * @return bool|array
  */
 public function verifyReturn()
 {
     require_once LIB_PATH . "Com/payment/alipay_warrant/alipay_notify.class.php";
     $alipayNotify = new AlipayNotify($this->_aliapy_config);
     $verify_result = $alipayNotify->verifyReturn();
     if (!$verify_result) {
         return false;
     }
     $result = array('out_trade_no' => $_GET['out_trade_no'], 'trade_no' => $_GET['trade_no'], 'total_fee' => $_GET['price'], 'trade_status' => $_GET['trade_status']);
     return $result;
 }
Esempio n. 29
0
 function returnurl()
 {
     //头部的处理跟上面两个方法一样,这里不罗嗦了!
     $alipay_config = C('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'];
         //交易状态
         $total_fee = $_GET['total_fee'];
         //交易金额
         $notify_id = $_GET['notify_id'];
         //通知校验ID。
         $notify_time = $_GET['notify_time'];
         //通知的发送时间。
         $buyer_email = $_GET['buyer_email'];
         //买家支付宝帐号;
         $parameter = array("out_trade_no" => $out_trade_no, "trade_no" => $trade_no, "total_fee" => $total_fee, "trade_status" => $trade_status, "notify_id" => $notify_id, "notify_time" => $notify_time, "buyer_email" => $buyer_email);
         if ($_GET['trade_status'] == 'TRADE_FINISHED' || $_GET['trade_status'] == 'TRADE_SUCCESS') {
             if (!checkorderstatus($out_trade_no)) {
                 orderhandle($parameter);
                 //进行订单处理,并传送从支付宝返回的参数;
             }
             $this->redirect(C('alipay.successpage'));
             //跳转到配置项中配置的支付成功页面;
         } else {
             echo "trade_status=" . $_GET['trade_status'];
             $this->redirect(C('alipay.errorpage'));
             //跳转到配置项中配置的支付失败页面;
         }
     } else {
         //验证失败
         //如要调试,请看alipay_notify.php页面的verifyReturn函数
         echo "支付失败!";
     }
 }
Esempio n. 30
0
 /**
  * 手机支付宝异步响应操作
  */
 function respond($payment)
 {
     global $_CFG, $ecs, $db;
     require_once "alipaylib/alipay_notify.class.php";
     //file_put_contents(__DIR__ .'/respond.log', print_r($_REQUEST, true), FILE_APPEND);
     $is_sync = $payment['call_type'] == 'sync';
     $alipayNotify = new AlipayNotify($this->get_config($payment));
     $verify_result = $is_sync ? $alipayNotify->verifyReturn() : $alipayNotify->verifyNotify();
     if ($verify_result) {
         $tmp = explode('_', $_REQUEST['out_trade_no']);
         $order_sn = $tmp[0];
         $log_id = $tmp[1];
         $trade_no = $_REQUEST['trade_no'];
         //支付宝交易号
         $trade_status = $_REQUEST['trade_status'];
         //交易状态
         $order_url = $_CFG['site_url'] . "/user.php?act=order_detail&order_sn={$order_sn}";
         if ($trade_status == 'TRADE_FINISHED' || $trade_status == 'TRADE_SUCCESS') {
             // 支付成功
             if ($is_sync) {
                 //跳转到订单详情
                 show_message('支付完成', '查看订单', "javascript:top.location.href='{$order_url}'");
             } else {
                 //异步通知更新支付状态
                 order_paid($log_id, PS_PAYED, 'alipay_wap');
                 //更新pay_log的order_sn,退款时会用到
                 $sql = "UPDATE " . $ecs->table('pay_log') . " SET outer_sn = '{$trade_no}' WHERE log_id = '{$log_id}'";
                 $db->query($sql);
             }
         } elseif ($trade_status == 'TRADE_CLOSED') {
             $sql = 'UPDATE ' . $ecs->table('pay_log') . " SET is_paid = '4' WHERE log_id = '{$log_id}'";
             $db->query($sql);
         }
         //其他支付状态
         if ($is_sync) {
             echo "<html><script>top.location.href='{$order_url}';</sctipt></html>";
         } else {
             echo 'success';
         }
     } else {
         echo 'fail';
     }
     exit;
 }