分账

添加接收方

  1. // 添加接收方。多次调用表示添加多个接收方
  2. paymentService.ProfitSharing.AddReceiver(
  3. ctx,
  4. "[type]",
  5. "[account]",
  6. "[name]",
  7. "[relation_type]",
  8. "[custom_relation]",
  9. )

微信官方文档: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_8.shtml

删除接收方

  1. paymentService.ProfitSharing.DeleteReceiver(ctx,"[type]", "[account]")

微信官方文档:https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_9.shtml

单次分账

  1. paymentService.ProfitSharing.Share(
  2. ctx,
  3. &request.RequestShare{
  4. AppID: "[app_id]",
  5. TransactionID: "[transaction_id]" // OutTradeNo 和 TransactionID 二选一
  6. OutOrderNO: "[out_order_no]",
  7. Receivers: []*request.Receiver{
  8. &request.Receiver{
  9. Type: "MERCHANT_ID",
  10. Account: "86693852",
  11. Name: "hu89ohu89ohu89o",
  12. Amount: 888,
  13. Description: "分给商户A",
  14. }
  15. }),
  16. UnfreezeUnSplit: false,
  17. }
  18. )

微信官方文档:https://pay.weixin.qq.com/wiki/doc/api/allocation.php?chapter=27_1&index=1

分账查询

  1. paymentService.ProfitSharing.Query(ctx,"[transaction_id]", "[out_trade_no]")

微信官方文档: https://pay.weixin.qq.com/wiki/doc/api/allocation.php?chapter=27_2&index=3

分帐回退

  1. paymentService.ProfitSharing.Return(ctx, &request.RequestShareReturn{
  2. AppID: "[app_id]",
  3. MchID: "[mch_id]"
  4. OutOrderNo: "[transaction_id]",
  5. OutReturnNo: "[out_trade_no]"
  6. ReturnAccountType: "[return_account_type]"
  7. ReturnAccount: "[return_account]"
  8. ReturnAmount: "[return_amount]"
  9. Description: "[description]"
  10. })

微信官方文档: https://pay.weixin.qq.com/wiki/doc/api/allocation.php?chapter=27_7&index=8