Exemple #1
0
 /**
  * 生成预存款支付代码
  */
 function get_predeposit_pay_code($order_info, $pay_info)
 {
     /***设置支付宝config Start*****/
     $payment_config = unserialize($pay_info['payment_config']);
     $alipay_account = $payment_config['alipay_account'];
     //支付宝账户
     $alipay_partner = $payment_config['alipay_partner'];
     //开发者ID
     $alipay_key = $payment_config['alipay_key'];
     //开发者key
     $alipay_pay_method = $payment_config['alipay_pay_method'];
     //接口模式
     $alipay_config['partner'] = $alipay_partner;
     $alipay_config['key'] = $alipay_key;
     $alipay_config['sign_type'] = strtoupper('MD5');
     $alipay_config['input_charset'] = strtolower('utf-8');
     $alipay_config['cacert'] = FCPATH . "libs\\wmlibs\\libraries\\payment\\cacert.pem";
     $alipay_config['transport'] = 'http';
     /***设置支付宝config End*****/
     //支付类型
     $payment_type = "1";
     //1代表商品购买
     $notify_url = base_url() . "predeposit/alipay_notify_url.php";
     $return_url = base_url() . "predeposit/alipay_return_url.php";
     $seller_email = $alipay_account;
     $out_trade_no = $order_info['pdr_sn'];
     $subject = '预存款充值订单' . $out_trade_no;
     $price = $order_info['pdr_price'];
     $show_url = base_url() . "index.php?m=member&c=predeposit&a=recharge_list";
     //建立请求
     $alipaySubmit = new AlipaySubmit($alipay_config);
     if ($alipay_pay_method == 3) {
         //即时到帐接口
         //防钓鱼时间戳
         $anti_phishing_key = $alipaySubmit->query_timestamp_pay_by();
         //客户端的IP地址
         $exter_invoke_ip = ip();
         //构造要请求的参数数组,无需改动
         $parameter = array("service" => "create_direct_pay_by_user", "partner" => trim($alipay_config['partner']), "payment_type" => $payment_type, "notify_url" => $notify_url, "return_url" => $return_url, "seller_email" => $seller_email, "out_trade_no" => $out_trade_no, "subject" => $subject, "total_fee" => $price, "body" => '', "show_url" => $show_url, "anti_phishing_key" => $anti_phishing_key, "exter_invoke_ip" => $exter_invoke_ip, "_input_charset" => trim(strtolower($alipay_config['input_charset'])));
         $html_text = $alipaySubmit->buildRequestButton($parameter, "get", "确认支付");
     } else {
         $html_text = '网站不支持支付宝预存款,请选择其他充值方式或联系网站管理员!';
     }
     return $html_text;
 }