微信支付新增企业付款和分账,添加分账接收方接口
This commit is contained in:
@@ -73,17 +73,6 @@ type RequestBase struct {
|
|||||||
SignType string `json:"sign_type,omitempty" xml:"sign_type,omitempty"`
|
SignType string `json:"sign_type,omitempty" xml:"sign_type,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type RequestBase2 struct {
|
|
||||||
XMLName xml.Name `json:"-" xml:"xml"`
|
|
||||||
|
|
||||||
AppID string `json:"mch_appid" xml:"mch_appid"`
|
|
||||||
DeviceInfo string `json:"device_info,omitempty" xml:"device_info,omitempty"`
|
|
||||||
MchID string `json:"mchid" xml:"mchid"`
|
|
||||||
NonceStr string `json:"nonce_str" xml:"nonce_str"`
|
|
||||||
Sign string `json:"sign" xml:"sign"`
|
|
||||||
SignType string `json:"sign_type,omitempty" xml:"sign_type,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type IRequestBase interface {
|
type IRequestBase interface {
|
||||||
SetAppID(action, appID string)
|
SetAppID(action, appID string)
|
||||||
SetMchID(action, mchID string)
|
SetMchID(action, mchID string)
|
||||||
@@ -275,7 +264,7 @@ type MultiProfitSharingResult struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Transfers struct {
|
type Transfers struct {
|
||||||
RequestBase2
|
RequestBase
|
||||||
PartnerTradeNo string `json:"partner_trade_no" xml:"partner_trade_no"`
|
PartnerTradeNo string `json:"partner_trade_no" xml:"partner_trade_no"`
|
||||||
OpenID string `json:"openid" xml:"openid"`
|
OpenID string `json:"openid" xml:"openid"`
|
||||||
CheckName string `json:"check_name" xml:"check_name"`
|
CheckName string `json:"check_name" xml:"check_name"`
|
||||||
@@ -402,9 +391,13 @@ func (a *API) AccessAPI(action string, requestParam IRequestBase) (retVal map[st
|
|||||||
requestParam.SetAppID(action, a.appID)
|
requestParam.SetAppID(action, a.appID)
|
||||||
requestParam.SetMchID(action, a.mchID)
|
requestParam.SetMchID(action, a.mchID)
|
||||||
requestParam.SetNonceStr(utils.GetUUID())
|
requestParam.SetNonceStr(utils.GetUUID())
|
||||||
sigType := sigTypeSha256
|
var sigType string
|
||||||
// sigType := sigTypeMd5
|
if action != specialAction {
|
||||||
requestParam.SetSignType(sigType)
|
sigType = sigTypeSha256
|
||||||
|
requestParam.SetSignType(sigType)
|
||||||
|
} else {
|
||||||
|
sigType = sigTypeMd5
|
||||||
|
}
|
||||||
signStr := a.signParam(sigType, utils.Struct2FlatMap(requestParam))
|
signStr := a.signParam(sigType, utils.Struct2FlatMap(requestParam))
|
||||||
requestParam.SetSign(signStr)
|
requestParam.SetSign(signStr)
|
||||||
|
|
||||||
@@ -545,10 +538,10 @@ func (a *API) MultiProfitSharing(param *MultiProfitSharing) (result *MultiProfit
|
|||||||
//企业付款
|
//企业付款
|
||||||
//https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=14_2
|
//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) {
|
func (a *API) Transfers(param *Transfers) (result *TransfersResult, err error) {
|
||||||
// retVal, err := a.AccessAPI("mmpaymkttransfers/promotion/transfers", param)
|
retVal, err := a.AccessAPI(specialAction, param)
|
||||||
// if err == nil {
|
if err == nil {
|
||||||
// err = a.translateResult(retVal, &result)
|
err = a.translateResult(retVal, &result)
|
||||||
// }
|
}
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ func init() {
|
|||||||
baseapi.Init(sugarLogger)
|
baseapi.Init(sugarLogger)
|
||||||
certPEMBlock, _ := ioutil.ReadFile("1390686702_20190115_cert/apiclient_cert.pem")
|
certPEMBlock, _ := ioutil.ReadFile("1390686702_20190115_cert/apiclient_cert.pem")
|
||||||
keyPEMBlock, _ := ioutil.ReadFile("1390686702_20190115_cert/apiclient_key.pem")
|
keyPEMBlock, _ := ioutil.ReadFile("1390686702_20190115_cert/apiclient_key.pem")
|
||||||
api = NewWithCertificate("wx4b5930c13f8b1170", "XKJPOIHJ233adf01KJIXlIeQDSDKFJAD", "1390686702", certPEMBlock, keyPEMBlock)
|
api = NewWithCertificate("wx2bb99eb5d2c9b82c", "XKJPOIHJ233adf01KJIXlIeQDSDKFJAD", "1390686702", certPEMBlock, keyPEMBlock)
|
||||||
// api = New("wx4b5930c13f8b1170", "XKJPOIHJ233adf01KJIXlIeQDSDKFJAD", "1390686702")
|
// api = New("wx4b5930c13f8b1170", "XKJPOIHJ233adf01KJIXlIeQDSDKFJAD", "1390686702")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ func TestCreateUnifiedOrder(t *testing.T) {
|
|||||||
OutTradeNo: orderNo,
|
OutTradeNo: orderNo,
|
||||||
SpbillCreateIP: "114.114.114.114",
|
SpbillCreateIP: "114.114.114.114",
|
||||||
TradeType: TradeTypeNative,
|
TradeType: TradeTypeNative,
|
||||||
TotalFee: 1,
|
TotalFee: 10,
|
||||||
ProfitSharing: OptYes,
|
ProfitSharing: OptYes,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -105,9 +105,9 @@ func TestXml2Json(t *testing.T) {
|
|||||||
|
|
||||||
func TestMultiProfitSharing(t *testing.T) {
|
func TestMultiProfitSharing(t *testing.T) {
|
||||||
result, err := api.MultiProfitSharing(&MultiProfitSharing{
|
result, err := api.MultiProfitSharing(&MultiProfitSharing{
|
||||||
TransactionID: "4200000508202002040201497455",
|
TransactionID: "4200000503202002048392355582",
|
||||||
OutOrderNo: "6E74BA38472F11EA8BB87824AF852DFE",
|
OutOrderNo: "1730C9A5473311EAAAEA7824AF852DFE",
|
||||||
Receivers: `[{"type":"PERSONAL_WECHATID","account":"wxid_r93tvy06srbp22","amount":10,"description":"分到个人"}]`,
|
Receivers: `[{"type":"PERSONAL_WECHATID","account":"wxid_r93tvy06srbp22","amount":1,"description":"分到个人"}]`,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
@@ -119,7 +119,7 @@ func TestTransfers(t *testing.T) {
|
|||||||
orderNo := utils.GetUUID()
|
orderNo := utils.GetUUID()
|
||||||
result, err := api.Transfers(&Transfers{
|
result, err := api.Transfers(&Transfers{
|
||||||
PartnerTradeNo: orderNo,
|
PartnerTradeNo: orderNo,
|
||||||
OpenID: "oylsKxEeRKJSdo1OE2aA1fRloaN4",
|
OpenID: "oYN_usv1RPvrSxCvo1WsbwI8lZa0",
|
||||||
CheckName: "FORCE_CHECK",
|
CheckName: "FORCE_CHECK",
|
||||||
ReUserName: "苏尹岚",
|
ReUserName: "苏尹岚",
|
||||||
Amount: 100,
|
Amount: 100,
|
||||||
|
|||||||
Reference in New Issue
Block a user