Example #1
0
 function submit()
 {
     $tenpay = new tenpay_lib();
     $tenpay->set_key($this->payment['param']['key']);
     $array = array($GLOBALS['app']->config['ctrl_id'], $GLOBALS['app']->config['func_id'], 'sign', 'id');
     $trade_mode = $GLOBALS['app']->get('trade_mode', 'int');
     $trade_status = $GLOBALS['app']->get('trade_state', 'int');
     //检测为fail的几种情况
     if ($trade_mode != '1' && $trade_mode != '2') {
         error('订单错误:参数传递错误!', '', 'error');
     }
     if ($trade_mode == '1') {
         if ($trade_status != '0') {
             error('订单错误:付款失败!', '', 'error');
         }
     }
     $attach = $GLOBALS['app']->get('attach');
     if ($this->order['passwd'] != $attach) {
         error('您没有权限查看此订单信息', '', 'error');
     }
     //回调验证不成功时,直接中止
     if (!$tenpay->check_sign($array)) {
         error('验证不通过,请检查', '', 'error');
     }
     if ($GLOBALS['app']->get('retcode', 'int') != '0') {
         error('付款失败,请检查', '', 'error');
     }
     $pay_date = $tenpay->get_date();
     if ($pay_date) {
         $pay_date = strtotime($pay_date);
     }
     $price = round($tenpay->param('total_fee') / 100, 2);
     //更新订单信息
     $array = array('pay_status' => "已付款", 'pay_date' => $pay_date, 'pay_price' => $price, 'pay_end' => 1);
     $array['status'] = "付款完成";
     //更新扩展数据
     $info = array();
     $info['fee_type'] = $tenpay->param('fee_type');
     $info['notify_id'] = $tenpay->param('notify_id');
     $info['time_end'] = $tenpay->param('time_end');
     $info['total_fee'] = $tenpay->param('total_fee');
     $info['transaction_id'] = $tenpay->param('transaction_id');
     $array['ext'] = serialize($info);
     $GLOBALS['app']->model('order')->save($array, $this->order['id']);
     return true;
 }
Example #2
0
 function submit()
 {
     $tenpay = new tenpay_lib();
     $tenpay->set_key($this->payment['param']['key']);
     //签名验证
     //设置不包含的参数
     $array = array($GLOBALS['app']->config['ctrl_id'], $GLOBALS['app']->config['func_id'], 'sign', 'sn');
     $trade_mode = $GLOBALS['app']->get('trade_mode', 'int');
     $trade_status = $GLOBALS['app']->get('trade_state', 'int');
     //检测为fail的几种情况
     if ($trade_mode != '1' && $trade_mode != '2') {
         phpok_log('支付模式不符合要求');
         exit('fail');
     }
     if ($trade_mode == '1') {
         if ($trade_status != '0') {
             phpok_log('订单失败');
             exit('fail');
         }
     }
     $attach = $GLOBALS['app']->get('attach');
     //密码不一致时,返回错误
     if ($this->order['passwd'] != $attach || !$attach) {
         phpok_log('订单密码验证不通过');
         exit('fail');
     }
     //初始化内容参数
     $tenpay->param_clear();
     $notify_id = $GLOBALS['app']->get('notify_id');
     //通过通知ID查询,确保通知来至财付通
     $tenpay->set_url('https://gw.tenpay.com/gateway/simpleverifynotifyid.xml');
     $tenpay->param('partner', $this->payment['param']['pid']);
     $tenpay->param('notify_id', $notify_id);
     $tenpay->set_key($this->payment['param']['key']);
     $url = $tenpay->url();
     $call = $tenpay->call($url);
     //请求数据失败
     if (!$call) {
         phpok_log('财付通请求不成功,请检查');
         exit('fail');
     }
     $tenpay->param_clear();
     $tenpay->set_key($this->payment['param']['key']);
     $tenpay->set_xml_content();
     //取得订单通知
     if (!$tenpay->check_sign($array)) {
         phpok_log('验证不通过,请检查');
         exit('fail');
     }
     if ($tenpay->param('retcode') == '0') {
         $pay_date = $tenpay->get_date();
         $pay_date = $pay_date ? strtotime($pay_date) : $GLOBALS['app']->time;
         $price = round($tenpay->param('total_fee') / 100, 2);
         //更新订单信息
         $array = array('pay_status' => "付款完成", 'pay_date' => $pay_date, 'pay_price' => $price, 'pay_end' => 1);
         $array['status'] = '付款完成';
         //更新扩展数据
         $tenpay = array();
         $tenpay['fee_type'] = $tenpay->param('fee_type');
         $tenpay['notify_id'] = $tenpay->param('notify_id');
         $tenpay['time_end'] = $tenpay->param('time_end');
         $tenpay['total_fee'] = $tenpay->param('total_fee');
         $tenpay['transaction_id'] = $tenpay->param('transaction_id');
         $array['ext'] = serialize($tenpay);
         $GLOBALS['app']->model('order')->save($array, $this->order['id']);
         exit('success');
     }
     exit('success');
 }
