首先,确保在你的 WordPress 中安装了 RiPro-v5 主题。如果没有,请先安装该主题。也可以下载我们发布的集成好的整站资源包。

整站源码包下载:https://addon.zhifux.com/42.html

本文介绍下如何在你已经运营的网站中增加我们的支付方式。

1.文件路径参考如下
  1. wp-content/themes/ripro-v5/inc/options/admin-options.php
  2. wp-content/themes/ripro-v5/inc/template-shop.php
  3. wp-content/themes/ripro-v5/inc/shop/zhifux/notify.php
  4. wp-content/themes/ripro-v5/inc/shop/zhifux/return.php
  5. wp-content/themes/ripro-v5/assets/css/main.min.css
2.具体修改代码
2.1admin-options.php的2250行左右加入如下代码

RiPro-v5-7.13主题接入支付FM插件 - 图1

  1. // zhifux.com 支付FM 开始
  2. // 支付FM-支付宝
  3. array(
  4. 'id' => 'is_zhifux_alipay',
  5. 'type' => 'switcher',
  6. 'title' => '支付FM(支付宝收款码)',
  7. 'label' => '支付宝免签类型,本API接口为支付FM 免签支付宝收款码收款接口',
  8. 'default' => false,
  9. ),
  10. array(
  11. 'id' => 'zhifux_alipay',
  12. 'type' => 'fieldset',
  13. 'title' => '配置详情',
  14. 'fields' => array(
  15. array(
  16. 'type' => 'notice',
  17. 'style' => 'success',
  18. 'content' => '支付FM<a target="_blank" href="https://www.zhifux.com">注册地址</a>',
  19. ),
  20. array(
  21. 'id' => 'pid',
  22. 'type' => 'text',
  23. 'title' => '商户号',
  24. 'desc' => '',
  25. 'default' => '',
  26. ),
  27. array(
  28. 'id' => 'key',
  29. 'type' => 'text',
  30. 'title' => '接入密钥',
  31. 'desc' => '',
  32. 'default' => '',
  33. 'attributes' => array(
  34. 'type' => 'password',
  35. ),
  36. ),
  37. array(
  38. 'id' => 'apiurl',
  39. 'type' => 'text',
  40. 'title' => 'API接口地址',
  41. 'desc' => '请填写你的支付FM-接口地址,在支付FM后台的用户中心页面查看,本站https如果启用的话,接口地址也要用https的。',
  42. 'default' => '',
  43. ),
  44. ),
  45. 'dependency' => array('is_zhifux_alipay', '==', 'true'),
  46. ),
  47. // 支付FM-微信收款码
  48. array(
  49. 'id' => 'is_zhifux_weixin',
  50. 'type' => 'switcher',
  51. 'title' => '支付FM(微信收款码)',
  52. 'label' => '微信免签类型,本API接口为支付FM 免签微信收款码收款接口',
  53. 'default' => false,
  54. ),
  55. array(
  56. 'id' => 'zhifux_weixin',
  57. 'type' => 'fieldset',
  58. 'title' => '配置详情',
  59. 'fields' => array(
  60. array(
  61. 'type' => 'notice',
  62. 'style' => 'success',
  63. 'content' => '支付FM <a target="_blank" href="https://www.zhifux.com">注册地址</a>',
  64. ),
  65. array(
  66. 'id' => 'pid',
  67. 'type' => 'text',
  68. 'title' => '商户号',
  69. 'desc' => '',
  70. 'default' => '',
  71. ),
  72. array(
  73. 'id' => 'key',
  74. 'type' => 'text',
  75. 'title' => '接入密钥',
  76. 'desc' => '',
  77. 'default' => '',
  78. 'attributes' => array(
  79. 'type' => 'password',
  80. ),
  81. ),
  82. array(
  83. 'id' => 'apiurl',
  84. 'type' => 'text',
  85. 'title' => 'API接口地址',
  86. 'desc' => '请填写你的支付FM-接口地址,在支付FM后台的用户中心页面查看,本站https如果启用的话,接口地址也要用https的。',
  87. 'default' => '',
  88. ),
  89. ),
  90. 'dependency' => array('is_zhifux_weixin', '==', 'true'),
  91. ),
  92. array(
  93. 'id' => 'is_zhifux_alipay_pc_all',
  94. 'type' => 'switcher',
  95. 'title' => '支付FM(支付宝签约)',
  96. 'label' => '支付宝签约类型集成通道,个人也可以开商户,接口支持官方支付宝、富友、杉德等通道轮训+商户号混合轮训',
  97. 'default' => false,
  98. ),
  99. array(
  100. 'id' => 'zhifux_alipay_pc_all',
  101. 'type' => 'fieldset',
  102. 'title' => '配置详情',
  103. 'fields' => array(
  104. array(
  105. 'type' => 'notice',
  106. 'style' => 'success',
  107. 'content' => '支付FM<a target="_blank" href="https://www.zhifux.com">注册地址</a>',
  108. ),
  109. array(
  110. 'id' => 'pid',
  111. 'type' => 'text',
  112. 'title' => '商户号',
  113. 'desc' => '',
  114. 'default' => '',
  115. ),
  116. array(
  117. 'id' => 'key',
  118. 'type' => 'text',
  119. 'title' => '接入密钥',
  120. 'desc' => '',
  121. 'default' => '',
  122. 'attributes' => array(
  123. 'type' => 'password',
  124. ),
  125. ),
  126. array(
  127. 'id' => 'apiurl',
  128. 'type' => 'text',
  129. 'title' => 'API接口地址',
  130. 'desc' => '请填写你的支付FM-接口地址,在支付FM后台的用户中心页面查看,本站https如果启用的话,接口地址也要用https的。',
  131. 'default' => '',
  132. ),
  133. ),
  134. 'dependency' => array('is_zhifux_alipay_pc_all', '==', 'true'),
  135. ),
  136. // 支付FM-微信签约全部
  137. array(
  138. 'id' => 'is_zhifux_wechat_pc_all',
  139. 'type' => 'switcher',
  140. 'title' => '支付FM(微信签约)',
  141. 'label' => '微信签约类型集成通道,个人也可以开商户,接口支持官方支付宝、富友、杉德等通道轮训+商户号混合轮训',
  142. 'default' => false,
  143. ),
  144. array(
  145. 'id' => 'zhifux_wechat_pc_all',
  146. 'type' => 'fieldset',
  147. 'title' => '配置详情',
  148. 'fields' => array(
  149. array(
  150. 'type' => 'notice',
  151. 'style' => 'success',
  152. 'content' => '支付FM <a target="_blank" href="https://www.zhifux.com">注册地址</a>',
  153. ),
  154. array(
  155. 'id' => 'pid',
  156. 'type' => 'text',
  157. 'title' => '商户号',
  158. 'desc' => '',
  159. 'default' => '',
  160. ),
  161. array(
  162. 'id' => 'key',
  163. 'type' => 'text',
  164. 'title' => '接入密钥',
  165. 'desc' => '',
  166. 'default' => '',
  167. 'attributes' => array(
  168. 'type' => 'password',
  169. ),
  170. ),
  171. array(
  172. 'id' => 'apiurl',
  173. 'type' => 'text',
  174. 'title' => 'API接口地址',
  175. 'desc' => '请填写你的支付FM-接口地址,在支付FM后台的用户中心页面查看,本站https如果启用的话,接口地址也要用https的。',
  176. 'default' => '',
  177. ),
  178. ),
  179. 'dependency' => array('is_zhifux_wechat_pc_all', '==', 'true'),
  180. ),
  181. //zhifux.com 支付FM结束
