コード例 #1
0
ファイル: submit.php プロジェクト: renlong567/43168
 function submit()
 {
     $notify_url = $this->baseurl . "payment/alipay/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']);
     }
     $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);
     $parameter = array("service" => $this->param['param']['ptype'], "partner" => trim($this->param['param']['pid']), "payment_type" => 1, "notify_url" => $notify_url, "return_url" => $return_url, "seller_email" => $this->param['param']['email'], "out_trade_no" => $this->order['sn'], "subject" => '订单号:' . $this->order['sn'], "body" => '订单号:' . $this->order['sn'], "show_url" => $show_url, "_input_charset" => 'utf-8');
     if ($this->param['param']['ptype'] != 'create_direct_pay_by_user') {
         $parameter['price'] = $total_fee;
         $parameter['quantity'] = '1';
         $parameter['logistics_fee'] = '0.00';
         $parameter['logistics_type'] = 'EXPRESS';
         $parameter['logistics_payment'] = 'SELLER_PAY';
         $address = $GLOBALS['app']->model('order')->address_shipping($this->order['id']);
         if (!$address) {
             $address = array('province' => '未知', 'city' => '未知', 'county' => '未知');
             $address['address'] = '未知';
             $address['mobile'] = '13000000000';
             $address['zipcode'] = '000000';
             $address['tel'] = '0000-00000000';
             $address['fullname'] = '未知';
         }
         $parameter['receive_name'] = $address['fullname'];
         $parameter['receive_address'] = $address['province'] . $address['city'] . $address['county'] . $address['address'];
         $parameter['receive_zip'] = $address['zipcode'];
         $parameter['receive_phone'] = $address['tel'];
         $parameter['receive_mobile'] = $address['mobile'];
     } else {
         $parameter['total_fee'] = $total_fee;
         $parameter['anti_phishing_key'] = '';
         $parameter['exter_invoke_ip'] = phpok_ip();
     }
     //合作身份者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';
     //建立请求
     $alipaySubmit = new AlipaySubmit($alipay_config);
     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 $alipaySubmit->buildRequestForm($parameter, "get", "确认");
     echo "\n" . '</body>' . "\n</html>";
     exit;
 }
コード例 #2
0
ファイル: cart_control.php プロジェクト: renlong567/43168
 public function checkout_f()
 {
     $rslist = $this->model('cart')->get_all($this->cart_id);
     if (!$rslist) {
         error(P_Lang('您的购物车里没有任何产品'), $this->url, "notice", 5);
     }
     //生成随机码,以确定客户通过正确途径下单
     $_SESSION['order_spam'] = str_rand(10);
     $totalprice = 0;
     foreach ($rslist as $key => $value) {
         $totalprice += price_format_val($value['price'] * $value['qty'], $value['currency_id'], $this->site['currency_id']);
     }
     $price = price_format($totalprice, $this->site['currency_id']);
     $this->assign('price', $price);
     $this->assign("rslist", $rslist);
     $shipping = $billing = array();
     if ($_SESSION['user_id']) {
         $shipping_list = $this->model('address')->address_list($_SESSION['user_id'], 'shipping');
         if ($shipping_list) {
             foreach ($shipping_list as $key => $value) {
                 if ($value['is_default']) {
                     $shipping = $value;
                 }
             }
             if (!$shipping) {
                 reset($shipping_list);
                 $shipping = current($shipping_list);
             }
         }
         if ($this->site['biz_billing']) {
             $billing_list = $this->model('address')->address_list($_SESSION['user_id'], 'billing');
             if ($billing_list) {
                 foreach ($billing_list as $key => $value) {
                     if ($value['is_default']) {
                         $billing = $value;
                     }
                 }
                 if (!$billing) {
                     reset($billing_list);
                     $billing = current($billing_list);
                 }
             }
         }
     } else {
         if ($_SESSION['address']['shipping']) {
             $shipping = $_SESSION['address']['shipping'];
         }
         if ($_SESSION['address']['billing']) {
             $billing = $_SESSION['address']['billing'];
         }
     }
     $this->assign('shipping', $shipping);
     $this->assign('billing', $billing);
     $this->view("cart_checkout");
 }
