Jerry 6 лет назад
Родитель
Сommit
900d9e0377
3 измененных файлов с 9 добавлено и 5 удалено
  1. 1 1
      alipay_client_test.go
  2. 2 1
      alipay_rsp.go
  3. 6 3
      alipay_server_api.go

+ 1 - 1
alipay_client_test.go

@@ -77,7 +77,7 @@ func TestAliPayClient_AliPayTradePagePay(t *testing.T) {
 	//请求参数
 	body := make(BodyMap)
 	body.Set("subject", "网站测试支付")
-	body.Set("out_trade_no", "GYWX201901301040355706100426")
+	body.Set("out_trade_no", "GYWX201901301040355706100427")
 	body.Set("quit_url", "https://www.igoogle.ink")
 	body.Set("total_amount", "88.88")
 	body.Set("product_code", "FAST_INSTANT_TRADE_PAY")

+ 2 - 1
alipay_rsp.go

@@ -14,6 +14,7 @@ type AliPayNotifyRequest struct {
 	Version           string                  `json:"version"`
 	SignType          string                  `json:"sign_type"`
 	Sign              string                  `json:"sign"`
+	AuthAppId         string                  `json:"auth_app_id"`
 	TradeNo           string                  `json:"trade_no"`
 	OutTradeNo        string                  `json:"out_trade_no"`
 	OutBizNo          string                  `json:"out_biz_no"`
@@ -40,7 +41,7 @@ type AliPayNotifyRequest struct {
 }
 
 type FundBillListInfo struct {
-	FundChannel string `json:"fund_channel"`
+	FundChannel string `json:"fundChannel"`
 	Amount      string `json:"amount"`
 }
 

+ 6 - 3
alipay_server_api.go

@@ -9,7 +9,6 @@ import (
 	"bytes"
 	"encoding/json"
 	"fmt"
-	"log"
 	"net/http"
 )
 
@@ -24,6 +23,7 @@ func ParseAliPayNotifyResult(req *http.Request) (notifyRsp *AliPayNotifyRequest,
 	notifyRsp.Version = req.FormValue("version")
 	notifyRsp.SignType = req.FormValue("sign_type")
 	notifyRsp.Sign = req.FormValue("sign")
+	notifyRsp.AuthAppId = req.FormValue("auth_app_id")
 	notifyRsp.TradeNo = req.FormValue("trade_no")
 	notifyRsp.OutTradeNo = req.FormValue("out_trade_no")
 	notifyRsp.OutBizNo = req.FormValue("out_biz_no")
@@ -45,7 +45,7 @@ func ParseAliPayNotifyResult(req *http.Request) (notifyRsp *AliPayNotifyRequest,
 	notifyRsp.GmtRefund = req.FormValue("gmt_refund")
 	notifyRsp.GmtClose = req.FormValue("gmt_close")
 	billList := req.FormValue("fund_bill_list")
-	log.Println("billList:", billList)
+	//log.Println("billList:", billList)
 	if billList != null {
 		bills := make([]FundBillListInfo, 0)
 		err = json.Unmarshal([]byte(billList), &bills)
@@ -58,7 +58,7 @@ func ParseAliPayNotifyResult(req *http.Request) (notifyRsp *AliPayNotifyRequest,
 	}
 	notifyRsp.PassbackParams = req.FormValue("passback_params")
 	detailList := req.FormValue("voucher_detail_list")
-	log.Println("detailList:", detailList)
+	//log.Println("detailList:", detailList)
 	if detailList != null {
 		details := make([]VoucherDetailListInfo, 0)
 		err = json.Unmarshal([]byte(detailList), &details)
@@ -125,6 +125,9 @@ func VerifyAliPayResultSign(aliPayPublicKey string, notifyRsp *AliPayNotifyReque
 }
 
 func jsonToString(v interface{}) (str string) {
+	if v == nil {
+		return ""
+	}
 	bs, err := json.Marshal(v)
 	if err != nil {
 		fmt.Println("err:", err)