Jerry před 7 roky
rodič
revize
2d1f502912
5 změnil soubory, kde provedl 10 přidání a 11 odebrání
  1. 0 1
      alipay_client.go
  2. 1 1
      alipay_params.go
  3. 4 0
      constant.go
  4. 1 1
      wechat_client_test.go
  5. 4 8
      wechat_params.go

+ 0 - 1
alipay_client.go

@@ -4,7 +4,6 @@ type aliPayClient struct {
 	AppId     string
 	MchId     string
 	secretKey string
-	Params    *AliPayParams
 	isProd    bool
 }
 

+ 1 - 1
alipay_params.go

@@ -5,7 +5,7 @@
 //==================================
 package gopay
 
-type AliPayParams struct {
+type aliPayParams struct {
 	NonceStr       string `xml:"nonce_str"`
 	Body           string `xml:"body"`
 	OutTradeNo     string `xml:"out_trade_no"`

+ 4 - 0
constant.go

@@ -1,6 +1,10 @@
 package gopay
 
 const (
+	null       string = ""
+	TimeLayout string = "2006-01-02 15:04:05"
+	DateLayout string = "2006-01-02"
+
 	//URL
 	wx_base_url        = "https://api.mch.weixin.qq.com/"
 	wx_sanbox_base_url = "https://api.mch.weixin.qq.com/sandboxnew/"

+ 1 - 1
wechat_client_test.go

@@ -22,7 +22,7 @@ func TestWeChatClient_UnifiedOrder(t *testing.T) {
 	number := GetRandomString(32)
 	log.Println("Number:", number)
 	body.Set("out_trade_no", number)
-	body.Set("total_fee", 10)
+	body.Set("total_fee", 1)
 	body.Set("spbill_create_ip", "180.171.101.212")
 	body.Set("notify_url", "http://www.igoogle.ink")
 	body.Set("trade_type", TradeType_JsApi)

+ 4 - 8
wechat_params.go

@@ -6,7 +6,6 @@ import (
 	"crypto/md5"
 	"crypto/sha256"
 	"encoding/hex"
-	"strconv"
 	"strings"
 )
 
@@ -53,13 +52,10 @@ func generateXml(bm BodyMap) (reqXml string) {
 		buffer.WriteString("<")
 		buffer.WriteString(k)
 		buffer.WriteString("><![CDATA[")
-		value, ok := v.(int)
-		if ok {
-			value := strconv.Itoa(value)
-			buffer.WriteString(value)
-		} else {
-			buffer.WriteString(v.(string))
-		}
+
+		valueStr := convert2String(v)
+		buffer.WriteString(valueStr)
+
 		buffer.WriteString("]]></")
 		buffer.WriteString(k)
 		buffer.WriteString(">")