请求单次分账接口:https://api.mch.weixin.qq.com/secapi/pay/profitsharing
POST提交设置:
$ch = curl_init ();
//超时时间
curl_setopt ( $ch, CURLOPT_TIMEOUT, $second );
curl_setopt ( $ch, CURLOPT_URL, $url );
curl_setopt ( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt ( $ch, CURLOPT_SSL_VERIFYHOST, FALSE );
//设置header
curl_setopt ( $ch, CURLOPT_HEADER, FALSE );
//要求结果为字符串且输出到屏幕上
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, TRUE );
//设置证书
//使用证书:cert 与 key 分别属于两个.pem文件
//默认格式为PEM,可以注释
curl_setopt ( $ch, CURLOPT_SSLCERTTYPE, 'PEM' );
curl_setopt ( $ch, CURLOPT_SSLCERT, dirname(__FILE__).'/cacert/apiclient_cert.pem' );
//默认格式为PEM,可以注释
curl_setopt ( $ch, CURLOPT_SSLKEYTYPE, 'PEM' );
curl_setopt ( $ch, CURLOPT_SSLKEY, dirname(__FILE__).'/cacert/apiclient_key.pem' );
//证书密码
curl_setopt($ch, CURLOPT_SSLCERTPASSWD, '1414338702');
//post提交方式
curl_setopt ( $ch, CURLOPT_POST, true );
curl_setopt ( $ch, CURLOPT_POSTFIELDS, $xml );
curl_setopt($ch, CURLOPT_VERBOSE, '1');
xml:
<xml><appid>wx**************</appid><mch_id>************</mch_id><nonce_str>21b9b96890670a9c5a08bd8a94050253</nonce_str><transaction_id>4200000546**************</transaction_id><out_order_no>**************529000001691590717324</out_order_no><receivers>[{"type":"PERSONAL_OPENID","account":"oSE36wNPQy0Gtnmvk**************","amount":1,"description":"salary"},{"type":"PERSONAL_OPENID","account":"oSE36wDHPK3wx-lL3RPCIMclKA-U","amount":1,"description":"salary"},{"type":"PERSONAL_OPENID","account":"oSE36wF2hvEp7D6JTQ3DhVoChcaM","amount":1,"description":"salary"}]</receivers><sign>D3BD02FFC1BF80C21DC0DEC81608481FBFB6BBCF1E24DED095CDBD5A6B76D1B5</sign></xml>
问题已解决。
1、想看结果,需要打印:
$ary = $sub_ledger->profitSharing($profitSharingOrders, $profitSharingAccounts);
print_r($ary);
2、想看具体内容,按F12,然后右边会有返回结果
谢谢您的回复。这个是分账的配置;
使用支付接口时,我已经加profit_sharing参数了。
您好,1,你的订单是否加上了分账标志。只有加上才可以进行分账。
2,分账需要调用双向证书。
3,https://pay.weixin.qq.com/wiki/doc/api/allocation.php?chapter=27_1&index=1核实你的参数传参。如还有问题,可以继续回复拉群给你解决。
没有报错信息吗?官方分账接口正常。
微信支付参数需要加上<profit_sharing>Y</profit_sharing>
支付时,我已经加profit_sharing参数了。