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)

大家都在看

  • 排序起步!Insertion Sort&Bubble Sort: 插排和冒牌排序、冒泡排序优化

    Introduction to Sorting Sorting is the process of Taking a list of objects which could be …

    Linux 2023年6月13日
    087
  • sublime text里面中文字体显示异常解决方案

    sublime text下载之后一开始转成中文之后,会出现中文显示异常的问题,比如下图中”门”字显示异常 通过如下的设置可以解决该问题: 首选项&#8211…

    Linux 2023年6月13日
    0198
  • vscode配置指南,美化技巧

    "workbench.colorCustomizations": { "editor.selectionBackground": &quot…

    Linux 2023年6月14日
    090
  • 一文说清OpenCL框架

    背景 Read the fucking official documents! –By 鲁迅 A picture is worth a thousand words. …

    Linux 2023年6月8日
    0116
  • Pytorch的类(nn.Module的子类)中的forward函数

    使用 直接通过类的实例对象就可以向类中的forward函数进行参数的传递(当然也可以通过调用forward函数进行传参) import torch.nn as nn class M…

    Linux 2023年6月7日
    0120
  • 【Docker搭建】2. 在Docker中安装Redis5.0

    1. 安装Docker,详细 请看安装教程 。若已安装,请看 2. 2. 拉取 Redis 镜像 docker pull redis:5.0.5 3. 设置 Redis 配置文件 …

    Linux 2023年6月13日
    089
  • Linux命令

    Linux命令是对Linux系统进行管理的命令,对于Linux系统来说,无论是中央处理器、内存、磁盘驱动器、键盘、鼠标,还是用户等都是文件,Linux系统管理的命令是它正常运行的核…

    Linux 2023年5月27日
    095
  • SpringBoot 2.x 开发案例之 Shiro 整合 Redis

    前言 前段时间做了一个图床的小项目,安全框架使用的是 Shiro。为了使用户 7×24小时访问,决定把项目由单机升级为集群部署架构。但是安全框架 shiro只有单机存储的 Sess…

    Linux 2023年5月28日
    0112
  • Linux下使用压力测试工具stress

    首先解压安装包到/usr/local/src/下 mv stress-1.0.4.tar.gz /usr/local/src​tar -zxf stress-1.0.4.tar.g…

    Linux 2023年6月13日
    091
  • 面试复盘(1)

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

    Linux 2023年6月7日
    0104
  • 在公司当上PD的心路历程

    前不久因为接了个新项目,我被选中当上PD也就是专门负责给客户演示,推进项目、录视频、写文档、做测试,因为我本来就需要测这些东西,熟悉算法、应用、固件,所以大部分人就觉得非我不可。 …

    Linux 2023年6月8日
    099
  • WPF 制作一个占用文件的测试工具

    我在开发软件进行测试时,需要测试拖入的文件被占用时软件的行为,于是就做了一个文件占用工具,此工具可以将某个文件进行占用,以及获取某个文件被哪个进程占用 先给大家看一下效果: 以上是…

    Linux 2023年6月6日
    0120
  • 简单交叉编译学习

    交叉编译 交叉编译是在一个平台上生成另一个平台上的可执行代码。 同一个体系结构可以运行不同的操作系统;同样,同一个操作系统也可以在不同的体系结构上运行。通常是自己的电脑写好代码编译…

    Linux 2023年6月7日
    0134
  • linux命令__ln

    ln ln是linux中又一个非常重要命令,请大家一定要熟悉。它的功能是为某一个文件在另外一个位置建立一个同步的链接,这个命令最常用的参数是-s,具体用法是:ln –s 源文件 目…

    Linux 2023年6月7日
    0107
  • 正则表达式

    1.正则表达式分类 正则表达式:REGEXP,REGular EXPression。正则表达式分为两类: Basic REGEXP(基本正则表达式) Extended REGEXP…

    Linux 2023年6月6日
    0100
  • Linux进程调度器

    完全公平调度器 用黑体标出的是文章的主线,未用黑体标出的内容是对黑体内容的解释或注解。 每次调用调度器时,它会挑选具有最高等待时间的进程,把CPU提供给该进程。如果经常发生这种情况…

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