微信支付新增企业付款和分账,添加分账接收方接口
This commit is contained in:
@@ -73,17 +73,6 @@ type RequestBase struct {
|
||||
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 {
|
||||
SetAppID(action, appID string)
|
||||
SetMchID(action, mchID string)
|
||||
@@ -275,7 +264,7 @@ type MultiProfitSharingResult struct {
|
||||
}
|
||||
|
||||
type Transfers struct {
|
||||
RequestBase2
|
||||
RequestBase
|
||||
PartnerTradeNo string `json:"partner_trade_no" xml:"partner_trade_no"`
|
||||
OpenID string `json:"openid" xml:"openid"`
|
||||
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.SetMchID(action, a.mchID)
|
||||
requestParam.SetNonceStr(utils.GetUUID())
|
||||
sigType := sigTypeSha256
|
||||
// sigType := sigTypeMd5
|
||||
requestParam.SetSignType(sigType)
|
||||
var sigType string
|
||||
if action != specialAction {
|
||||
sigType = sigTypeSha256
|
||||
requestParam.SetSignType(sigType)
|
||||
} else {
|
||||
sigType = sigTypeMd5
|
||||
}
|
||||
signStr := a.signParam(sigType, utils.Struct2FlatMap(requestParam))
|
||||
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
|
||||
func (a *API) Transfers(param *Transfers) (result *TransfersResult, err error) {
|
||||
// retVal, err := a.AccessAPI("mmpaymkttransfers/promotion/transfers", param)
|
||||
// if err == nil {
|
||||
// err = a.translateResult(retVal, &result)
|
||||
// }
|
||||
retVal, err := a.AccessAPI(specialAction, param)
|
||||
if err == nil {
|
||||
err = a.translateResult(retVal, &result)
|
||||
}
|
||||
return result, err
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ func init() {
|
||||
baseapi.Init(sugarLogger)
|
||||
certPEMBlock, _ := ioutil.ReadFile("1390686702_20190115_cert/apiclient_cert.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")
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ func TestCreateUnifiedOrder(t *testing.T) {
|
||||
OutTradeNo: orderNo,
|
||||
SpbillCreateIP: "114.114.114.114",
|
||||
TradeType: TradeTypeNative,
|
||||
TotalFee: 1,
|
||||
TotalFee: 10,
|
||||
ProfitSharing: OptYes,
|
||||
})
|
||||
if err != nil {
|
||||
@@ -105,9 +105,9 @@ func TestXml2Json(t *testing.T) {
|
||||
|
||||
func TestMultiProfitSharing(t *testing.T) {
|
||||
result, err := api.MultiProfitSharing(&MultiProfitSharing{
|
||||
TransactionID: "4200000508202002040201497455",
|
||||
OutOrderNo: "6E74BA38472F11EA8BB87824AF852DFE",
|
||||
Receivers: `[{"type":"PERSONAL_WECHATID","account":"wxid_r93tvy06srbp22","amount":10,"description":"分到个人"}]`,
|
||||
TransactionID: "4200000503202002048392355582",
|
||||
OutOrderNo: "1730C9A5473311EAAAEA7824AF852DFE",
|
||||
Receivers: `[{"type":"PERSONAL_WECHATID","account":"wxid_r93tvy06srbp22","amount":1,"description":"分到个人"}]`,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -119,7 +119,7 @@ func TestTransfers(t *testing.T) {
|
||||
orderNo := utils.GetUUID()
|
||||
result, err := api.Transfers(&Transfers{
|
||||
PartnerTradeNo: orderNo,
|
||||
OpenID: "oylsKxEeRKJSdo1OE2aA1fRloaN4",
|
||||
OpenID: "oYN_usv1RPvrSxCvo1WsbwI8lZa0",
|
||||
CheckName: "FORCE_CHECK",
|
||||
ReUserName: "苏尹岚",
|
||||
Amount: 100,
|
||||
|
||||
Reference in New Issue
Block a user