예제 #1
0
 /**
  * App支付Notify
  */
 function alipay_notify_app()
 {
     $alipay_config_app = $this->config->item('alipay_config_app');
     $alipayNotify = new AlipayNotify($alipay_config_app);
     $verify_result = $alipayNotify->verifyNotify();
     if ($verify_result) {
         //验证成功
         $out_trade_no = $_POST['out_trade_no'];
         //支付宝交易号
         $trade_no = $_POST['trade_no'];
         //交易状态
         $trade_status = $_POST['trade_status'];
         $this->log_result('alipay_notify', "【支付宝回调App】:\n" . json_encode($_POST) . "\n");
         if ($trade_status == 'TRADE_FINISHED' || $trade_status == 'TRADE_SUCCESS') {
             //判断该笔订单是否在商户网站中已经做过处理
             //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
             //如果有做过处理,不执行商户的业务程序
             $order = $this->order_model->get_order_info($out_trade_no);
             if ($order['TradeStatus'] != 'TRADE_FINISHED' && $order['TradeStatus'] != 'TRADE_SUCCESS') {
                 $data = array('TradeStatus' => $trade_status, 'TradeNo' => $trade_no, 'PayTime' => time(), 'PayType' => 'alipay');
                 $this->order_model->update_order_info($out_trade_no, $data);
             }
         }
         //——请根据您的业务逻辑来编写程序(以上代码仅作参考)——
         echo "success";
         //请不要修改或删除
         /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     } else {
         //验证失败
         echo "fail";
         //调试用,写文本函数记录程序运行情况是否正常
         //logResult("这里写入想要调试的代码变量值,或其他运行的结果记录");
     }
 }
예제 #2
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;
        }
    }
예제 #3
0
 public function verifyReturn()
 {
     require_once "alipay.config.php";
     require_once "lib/alipay_notify.class.php";
     $alipayNotify = new \AlipayNotify($alipay_config);
     return $alipayNotify->verifyReturn();
 }
예제 #4
0
 public function ValidateNotification($txn_id = null)
 {
     parent::ValidateNotification($txn_id);
     $alipay_config = $this->_getConfig();
     $alipayNotify = new AlipayNotify($alipay_config);
     return $alipayNotify->getResponse($txn_id);
 }
예제 #5
0
 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]);
 }
예제 #6
0
 public function notify($req)
 {
     require_once __DIR__ . '/mobiAlipay/lib/alipay_notify.class.php';
     //计算得出通知验证结果
     $alipayNotify = new AlipayNotify($this->mobiAlipayConfig);
     $verifyResult = $alipayNotify->verifyNotify();
     if ($verifyResult) {
         //商户订单号
         $out_trade_no = $req['out_trade_no'];
         //支付宝交易号
         $trade_no = $req['trade_no'];
         //交易状态
         $trade_status = $req['trade_status'];
         if ($req['trade_status'] == 'TRADE_FINISHED' || $req['trade_status'] == 'TRADE_SUCCESS') {
             //处理订单状态
             $uid = (new \Mall\Mdu\OrderModule())->setOrderStatus($out_trade_no, $_SERVER['REQUEST_TIME']);
             if ($uid != 0) {
                 (new \Mall\Mdu\OrderLogsModule())->addOrderLogBySn($out_trade_no, $this->di['sysconfig']['orderActType']['successPayment'], $uid, '用户', '支付成功');
                 echo 'success';
             } else {
                 echo 'fail';
             }
         }
     } else {
         echo "fail";
     }
 }
