首先,确保在你的 WordPress 中安装了 RiPro-v5 主题。如果没有,请先安装该主题。也可以下载我们发布的集成好的开心版整站资源包,附免授权激活文件。
整站资源包说明:
当前版本:RiPro-V5 7.1.3 附免授权激活文件
整站源码下载:https://addon.zhifux.com/42.html
使用方法:
1、下载主题源码 ripro-v5.gz 进行安装。
2、激活文件 ripro-v5-active.php确认在wp根目录,访问一次,即可激活。
本文介绍下如何自己增加我们的支付方式。
1.文件路径参考如下
wp-content/themes/ripro-v5/inc/options/admin-options.php
wp-content/themes/ripro-v5/inc/template-shop.php
wp-content/themes/ripro-v5/inc/shop/zhifux/notify.php
wp-content/themes/ripro-v5/inc/shop/zhifux/return.php
wp-content/themes/ripro-v5/assets/css/main.min.css
2.具体修改代码
2.1admin-options.php的2250行左右加入如下代码
// zhifux.com 支付FM 开始
// 支付FM-支付宝
array(
'id' => 'is_zhifux_alipay',
'type' => 'switcher',
'title' => '支付FM(支付宝收款码)',
'label' => '支付宝免签类型,本API接口为支付FM 免签支付宝收款码收款接口',
'default' => false,
),
array(
'id' => 'zhifux_alipay',
'type' => 'fieldset',
'title' => '配置详情',
'fields' => array(
array(
'type' => 'notice',
'style' => 'success',
'content' => '支付FM<a target="_blank" href="https://www.zhifux.com">注册地址</a>',
),
array(
'id' => 'pid',
'type' => 'text',
'title' => '商户号',
'desc' => '',
'default' => '',
),
array(
'id' => 'key',
'type' => 'text',
'title' => '接入密钥',
'desc' => '',
'default' => '',
'attributes' => array(
'type' => 'password',
),
),
array(
'id' => 'apiurl',
'type' => 'text',
'title' => 'API接口地址',
'desc' => '请填写你的支付FM-接口地址,在支付FM后台的用户中心页面查看,本站https如果启用的话,接口地址也要用https的。',
'default' => '',
),
),
'dependency' => array('is_zhifux_alipay', '==', 'true'),
),
// 支付FM-微信收款码
array(
'id' => 'is_zhifux_weixin',
'type' => 'switcher',
'title' => '支付FM(微信收款码)',
'label' => '微信免签类型,本API接口为支付FM 免签微信收款码收款接口',
'default' => false,
),
array(
'id' => 'zhifux_weixin',
'type' => 'fieldset',
'title' => '配置详情',
'fields' => array(
array(
'type' => 'notice',
'style' => 'success',
'content' => '支付FM <a target="_blank" href="https://www.zhifux.com">注册地址</a>',
),
array(
'id' => 'pid',
'type' => 'text',
'title' => '商户号',
'desc' => '',
'default' => '',
),
array(
'id' => 'key',
'type' => 'text',
'title' => '接入密钥',
'desc' => '',
'default' => '',
'attributes' => array(
'type' => 'password',
),
),
array(
'id' => 'apiurl',
'type' => 'text',
'title' => 'API接口地址',
'desc' => '请填写你的支付FM-接口地址,在支付FM后台的用户中心页面查看,本站https如果启用的话,接口地址也要用https的。',
'default' => '',
),
),
'dependency' => array('is_zhifux_weixin', '==', 'true'),
),
array(
'id' => 'is_zhifux_alipay_pc_all',
'type' => 'switcher',
'title' => '支付FM(支付宝签约)',
'label' => '支付宝签约类型集成通道,个人也可以开商户,接口支持官方支付宝、富友、杉德等通道轮训+商户号混合轮训',
'default' => false,
),
array(
'id' => 'zhifux_alipay_pc_all',
'type' => 'fieldset',
'title' => '配置详情',
'fields' => array(
array(
'type' => 'notice',
'style' => 'success',
'content' => '支付FM<a target="_blank" href="https://www.zhifux.com">注册地址</a>',
),
array(
'id' => 'pid',
'type' => 'text',
'title' => '商户号',
'desc' => '',
'default' => '',
),
array(
'id' => 'key',
'type' => 'text',
'title' => '接入密钥',
'desc' => '',
'default' => '',
'attributes' => array(
'type' => 'password',
),
),
array(
'id' => 'apiurl',
'type' => 'text',
'title' => 'API接口地址',
'desc' => '请填写你的支付FM-接口地址,在支付FM后台的用户中心页面查看,本站https如果启用的话,接口地址也要用https的。',
'default' => '',
),
),
'dependency' => array('is_zhifux_alipay_pc_all', '==', 'true'),
),
// 支付FM-微信签约全部
array(
'id' => 'is_zhifux_wechat_pc_all',
'type' => 'switcher',
'title' => '支付FM(微信签约)',
'label' => '微信签约类型集成通道,个人也可以开商户,接口支持官方支付宝、富友、杉德等通道轮训+商户号混合轮训',
'default' => false,
),
array(
'id' => 'zhifux_wechat_pc_all',
'type' => 'fieldset',
'title' => '配置详情',
'fields' => array(
array(
'type' => 'notice',
'style' => 'success',
'content' => '支付FM <a target="_blank" href="https://www.zhifux.com">注册地址</a>',
),
array(
'id' => 'pid',
'type' => 'text',
'title' => '商户号',
'desc' => '',
'default' => '',
),
array(
'id' => 'key',
'type' => 'text',
'title' => '接入密钥',
'desc' => '',
'default' => '',
'attributes' => array(
'type' => 'password',
),
),
array(
'id' => 'apiurl',
'type' => 'text',
'title' => 'API接口地址',
'desc' => '请填写你的支付FM-接口地址,在支付FM后台的用户中心页面查看,本站https如果启用的话,接口地址也要用https的。',
'default' => '',
),
),
'dependency' => array('is_zhifux_wechat_pc_all', '==', 'true'),
),
//zhifux.com 支付FM结束
2.2template-shop.php 1124行左右,1178行,1349行左右增加支付FM相关代码如下
101 => ['id' => 'zhifux_alipay', 'name' => '支付宝', 'is' => (bool) _cao('is_zhifux_alipay')],
102 => ['id' => 'zhifux_weixin', 'name' => '微信', 'is' => (bool) _cao('is_zhifux_weixin')],
111 => ['id' => 'zhifux_alipay_pc_all', 'name' => '支付宝', 'is' => (bool) _cao('is_zhifux_alipay_pc_all')],
112 => ['id' => 'zhifux_wechat_pc_all', 'name' => '微信', 'is' => (bool) _cao('is_zhifux_wechat_pc_all')],
//获取支付弹窗内容
function zb_get_pay_body_html($id, $price, $qrimg) {
//分组
$alipay_group = [1, 11, 21, 31, 41,101,111];
$weixinpay_group = [2, 12, 22, 32, 42,102,112];
case 'zhifux_alipay':
case 'zhifux_weixin':
case 'zhifux_alipay_pc_all':
case 'zhifux_wechat_pc_all':
#支付FM
$the_pay_type = $pay_optons['id'];
$type = $the_pay_type;
$zhifuxconfig = _cao('zhifux_alipay');
if($the_pay_type== "zhifux_alipay"){
$zhifuxconfig = _cao('zhifux_alipay');
$type = "alipay";
}else if($the_pay_type== "zhifux_weixin"){
$zhifuxconfig = _cao('zhifux_weixin');
$type = "wechat";
}else if($the_pay_type== "zhifux_alipay_pc_all"){
$zhifuxconfig = _cao('zhifux_alipay_pc_all');
$type = "alipay-pc-all";
}else if($the_pay_type== "zhifux_wechat_pc_all"){
$zhifuxconfig = _cao('zhifux_wechat_pc_all');
$type = "wechat-pc-all";
}
//商户参数
$returnType = "json";
$api_url = $zhifuxconfig['apiurl'];; //在用户中心页面查看 接口地址
$merchantNum = $zhifuxconfig['pid'];
$secret = $zhifuxconfig['key'];
$notifyUrl = home_url('/') . 'pay/callback/zhifux/notify/';
$sign = md5($merchantNum.$order_data['order_trade_no'].$order_data['order_price']. $notifyUrl.$secret);
$native = array(
"merchantNum" => $merchantNum,
"payType" => $type,
"amount" => $order_data['order_price'],//金额,
"orderNo" => $order_data['order_trade_no'],
"subject"=> $order_data['order_name'],
"notifyUrl" => $notifyUrl,
"returnUrl" => home_url('/') . 'pay/callback/zhifux/return/',
"sign" => $sign,
"returnType" =>$returnType
);
$param = http_build_query($native);
$return = http_request_fm($api_url, $param, 'application/x-www-form-urlencoded;charset=utf-8');
if(strpos($return,'{') === 0){
$resultData = json_decode($return,true);
if($resultData['success']){
$data = $resultData['data']['payUrl'];
//方式1 弹窗
$pay_url = $data;
$pay_url = zb_get_pay_body_html($order_data['pay_type'], $order_data['pay_price'], get_qrcode_url($pay_url));
// 方式2 跳转
//if (!empty($data)) {
// $result['method'] = 'url';
// $pay_url = $data;
// }
}else{
echo json_encode(array('status' => '0', 'msg' => $resultData['msg']));exit;
}
}else{
echo json_encode(array('status' => '0', 'msg' => $return));exit;
}
break;
2.3创建目录zhifux,上传附件里面的文件notify.php和return.php
下载链接:https://share.weiyun.com/oXRwavYv 密码:ha8fbs
2.4 main.min.css增加样式代码
搜索alipay-i.png,在如下图位置处增加样式代码
图中红线部分对应的css代码,注意签名的逗号别漏了
,.pay-select-box .pay-item>i.zhifux_alipay_pc_all,.pay-select-box .pay-item>i.zhifux_alipay
图中绿线部分对应的css代码
,.pay-select-box .pay-item>i.zhifux_weixin,.pay-select-box .pay-item>i.zhifux_wechat_pc_all
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
评论(0)