冲突解决
This commit is contained in:
@@ -32,6 +32,8 @@ const (
|
||||
sigTypeKey = "sign_type"
|
||||
sigTypeMd5 = "MD5"
|
||||
sigTypeSha256 = "HMAC-SHA256"
|
||||
|
||||
specialAction = "mmpaymkttransfers/promotion/transfers"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -59,9 +61,13 @@ type API struct {
|
||||
type RequestBase struct {
|
||||
XMLName xml.Name `json:"-" xml:"xml"`
|
||||
|
||||
AppID string `json:"appid" xml:"appid"`
|
||||
AppID string `json:"appid" xml:"appid,omitempty"`
|
||||
MchID string `json:"mch_id" xml:"mch_id,omitempty"`
|
||||
// 企业付款基础参数不一样
|
||||
AppID2 string `json:"mch_appid,omitempty" xml:"mch_appid,omitempty"`
|
||||
MchID2 string `json:"mchid,omitempty" xml:"mchid,omitempty"`
|
||||
|
||||
DeviceInfo string `json:"device_info,omitempty" xml:"device_info,omitempty"`
|
||||
MchID string `json:"mch_id" xml:"mch_id"`
|
||||
NonceStr string `json:"nonce_str" xml:"nonce_str"`
|
||||
Sign string `json:"sign" xml:"sign"`
|
||||
SignType string `json:"sign_type,omitempty" xml:"sign_type,omitempty"`
|
||||
@@ -79,19 +85,27 @@ type RequestBase2 struct {
|
||||
}
|
||||
|
||||
type IRequestBase interface {
|
||||
SetAppID(appID string)
|
||||
SetMchID(mchID string)
|
||||
SetAppID(action, appID string)
|
||||
SetMchID(action, mchID string)
|
||||
SetNonceStr(nonceStr string)
|
||||
SetSign(sign string)
|
||||
SetSignType(signType string)
|
||||
}
|
||||
|
||||
func (r *RequestBase) SetAppID(appID string) {
|
||||
r.AppID = appID
|
||||
func (r *RequestBase) SetAppID(action, appID string) {
|
||||
if action != specialAction {
|
||||
r.AppID = appID
|
||||
} else {
|
||||
r.AppID2 = appID
|
||||
}
|
||||
}
|
||||
|
||||
func (r *RequestBase) SetMchID(mchID string) {
|
||||
r.MchID = mchID
|
||||
func (r *RequestBase) SetMchID(action, mchID string) {
|
||||
if action != specialAction {
|
||||
r.MchID = mchID
|
||||
} else {
|
||||
r.MchID2 = mchID
|
||||
}
|
||||
}
|
||||
|
||||
func (r *RequestBase) SetNonceStr(nonceStr string) {
|
||||
@@ -385,8 +399,8 @@ func mustMarshalXML(obj interface{}) []byte {
|
||||
}
|
||||
|
||||
func (a *API) AccessAPI(action string, requestParam IRequestBase) (retVal map[string]interface{}, err error) {
|
||||
requestParam.SetAppID(a.appID)
|
||||
requestParam.SetMchID(a.mchID)
|
||||
requestParam.SetAppID(action, a.appID)
|
||||
requestParam.SetMchID(action, a.mchID)
|
||||
requestParam.SetNonceStr(utils.GetUUID())
|
||||
sigType := sigTypeSha256
|
||||
// sigType := sigTypeMd5
|
||||
|
||||
@@ -44,7 +44,8 @@ func TestCreateUnifiedOrder(t *testing.T) {
|
||||
OutTradeNo: orderNo,
|
||||
SpbillCreateIP: "114.114.114.114",
|
||||
TradeType: TradeTypeNative,
|
||||
TotalFee: 2,
|
||||
TotalFee: 1,
|
||||
ProfitSharing: OptYes,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -64,11 +65,11 @@ func TestCloseOrder(t *testing.T) {
|
||||
func TestPayRefund(t *testing.T) {
|
||||
result, err := api.PayRefund(&PayRefundParam{
|
||||
TransactionID: "",
|
||||
OutTradeNo: "8E0DD6260B7511EA908C186590E02977",
|
||||
OutTradeNo: "88316516447981",
|
||||
NotifyURL: "http://callback.test.jxc4.com/wxpay/msg/",
|
||||
OutRefundNo: utils.GetUUID(),
|
||||
TotalFee: 1,
|
||||
RefundFee: 1,
|
||||
OutRefundNo: "88316516447981",
|
||||
TotalFee: 8987,
|
||||
RefundFee: 8987,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
Reference in New Issue
Block a user