예제 #7
0
 function notify()
 {
     //计算得出通知验证结果
     $alipayNotify = new AlipayNotify($this->alipay_config);
     $verify_result = $alipayNotify->verifyNotify();
     $this->log('deposit/notify ' . 'verify:' . ($verify_result ? 'true' : 'false') . ' ' . json_encode($_POST, JSON_UNESCAPED_UNICODE));
     if ($verify_result) {
         //验证成功
         //商户订单号
         $out_trade_no = $_POST['out_trade_no'];
         //支付宝交易号
         $trade_no = $_POST['trade_no'];
         //交易状态
         $trade_status = $_POST['trade_status'];
         $deposit_id = intval($out_trade_no);
         if (!$deposit_id) {
             echo "fail";
             return FALSE;
         }
         $record = DB::fetch_first('SELECT * FROM ' . DB::table('user_deposit') . ' WHERE ' . DB::implode(array('id' => $deposit_id)));
         if (!$record) {
             echo "fail";
             return FALSE;
         }
         if ($record['status'] == TRADE_FINISHED) {
             echo "success";
             return TRUE;
         }
         switch ($trade_status) {
             case 'WAIT_BUYER_PAY':
                 DB::update('user_deposit', array('trade_no' => $trade_no, 'status' => WAIT_BUYER_PAY, 'updatetime' => TIMESTAMP), array('id' => $deposit_id));
                 break;
             case 'TRADE_CLOSED':
                 DB::update('user_deposit', array('status' => TRADE_CLOSED, 'updatetime' => TIMESTAMP), array('id' => $deposit_id));
                 break;
             case 'WAIT_SELLER_SEND_GOODS':
                 $this->send_goods($record, $trade_no);
                 DB::update('user_deposit', array('status' => WAIT_BUYER_CONFIRM, 'updatetime' => TIMESTAMP), array('id' => $deposit_id));
                 break;
             case 'WAIT_BUYER_CONFIRM_GOODS':
                 DB::update('user_deposit', array('status' => WAIT_BUYER_CONFIRM, 'updatetime' => TIMESTAMP), array('id' => $deposit_id));
                 break;
             case 'TRADE_SUCCESS':
                 DB::update('user_deposit', array('status' => TRADE_UNSUPPORTED, 'updatetime' => TIMESTAMP), array('id' => $deposit_id));
                 break;
             case 'TRADE_FINISHED':
                 DB::update('user_deposit', array('status' => TRADE_FINISHED, 'updatetime' => TIMESTAMP), array('id' => $deposit_id));
                 if ($record && $record['uid']) {
                     DB::query('UPDATE ' . DB::table('user_status') . ' SET ' . DB::quote_field('balance') . ' = ' . DB::quote_field('balance') . ' + ' . $record['price'] . ' WHERE ' . DB::implode(array('uid' => $record['uid'])));
                 }
                 break;
         }
         $this->log('deposit/notify id:' . $deposit_id . ' ' . $trade_status);
         echo "success";
         return TRUE;
     } else {
         echo "fail";
         return FALSE;
     }
 }
예제 #8
0
 public function actionNotifyUrl()
 {
     //计算得出通知验证结果
     $alipayNotify = new \AlipayNotify($this->alipayConfig());
     $verify_result = $alipayNotify->verifyNotify();
     if ($verify_result) {
         //验证成功
         if ($_REQUEST['trade_status'] == 'TRADE_FINISHED') {
             //退款日期超过可退款期限后(如三个月可退款),支付宝系统发送该交易状态通知
             echo '退款';
         } else {
             if ($_REQUEST['trade_status'] == 'TRADE_SUCCESS') {
                 //付款完成后,支付宝系统发送该交易状态通知
                 if (ChargeOrder::getInstance()->setOrderStatus($_REQUEST['out_trade_no'])) {
                     // 设置订单状态
                     return $this->redirect('http://wechat.baihey.com/wap/site/main#/charge_order?orderId=' . $_REQUEST['out_trade_no'] . '&payType=4');
                 } else {
                     // 设置订单状态失败
                     return $this->redirect('http://wechat.baihey.com/wap/site/main#/charge_order?orderId=' . $_REQUEST['out_trade_no'] . '&payType=4');
                 }
             } else {
                 // 未付款
                 return $this->redirect('http://wechat.baihey.com/wap/site/main#/charge_order?orderId=' . $_REQUEST['out_trade_no'] . '&payType=4');
             }
         }
         echo "success";
         //请不要修改或删除
     } else {
         //验证失败
         echo "fail";
         return $this->redirect('http://wechat.baihey.com/wap/site/main#/charge_order?orderId=' . $_REQUEST['out_trade_no'] . '&payType=4');
     }
 }
