Jerry 6 лет назад
Родитель
Сommit
7279c22c09
4 измененных файлов с 15 добавлено и 15 удалено
  1. 1 1
      README.md
  2. 1 1
      alipay/param.go
  3. 12 12
      examples/wechat/wx_UnifiedOrder.go
  4. 1 1
      release_note.txt

+ 1 - 1
README.md

@@ -219,7 +219,7 @@ client := alipay.NewClient("2016091200494382", privateKey, false)
 // 设置支付宝请求 公共参数
 //    注意:具体设置哪些参数,根据不同的方法而不同,此处列举出所以设置参数
 client.SetLocation().                       // 设置时区,不设置或出错均为默认服务器时间
-    SetPrivateKeyType().                    // 设置 支付宝 私钥类型,alipay.PKCS1 或 alipay.PKCS1,默认 PKCS1
+    SetPrivateKeyType().                    // 设置 支付宝 私钥类型,alipay.PKCS1 或 alipay.PKCS8,默认 PKCS1
     SetAliPayRootCertSN().                  // 设置支付宝根证书SN,通过 alipay.GetRootCertSN() 获取
     SetAppCertSN().                         // 设置应用公钥证书SN,通过 alipay.GetCertSN() 获取
     SetAliPayPublicCertSN().                // 设置支付宝公钥证书SN,通过 alipay.GetCertSN() 获取

+ 1 - 1
alipay/param.go

@@ -41,7 +41,7 @@ type OpenApiRoyaltyDetailInfoPojo struct {
 	Desc         string `json:"desc,omitempty"`
 }
 
-// 设置 支付宝 私钥类型,alipay.PKCS1 或 alipay.PKCS1,默认 PKCS1
+// 设置 支付宝 私钥类型,alipay.PKCS1 或 alipay.PKCS8,默认 PKCS1
 func (a *Client) SetPrivateKeyType(t PKCSType) (client *Client) {
 	a.mu.Lock()
 	a.PrivateKeyType = t

+ 12 - 12
examples/wechat/wx_UnifiedOrder.go

@@ -24,16 +24,16 @@ func UnifiedOrder() {
 	fmt.Println("out_trade_no:", number)
 
 	//初始化参数Map
-	body := make(gopay.BodyMap)
-	body.Set("nonce_str", gopay.GetRandomString(32))
-	body.Set("body", "H5支付")
-	body.Set("out_trade_no", number)
-	body.Set("total_fee", 1)
-	body.Set("spbill_create_ip", "127.0.0.1")
-	body.Set("notify_url", "http://www.gopay.ink")
-	body.Set("trade_type", wechat.TradeType_H5)
-	body.Set("device_info", "WEB")
-	body.Set("sign_type", wechat.SignType_MD5)
+	bm := make(gopay.BodyMap)
+	bm.Set("nonce_str", gopay.GetRandomString(32))
+	bm.Set("body", "H5支付")
+	bm.Set("out_trade_no", number)
+	bm.Set("total_fee", 1)
+	bm.Set("spbill_create_ip", "127.0.0.1")
+	bm.Set("notify_url", "http://www.gopay.ink")
+	bm.Set("trade_type", wechat.TradeType_H5)
+	bm.Set("device_info", "WEB")
+	bm.Set("sign_type", wechat.SignType_MD5)
 
 	sceneInfo := make(map[string]map[string]string)
 	h5Info := make(map[string]string)
@@ -41,7 +41,7 @@ func UnifiedOrder() {
 	h5Info["wap_url"] = "http://www.gopay.ink"
 	h5Info["wap_name"] = "H5测试支付"
 	sceneInfo["h5_info"] = h5Info
-	body.Set("scene_info", sceneInfo)
+	bm.Set("scene_info", sceneInfo)
 
 	//body.Set("openid", "o0Df70H2Q0fY8JXh1aFPIRyOBgu8")
 
@@ -52,7 +52,7 @@ func UnifiedOrder() {
 	//body.Set("sign", sign)
 
 	//请求支付下单,成功后得到结果
-	wxRsp, err := client.UnifiedOrder(body)
+	wxRsp, err := client.UnifiedOrder(bm)
 	if err != nil {
 		fmt.Println("Error:", err)
 		return

+ 1 - 1
release_note.txt

@@ -1,7 +1,7 @@
 版本号:Release 1.5.6
 发布时间:2020/03/06 17:32
 修改记录:
-   (1) 支付宝:新增Client方法:client.SetPrivateKeyType(),设置 支付宝 私钥类型,alipay.PKCS1 或 alipay.PKCS1,默认 PKCS1。
+   (1) 支付宝:新增Client方法:client.SetPrivateKeyType(),设置 支付宝 私钥类型,alipay.PKCS1 或 alipay.PKCS8,默认 PKCS1。
    (2) 支付宝:修改公共方法:alipay.GetRsaSign(),增加了私钥类型参数,并将私钥的格式化操作,移动到该方法内,传入的私钥无需事先格式化。
 
 版本号:Release 1.5.5