<xml><appid>wx7888493b589bb548</appid><mch_id>1378820302</mch_id><nonce_str>C4411Q4Dx6a1aXd8xHzdd4eDq460DeZh</nonce_str><out_order_no>SK20200118173743113186</out_order_no><receivers>[{"type":"PERSONAL_OPENID","account":"oVUjTvyQlLm_NHf17ZWbQBulZP8I","amount":1,"description":"TEST:4"}]</receivers><transaction_id>4200000508202001184570067415</transaction_id><sign_type>HMAC-SHA256</sign_type><sign>0562D988C411521FE4D18A109340EC6302E4BD6224CEDC17151D946F0C7836F5</sign></xml>
微信调用分账接口,一直返回服务器空应答( Empty reply from server)是什么原因附函数代码: //微信单次分账支付, $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的值'); return $response; }
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; }
如何解决微信分账出现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;
2020-01-18