예제 #9
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'));
     }
 }
예제 #10
0
 /**
  * 支付宝回调
  */
 public static function alipayNotify()
 {
     vendor('Alipay.Notify', COMMON_PATH . 'Vendor');
     $alipay_config = C('ALIPAY');
     $AlipayNotify = new \AlipayNotify($alipay_config);
     return $AlipayNotify->verifyNotify();
 }
예제 #11
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('不存在的订单');
     }
 }
예제 #12
0
function verifyAlipayNotify(array $alipayConfig)
{
    $alipayConfig = getAlipayConfig($alipayConfig);
    $alipayNotify = new AlipayNotify($alipayConfig);
    $verifyResult = (bool) $alipayNotify->verifyNotify();
    echo $verifyResult ? 'success' : 'fail';
    return $verifyResult;
}
예제 #13
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;
 }
예제 #14
0
파일: Alipay.php 프로젝트: pancke/yyaf
 /**
  * 支付宝回调
  * @param unknown $aParams
  * @return Ambigous <验证结果, boolean>
  */
 public static function callback($aParams)
 {
     require_once LIB_PATH . '/Payment/Alipay/alipay_service.class.php';
     require_once LIB_PATH . '/Payment/Alipay/alipay_notify.class.php';
     $alipay_config = Yaf_G::getConf('aliapy_config', null, 'alipay');
     $alipayNotify = new AlipayNotify($alipay_config);
     return $alipayNotify->verifyNotify($aParams);
 }
예제 #15
0
파일: AliTel.php 프로젝트: eappl/prototype
 function endPay($PassageInfo, $OrderInfo)
 {
     /* 商户号 */
     $partner = $PassageInfo['StagePartnerId'];
     /* 密钥 */
     $key = $PassageInfo['StageSecureCode'];
     require "AliPayClass/notify_url.php";
     //计算得出通知验证结果
     $alipayNotify = new AlipayNotify($aliapy_config);
     $verify_result = $alipayNotify->verifyNotify();
     if ($verify_result) {
         //验证成功
         /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
         //请在这里加上商户的业务逻辑程序代
         //——请根据您的业务逻辑来编写程序(以下代码仅作参考)——
         //获取支付宝的通知返回参数,可参考技术文档中服务器异步通知参数列表
         $out_trade_no = $_REQUEST['out_trade_no'];
         //获取订单号
         $trade_no = $_REQUEST['trade_no'];
         //获取支付宝交易号
         $total_fee = $_REQUEST['total_fee'];
         //获取总价格
         if ($OrderInfo['OrderId'] == $out_trade_no && $total_fee == $OrderInfo['Coin']) {
             $Pay['OrderId'] = $OrderInfo['OrderId'];
             $Pay['PayUserId'] = $OrderInfo['PayUserId'];
             $Pay['AcceptUserId'] = $OrderInfo['AcceptUserId'];
             $Pay['PassageId'] = $OrderInfo['PassageId'];
             $Pay['AppId'] = $OrderInfo['AppId'];
             $Pay['PartnerId'] = $OrderInfo['PartnerId'];
             $Pay['SubPassageId'] = $OrderInfo['SubPassageId'];
             $Pay['Amount'] = $OrderInfo['Amount'];
             $Pay['Coin'] = $OrderInfo['Coin'];
             $Pay['Credit'] = $OrderInfo['Credit'];
             $Pay['PayIP'] = $OrderInfo['PayIP'];
             $Pay['PayTime'] = $OrderInfo['PayTime'];
             $Pay['UserSourceId'] = $OrderInfo['UserSourceId'];
             $Pay['UserSourceDetail'] = $OrderInfo['UserSourceDetail'];
             $Pay['UserSourceProjectId'] = $OrderInfo['UserSourceProjectId'];
             $Pay['UserSourceActionId'] = $OrderInfo['UserSourceActionId'];
             $Pay['UserRegTime'] = $OrderInfo['UserRegTime'];
             $Pay['PayedTime'] = strtotime($_REQUEST['notify_time']);
             $Pay['StageOrder'] = $trade_no;
             $Pay['comment'] = json_encode(array('buyer_email' => $_REQUEST['buyer_email'], 'buyer_id' => $_REQUEST['buyer_id']));
             return $Pay;
         } else {
             return false;
         }
         //——请根据您的业务逻辑来编写程序(以上代码仅作参考)——
         echo "success";
         //请不要修改或删除
         /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     } else {
         //验证失败
         echo "fail";
         //调试用,写文本函数记录程序运行情况是否正常
         //logResult("这里写入想要调试的代码变量值,或其他运行的结果记录");
     }
 }
