From dfb7090fb119ad85ef49ff7047020754698b899d Mon Sep 17 00:00:00 2001 From: jiaoboxiang Date: Fri, 16 Sep 2022 11:04:45 +0800 Subject: [PATCH] add Reverse: for v1.3.6 --- md/join.go | 17 +++++++++++++++++ pay/pay_by_join.go | 21 +++++++++++---------- test/join_pay_test.go | 2 +- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/md/join.go b/md/join.go index d34f483..7be36e8 100644 --- a/md/join.go +++ b/md/join.go @@ -53,3 +53,20 @@ type JoinPayReq struct { 商户端终端设备 IP 地址。微信/支付宝被扫支付必填(即当q1_FrpCode= ALIPAY_CARD、WEIXIN_CARD);否"` Hmac string `json:"hmac" label:"签名数据;参见签名机制;是"` } + +type JoinPayResponse struct { + R7TrxNo string `json:"r7_TrxNo"` + RbCodeMsg string `json:"rb_CodeMsg"` + R2OrderNo string `json:"r2_OrderNo"` + R3Amount string `json:"r3_Amount"` + R6FrpCode string `json:"r6_FrpCode"` + RcResult string `json:"rc_Result"` + RaCode int `json:"ra_Code"` + Hmac string `json:"hmac"` + RdPic string `json:"rd_Pic"` + R4Cur string `json:"r4_Cur"` + R5Mp string `json:"r5_Mp"` + R8MerchantBankCode string `json:"r8_MerchantBankCode"` + R0Version string `json:"r0_Version"` + R1MerchantNo string `json:"r1_MerchantNo"` +} \ No newline at end of file diff --git a/pay/pay_by_join.go b/pay/pay_by_join.go index 767625d..f97599f 100644 --- a/pay/pay_by_join.go +++ b/pay/pay_by_join.go @@ -9,19 +9,20 @@ import ( "strings" ) -func UniPayByJoin(payParams *md.JoinPayReq, paySecretKey string,isPrd bool) (map[string]interface{}, error) { +func UniPayByJoin(payParams *md.JoinPayReq, paySecretKey string,isPrd bool) (*md.JoinPayResponse, error) { payParams.P0Version = "2.1" - //payParams.P1MerchantNo = md.PayTestAccount + payParams.P1MerchantNo = md.PayTestAccount payParams.P4Cur = "1" - //payParams.P2OrderNo = "9527" - //payParams.P3Amount = "10" - //payParams.P5ProductName = "测试商品" - //payParams.P9NotifyUrl = "AB|https://www.baidu.com" + payParams.P2OrderNo = "95271" + payParams.P3Amount = "0.1" + payParams.P5ProductName = "测试商品" + payParams.P9NotifyUrl = "AB|https://www.baidu.com" //--交易类型//payParams.Q1FrpCode = md.Q1FrpCodeWEIXINPAYH5 - //payParams.Q1FrpCode = md.Q1FrpCodeALIPAY + payParams.Q1FrpCode = md.Q1FrpCodeALIPAY //原始微信AppId//payParams.Q7AppId = "gh_5a236de9850a" //微信AppId//payParams.Q7AppId = "wx5bb10bb79cb5da1c" - //商家报备编号(分微信和支付宝的);支付宝的://payParams.QATradeMerchantNo = md.PayTestAliAccount + //商家报备编号(分微信和支付宝的);支付宝的: + payParams.QATradeMerchantNo = md.PayTestAliAccount //商家报备编号(分微信和支付宝的);微信的://payParams.QATradeMerchantNo = md.PayTestWeChatAccount postData := url.Values{} creatHmac(payParams,paySecretKey, &postData) @@ -34,9 +35,9 @@ func UniPayByJoin(payParams *md.JoinPayReq, paySecretKey string,isPrd bool) (map } defer response.Body.Close() body, err := ioutil.ReadAll(response.Body) - resp := make(map[string]interface{}) + resp := md.JoinPayResponse{} zhios_pay_utils.Unserialize(body, &resp) - return resp, err + return &resp, err } func creatHmac(payParams *md.JoinPayReq,paySecretKey string, postData *url.Values) { diff --git a/test/join_pay_test.go b/test/join_pay_test.go index 12b7664..dd95946 100644 --- a/test/join_pay_test.go +++ b/test/join_pay_test.go @@ -7,5 +7,5 @@ import ( ) func TestUniPayByJoin(t *testing.T) { - pay.UniPayByJoin(&md.JoinPayReq{}, false) + pay.UniPayByJoin(&md.JoinPayReq{},"a12ceace4cc5423eae32b4626adf56c9" ,false) }