微信分账接口
This commit is contained in:
@@ -288,6 +288,25 @@ type TransfersResult struct {
|
||||
PaymentTime string `json:"payment_time" xml:"payment_time"`
|
||||
}
|
||||
|
||||
type AddProfitSharingReceiver struct {
|
||||
RequestBase
|
||||
Receiver CData `json:"receiver" xml:"receiver"`
|
||||
}
|
||||
|
||||
type AddProfitSharingReceiverResult struct {
|
||||
ReturnCode string `json:"return_code" xml:"return_code"`
|
||||
ReturnMsg string `json:"return_msg" xml:"return_msg"`
|
||||
|
||||
ResultCode string `json:"result_code" xml:"result_code"`
|
||||
ErrCode string `json:"err_code,omitempty" xml:"err_code,omitempty"`
|
||||
ErrCodeDes string `json:"err_code_des,omitempty" xml:"err_code_des,omitempty"`
|
||||
AppID string `json:"appid" xml:"appid"`
|
||||
MchID string `json:"mch_id" xml:"mch_id"`
|
||||
NonceStr string `json:"nonce_str" xml:"nonce_str"`
|
||||
Sign string `json:"sign" xml:"sign"`
|
||||
Receiver string `json:"receiver" xml:"receiver"`
|
||||
}
|
||||
|
||||
func New(appID, appKey, mchID string, config ...*platformapi.APIConfig) *API {
|
||||
curConfig := platformapi.DefAPIConfig
|
||||
if len(config) > 0 {
|
||||
@@ -512,7 +531,17 @@ func (a *API) MultiProfitSharing(param *MultiProfitSharing) (result *MultiProfit
|
||||
//企业付款
|
||||
//https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=14_2
|
||||
func (a *API) Transfers(param *Transfers) (result *TransfersResult, err error) {
|
||||
retVal, err := a.AccessAPI("mmpaymkttransfers/promotion/transfers", param)
|
||||
// retVal, err := a.AccessAPI("mmpaymkttransfers/promotion/transfers", param)
|
||||
// if err == nil {
|
||||
// err = a.translateResult(retVal, &result)
|
||||
// }
|
||||
return result, err
|
||||
}
|
||||
|
||||
//添加分账接收方
|
||||
//https://pay.weixin.qq.com/wiki/doc/api/allocation.php?chapter=27_3&index=4
|
||||
func (a *API) AddProfitSharingReceiver(param *AddProfitSharingReceiver) (result *AddProfitSharingReceiverResult, err error) {
|
||||
retVal, err := a.AccessAPI("pay/profitsharingaddreceiver", param)
|
||||
if err == nil {
|
||||
err = a.translateResult(retVal, &result)
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ func TestCreateUnifiedOrder(t *testing.T) {
|
||||
OutTradeNo: orderNo,
|
||||
SpbillCreateIP: "114.114.114.114",
|
||||
TradeType: TradeTypeNative,
|
||||
TotalFee: 1,
|
||||
TotalFee: 2,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -101,3 +101,47 @@ func TestXml2Json(t *testing.T) {
|
||||
}
|
||||
t.Log(utils.Format4Output(mv, false))
|
||||
}
|
||||
|
||||
func TestMultiProfitSharing(t *testing.T) {
|
||||
result, err := api.MultiProfitSharing(&MultiProfitSharing{
|
||||
TransactionID: "4200000508202002040201497455",
|
||||
OutOrderNo: "6E74BA38472F11EA8BB87824AF852DFE",
|
||||
Receivers: `[{"type":"PERSONAL_WECHATID","account":"wxid_r93tvy06srbp22","amount":10,"description":"分到个人"}]`,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
func TestTransfers(t *testing.T) {
|
||||
orderNo := utils.GetUUID()
|
||||
result, err := api.Transfers(&Transfers{
|
||||
PartnerTradeNo: orderNo,
|
||||
OpenID: "oylsKxEeRKJSdo1OE2aA1fRloaN4",
|
||||
CheckName: "FORCE_CHECK",
|
||||
ReUserName: "苏尹岚",
|
||||
Amount: 100,
|
||||
Desc: "测试",
|
||||
SpbillCreateIP: "114.114.114.114",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
func TestAddProfitSharingReceiver(t *testing.T) {
|
||||
result, err := api.AddProfitSharingReceiver(&AddProfitSharingReceiver{
|
||||
Receiver: `{
|
||||
"type": "PERSONAL_WECHATID",
|
||||
"account":"wxid_r93tvy06srbp22",
|
||||
"name": "苏尹岚",
|
||||
"relation_type": "STAFF"
|
||||
}`,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user