예제 #16
0
 /**
  * 验证支付宝的服务器返回
  *
  * @return boolen 返回验证状态, true代表合法请求,fasle代表无效返回
  */
 public function verifyReturn()
 {
     $notify = new \AlipayNotify($this->_config);
     if ($notify->verifyNotify()) {
         return true;
     } else {
         return false;
     }
 }
예제 #17
0
 public function alipay_notify($post)
 {
     require_once "lib/alipay_notify.class.php";
     $this->alipay_config['cacert'] = $this->cacert;
     $alipayNotify = new AlipayNotify($this->alipay_config);
     $verify_result = $alipayNotify->verifyNotify();
     if ($verify_result) {
         return $post['trade_status'];
     } else {
         return "error";
     }
 }
예제 #18
0
파일: alipay.php 프로젝트: onlineshine/myzf
 public function notifyVerify()
 {
     require_once "alipay/alipay_notify.class.php";
     $alipayNotify = new AlipayNotify($this->_config);
     $verify_result = $alipayNotify->verifyNotify();
     //验证
     if ($verify_result) {
         return $_POST;
     } else {
         return false;
     }
 }
예제 #19
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 "验证失败";
     }
 }
예제 #20
0
 public function verifyNotify()
 {
     $basePath = base_path();
     require_once $basePath . "/vendor/alipay/alipay.config.php";
     require_once $basePath . "/vendor/alipay/lib/alipay_notify.class.php";
     $alipayNotify = new AlipayNotify($alipay_config);
     $verify_result = $alipayNotify->verifyNotify();
     if (!$verify_result) {
         throw new Exception("支付宝验证失败", 9001);
     } else {
         return true;
     }
 }
예제 #21
0
 /**
  * 回调地址
  */
 public function callback()
 {
     require_once APP_PATH . "SDK/Payment/alipay_server/lib/alipay_notify.class.php";
     //计算得出通知验证结果
     $alipayNotify = new \AlipayNotify($this->alipay_config);
     $verify_result = $alipayNotify->verifyNotify();
     if ($verify_result) {
         //验证成功
         /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
         //请在这里加上商户的业务逻辑程序代
         //——请根据您的业务逻辑来编写程序(以下代码仅作参考)——
         //获取支付宝的通知返回参数,可参考技术文档中服务器异步通知参数列表
         //商户订单号
         $out_trade_no = $_POST['out_trade_no'];
         M('test')->where(array('order' => $out_trade_no))->save(array('content' => json_encode(I()), 'pay_time' => time()));
         //支付宝交易号
         $trade_no = $_POST['trade_no'];
         //交易状态
         $trade_status = $_POST['trade_status'];
         if ($_POST['trade_status'] == 'TRADE_FINISHED') {
             //判断该笔订单是否在商户网站中已经做过处理
             //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
             //如果有做过处理,不执行商户的业务程序
             //注意:
             //退款日期超过可退款期限后(如三个月可退款),支付宝系统发送该交易状态通知
             //请务必判断请求时的total_fee、seller_id与通知时获取的total_fee、seller_id为一致的
             //调试用,写文本函数记录程序运行情况是否正常
             //logResult("这里写入想要调试的代码变量值,或其他运行的结果记录");
         } else {
             if ($_POST['trade_status'] == 'TRADE_SUCCESS') {
                 //判断该笔订单是否在商户网站中已经做过处理
                 //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
                 //如果有做过处理,不执行商户的业务程序
                 //注意:
                 //付款完成后,支付宝系统发送该交易状态通知
                 //请务必判断请求时的total_fee、seller_id与通知时获取的total_fee、seller_id为一致的
                 //调试用,写文本函数记录程序运行情况是否正常
                 //logResult("这里写入想要调试的代码变量值,或其他运行的结果记录");
             }
         }
         //——请根据您的业务逻辑来编写程序(以上代码仅作参考)——
         echo "success";
         //请不要修改或删除
         /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     } else {
         //验证失败
         echo "fail";
         //调试用,写文本函数记录程序运行情况是否正常
         //logResult("这里写入想要调试的代码变量值,或其他运行的结果记录");
     }
 }
