Example #1
0
 /**
  * @brief 【重要】支付回调[异步]
  */
 function server_callback()
 {
     //从URL中获取支付方式
     $payment_id = IFilter::act(IReq::get('_id'), 'int');
     $paymentInstance = Payment::createPaymentInstance($payment_id);
     if (!is_object($paymentInstance)) {
         die('fail');
     }
     //初始化参数
     $money = '';
     $message = '支付失败';
     $orderNo = '';
     //执行接口回调函数
     $callbackData = array_merge($_POST, $_GET);
     unset($callbackData['controller']);
     unset($callbackData['action']);
     unset($callbackData['_id']);
     $return = $paymentInstance->callback($callbackData, $payment_id, $money, $message, $orderNo);
     //支付成功
     if ($return == 1) {
         //充值方式
         if (stripos($orderNo, 'recharge_') !== false) {
             $tradenoArray = explode('_', $orderNo);
             $recharge_no = isset($tradenoArray[1]) ? $tradenoArray[1] : 0;
             if (payment::updateRecharge($recharge_no)) {
                 $paymentInstance->notifyStop();
                 exit;
             }
         } else {
             $order_id = Order_Class::updateOrderStatus($orderNo);
             if ($order_id) {
                 $paymentInstance->notifyStop();
                 exit;
             }
         }
     } else {
         $paymentInstance->notifyStop();
         exit;
     }
 }
Example #2
0
 function server_callback()
 {
     $payment_name = is_array($payment_name = IReq::get('payment_name')) ? IFilter::act($payment_name[0]) : IFilter::act(IReq::get('payment_name'));
     //初始化参数
     $money = null;
     $message = null;
     $tradeno = null;
     //获取支付payment的id值
     $pObj = new IModel('payment as a,pay_plugin as b');
     $paymentRow = $pObj->getObj('b.file_path = "' . $payment_name . '" and a.plugin_id = b.id', 'a.id');
     //载入支付接口文件
     $paymentObj = new Payment();
     $payObj = $paymentObj->loadMethod($payment_name);
     if (!is_object($payObj)) {
         echo 'fail';
         exit;
     }
     //执行接口回调函数
     $return = $payObj->serverCallback(array_merge($_POST, $_GET), $paymentRow['id'], $money, $message, $tradeno);
     //判断返回状态
     if ($return == 1) {
         if (stripos($tradeno, 'recharge_') !== false) {
             $tradenoArray = explode('_', $tradeno);
             $recharge_no = isset($tradenoArray[1]) ? $tradenoArray[1] : 0;
             if (payment::updateRecharge($recharge_no)) {
                 echo 'success';
                 exit;
             } else {
                 echo 'fail';
             }
         } else {
             if (payment::updateOrder($tradeno)) {
                 echo 'success';
                 exit;
             } else {
                 echo 'fail';
             }
         }
     } else {
         echo 'fail';
     }
 }
Example #3
0
 /**
  * @brief 【重要】支付回调[异步]
  */
 function server_callback()
 {
     //从URL中获取支付方式
     $payment_id = IFilter::act(IReq::get('_id'), 'int');
     $paymentInstance = Payment::createPaymentInstance($payment_id);
     if (!is_object($paymentInstance)) {
         die('fail');
     }
     //初始化参数
     $money = '';
     $message = '支付失败';
     $orderNo = '';
     //执行接口回调函数
     $callbackData = array_merge($_POST, $_GET);
     unset($callbackData['controller']);
     unset($callbackData['action']);
     unset($callbackData['_id']);
     $return = $paymentInstance->serverCallback($callbackData, $payment_id, $money, $message, $orderNo);
     //支付成功
     if ($return == 1) {
         //充值方式
         if (stripos($orderNo, 'recharge') !== false) {
             $tradenoArray = explode('recharge', $orderNo);
             $recharge_no = isset($tradenoArray[1]) ? $tradenoArray[1] : 0;
             if (payment::updateRecharge($recharge_no)) {
                 $paymentInstance->notifyStop();
                 exit;
             }
         } else {
             //读取批量订单付款
             $cacheObj = new ICache('file');
             $moreOrder = $cacheObj->get($orderNo);
             $moreOrder = $moreOrder ? explode(",", $moreOrder) : array($orderNo);
             foreach ($moreOrder as $key => $item) {
                 $order_id = Order_Class::updateOrderStatus($item);
                 if (!$order_id) {
                     throw new IException("异步支付回调修改状态错误,订单ID:" . $order_id);
                 }
             }
             $paymentInstance->notifyStop();
             exit;
         }
     } else {
         $paymentInstance->notifyStop();
         exit;
     }
 }