Example #3
0
 function submit()
 {
     $tenpay = new tenpay_lib();
     $tenpay->set_key($this->param['param']['key']);
     $tenpay->set_biz($this->param['param']['pid']);
     $tenpay->set_email($this->param['param']['email']);
     $tenpay->set_url('https://gw.tenpay.com/gateway/pay.htm');
     $notify_url = $this->baseurl . "payment/tenpay/notify_url.php";
     //同步通知网址
     if ($_SESSION['user_id']) {
         $return_url = $GLOBALS['app']->url('payment', 'notice', 'id=' . $this->order['id'], 'www', true);
     } else {
         $return_url = $GLOBALS['app']->url('payment', 'notice', 'sn=' . $this->order['sn'] . '&passwd=' . $this->order['passwd'], 'www', true);
     }
     $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);
     /************************************************************/
     //商户编号
     $desc = 'SN:' . $this->order['sn'];
     $tenpay->param('partner', $this->param['param']['pid']);
     $tenpay->param("out_trade_no", $this->order['sn']);
     $tenpay->param("total_fee", $total_fee * 100);
     //总金额
     $tenpay->param("return_url", $return_url);
     $tenpay->param("notify_url", $notify_url);
     $tenpay->param("body", $desc);
     //银行类型
     if ($this->param['param']['bank']) {
         $tenpay->param("bank_type", trim(strtoupper($this->param['param']['bank'])));
     } else {
         $tenpay->param("bank_type", "DEFAULT");
     }
     //用户ip
     $tenpay->param("spbill_create_ip", $GLOBALS['app']->lib('common')->ip());
     //客户端IP
     $tenpay->param("fee_type", "1");
     //币种
     $tenpay->param("subject", $desc);
     //商品名称,(中介交易时必填)
     //系统可选参数
     $tenpay->param("sign_type", "MD5");
     //签名方式,默认为MD5,可选RSA
     $tenpay->param("service_version", "1.0");
     //接口版本号
     $tenpay->param("input_charset", "utf-8");
     //字符集
     $tenpay->param("sign_key_index", "1");
     //密钥序号
     //业务可选参数
     $ptype = $this->param['param']['ptype'] == 'create_direct_pay_by_user' ? 1 : 2;
     $tenpay->param("attach", $this->order['passwd']);
     //附件数据,原样返回就可以了
     $tenpay->param("product_fee", "");
     //商品手续费用
     $tenpay->param("transport_fee", "0");
     //物流费用
     $tenpay->param("time_start", date("YmdHis", $this->time));
     //订单生成时间
     $tenpay->param("time_expire", "");
     //订单失效时间
     $tenpay->param("buyer_id", "");
     //买方财付通帐号
     $tenpay->param("goods_tag", "");
     //商品标记
     $tenpay->param("trade_mode", $ptype);
     //交易模式(1.即时到帐模式,2.中介担保模式,3.后台选择(卖家进入支付中心列表选择))
     $tenpay->param("transport_desc", "");
     //物流说明
     $tenpay->param("trans_type", "1");
     //交易类型
     $tenpay->param("agentid", "");
     //平台ID
     $tenpay->param("agent_type", 0);
     //代理模式(0.无代理,1.表示卡易售模式,2.表示网店模式)
     $tenpay->param("seller_id", "");
     //卖家的商户号
     $url = $tenpay->url();
     header("Location:" . $url);
     exit;
 }