给系统(只适合版本6.0)增加支付宝花呗分期,系统原本是没有支付宝花呗分期
1、先在met_pay_config表中,增加支付宝花呗分期参数,17=支付宝花呗分期
2、在系统中,浏览器在手机状态下增加京东支付
路径:\app\system\pay\web\include\class interface_pay.class.php
//支付宝 花呗分期
if(strstr($payment_type['value'], '17')){
$return['alipay_hb']['have'] = 1;
$return['alipay_hb']['url'] = $url.'17';
}
public function get_pay_list() {
global $_M;
$return = array();
$query = "SELECT * FROM {$_M['table'][pay_config]} WHERE name='payment_type' and lang='{$_M['lang']}'";
$payment_type = DB::get_one($query);
$list = explode('|', $payment_type['value']);
$url = "{$_M['url']['site']}pay/app.php?paytype=";
if($this->is_weixin()){//微信端
if(strstr($payment_type['value'], '6')){
$openId = $this->weixinopenId();
$return['weixin_h5']['have'] = 1;
//var_dump($return['weixin_h5']['have']);
$return['weixin_h5']['url'] = $url.'6';
$return['weixin_h5']['check_url'] = "{$_M['url']['site']}pay/orderquery.php?paytype=1&out_trade_no=";
}
//var_dump($url);
// if(strstr($payment_type['value'], '3')){
// $return['alipay']['have'] = 1;
// $return['alipay']['url'] = $url.'3';
// }
}else if($this->is_mobile()){//是移动端,就出现下面这些支付方式1
if(strstr($payment_type['value'], '3')){
$return['alipay']['have'] = 1;
$return['alipay']['url'] = $url.'3';
}
if(strstr($payment_type['value'], '5')){
$return['paypal']['have'] = 1;
$return['paypal']['url'] = $url.'5';
}
if(strstr($payment_type['value'], '4')){
$return['upay']['have'] = 1;
$return['upay']['url'] = $url.'4';
}
if(strstr($payment_type['value'], '7')){//京东支付
$return['jd']['have'] = 1;
$return['jd']['url'] = $url.'7';
}
// if(strstr($payment_type['value'], '6')){//微信公众号支付
// //$openId = $this->weixinopenId();
// $return['weixin_h5']['have'] = 1;
// $return['weixin_h5']['url'] = $url.'6';
// $return['weixin_h5']['check_url'] = "{$_M['url']['site']}pay/orderquery.php?paytype=1&out_trade_no=";
// }
if(strstr($payment_type['value'], '9')){//微信H5支付
//$out_trade_no=date('YmdHis').rand(1, 100000);
$return['weixin_jspay']['have'] = 1;
$return['weixin_jspay']['url'] = $url.'9';
//$return['weixin_jspay']['check_url'] = "{$_M['url']['site']}pay/orderquery.php?paytype=9&out_trade_no=";
}
}else{//其它端,比如PC
if(strstr($payment_type['value'], '1')){
$return['weixin']['have'] = 1;
$return['weixin']['url'] = $url.'1';
$return['weixin']['check_url'] = "{$_M['url']['site']}pay/orderquery.php?paytype=1&out_trade_no=";
}
if(strstr($payment_type['value'], '2')){
$return['tenpay']['have'] = 1;
$return['tenpay']['url'] = $url.'2';
}
if(strstr($payment_type['value'], '3')){
$return['alipay']['have'] = 1;
$return['alipay']['url'] = $url.'3';
}
//支付宝 花呗分期
if(strstr($payment_type['value'], '17')){
$return['alipay_hb']['have'] = 1;
$return['alipay_hb']['url'] = $url.'17';
}
if(strstr($payment_type['value'], '5')){
$return['paypal']['have'] = 1;
$return['paypal']['url'] = $url.'5';
}
if(strstr($payment_type['value'], '4')){
$return['upay']['have'] = 1;
$return['upay']['url'] = $url.'4';
}
if(strstr($payment_type['value'], '7')){
$return['jd']['have'] = 1;
$return['jd']['url'] = $url.'7';
}
}
return $return;
}
3、在前端模块中增加京东支付链接
\app\app\shop\web\templates\met shop_pay_order.php
<!--
EOT;
}
if($pay_list['alipay_hb']){
$price=substr($order[tprice_str], 0, -3);
//$url1=$pay_list['alipay_hb']['url'];
//$url2 = explode('?',$pay_list['alipay_hb']['url']);
//$url =$url2[1];
echo <<<EOT
-->
<li class="text-xs-center pay-order-zhifubao" data-toggle="modal" data-target="#pay-order-modal">
<a class="block cover pay-online" href="javascript:;" onclick="onLayer2()"><img src="{$_M[url][shop_ui]}static/img/payOnline_zfb.png" class='img-fluid inline-block'/></a>
</li>
<script>
function onLayer2(){
layer.open({
content: '<iframe src="/shop/order_alipay_hb.php?lang=cn&pid={$pid}&price={$price}&id={$id}" width=100% height=360 frameborder=0 scrolling=auto border="0"></iframe>'
,btn: '支付完成'
});
}
</script>
4、支付的时候转到
\app\system\pay\web app.class.php
$date['p'] = $_M['form']['p'];//每月费用
$date['n'] = $_M['form']['n'];//多少期
case 17://支付宝 花呗分期支付
$this->Payment_alipay_hb($date);
break;
//支付 花呗分期
public function Payment_alipay_hb($date) {
$alipay = load::mod_class('pay/web/alipay.class.php', 'new'); //加载支付宝支付处理类
$alipay->alipay($date); //调用支付宝支付接口
}
6、新增加alipay.class类文件。路径在:\app\system\pay\web\
//花呗分期 参数
if($date["n"]){
$hb_fq_param = "hb_fq_seller_percent^0|hb_fq_num^".$date["n"];//hb_fq_num:代表花呗分期数;hb_fq_seller_percent:商家承担手续费传入100,用户承担手续费传入0。
//var_dump($hb_fq_param);die;
}
public function alipay($date) {
global $_M;
require_once("alipay/alipay_submit.class.php");
$payment_type = "1";
$notify_url = is_strinclude($_M['url']['pay_notify'], 'localhost')?'http://mall.kisbox.com/paytool/alipay/notify_url.php':$_M['url']['pay_notify'];
$return_url = is_strinclude($_M['url']['pay_return'], 'localhost')?'http://mall.kisbox.com/paytool/alipay/return_url.php':$_M['url']['pay_return'];
$anti_phishing_key = "";
$exter_invoke_ip = "";
$out_trade_no = $date["out_trade_no"];
$subject = $date["subject"];
$total_fee = $date["total_fee"];
$body = $date["body"];
$show_url = $date["show_url"];
//花呗分期 参数
if($date["n"]){
$hb_fq_param = "hb_fq_seller_percent^0|hb_fq_num^".$date["n"];//hb_fq_num:代表花呗分期数;hb_fq_seller_percent:商家承担手续费传入100,用户承担手续费传入0。
//var_dump($hb_fq_param);die;
}
//构造要请求的参数数组,无需改动
$parameter = array(
"service" => "create_direct_pay_by_user",
"partner" => trim($this->alipay_config['partner']),
"seller_email" => trim($this->alipay_config['seller_email']),
"payment_type" => $payment_type,
"hb_fq_param" => $hb_fq_param,//花呗分期 参数
"notify_url" => $notify_url,
"return_url" => $return_url,
"out_trade_no" => $out_trade_no,
"subject" => $subject,
"total_fee" => $total_fee,
"body" => $body,
"show_url" => $show_url,
"anti_phishing_key" => $anti_phishing_key,
"exter_invoke_ip" => $exter_invoke_ip,
"_input_charset" => trim(strtolower($this->alipay_config['input_charset']))
);
//建立请求
$alipaySubmit = new AlipaySubmit($this->alipay_config);
$html_text = $alipaySubmit->buildRequestForm($parameter,"get", "确认");
echo $html_text;
}