예제 #22
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 "验证失败";
     }
 }
예제 #23
0
 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;
 }
예제 #24
0
 function notifyurl()
 {
     /*                 
     同理去掉以下两句代码;                
     */
     //require_once("alipay.config.php");
     //require_once("lib/alipay_notify.class.php");
     //这里还是通过C函数来读取配置项,赋值给$alipay_config
     $alipay_config = C('alipay_config');
     //计算得出通知验证结果
     $alipayNotify = new AlipayNotify($alipay_config);
     $verify_result = $alipayNotify->verifyNotify();
     if ($verify_result) {
         //验证成功
         //获取支付宝的通知返回参数,可参考技术文档中服务器异步通知参数列表
         $out_trade_no = $_POST['out_trade_no'];
         //商户订单号
         $trade_no = $_POST['trade_no'];
         //支付宝交易号
         $trade_status = $_POST['trade_status'];
         //交易状态
         $total_fee = $_POST['total_fee'];
         //交易金额
         $notify_id = $_POST['notify_id'];
         //通知校验ID。
         $notify_time = $_POST['notify_time'];
         //通知的发送时间。格式为yyyy-MM-dd HH:mm:ss。
         $buyer_email = $_POST['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 ($_POST['trade_status'] == 'TRADE_FINISHED') {
             //
         } else {
             if ($_POST['trade_status'] == 'TRADE_SUCCESS') {
                 if (!checkorderstatus($out_trade_no)) {
                     orderhandle($parameter);
                     //进行订单处理,并传送从支付宝返回的参数;
                 }
             }
         }
         echo "success";
         //请不要修改或删除
     } else {
         //验证失败
         echo "fail";
     }
 }
 public function notify()
 {
     require_once './Application/Recharge/Lib/Alipay/alipay.config.php';
     require_once './Application/Recharge/Lib/Alipay/lib/alipay_notify.class.php';
     $alipayNotify = new \AlipayNotify($alipay_config);
     $verify_result = $alipayNotify->verifyNotify();
     if ($verify_result) {
         //验证成功
         $record['body'] = I('post.body', '未获取', 'op_t');
         $record['buyer_email'] = I('post.buyer_email', '未获取', 'op_t');
         $record['buyer_id'] = I('post.buyer_id', '未获取', 'op_t');
         $record['exterface'] = I('post.exterface', '未获取', 'op_t');
         $record['is_success'] = I('post.is_success', '未获取', 'op_t');
         $record['notify_id'] = I('post.notify_id', '未获取', 'op_t');
         $record['notify_time'] = I('post.notify_time', '0', 'strtotime');
         $record['notify_type'] = I('post.notify_type', '未获取', 'op_t');
         $record['out_trade_no'] = I('post.out_trade_no', '未获取', 'op_t');
         $record['payment_type'] = I('post.payment_type', '未获取', 'op_t');
         $record['seller_email'] = I('post.seller_email', '未获取', 'op_t');
         $record['seller_id'] = I('post.seller_id', '未获取', 'op_t');
         $record['subject'] = I('post.subject', '未获取', 'op_t');
         $record['total_fee'] = I('post.total_fee', '未获取', 'op_t');
         $record['trade_no'] = I('post.trade_no', '未获取', 'op_t');
         $record['trade_status'] = I('post.trade_status', '未获取', 'op_t');
         $record['sign'] = I('post.sign', '未获取', 'op_t');
         $record['sign_type'] = I('post.sign', '未获取', 'op_t');
         //商户订单号
         $order_id = $record['out_trade_no'];
         $alipayRecordModel = M('recharge_record_alipay');
         if (!($rs = $alipayRecordModel->add($record))) {
             return '失败——保存支付结果失败。请联系管理员。';
             /*                $this->error('保存支付结果失败。请联系管理员。');*/
         }
         $record['record_id'] = $rs;
         $link = M('order_link')->where(array('order_id' => $order_id))->find();
         $result = R(ucfirst($link['app']) . '/Pay/afterPayAlipay', array('record' => $record), 'Widget');
         if ($result) {
             M('order_link')->where(array('order_id' => $order_id))->setField('method', 'alipay');
             exit($result);
         } else {
             exit('error');
         }
     } else {
         exit('error');
     }
 }
