收藏
回答

如何解决微信分账出现Empty reply from server问题?

    $dat='<xml>
   <appid>wx35ec6d7f8a84088d</appid>
   <mch_id>1541299971</mch_id>
   <nonce_str>'.random(32).'</nonce_str>
   <out_order_no>ME20191105131500813628</out_order_no>
   <transaction_id>4200000427201911052688896404</transaction_id>
   <sign>'.strtoupper(md5(trim($string1))).'</sign>
   <sign_type>HMAC-SHA256</sign_type>
   <receivers>
[
{
       "type"=>"PERSONAL_WECHATID",
     "account"=>"zmyzmy812",
     "amount"=>5,
     "description"=>"测试分到个人"
}
]
</receivers>
</xml>';
     $url="https://api.mch.weixin.qq.com/secapi/pay/profitsharing";
     $response = ihttp_post($url, $dat);
//    $response = $this->test($url,$dat);
     return $response;


回答关注问题邀请回答
收藏

2 个回答

  • 深蓝
    深蓝
    2020-01-18
    请问楼主的这个问题有解决吗?我也遇到同样的问题,不知道什么原因。
    //微信单次分账支付, $receive 分账接收方列表
    public function wechat_profitsharing_buid($params, $wechat,$receive){
    		global $_W;
    		load()->func("communication");
    		$wOpt = array( );
    		$package = array( );
    		// $platform_amount = ($params['fee'] - array_sum(array_column($receive, 'amount')));//平台分成 = 订单总金额 - 分给接收方的分成
    		// $platform = array('type'=>'MERCHANT_ID','account'=>$wechat["mch_id"],'amount'=>$platform_amount,'description'=>'分给平台');//平台
    		$package["mch_id"] = trim($wechat["mch_id"]);//商户号
    		$package["appid"] = trim($wechat["appid"]);//公众账号ID
    		$package["nonce_str"] = random(32);//32位随机字符串
    		$package["transaction_id"] = $params['transaction_id'];//微信支付订单号
    		$package["out_order_no"] = trim($params["tid"]);//商户分账单号
    		$package['receivers']=json_encode(array($receive));//接收会员列表,包含字段:type、account、amount、description
    		ksort($package, SORT_STRING);
    		$string1 = "";
    		foreach( $package as $key => $v ) 
    		{
    			if( empty($v) ) 
    			{
    				continue;
    			}
    			$string1 .= (string) $key . "=" . $v . "&";
    		}
    		$string1 .= "key=" . $wechat["apikey"];
    		$package['sign_type'] = 'HMAC-SHA256';//签名类型,目前只支持HMAC-SHA256
    		$package["sign"] = strtoupper(hash_hmac('sha256',trim($string1),$wechat["apikey"]));//sha256签名,
    		flog($package,'common.wechat_profitsharing_buid.log','ewei_shop.model','package封装请求的参数');
    		$dat = array2xml($package);
    		$response = ihttp_request("https://api.mch.weixin.qq.com/secapi/pay/profitsharing", $dat);
    		
    		flog($response,'common.wechat_profitsharing_buid.log','ewei_shop.model','RESPONSE的值');
    		if( is_error($response) ) 
    		{
    			return $response;
    		}
    		libxml_disable_entity_loader(true);
    		$xml = @simplexml_load_string(@trim($response["content"]), "SimpleXMLElement", LIBXML_NOCDATA);
    		if( strval($xml->return_code) == "FAIL" ) 
    		{
    			return error(-1, strval($xml->return_msg));
    		}
    		if( strval($xml->result_code) == "FAIL" ) 
    		{
    			return error(-1, strval($xml->err_code) . ": " . strval($xml->err_code_des));
    		}
    		$prepayid = $xml->prepay_id;
    		$wOpt["appId"] = trim($wechat["appid"]);
    		$wOpt["timeStamp"] = TIMESTAMP . "";
    		$wOpt["nonceStr"] = random(32);
    		$wOpt["package"] = "prepay_id=" . $prepayid;
    		$wOpt["signType"] = "MD5";
    		ksort($wOpt, SORT_STRING);
    		$string = "";
    		foreach( $wOpt as $key => $v ) 
    		{
    			$string .= (string) $key . "=" . $v . "&";
    		}
    		$string .= "key=" . $wechat["apikey"];
    		$wOpt["paySign"] = strtoupper(md5(trim($string)));
    		return $wOpt;
    }
    
    2020-01-18
    有用
    回复
  • 微信支付技术助手1
    微信支付技术助手1
    2019-11-08

    这应该是你本地代码的问题。不是接口的错误。请仔细核对检查代码

    2019-11-08
    有用
    回复 2
    • 2019-12-18
      能提供一份demo吗
      2019-12-18
      回复
    • 2019-12-18
      关于微信分账的 php版本的demo
      2019-12-18
      回复
登录 后发表内容