php微信分账功能 —— app支付

/**

  • 微信分账功能

  • $out_order_no 系统自定义的单号

  • $transaction_id 微信支付单号

  • $profitSharingAccounts array 分账接收方

public function ProfitShare($out_order_no, $transaction_id, $profitSharingAccounts)

$result = array();

$result[‘status’] = false;

$result[‘message’] = ‘未知错误!’;

if ($out_order_no == ”) {

$result[‘message’] = ‘系统单号为空!’;

if ($transaction_id == ”) {

$result[‘message’] = ‘支付单号为空!’;

$url = ‘https://api.mch.weixin.qq.com/secapi/pay/profitsharing’;

//添加请求xml

$xmlArr = array();

$xmlArr[‘appid’] = config(‘jshop.service_wechatgzh_appid’);

$xmlArr[‘mch_id’] = config(‘jshop.service_wechatpay_mch_id’);

$xmlArr[‘out_order_no’] = $out_order_no;

$xmlArr[‘transaction_id’] = $transaction_id;

$xmlArr[‘nonce_str’] = $this->getNonceStr();

$xmlArr[‘sign_type’] = ‘HMAC-SHA256’;

$xmlArr[‘receivers’] = json_encode($profitSharingAccounts);

$sign = $this->makeSignBySHA($xmlArr);

$xmlArr[‘sign’] = $sign;

$XmlStr = $this->toXml($xmlArr);

$res = $this->postXmlCurl($XmlStr, $url, true);

$res = $this->fromXml($res);

if ($res[‘return_code’] == ‘SUCCESS’) {

$result[‘status’] = true;

$result[‘message’] = ‘查询成功!’;

return $result;

/**

  • 查询分账结果

  • $out_order_no 系统自定义的单号

  • $transaction_id 微信支付单号

public function ProfitsharingQuery($out_order_no, $transaction_id)

$result = array();

$result[‘status’] = false;

$result[‘message’] = ‘未知错误!’;

if ($out_order_no == ”) {

$result[‘message’] = ‘系统单号为空!’;

if ($transaction_id == ”) {

$result[‘message’] = ‘支付单号为空!’;

$url = ‘https://api.mch.weixin.qq.com/pay/profitsharingquery’;

$xmlArr = array();

$xmlArr[‘mch_id’] = config(‘jshop.service_wechatpay_mch_id’);

$xmlArr[‘out_order_no’] = $out_order_no;

$xmlArr[‘transaction_id’] = $transaction_id;

$xmlArr[‘nonce_str’] = $this->getNonceStr();

$xmlArr[‘sign_type’] = ‘HMAC-SHA256’;

$sign = $this->makeSignBySHA($xmlArr);

$xmlArr[‘sign’] = $sign;

$XmlStr = $this->toXml($xmlArr);

$res = $this->postXmlCurl($XmlStr, $url);

$res = $this->fromXml($res);

$result[‘data’] = $res;

if ($res[‘return_code’] == ‘SUCCESS’ && $res[‘result_code’] == ‘SUCCESS’) {

$result[‘status’] = true;

$result[‘message’] = ‘查询成功!’;

return $result;

/**

  • 添加分账方

public function ProfitSharingAddReceiver($profitSharingAccounts)

$result = array();

$result[‘status’] = false;

$result[‘message’] = ‘未知错误!’;

if (count($profitSharingAccounts) == 0) {

$result[‘message’] = ‘分账接收为空!’;

return $result;

$url = ‘https://api.mch.weixin.qq.com/pay/profitsharingaddreceiver’;

//添加请求xml

$xmlArr = array();

$xmlArr[‘appid’] = config(‘jshop.service_wechatgzh_appid’);

$xmlArr[‘mch_id’] = config(‘jshop.service_wechatpay_mch_id’);

$xmlArr[‘nonce_str’] = $this->getNonceStr();

$xmlArr[‘sign_type’] = ‘HMAC-SHA256’;

$xmlArr[‘receiver’] = json_encode($profitSharingAccounts);

$sign = $this->makeSignBySHA($xmlArr);

$xmlArr[‘sign’] = $sign;

$XmlStr = $this->toXml($xmlArr);

$res = $this->postXmlCurl($XmlStr, $url);

var_dump($res);

/**

  • 删除分账方

  • profitSharingAccounts 分账方数组

public function ProfitSharingRemoverEceiver($profitSharingAccounts)

$result = array();

$result[‘status’] = false;

$result[‘message’] = ‘未知错误!’;

if (count($profitSharingAccounts) == 0) {

$result[‘message’] = ‘分账接收为空!’;

return $result;

$url = ‘https://api.mch.weixin.qq.com/pay/profitsharingremovereceiver

//添加请求xml

$xmlArr = array();

$xmlArr[‘appid’] = config(‘jshop.service_wechatgzh_appid’);

$xmlArr[‘mch_id’] = config(‘jshop.service_wechatpay_mch_id’);

$xmlArr[‘nonce_str’] = $this->getNonceStr();

$xmlArr[‘sign_type’] = ‘HMAC-SHA256’;

$xmlArr[‘receiver’] = json_encode($profitSharingAccounts);

$sign = $this->makeSignBySHA($xmlArr);

$xmlArr[‘sign’] = $sign;

$XmlStr = $this->toXml($xmlArr);

$res = $this->postXmlCurl($XmlStr, $url);

var_dump($res);

/**

  • 完结分账

    • $out_order_no 系统自定义的单号
  • $transaction_id 微信支付单号

public function ProfitSharingFinish($out_order_no, $transaction_id)

$result = array();

$result[‘status’] = false;

$result[‘message’] = ‘未知错误!’;

if ($out_order_no == ”) {

$result[‘message’] = ‘系统单号为空!’;

if ($transaction_id == ”) {

$result[‘message’] = ‘支付单号为空!’;

$url = ‘https://api.mch.weixin.qq.com/secapi/pay/profitsharingfinish’;

$xmlArr = array();

$xmlArr[‘mch_id’] = config(‘jshop.service_wechatpay_mch_id’);

$xmlArr[‘appid’] = config(‘jshop.service_wechatgzh_appid’);

$xmlArr[‘out_order_no’] = $out_order_no.’1′;

$xmlArr[‘transaction_id’] = $transaction_id;

$xmlArr[‘nonce_str’] = $this->getNonceStr();

$xmlArr[‘sign_type’] = ‘HMAC-SHA256’;

$xmlArr[‘description’] = ‘完结分账’;

$sign = $this->makeSignBySHA($xmlArr);

$xmlArr[‘sign’] = $sign;

$XmlStr = $this->toXml($xmlArr);

$res = $this->postXmlCurl($XmlStr, $url, true);

$res = $this->fromXml($res);

$result[‘data’] = $res;

if ($res[‘return_code’] == ‘SUCCESS’) {

$result[‘status’] = true;

$result[‘message’] = ‘查询成功!’;

return $result;

Original: https://www.cnblogs.com/wangbaishi/p/14475975.html
Author: wangbaishi
Title: php微信分账功能 —— app支付

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/578604/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

  • 剑指offer计划26(字符串中等)—java

    1.1、题目1 剑指 Offer 20. 表示数值的字符串 1.2、解法 这题表示直接上大佬的题解把。。。。代码太长了。有限状态自动机。对状态机一无所知的我一脸懵 1.3、代码 c…

    Linux 2023年6月11日
    089
  • LVS负载均衡

    LVS负载均衡 LVS负载均衡 一、LVS是什么 二、LVS的作用 三、lvs的三种工作模式 1.基于NAT的LVS模式负载均衡 2.基于TUN模式的LVS负载均衡 3.LVS(D…

    Linux 2023年6月6日
    087
  • 011 Linux 打包与解压 tar

    01 压缩、打包命令有哪些? Linux上有着各种压缩、打包的工具:tar、gzip、zip、7z,而 tar 应该算是 Linux 官宣的压缩工具了。tar 的核心压缩工具其实是…

    Linux 2023年5月27日
    069
  • 安卓手机改造服务器——解决chroot下无法使用systemctl

    在Linux Deploy中安装的CentOS7无法使用 systemctl命令,没关系我们有其他办法 写在前面 对于这个问题,我也是第一次遇见。并没有深入研究,所有如果有哪些地方…

    Linux 2023年6月8日
    0128
  • shell ${val:0:3)含义

    ${file:0:5}:提取最左边的5个字节:/dir1${file:5:5}:提取第5个字节右边的连续5个字节:/dir2 例子: pval=12345678 r=${pval:…

    Linux 2023年5月28日
    061
  • bash获取机器IP后缀

    1.先获取部分数据 ip_0=ip a | grep inet | grep -v inet6 | grep ens | awk ‘NR==1{print $2}’ | cut -…

    Linux 2023年6月7日
    087
  • 你有想过在同一台服务器中,同时多开几个tomcat吗

    tomcat作为许多java项目的运行的环境,常用来跑java项目。而一台服务器只跑一个tomcat服务又太浪费资源了,so,我们可以在同一台服务器上,同时跑多个tomcat服务进…

    Linux 2023年6月8日
    087
  • 4.8 Linux解压.bz2格式的文件(bunzip2命令)

    要解压”.bz2″格式的压缩包文件,除了使用”bzip2 -d 压缩包名”命令外,还可以使用 bunzip2 命令。 bunzip2…

    Linux 2023年6月7日
    075
  • 分布式计算的本质、特点和未来

    在计算机早期,都是由一台主机承担全部存储和计算工作,这种方式被称为集中处理。后来随着处理器发展和网络出现,衍生出客户机/服务器架构,即由服务器完成主要的存储计算工作,客户机则负责较…

    Linux 2023年6月6日
    0107
  • Java秒杀系统二:Service层

    404. 抱歉,您访问的资源不存在。 可能是网址有误,或者对应的内容被删除,或者处于私有状态。 代码改变世界,联系邮箱 contact@cnblogs.com 园子的商业化努力-困…

    Linux 2023年6月11日
    093
  • N68第二周作业

    完成作业:完成一个shell脚本,脚本的作用。1. 运行脚本可以显示出本机的ip地址2. 如果ip地址中有3这个数字,那么就打印出当前的系统时间3. 如果ip地址中不含3这个数字,…

    Linux 2023年6月7日
    0141
  • 【CentOS】检查系统是否安装OpenSSH

    CentOS7 远程联机 哔哩哔哩 萌狼蓝天 博客:https://mllt.cc 微信公众号:萌狼蓝天 检查与安装配置OpenSSH [CentOS7]检查系统是否安装OpenS…

    Linux 2023年5月27日
    088
  • 杨辉三角的变形—牛客网

    杨辉三角的变形_牛客题霸_牛客网 (nowcoder.com) #include using namespace std; int main() { //这个树的偶数规律为 -1 …

    Linux 2023年6月13日
    0114
  • Java高级

    抽象类和抽象方法 1.定义 随着继承层次中一个个新子类的定义,类变得越来越具体,而父类则更一般,更通用。 类的设计应该保证父类和子类都能够共享特征。 有时候将一个父类设计的非常抽象…

    Linux 2023年6月13日
    0104
  • R语言-tidyr和dplyr

    一、安装和加载 1、安装并加载tidyr和dplyr包 install.packages("tidyr") library(tidyr) install.pac…

    Linux 2023年6月8日
    085
  • AIX下安装bash

    在AIX系统下,默认是没有安装bash环境的,对于经常操作的维护人员来说,非常不方便,所以下面我们来动手安装bash。 1、确认系统是否已安装bash 方法1:之间敲bash命令,…

    Linux 2023年6月14日
    067
亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球