电商收付通系列⑨,分账之添加分账接收方和请求分账
大家好,我是小悟
1、添加分账接收方
1.1、介绍
电商平台可通过此接口添加分账接收方,建立分账接收方列表。后续通过发起分账请求,将电商平台下的二级商户结算后的资金,分给分账接收方列表中具体的分账接收方。
添加的分账接收方统一都在电商平台维度进行管理,其他二级商户,均可向该分账接收方列表中的接收方进行分账。
1.2、参数实体ReceiverAddParam
@Data
public class ReceiverAddParam {
private String type;
private String account;
private String name;
private String relation_type;
}
1.3、发送请求receiversAdd
public static JSONObject receiversAdd() {
ReceiverAddParam param = new ReceiverAddParam();
param.setType("MERCHANT_ID");
param.setAccount("分账接收方的商户号");
param.setName("分账接收方的名称");
param.setRelation_type("OTHERS");
String requestParam = JSON.toJSONString(param);
logger.info("receiversAdd param:{}",requestParam);
HttpResponse response = HttpUtils.v3HttpExecute("POST", ProfitsharingUrl.RECEIVERS_ADD,
"自己系统的应用名称","服务商商户号","商户API证书序列号","平台证书序列号",requestParam,"商户API证书位置.pem",null);
JSONObject body = JSONObject.parseObject(response.body());
logger.info("receiversAdd heads result:{}",response.headers());
logger.info("receiversAdd body result:{}",body);
return body;
}
1.4、结果
添加分账接收方成功 Response Body:
{"account":"1766445801","type":"MERCHANT_ID"}
1.5、问题
添加分账接收方如果返回微信用户姓名与实名不一致的提示,可能是因为:
字段name传值了,传值了就会触发微信校验用户实名是否正确,填写正确的用户姓名即可通过校验。
2、分账
2.1、介绍
微信订单支付成功后,由电商平台发起分账请求,将结算后的资金分给分账接收方。对同一笔订单最多能发起50次分账请求,每次请求最多分给50个接收方。
分账资金的冻结期默认是180天。从订单支付成功之日起,180天内需要发起分账,若180天内未发起分账,待分账资金将会自动解冻给分账方。
2.2、参数实体OrdersParam
@Data
public class OrdersParam {
private String sub_mchid;
private String transaction_id;
private String out_order_no;
private List<Receiver> receivers;
private Boolean finish;
}
2.3、参数实体Receiver
@Data
public class Receiver {
private String receiver_mchid;
private Integer amount;
private String description;
}
2.4、发送请求orders
public static JSONObject orders() {
OrdersParam param = new OrdersParam();
param.setSub_mchid("1644580761");
param.setTransaction_id("4326600000477222420921012027");
param.setOut_order_no(System.currentTimeMillis() + "");
Receiver receiver = new Receiver();
receiver.setAmount(3);
receiver.setReceiver_mchid("1766445801");
receiver.setDescription("分给商户"+receiver.getReceiver_mchid());
List<Receiver> receivers = new ArrayList<>();
receivers.add(receiver);
param.setReceivers(receivers);
param.setFinish(false);
String requestParam = JSON.toJSONString(param);
logger.info("orders param:{}",requestParam);
HttpResponse response = HttpUtils.v3HttpExecute("POST", ProfitsharingUrl.ORDERS,
"自己系统的应用名称","服务商商户号","商户API证书序列号","平台证书序列号",requestParam,"商户API证书位置.pem",null);
JSONObject body = JSONObject.parseObject(response.body());
logger.info("orders heads result:{}",response.headers());
logger.info("orders body result:{}",body);
return body;
}
2.5、结果
分账成功 Response Body:
{"order_id":"30008200140008956302003220428","out_order_no":"1524484842044","sub_mchid":"1644580761","transaction_id":"4326600000477222420921012027"}
2.6、问题
分账如果返回分账金额不足的提示,可能是因为:
1、该订单已全额退款,没有资金可以分账。
2、在微信支付中,实际收款之后微信支付会收取一定的结算手续费,在减去手续费后剩余的钱才能分账。
3、该订单已解冻,已无分账资金。
4、超过订单剩余可分账金额或者该订单已无可分账金额。
您的一键三连,是我更新的最大动力,谢谢
山水有相逢,来日皆可期,谢谢阅读,我们再会
我手中的金箍棒,上能通天,下能探海
- 点赞
- 收藏
- 关注作者
评论(0)