コード例 #3
0
ファイル: payment_control.php プロジェクト: renlong567/43168
 public function submit_f()
 {
     $chk = $this->auth_check();
     $rs = $chk['rs'];
     $error_url = $chk['error_url'];
     unset($chk);
     if ($rs['pay_end']) {
         error(P_Lang('该订单已结束,不能再执行付款操作'), $error_url, 'error');
     }
     $payment = $this->get('payment', 'int');
     if (!$payment) {
         error(P_Lang('未指定付款方式'), $error_url, "error");
     }
     $payment_rs = $this->model('payment')->get_one($payment);
     if (!$payment_rs) {
         error(P_Lang('支付方式不存在'), $error_url, 'error');
     }
     if (!$payment_rs['status']) {
         error(P_Lang('支付方式未启用'), $error_url, 'error');
     }
     //进入支付页
     $file = $this->dir_root . 'payment/' . $payment_rs['code'] . '/submit.php';
     if (!is_file($file)) {
         error(P_Lang('支付接口异常'), $error_url, 'error');
     }
     include_once $file;
     //更新定单支付信息
     $data = array('pay_id' => $payment_rs['id'], 'pay_title' => $payment_rs['title']);
     $data['pay_date'] = $this->time;
     $data['pay_status'] = '正在支付';
     $currency = $payment_rs['currency']['id'] ? $payment_rs['currency']['id'] : $rs['currency_id'];
     $price = price_format_val($rs['price'], $rs['currency_id'], $currency);
     $data['pay_price'] = $price;
     $data['pay_currency'] = $currency;
     if ($currency) {
         $currency_rs = $this->model('currency')->get_one($currency);
         $currency_code = $currency_rs['code'];
         $pay_currency_rate = $currency_rs['val'];
     } else {
         $currency_code = 'CNY';
         $currency_rate = '1.00000000';
     }
     $data['pay_currency_code'] = $currency_code;
     $data['pay_currency_rate'] = $pay_currency_rate;
     $data['pay_end'] = 0;
     $this->model('order')->save($data, $rs['id']);
     $name = $payment_rs['code'] . "_submit";
     $payment = new $name($rs, $payment_rs);
     $payment->submit();
 }
コード例 #4
0
ファイル: submit.php プロジェクト: renlong567/43168
 public function submit()
 {
     $notify_url = $this->baseurl . "payment/paypal/notify_url.php";
     if ($_SESSION['user_id']) {
         $return_url = $GLOBALS['app']->url('payment', 'notice', 'id=' . $this->order['id'], 'www', true);
         $cancel_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);
         $cancel_url = $GLOBALS['app']->url('order', 'info', 'sn=' . $this->order['sn'] . '&passwd=' . $this->order['passwd'], 'www', true);
     }
     $paypal = new paypal_payment($this->param['param']["payid"], $this->param['param']["at"]);
     $price = price_format_val($this->order['price'], $this->order['currency_id'], $this->param['currency']['id']);
     $paypal->set_value("amount", $price);
     $currency = $this->param['currency']['code'];
     $paypal->set_value("currency", $currency);
     $paypal->set_value("ordersn", $this->order["sn"]);
     $paypal->set_value("action_url", $this->param['param']["action"]);
     $paypal->set_value("return_url", $return_url);
     //成功返回
     $paypal->set_value("cancel_return", $cancel_url);
     //取消退出
     $paypal->set_value("notify_url", $notify_url);
     //订单成功后发送给网站的信息
     $htmlbutton = $paypal->create_button();
     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 '<div class="div"><p>正在跳转至Paypal,请稍候...</p><input type="button" value="提交" onclick="go_paypal()"/></div>' . "\n";
     echo '<div style="display:none">' . $htmlbutton . "</div>\n";
     echo '<script type="text/javascript">' . "\n";
     echo 'function go_paypal(){' . "\n";
     echo 'document.getElementById("paypalform").submit();' . "\n";
     echo 'return true;' . "\n";
     echo '}' . "\n";
     echo 'go_paypal();' . "\n";
     echo '</script>' . "\n";
     echo "\n" . '</body>' . "\n</html>";
     exit;
 }
