普乐智能

查看: 7110|回复: 4

微信服务商分账功能 PHP

[复制链接]

338

主题

424

帖子

1670

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1670
发表于 2022-1-11 10:22:57 | 显示全部楼层 |阅读模式
项目说明
微信服务商分账接口说明:https://pay.weixin.qq.com/wiki/d ... er=24_1&index=1
项目大概逻辑
开通分账功能(https://pay.weixin.qq.com/wiki/d ... er=24_2&index=2
服务商代子商户发起添加分账接收方请求
在统一下单API、付款码支付API、委托扣款API中上传新增参数profit_sharing,请求支付
支付完成后,调用请求分账接口,完成分账
其他注意事项
分账接口分为单次分账和多次分账
当用户需要退款时,单次分账调用接口的步骤是:分账回退->申请退款
当用户需要退款时,多次分账调用接口的步骤是:分账完结->分账回退->申请退款
这里画重点,商户系统内部的分账单号,在商户系统内部唯一(***单次分账、多次分账、完结分账应使用不同的商户分账单号),同一分账单号多次请求等同一次。**只能是数字、大小写字母_-|@
Ilog是一个日志类,这里就不提供了,大家都有自己的
ProfitSharingSign.class.php是用来生成签名的,跟微信支付、微信退款生成签名类是一样的,会贴在最后
ProfitSharingCurl.class.php是一个发送http请求的类,会贴在最后
pdo_*的方法是微擎框架自带的数据库操作(这框架估计没谁会喜欢…)
使用例子就不写了,单身狗都知道,new一个对象嘛,大家给我介绍一个也行的,然后照着参数传就行
回复

使用道具 举报

338

主题

424

帖子

1670

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1670
 楼主| 发表于 2022-1-11 10:23:35 | 显示全部楼层
分账接口类 ProfitSharing.class.php

  1. <?php
  2. require_once dirname(__FILE__) . "/ProfitSharingSign.class.php";
  3. require_once dirname(__FILE__) . "/ProfitSharingCurl.class.php";

  4. class ProfitSharing
  5. {
  6.     private $wxConfig = null;
  7.     private $sign = null;
  8.     private $curl = null;


  9.     public function __construct()
  10.     {
  11.         $this->wxConfig = $this->wxConfig();
  12.         $this->sign = new ProfitSharingSign();
  13.         $this->curl = new ProfitSharingCurl();
  14.     }


  15.     /**
  16.      * @function 发起请求所必须的配置参数
  17.      * @return mixed
  18.      */
  19.     private function wxConfig()
  20.     {
  21.         $wxConfig['app_id'] = '';//服务商公众号AppID
  22.         $wxConfig['mch_id'] = ''; //服务商商户号
  23.         $wxConfig['sub_app_id'] = '';//todo 子服务商公众号AppID
  24.         $wxConfig['sub_mch_id'] = ''; //todo 子服务商商户号
  25.         $wxConfig['md5_key'] = ''; //md5 秘钥
  26.         $wxConfig['app_cert_pem'] = '';//证书路径
  27.         $wxConfig['app_key_pem'] = '';//证书路径
  28.         return $wxConfig;
  29.     }


  30.     /**
  31.      * @function 请求多次分账接口
  32.      * @param $orders array 待分账订单
  33.      * @param $accounts array 分账接收方
  34.      * @return array
  35.      * @throws Exception
  36.      */
  37.     public function multiProfitSharing($orders,$accounts)
  38.     {
  39.         if(empty($orders)){
  40.             throw new Exception('没有待分帐订单');
  41.         }
  42.         if(empty($accounts)){
  43.             throw new Exception('接收分账账户为空');
  44.         }

  45.         //1.设置分账账号
  46.         $receivers = array();
  47.         foreach ($accounts as $account)
  48.         {
  49.             $tmp = array(
  50.                 'type'=>$account['type'],
  51.                 'account'=>$account['account'],
  52.                 'amount'=>intval($account['amount']),
  53.                 'description'=>$account['desc'],
  54.             );
  55.             $receivers[] = $tmp;
  56.         }
  57.         $receivers = json_encode($receivers,JSON_UNESCAPED_UNICODE);

  58.         $totalCount = count($orders);
  59.         $successCount = 0;
  60.         $failCount = 0;
  61.         $now = time();
  62.         foreach ($orders as $order)
  63.         {
  64.             //2.生成签名
  65.             $postArr = array(
  66.                 'appid'=>$this->wxConfig['app_id'],
  67.                 'mch_id'=>$this->wxConfig['mch_id'],
  68.                 'sub_mch_id'=>$this->wxConfig['sub_mch_id'],
  69.                 'sub_appid'=>$this->wxConfig['sub_app_id'],
  70.                 'nonce_str'=>md5(time() . rand(1000, 9999)),
  71.                 'transaction_id'=>$order['trans_id'],
  72.                 'out_order_no'=>$order['order_no'].$order['ticket_no'],
  73.                 'receivers'=>$receivers,
  74.             );

  75.             $sign = $this->sign->getSign($postArr, 'HMAC-SHA256',$this->wxConfig['md5_key']);
  76.             $postArr['sign'] = $sign;


  77.             //3.发送请求
  78.             $url = 'https://api.mch.weixin.qq.com/secapi/pay/multiprofitsharing';
  79.             $postXML = $this->toXml($postArr);
  80.             Ilog::DEBUG("multiProfitSharing.postXML: " . $postXML);

  81.             $opts = array(
  82.                 CURLOPT_HEADER    => 0,
  83.                 CURLOPT_SSL_VERIFYHOST    => false,
  84.                 CURLOPT_SSLCERTTYPE   => 'PEM', //默认支持的证书的类型,可以注释
  85.                 CURLOPT_SSLCERT   => $this->wxConfig['app_cert_pem'],
  86.                 CURLOPT_SSLKEY    => $this->wxConfig['app_key_pem'],
  87.             );
  88.             Ilog::DEBUG("multiProfitSharing.opts: " . json_encode($opts));

  89.             $curl_res = $this->curl->setOption($opts)->post($url,$postXML);
  90.             Ilog::DEBUG("multiProfitSharing.curl_res: " . $curl_res);

  91.             $ret = $this->toArray($curl_res);
  92.             if($ret['return_code']=='SUCCESS' and $ret['result_code']=='SUCCESS')
  93.             {
  94.                 //更新分账订单状态
  95.                 $params = array();
  96.                 $params['order_no'] =  $order['order_no'];
  97.                 $params['trans_id'] =  $order['trans_id'];
  98.                 $params['ticket_no'] =  $order['ticket_no'];

  99.                 $data = array();
  100.                 $data['profitsharing'] = $receivers;
  101.                 $data['state'] = 2;
  102.                 pdo_update('ticket_orders_profitsharing',$data,$params);
  103.                 $successCount++;

  104.             }else{
  105.                 $failCount++;
  106.             }
  107.             usleep(500000);//微信会报频率过高,所以停一下
  108.         }

  109.         return array('processTime'=>date('Y-m-d H:i:s',$now),'totalCount'=>$totalCount,'successCount'=>$successCount,'failCount'=>$failCount);

  110.     }


  111.     /**
  112.      * @function 请求单次分账接口
  113.      * @param $profitSharingOrders array 待分账订单
  114.      * @param $profitSharingAccounts array 分账接收方
  115.      * @return array
  116.      * @throws Exception
  117.      */
  118.     public function profitSharing($profitSharingOrders,$profitSharingAccounts)
  119.     {
  120.         if(empty($profitSharingOrders)){
  121.             throw new Exception('没有待分帐订单');
  122.         }
  123.         if(empty($profitSharingAccounts)){
  124.             throw new Exception('接收分账账户为空');
  125.         }

  126.         //1.设置分账账号
  127.         $receivers = array();
  128.         foreach ($profitSharingAccounts as $profitSharingAccount)
  129.         {
  130.             $tmp = array(
  131.                 'type'=>$profitSharingAccount['type'],
  132.                 'account'=>$profitSharingAccount['account'],
  133.                 'amount'=>intval($profitSharingAccount['amount']),
  134.                 'description'=>$profitSharingAccount['desc'],
  135.             );
  136.             $receivers[] = $tmp;
  137.         }
  138.         $receivers = json_encode($receivers,JSON_UNESCAPED_UNICODE);

  139.         $totalCount = count($profitSharingOrders);
  140.         $successCount = 0;
  141.         $failCount = 0;
  142.         $now = time();

  143.         foreach ($profitSharingOrders as $profitSharingOrder)
  144.         {
  145.             //2.生成签名
  146.             $postArr = array(
  147.                 'appid'=>$this->wxConfig['app_id'],
  148.                 'mch_id'=>$this->wxConfig['mch_id'],
  149.                 'sub_mch_id'=>$this->wxConfig['sub_mch_id'],
  150.                 'sub_appid'=>$this->wxConfig['sub_app_id'],
  151.                 'nonce_str'=>md5(time() . rand(1000, 9999)),
  152.                 'transaction_id'=>$profitSharingOrder['trans_id'],
  153.                 'out_order_no'=>$profitSharingOrder['order_no'].$profitSharingOrder['ticket_no'],
  154.                 'receivers'=>$receivers,
  155.             );

  156.             $sign = $this->sign->getSign($postArr, 'HMAC-SHA256',$this->wxConfig['md5_key']);
  157.             $postArr['sign'] = $sign;

  158.             //3.发送请求
  159.             $url = 'https://api.mch.weixin.qq.com/secapi/pay/profitsharing';
  160.             $postXML = $this->toXml($postArr);
  161.             Ilog::DEBUG("profitSharing.postXML: " . $postXML);

  162.             $opts = array(
  163.                 CURLOPT_HEADER    => 0,
  164.                 CURLOPT_SSL_VERIFYHOST    => false,
  165.                 CURLOPT_SSLCERTTYPE   => 'PEM', //默认支持的证书的类型,可以注释
  166.                 CURLOPT_SSLCERT   => $this->wxConfig['app_cert_pem'],
  167.                 CURLOPT_SSLKEY    => $this->wxConfig['app_key_pem'],
  168.             );
  169.             Ilog::DEBUG("profitSharing.opts: " . json_encode($opts));

  170.             $curl_res = $this->curl->setOption($opts)->post($url,$postXML);
  171.             Ilog::DEBUG("profitSharing.curl_res: " . $curl_res);

  172.             $ret = $this->toArray($curl_res);
  173.             if($ret['return_code']=='SUCCESS' and $ret['result_code']=='SUCCESS')
  174.             {
  175.                 //更新分账订单状态
  176.                 $params = array();
  177.                 $params['order_no'] =  $profitSharingOrder['order_no'];
  178.                 $params['trans_id'] =  $profitSharingOrder['trans_id'];
  179.                 $params['ticket_no'] =  $profitSharingOrder['ticket_no'];

  180.                 $data = array();
  181.                 $data['profitsharing'] = $receivers;
  182.                 $data['state'] = 2;
  183.                 pdo_update('ticket_orders_profitsharing',$data,$params);
  184.                 $successCount++;

  185.             }else{
  186.                 $failCount++;
  187.             }

  188.         }

  189.         return array('processTime'=>date('Y-m-d H:i:s',$now),'totalCount'=>$totalCount,'successCount'=>$successCount,'failCount'=>$failCount);

  190.     }


  191.     /**
  192.      * @function 查询分账结果
  193.      * @param $trans_id string 微信支付单号
  194.      * @param $out_order_no string 分账单号
  195.      * @return array|false
  196.      * @throws Exception
  197.      */
  198.     public function query($trans_id,$out_order_no)
  199.     {
  200.         //1.生成签名
  201.         $postArr = array(
  202.             'mch_id'=>$this->wxConfig['mch_id'],
  203.             'sub_mch_id'=>$this->wxConfig['sub_mch_id'],
  204.             'transaction_id'=>$trans_id,
  205.             'out_order_no'=>$out_order_no,
  206.             'nonce_str'=>md5(time() . rand(1000, 9999)),
  207.         );

  208.         $sign = $this->sign->getSign($postArr, 'HMAC-SHA256',$this->wxConfig['md5_key']);
  209.         $postArr['sign'] = $sign;


  210.         //2.发送请求
  211.         $url = 'https://api.mch.weixin.qq.com/pay/profitsharingquery';
  212.         $postXML = $this->toXml($postArr);
  213.         Ilog::DEBUG("query.postXML: " . $postXML);

  214.         $curl_res = $this->curl->post($url,$postXML);
  215.         Ilog::DEBUG("query.curl_res: " . $curl_res);

  216.         $ret = $this->toArray($curl_res);
  217.         return $ret;
  218.     }


  219.     /**
  220.      * @function 添加分账接收方
  221.      * @param $profitSharingAccount array 分账接收方
  222.      * @return array|false
  223.      * @throws Exception
  224.      */
  225.     public function addReceiver($profitSharingAccount)
  226.     {
  227.         //1.接收分账账户
  228.         $receiver = array(
  229.             'type'=>$profitSharingAccount['type'],
  230.             'account'=>$profitSharingAccount['account'],
  231.             'name'=>$profitSharingAccount['name'],
  232.             'relation_type'=>$profitSharingAccount['relation_type'],
  233.         );
  234.         $receiver = json_encode($receiver,JSON_UNESCAPED_UNICODE);

  235.         //2.生成签名
  236.         $postArr = array(
  237.             'appid'=>$this->wxConfig['app_id'],
  238.             'mch_id'=>$this->wxConfig['mch_id'],
  239.             'sub_mch_id'=>$this->wxConfig['sub_mch_id'],
  240.             'sub_appid'=>$this->wxConfig['sub_app_id'],
  241.             'nonce_str'=>md5(time() . rand(1000, 9999)),
  242.             'receiver'=>$receiver
  243.         );

  244.         $sign = $this->sign->getSign($postArr, 'HMAC-SHA256',$this->wxConfig['md5_key']);
  245.         $postArr['sign'] = $sign;


  246.         //3.发送请求
  247.         $url = 'https://api.mch.weixin.qq.com/pay/profitsharingaddreceiver';
  248.         $postXML = $this->toXml($postArr);
  249.         Ilog::DEBUG("addReceiver.postXML: " . $postXML);

  250.         $curl_res = $this->curl->post($url,$postXML);
  251.         Ilog::DEBUG("addReceiver.curl_res: " . $curl_res);

  252.         $ret = $this->toArray($curl_res);
  253.         return $ret;
  254.     }


  255.     /**
  256.      * @function 删除分账接收方
  257.      * @param $profitSharingAccount array 分账接收方
  258.      * @return array|false
  259.      * @throws Exception
  260.      */
  261.     public function removeReceiver($profitSharingAccount)
  262.     {
  263.         //1.接收分账账户
  264.         $receiver = array(
  265.             'type'=>$profitSharingAccount['type'],
  266.             'account'=>$profitSharingAccount['account'],
  267.             'name'=>$profitSharingAccount['name'],
  268.         );
  269.         $receiver = json_encode($receiver,JSON_UNESCAPED_UNICODE);

  270.         //2.生成签名
  271.         $postArr = array(
  272.             'appid'=>$this->wxConfig['app_id'],
  273.             'mch_id'=>$this->wxConfig['mch_id'],
  274.             'sub_mch_id'=>$this->wxConfig['sub_mch_id'],
  275.             'sub_appid'=>$this->wxConfig['sub_app_id'],
  276.             'nonce_str'=>md5(time() . rand(1000, 9999)),
  277.             'receiver'=>$receiver
  278.         );

  279.         $sign = $this->sign->getSign($postArr, 'HMAC-SHA256',$this->wxConfig['md5_key']);
  280.         $postArr['sign'] = $sign;


  281.         //3.发送请求
  282.         $url = 'https://api.mch.weixin.qq.com/pay/profitsharingremovereceiver';
  283.         $postXML = $this->toXml($postArr);
  284.         Ilog::DEBUG("removeReceiver.postXML: " . $postXML);

  285.         $curl_res = $this->curl->post($url,$postXML);
  286.         Ilog::DEBUG("removeReceiver.curl_res: " . $curl_res);

  287.         $ret = $this->toArray($curl_res);
  288.         return $ret;
  289.     }


  290.     /**
  291.      * @function 完结分账
  292.      * @param $profitOrder array 分账订单
  293.      * @param $description string 完结分账描述
  294.      * @return array|false
  295.      * @throws Exception
  296.      */
  297.     public function finish($profitOrder,$description='分账完结')
  298.     {
  299.         $ret = array();
  300.         if(!empty($profitOrder))
  301.         {
  302.             //1.签名
  303.             $postArr = array(
  304.                 'mch_id'=>$this->wxConfig['mch_id'],
  305.                 'sub_mch_id'=>$this->wxConfig['sub_mch_id'],
  306.                 'appid'=>$this->wxConfig['app_id'],
  307.                 'nonce_str'=>md5(time() . rand(1000, 9999)),
  308.                 'transaction_id'=>$profitOrder['trans_id'],
  309.                 'out_order_no'=>'finish'.'_'.$profitOrder['order_no'],
  310.                 'description'=>$description,
  311.             );

  312.             $sign = $this->sign->getSign($postArr, 'HMAC-SHA256',$this->wxConfig['md5_key']);
  313.             $postArr['sign'] = $sign;


  314.             //2.请求
  315.             $url = 'https://api.mch.weixin.qq.com/secapi/pay/profitsharingfinish';
  316.             $postXML = $this->toXml($postArr);
  317.             Ilog::DEBUG("finish.postXML: " . $postXML);

  318.             $opts = array(
  319.                 CURLOPT_HEADER    => 0,
  320.                 CURLOPT_SSL_VERIFYHOST    => false,
  321.                 CURLOPT_SSLCERTTYPE   => 'PEM', //默认支持的证书的类型,可以注释
  322.                 CURLOPT_SSLCERT   => $this->wxConfig['app_cert_pem'],
  323.                 CURLOPT_SSLKEY    => $this->wxConfig['app_key_pem'],
  324.             );
  325.             Ilog::DEBUG("finish.opts: " . json_encode($opts));

  326.             $curl_res = $this->curl->setOption($opts)->post($url,$postXML);
  327.             Ilog::DEBUG("finish.curl_res: " . $curl_res);

  328.             $ret = $this->toArray($curl_res);
  329.         }

  330.         return $ret;
  331.     }


  332.     /**
  333.      * @function 分账回退
  334.      * @param $profitOrder array 分账订单
  335.      * @return array
  336.      * @throws Exception
  337.      */
  338.     public function profitSharingReturn($profitOrder)
  339.     {
  340.         $ret = array();
  341.         if(!empty($profitOrder) and $profitOrder['channel']==1)
  342.         {
  343.             $accounts = json_decode($profitOrder['profitsharing'],true);
  344.             foreach ($accounts as $account)
  345.             {
  346.                 //1.签名
  347.                 $postArr = array(
  348.                     'appid'=>$this->wxConfig['app_id'],
  349.                     'mch_id'=>$this->wxConfig['mch_id'],
  350.                     'sub_mch_id'=>$this->wxConfig['sub_mch_id'],
  351.                     'sub_appid'=>$this->wxConfig['sub_app_id'],
  352.                     'nonce_str'=>md5(time() . rand(1000, 9999)),
  353.                     'out_order_no'=>$profitOrder['order_no'].$profitOrder['ticket_no'],
  354.                     'out_return_no'=>'return_'.$profitOrder['order_no'].$profitOrder['ticket_no'].'_'.$account['account'],
  355.                     'return_account_type'=>'MERCHANT_ID',
  356.                     'return_account'=>$account['account'],
  357.                     'return_amount'=>$account['amount'],
  358.                     'description'=>'用户退款',
  359.                     'sign_type'=>'HMAC-SHA256',
  360.                 );

  361.                 $sign = $this->sign->getSign($postArr, 'HMAC-SHA256',$this->wxConfig['md5_key']);
  362.                 $postArr['sign'] = $sign;


  363.                 //2.请求
  364.                 $url = 'https://api.mch.weixin.qq.com/secapi/pay/profitsharingreturn';
  365.                 $postXML = $this->toXml($postArr);
  366.                 Ilog::DEBUG("profitSharingReturn.postXML: " . $postXML);

  367.                 $opts = array(
  368.                     CURLOPT_HEADER    => 0,
  369.                     CURLOPT_SSL_VERIFYHOST    => false,
  370.                     CURLOPT_SSLCERTTYPE   => 'PEM', //默认支持的证书的类型,可以注释
  371.                     CURLOPT_SSLCERT   => $this->wxConfig['app_cert_pem'],
  372.                     CURLOPT_SSLKEY    => $this->wxConfig['app_key_pem'],
  373.                 );
  374.                 Ilog::DEBUG("profitSharingReturn.opts: " . json_encode($opts));

  375.                 $curl_res = $this->curl->setOption($opts)->post($url,$postXML);
  376.                 Ilog::DEBUG("profitSharingReturn.curl_res: " . $curl_res);

  377.                 $ret[] = $this->toArray($curl_res);
  378.             }

  379.         }
  380.         return $ret;
  381.     }


  382.     /**
  383.      * @function 回退结果查询
  384.      * @param $order_no string 本地订单号
  385.      * @param $ticket_no string 本地票号
  386.      * @return array|false
  387.      * @throws \Exception
  388.      */
  389.     public function returnQuery($order_no,$ticket_no)
  390.     {
  391.         $ret = array();
  392.         $profitOrder = pdo_fetch("SELECT * FROM zc_ticket_orders_profitsharing WHERE order_no='{$order_no}' AND ticket_no='{$ticket_no}'");
  393.         if($profitOrder['channel']==1 and $profitOrder['state']==2)
  394.         {
  395.             $accounts = json_decode($profitOrder['profitsharing'],true);
  396.             foreach ($accounts as $account)
  397.             {
  398.                 //1.签名
  399.                 $postArr = array(
  400.                     'appid'=>$this->wxConfig['app_id'],
  401.                     'mch_id'=>$this->wxConfig['mch_id'],
  402.                     'sub_mch_id'=>$this->wxConfig['sub_mch_id'],
  403.                     'nonce_str'=>md5(time() . rand(1000, 9999)),
  404.                     'out_order_no'=>$profitOrder['order_no'].$profitOrder['ticket_no'],
  405.                     'out_return_no'=>'return_'.$profitOrder['order_no'].$profitOrder['ticket_no'].'_'.$account['account'],
  406.                     'sign_type'=>'HMAC-SHA256',
  407.                 );

  408.                 $sign = $this->sign->getSign($postArr, 'HMAC-SHA256',$this->wxConfig['md5_key']);
  409.                 $postArr['sign'] = $sign;

  410.                 //2.请求
  411.                 $url = 'https://api.mch.weixin.qq.com/pay/profitsharingreturnquery';
  412.                 $postXML = $this->toXml($postArr);
  413.                 Ilog::DEBUG("returnQuery.postXML: " . $postXML);

  414.                 $curl_res = $this->curl->post($url,$postXML);
  415.                 Ilog::DEBUG("returnQuery.curl_res: " . $curl_res);

  416.                 $ret[] = $this->toArray($curl_res);
  417.             }

  418.         }
  419.         return $ret;
  420.     }


  421.     /**
  422.      * @function 将array转为xml
  423.      * @param array $values
  424.      * @return string|bool
  425.      * @author xiewg
  426.      **/
  427.     public function toXml($values)
  428.     {
  429.         if (!is_array($values) || count($values) <= 0) {
  430.             return false;
  431.         }

  432.         $xml = "<xml>";
  433.         foreach ($values as $key => $val) {
  434.             if (is_numeric($val)) {
  435.                 $xml.="<".$key.">".$val."</".$key.">";
  436.             } else {
  437.                 $xml.="<".$key."><![CDATA[".$val."]]></".$key.">";
  438.             }
  439.         }
  440.         $xml.="</xml>";
  441.         return $xml;
  442.     }

  443.     /**
  444.      * @function 将xml转为array
  445.      * @param string $xml
  446.      * @return array|false
  447.      * @author xiewg
  448.      */
  449.     public function toArray($xml)
  450.     {
  451.         if (!$xml) {
  452.             return false;
  453.         }

  454.         // 检查xml是否合法
  455.         $xml_parser = xml_parser_create();
  456.         if (!xml_parse($xml_parser, $xml, true)) {
  457.             xml_parser_free($xml_parser);
  458.             return false;
  459.         }

  460.         //将XML转为array
  461.         //禁止引用外部xml实体
  462.         libxml_disable_entity_loader(true);

  463.         $data = json_decode(json_encode(simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);

  464.         return $data;
  465.     }


  466. }
复制代码

回复

使用道具 举报

338

主题

424

帖子

1670

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1670
 楼主| 发表于 2022-1-11 11:20:53 | 显示全部楼层
微信支付服务商下申请的商户叫子商户,也叫特约商户。只有服务商才有分账功能。首先确认下这一点,不然后面做不了
回复

使用道具 举报

338

主题

424

帖子

1670

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1670
 楼主| 发表于 2022-1-11 11:22:22 | 显示全部楼层
服务商代子商户分账:apiKey要用服务商的apiKey
回复

使用道具 举报

338

主题

424

帖子

1670

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1670
 楼主| 发表于 2022-1-11 11:23:05 | 显示全部楼层
请按照以下几点进行排查:

1、使用签名检查工具(https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=20_1)校验签名算法是否有误

2、确认秘钥是否有误(服务商模式使用服务商商户号秘钥,秘钥是在商户平台配置,如果同一商户号调用其它接口成功可排除是秘钥问题)

3、确认接口实际的请求参数与生成签名原串的参数一致,不能增加或缺少参数(可通过打印签名原串进行排查)

4、确认参数的大小写,参数名与接口文档一致

5、签名原串的参数值使用原始值,不需要encode
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|11wo.com

Copyright © 2001-2013 Comsenz Inc.Template by Comsenz Inc.All Rights Reserved.

Powered by Discuz!X3.4( 备案号:桂ICP备18000909号-1 )QQ

快速回复 返回顶部 返回列表