2.2template-shop.php 1124行左右,1349行左右增加支付FM相关代码如下

RiPro-v5-7.13主题接入支付FM插件 - 图2

  1. 111 => ['id' => 'zhifux_alipay', 'name' => '支付宝', 'is' => (bool) _cao('is_zhifux_alipay')],
  2. 112 => ['id' => 'zhifux_weixin', 'name' => '微信', 'is' => (bool) _cao('is_zhifux_weixin')],
  3. 211 => ['id' => 'zhifux_alipay_pc_all', 'name' => '支付宝', 'is' => (bool) _cao('is_zhifux_alipay_pc_all')],
  4. 212 => ['id' => 'zhifux_wechat_pc_all', 'name' => '微信', 'is' => (bool) _cao('is_zhifux_wechat_pc_all')],

RiPro-v5-7.13主题接入支付FM插件 - 图3

  1. $alipay_group = [1, 11, 21, 31, 41,111,211];
  2. $weixinpay_group = [2, 12, 22, 32, 42,112,212];

RiPro-v5-7.13主题接入支付FM插件 - 图4

  1. case 'zhifux_alipay':
  2. case 'zhifux_weixin':
  3. case 'zhifux_alipay_pc_all':
  4. case 'zhifux_wechat_pc_all':
  5. #支付FM
  6. $the_pay_type = $pay_optons['id'];
  7. $type = $the_pay_type;
  8. $zhifuxconfig = _cao('zhifux_alipay');
  9. if($the_pay_type== "zhifux_alipay"){
  10. $zhifuxconfig = _cao('zhifux_alipay');
  11. $type = "alipay";
  12. }else if($the_pay_type== "zhifux_weixin"){
  13. $zhifuxconfig = _cao('zhifux_weixin');
  14. $type = "wechat";
  15. }else if($the_pay_type== "zhifux_alipay_pc_all"){
  16. $zhifuxconfig = _cao('zhifux_alipay_pc_all');
  17. $type = "alipay-pc-all";
  18. }else if($the_pay_type== "zhifux_wechat_pc_all"){
  19. $zhifuxconfig = _cao('zhifux_wechat_pc_all');
  20. $type = "wechat-pc-all";
  21. }
  22. //商户参数
  23. $returnType = "json";
  24. $api_url = $zhifuxconfig['apiurl'];; //在用户中心页面查看 接口地址
  25. $merchantNum = $zhifuxconfig['pid'];
  26. $secret = $zhifuxconfig['key'];
  27. $notifyUrl = home_url('/') . 'pay/callback/zhifux/notify/';
  28. $sign = md5($merchantNum.$order_data['order_trade_no'].$order_data['order_price']. $notifyUrl.$secret);
  29. $native = array(
  30. "merchantNum" => $merchantNum,
  31. "payType" => $type,
  32. "amount" => $order_data['order_price'],//金额,
  33. "orderNo" => $order_data['order_trade_no'],
  34. "subject"=> $order_data['order_name'],
  35. "notifyUrl" => $notifyUrl,
  36. "returnUrl" => home_url('/') . 'pay/callback/zhifux/return/',
  37. "sign" => $sign,
  38. "returnType" =>$returnType
  39. );
  40. $param = http_build_query($native);
  41. $return = http_request_fm($api_url, $param, 'application/x-www-form-urlencoded;charset=utf-8');
  42. if(strpos($return,'{') === 0){
  43. $resultData = json_decode($return,true);
  44. if($resultData['success']){
  45. $data = $resultData['data']['payUrl'];
  46. //方式1 弹窗
  47. $pay_url = $data;
  48. $pay_url = zb_get_pay_body_html($order_data['pay_type'], $order_data['pay_price'], get_qrcode_url($pay_url));
  49. // 方式2 跳转
  50. //if (!empty($data)) {
  51. // $result['method'] = 'url';
  52. // $pay_url = $data;
  53. // }
  54. }else{
  55. echo json_encode(array('status' => '0', 'msg' => $resultData['msg']));exit;
  56. }
  57. }else{
  58. echo json_encode(array('status' => '0', 'msg' => $return));exit;
  59. }
  60. break;
2.3创建目录zhifux,上传附件里面的文件notify.php和return.php

下载链接:https://share.weiyun.com/oXRwavYv 密码:ha8fbs
RiPro-v5-7.13主题接入支付FM插件 - 图5

2.4 main.min.css增加样式代码

搜索alipay-i.png,在如下图位置处增加样式代码 RiPro-v5-7.13主题接入支付FM插件 - 图6

  1. 图中红线部分对应的css代码,注意签名的逗号别漏了
  2. ,.pay-select-box .pay-item>i.zhifux_alipay_pc_all,.pay-select-box .pay-item>i.zhifux_alipay
  3. 图中绿线部分对应的css代码
  4. ,.pay-select-box .pay-item>i.zhifux_weixin,.pay-select-box .pay-item>i.zhifux_wechat_pc_all