Exemple #1
0
 /**
  * 第三方在线支付接口
  *
  */
 private function _api_pay($order_pay_info)
 {
     $inc_file = BASE_PATH . DS . 'api' . DS . 'payment' . DS . $this->payment_code . DS . $this->payment_code . '.php';
     if (!is_file($inc_file)) {
         output_error('支付接口不存在');
     }
     require $inc_file;
     $param = $this->payment_config;
     // wxpay_jsapi
     if ($this->payment_code == 'wxpay_jsapi') {
         $param['orderSn'] = $order_pay_info['pay_sn'];
         $param['orderFee'] = (int) (100 * $order_pay_info['api_pay_amount']);
         $param['orderInfo'] = C('site_name') . '商品订单' . $order_pay_info['pay_sn'];
         $param['orderAttach'] = $order_pay_info['order_type'] == 'real_order' ? 'r' : 'v';
         $api = new wxpay_jsapi();
         $api->setConfigs($param);
         try {
             echo $api->paymentHtml($this);
         } catch (Exception $ex) {
             if (C('debug')) {
                 header('Content-type: text/plain; charset=utf-8');
                 echo $ex, PHP_EOL;
             } else {
                 Tpl::output('msg', $ex->getMessage());
                 Tpl::showpage('payment_result');
             }
         }
         exit;
     }
     $param['order_sn'] = $order_pay_info['pay_sn'];
     $param['order_amount'] = $order_pay_info['api_pay_amount'];
     $param['order_type'] = $order_pay_info['order_type'] == 'real_order' ? 'r' : 'v';
     $payment_api = new $this->payment_code();
     $return = $payment_api->submit($param);
     echo $return;
     exit;
 }
 /**
  * 第三方在线支付接口
  *
  */
 private function _api_pay($order_pay_info, $payment_info)
 {
     $param = $payment_info['payment_config'];
     // wxpay_jsapi
     if ($payment_info['payment_code'] == 'wxpay_jsapi') {
         $param['orderSn'] = $order_pay_info['pay_sn'];
         $param['orderFee'] = (int) (100 * $order_pay_info['api_pay_amount']);
         $param['orderInfo'] = C('site_name') . $order_pay_info['subject'];
         $param['orderAttach'] = 'p';
         if ($_GET['from'] == 'mz') {
             $param['finishedUrl'] = 'http://mz.qinqin.net/trade/payment_pd_result.html?_=2&attach=_attach_';
             $param['undoneUrl'] = 'http://mz.qinqin.net/trade/payment_pd_result_failed.html?_=2&attach=_attach_';
         }
         $api = new wxpay_jsapi();
         $api->setConfigs($param);
         try {
             echo $api->paymentHtml($this);
         } catch (Exception $ex) {
             if (C('debug')) {
                 header('Content-type: text/plain; charset=utf-8');
                 echo $ex, PHP_EOL;
             } else {
                 Tpl::output('msg', $ex->getMessage());
                 Tpl::showpage('payment_result');
             }
         }
         exit;
     }
     $param['order_sn'] = $order_pay_info['pay_sn'];
     $param['order_amount'] = $order_pay_info['api_pay_amount'];
     $param['order_type'] = 'p';
     $payment_api = new $payment_info['payment_code']();
     $return = $payment_api->submit($param);
     echo $return;
     exit;
 }