Ejemplo n.º 1
0
 function submit()
 {
     $chinapay = new chinapay_lib();
     $debug = $this->payment['param']['env'] == 'start' ? false : true;
     $chinapay->set_debug($debug);
     $chinapay->set_pid($this->payment['param']['pid']);
     $chinapay->set_pri_key($this->payment['param']['prikey']);
     $chinapay->set_pub_key($this->payment['param']['pubkey']);
     $merid = $GLOBALS['app']->get('merid');
     $orderno = $GLOBALS['app']->get('orderno');
     $transdate = $GLOBALS['app']->get('transdate');
     $amount = $GLOBALS['app']->get('amount');
     $currencycode = $GLOBALS['app']->get('currencycode');
     $transtype = $GLOBALS['app']->get('transtype');
     $status = $GLOBALS['app']->get('status');
     $checkvalue = $GLOBALS['app']->get('checkvalue');
     $gateId = $GLOBALS['app']->get('gateId');
     $priv1 = $GLOBALS['app']->get('priv1');
     $opts = array('merid' => $merid, 'orderno' => $orderno, 'transdate' => $transdate, 'amount' => $amount);
     $opts['currencycode'] = $currencycode;
     $opts['transtype'] = $transtype;
     $opts['status'] = $status;
     $opts['checkvalue'] = $checkvalue;
     $opts['gateId'] = $gateId;
     $opts['priv1'] = $priv1;
     $verify = $chinapay->verify($opts);
     if (!$verify) {
         phpok_log('答名验证不通过');
         exit;
     }
     if ($status != '1001') {
         echo $status;
         exit;
     }
     $pay_date = $GLOBALS['app']->time;
     $price = $amount;
     //更新订单信息
     $array = array('pay_status' => "付款完成", 'pay_date' => $pay_date, 'pay_price' => $price, 'pay_end' => 1);
     $array['status'] = '付款完成';
     //更新扩展数据
     $tmp2 = array();
     $tmp2['orderno'] = $orderno;
     $tmp2['status'] = $status;
     $tmp2['amount'] = $amount;
     $array['ext'] = serialize($tmp2);
     $GLOBALS['app']->model('order')->save($array, $this->order['id']);
     exit('success');
 }
Ejemplo n.º 2
0
 function submit()
 {
     $notify_url = $this->baseurl . "payment/chinpay/notify_url.php";
     if ($_SESSION['user_id']) {
         $return_url = $GLOBALS['app']->url('payment', 'notice', 'id=' . $this->order['id'], 'www', true);
         $show_url = $GLOBALS['app']->url('order', 'info', 'id=' . $this->order['id'], 'www', true);
     } else {
         $return_url = $GLOBALS['app']->url('payment', 'notice', 'sn=' . $this->order['sn'] . '&passwd=' . $this->order['passwd'], 'www', true);
         $show_url = $GLOBALS['app']->url('order', 'info', 'sn=' . $this->order['sn'] . '&passwd=' . $this->order['passwd']);
     }
     $return_url = api_url('payment', 'notice', 'id=' . $this->order['id'], true);
     $currency_id = $this->param['currency'] ? $this->param['currency']['id'] : $this->order['currency_id'];
     $total_fee = price_format_val($this->order['price'], $this->order['currency_id'], $currency_id);
     $debug = $this->param['param']['env'] == 'start' ? false : true;
     $chinapay = new chinapay_lib($this->dir_root);
     $chinapay->set_debug($debug);
     $chinapay->set_pid($this->param['param']['pid']);
     $chinapay->set_pri_key($this->param['param']['prikey']);
     $chinapay->set_pub_key($this->param['param']['pubkey']);
     $chinapay->set_orderid($this->order['id']);
     $options = array('notify_url' => $notify_url, 'return_url' => $return_url, 'bankid' => $bankid, 'price' => $total_fee);
     $options['show_url'] = $show_url;
     $options['currency'] = $this->param['currency']['code'];
     $options['date'] = date("Ymd", $GLOBALS['app']->time);
     $options['passwd'] = $this->order['sn'];
     $chinapay->set_options($options);
     $info = $chinapay->action_form('paymentsubmit');
     if (!$info) {
         error(P_Lang('银行支付接口异常,数据未正常配置'), '', 'error');
     }
     //建立请求
     echo '<!DOCTYPE html>' . "\n";
     echo '<html>' . "\n";
     echo '<head>' . "\n\t";
     echo '<meta charset="utf-8" />' . "\n\t";
     echo '<title>付款中</title>' . "\n";
     echo '</head>' . "\n<body>\n";
     echo $info;
     echo '<script type="text/javascript">document.getElementById("paymentsubmit").submit()</script>';
     echo "\n" . '</body>' . "\n</html>";
     exit;
 }