예제 #26
0
파일: notice.php 프로젝트: renlong567/43168
 public function submit()
 {
     unset($_GET[$GLOBALS['app']->config['ctrl_id']], $_GET[$GLOBALS['app']->config['func_id']]);
     if ($_SESSION['user_id']) {
         unset($_GET['id']);
     } else {
         unset($_GET['sn'], $_GET['passwd']);
     }
     //合作身份者id,以2088开头的16位纯数字
     $alipay_config = array('partner' => $this->param['param']['pid'], 'key' => $this->param['param']['key']);
     $alipay_config['sign_type'] = 'MD5';
     $alipay_config['input_charset'] = 'utf-8';
     $alipay_config['cacert'] = $this->paydir . 'cacert.pem';
     $alipay_config['transport'] = 'http';
     $alipayNotify = new AlipayNotify($alipay_config);
     $verify_result = $alipayNotify->verify($_GET);
     if (!$verify_result) {
         error(P_Lang('订单验证不通过,请联系管理员确认'), $GLOBALS['app']->url, 'error');
     }
     //附款日期
     $pay_date = $GLOBALS['app']->get('notify_time');
     if ($pay_date) {
         $pay_date = strtotime($pay_date);
     }
     //附款金额,支付宝接口仅支持人民币
     $price = $GLOBALS['app']->get('total_fee', 'float');
     //更新订单信息
     $array = array('pay_status' => "付款完成", 'pay_date' => $pay_date, 'pay_price' => $price, 'pay_end' => 1);
     $array['status'] = '付款完成';
     //更新扩展数据
     $alipay = array();
     $alipay['buyer_email'] = $GLOBALS['app']->get('buyer_email');
     $alipay['buyer_id'] = $GLOBALS['app']->get('buyer_id');
     $alipay['time'] = $GLOBALS['app']->get('notify_time');
     $alipay['seller_email'] = $GLOBALS['app']->get('seller_email');
     $alipay['seller_id'] = $GLOBALS['app']->get('seller_id');
     $alipay['total_fee'] = $GLOBALS['app']->get('total_fee');
     $alipay['trade_no'] = $GLOBALS['app']->get('trade_no');
     $alipay['trade_status'] = $GLOBALS['app']->get('trade_status');
     $array['ext'] = serialize($alipay);
     $GLOBALS['app']->model('order')->save($array, $this->order['id']);
     return true;
 }