コード例 #5
0
ファイル: submit.php プロジェクト: renlong567/43168
 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;
 }
コード例 #6
0
ファイル: submit.php プロジェクト: renlong567/43168
 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;
 }
コード例 #7
0
ファイル: order_control.php プロジェクト: renlong567/43168
 public function create_f()
 {
     $rslist = $this->model('cart')->get_all($this->cart_id);
     if (!$rslist) {
         $this->json(P_Lang("您的购物车里没有产品"));
     }
     $totalprice = 0;
     $qty = 0;
     foreach ($rslist as $key => $value) {
         $totalprice += price_format_val($value['price'] * $value['qty'], $value['currency_id'], $this->site['currency_id']);
         $qty += $value['qty'];
     }
     $shipping = $this->shipping();
     $billing = $this->billing();
     $sn = $this->create_sn();
     $array['sn'] = $sn;
     $array['user_id'] = $_SESSION['user_id'];
     $array['addtime'] = $this->time;
     $array['qty'] = $qty;
     $array['price'] = $totalprice;
     $array['currency_id'] = $this->site['currency_id'];
     $array['status'] = P_Lang('审核中');
     $array['passwd'] = md5(str_rand(10));
     $oid = $this->model('order')->save($array);
     if (!$oid) {
         $this->json(P_Lang('订单创建失败'));
     }
     foreach ($rslist as $key => $value) {
         $tmp = array('order_id' => $oid, 'tid' => $value['tid']);
         $tmp['title'] = $value['title'];
         $tmp['price'] = price_format_val($value['price'], $value['currency_id'], $this->site['currency_id']);
         $tmp['qty'] = $value['qty'];
         $tmp['thumb'] = $value['thumb'] ? $value['thumb']['id'] : 0;
         $tmp['ext'] = $value['ext'] ? serialize(unserialize($value['ext'])) : '';
         $this->model('order')->save_product($tmp);
     }
     if ($shipping) {
         $tmp = array('order_id' => $oid, 'type_id' => 'shipping');
         $tmp['country'] = $shipping['country'];
         $tmp['province'] = $shipping['province'];
         $tmp['city'] = $shipping['city'];
         $tmp['county'] = $shipping['county'];
         $tmp['address'] = $shipping['address'];
         $tmp['zipcode'] = $shipping['zipcode'];
         $tmp['mobile'] = $shipping['mobile'];
         $tmp['tel'] = $shipping['tel'];
         $tmp['email'] = $shipping['email'];
         $tmp['fullname'] = $shipping['fullname'];
         $tmp['gender'] = $shipping['gender'];
         $this->model('order')->save_address($tmp);
     }
     if ($billing) {
         $tmp = array('order_id' => $oid, 'type_id' => 'billing');
         $tmp['country'] = $billing['country'];
         $tmp['province'] = $billing['province'];
         $tmp['city'] = $billing['city'];
         $tmp['county'] = $billing['county'];
         $tmp['address'] = $billing['address'];
         $tmp['zipcode'] = $billing['zipcode'];
         $tmp['mobile'] = $billing['mobile'];
         $tmp['tel'] = $billing['tel'];
         $tmp['email'] = $billing['email'];
         $tmp['fullname'] = $billing['fullname'];
         $tmp['gender'] = $billing['gender'];
         $this->model('order')->save_address($tmp);
     }
     $this->model('cart')->delete($this->cart_id);
     $this->save_shipping($shipping);
     $this->save_billing($billing);
     $this->email_notice($array);
     $rs = array('sn' => $sn, 'passwd' => $array['passwd'], 'id' => $oid);
     $this->json($rs, true);
 }
コード例 #8
0
ファイル: order_control.php プロジェクト: renlong567/43168
 function product_f()
 {
     $id = $this->get('id', 'int');
     if (!$id) {
         $this->json(P_Lang('未指定产品ID'));
     }
     $rs = $this->model('list')->get_one($id);
     if (!$rs) {
         $this->json(P_Lang('产品信息不存在'));
     }
     $currency_id = $this->get("currency_id", 'int');
     $rs['price'] = price_format_val($rs['price'], $rs['currency_id'], $currency_id);
     $this->json($rs, true);
 }