微信支付新增删除分账方和分账回退接口
This commit is contained in:
@@ -291,12 +291,12 @@ type TransfersResult struct {
|
||||
PaymentTime string `json:"payment_time" xml:"payment_time"`
|
||||
}
|
||||
|
||||
type AddProfitSharingReceiver struct {
|
||||
type ProfitSharingReceiver struct {
|
||||
RequestBase
|
||||
Receiver CData `json:"receiver" xml:"receiver"`
|
||||
}
|
||||
|
||||
type AddProfitSharingReceiverResult struct {
|
||||
type ProfitSharingReceiverResult struct {
|
||||
ReturnCode string `json:"return_code" xml:"return_code"`
|
||||
ReturnMsg string `json:"return_msg" xml:"return_msg"`
|
||||
|
||||
@@ -310,6 +310,39 @@ type AddProfitSharingReceiverResult struct {
|
||||
Receiver string `json:"receiver" xml:"receiver"`
|
||||
}
|
||||
|
||||
type ReturnProfitSharing struct {
|
||||
RequestBase
|
||||
OrderID string `json:"order_id" xml:"order_id"`
|
||||
OutOrderNo string `json:"out_order_no" xml:"out_order_no"`
|
||||
OutReturnNo string `json:"out_return_no" xml:"out_return_no"`
|
||||
ReturnAccountType string `json:"return_account_type" xml:"return_account_type"`
|
||||
ReturnAccount string `json:"return_account" xml:"return_account"`
|
||||
ReturnAmount int `json:"return_amount" xml:"return_amount"`
|
||||
Description string `json:"description" xml:"description"`
|
||||
}
|
||||
|
||||
type ReturnProfitSharingResult struct {
|
||||
ReturnCode string `json:"return_code" xml:"return_code"`
|
||||
ErrorCode string `json:"error_code,omitempty" xml:"error_code,omitempty"`
|
||||
ErrorMsg string `json:"error_msg,omitempty" xml:"error_msg,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"`
|
||||
OrderID string `json:"order_id" xml:"order_id"`
|
||||
OutOrderNo string `json:"out_order_no" xml:"out_order_no"`
|
||||
OutReturnNo string `json:"out_return_no" xml:"out_return_no"`
|
||||
ReturnNo string `json:"return_no" xml:"return_no"`
|
||||
ReturnAccountType string `json:"return_account_type" xml:"return_account_type"`
|
||||
ReturnAccount string `json:"return_account" xml:"return_account"`
|
||||
ReturnAmount int `json:"return_amount" xml:"return_amount"`
|
||||
Description string `json:"description" xml:"description"`
|
||||
Result string `json:"result" xml:"result"`
|
||||
FailReason string `json:"fail_reason,omitempty" xml:"fail_reason,omitempty"`
|
||||
FinishTime string `json:"finish_time" xml:"finish_time"`
|
||||
}
|
||||
|
||||
func New(appID, appKey, mchID string, config ...*platformapi.APIConfig) *API {
|
||||
curConfig := platformapi.DefAPIConfig
|
||||
if len(config) > 0 {
|
||||
@@ -547,10 +580,30 @@ func (a *API) Transfers(param *Transfers) (result *TransfersResult, err error) {
|
||||
|
||||
//添加分账接收方
|
||||
//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) {
|
||||
func (a *API) AddProfitSharingReceiver(param *ProfitSharingReceiver) (result *ProfitSharingReceiverResult, err error) {
|
||||
retVal, err := a.AccessAPI("pay/profitsharingaddreceiver", param)
|
||||
if err == nil {
|
||||
err = a.translateResult(retVal, &result)
|
||||
}
|
||||
return result, err
|
||||
}
|
||||
|
||||
//删除分账接收方
|
||||
//https://pay.weixin.qq.com/wiki/doc/api/allocation.php?chapter=27_4&index=5
|
||||
func (a *API) DeleteProfitSharingReceiver(param *ProfitSharingReceiver) (result *ProfitSharingReceiverResult, err error) {
|
||||
retVal, err := a.AccessAPI("pay/profitsharingremovereceiver", param)
|
||||
if err == nil {
|
||||
err = a.translateResult(retVal, &result)
|
||||
}
|
||||
return result, err
|
||||
}
|
||||
|
||||
//分账回退
|
||||
//https://pay.weixin.qq.com/wiki/doc/api/allocation.php?chapter=27_7&index=7
|
||||
func (a *API) ReturnProfitSharing(param *ReturnProfitSharing) (result *ReturnProfitSharingResult, err error) {
|
||||
retVal, err := a.AccessAPI("pay/profitsharingreturn", param)
|
||||
if err == nil {
|
||||
err = a.translateResult(retVal, &result)
|
||||
}
|
||||
return result, err
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ func TestTransfers(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddProfitSharingReceiver(t *testing.T) {
|
||||
result, err := api.AddProfitSharingReceiver(&AddProfitSharingReceiver{
|
||||
result, err := api.AddProfitSharingReceiver(&ProfitSharingReceiver{
|
||||
Receiver: `{
|
||||
"type": "PERSONAL_WECHATID",
|
||||
"account":"wxid_r93tvy06srbp22",
|
||||
@@ -146,3 +146,16 @@ func TestAddProfitSharingReceiver(t *testing.T) {
|
||||
}
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
func TestDeleteProfitSharingReceiver(t *testing.T) {
|
||||
result, err := api.DeleteProfitSharingReceiver(&ProfitSharingReceiver{
|
||||
Receiver: `{
|
||||
"type": "PERSONAL_WECHATID",
|
||||
"account":"wxid_r93tvy06srbp22"
|
||||
}`,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user