예제 #27
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);
    }
}
예제 #28
0
파일: notify.php 프로젝트: renlong567/43168
 public function submit()
 {
     unset($_GET[$GLOBALS['app']->config['ctrl_id']], $_GET[$GLOBALS['app']->config['func_id']], $_GET['sn']);
     $alipay_config = array('partner' => $this->param['param']['pid'], 'key' => $this->param['param']['key']);
     $alipay_config['sign_type'] = 'MD5';
     $alipay_config['input_charset'] = 'utf-8';
     $alipay_config['cacert'] = $this->paydir . 'cacert.pem';
     $alipay_config['transport'] = 'http';
     $alipayNotify = new AlipayNotify($alipay_config);
     $verify_result = $alipayNotify->verify($_GET);
     if (!$verify_result) {
         phpok_log(P_Lang('异步通知:支付宝验证不通过'));
         exit('fail');
     }
     //附款日期
     $pay_date = $GLOBALS['app']->get('notify_time');
     if ($pay_date) {
         $pay_date = strtotime($pay_date);
     }
     //附款金额,支付宝接口仅支持人民币
     $price = $GLOBALS['app']->get('total_fee', 'float');
     $trade_status = $GLOBALS['app']->get('trade_status');
     $tmp = array('WAIT_SELLER_SEND_GOODS', 'WAIT_BUYER_CONFIRM_GOODS', 'TRADE_FINISHED', 'TRADE_SUCCESS');
     if (in_array($trade_status, $tmp)) {
         $array = array('pay_status' => "付款完成", 'pay_date' => $pay_date, 'pay_price' => $price, 'pay_end' => 1);
         $array['status'] = '付款完成';
         //更新扩展数据
         $alipay = array();
         $alipay['buyer_email'] = $GLOBALS['app']->get('buyer_email');
         $alipay['buyer_id'] = $GLOBALS['app']->get('buyer_id');
         $alipay['time'] = $GLOBALS['app']->get('notify_time');
         $alipay['seller_email'] = $GLOBALS['app']->get('seller_email');
         $alipay['seller_id'] = $GLOBALS['app']->get('seller_id');
         $alipay['total_fee'] = $GLOBALS['app']->get('total_fee');
         $alipay['trade_no'] = $GLOBALS['app']->get('trade_no');
         $alipay['trade_status'] = $GLOBALS['app']->get('trade_status');
         $array['ext'] = serialize($alipay);
         $GLOBALS['app']->model('order')->save($array, $rs['id']);
     }
     exit('success');
 }
예제 #29
0
 public function notify()
 {
     require_once ROOT . "/libs/alipay_wap_lib/alipay_notify.class.php";
     $alipayNotify = new AlipayNotify($this->alipay_config);
     $verify_result = $alipayNotify->verifyNotify();
     $ret = array();
     if ($verify_result) {
         $out_trade_no = $_POST['out_trade_no'];
         $trade_no = $_POST['trade_no'];
         $trade_status = $_POST['trade_status'];
         if ($trade_status == 'TRADE_SUCCESS' || $trade_status == 'TRADE_FINISHED') {
             $ret["result"] = "SUCCESS";
             $ret["trade_no"] = $trade_no;
         } else {
             $ret["result"] = "FAIL";
         }
     } else {
         $ret["result"] = "FAIL";
     }
     return $ret;
 }
예제 #30
0
파일: alipay2.php 프로젝트: noikiy/meizhan
 /**
  * 获取notify信息
  */
 public function getNotifyInfo($payment_config)
 {
     $alipay_config['partner'] = $payment_config['alipay_partner'];
     $alipay_config['private_key_path'] = 'key/rsa_private_key.pem';
     $alipay_config['ali_public_key_path'] = 'key/alipay_public_key.pem';
     $alipay_config['sign_type'] = strtoupper('RSA');
     $alipay_config['input_charset'] = strtolower('utf-8');
     $alipay_config['cacert'] = getcwd() . '\\cacert.pem';
     $alipay_config['transport'] = 'http';
     require_once BASE_PATH . DS . 'api/payment/alipay2/lib/alipay_notify.class.php';
     //计算得出通知验证结果
     $alipayNotify = new AlipayNotify($alipay_config);
     $verify_result = $alipayNotify->verifyNotify();
     if ($verify_result) {
         //验证成功
         if ($_POST['trade_status'] == 'TRADE_FINISHED' || $_POST['trade_status'] == 'TRADE_SUCCESS') {
             return array('out_trade_no' => $_POST['out_trade_no'], 'trade_no' => $_POST['trade_no']);
         }
     }
     return false;
 }