Parcourir la source

Merge remote-tracking branch 'origin/master'

Jerry il y a 6 ans
Parent
commit
caff0fb8d4
5 fichiers modifiés avec 30 ajouts et 21 suppressions
  1. 9 8
      README.md
  2. 6 5
      README_EN.md
  3. 1 1
      alipay_client.go
  4. 13 6
      alipay_service_api.go
  5. 1 1
      constant.go

+ 9 - 8
README.md

@@ -7,11 +7,12 @@
 
 微信和支付宝的Golang版本SDK
 
-[![](https://img.shields.io/badge/Author-Jerry-blue.svg)](https://www.gopay.ink)
-[![](https://img.shields.io/badge/Golang-1.11+-brightgreen.svg)](https://golang.org)
-[![](https://img.shields.io/badge/Version-1.3.2-blue.svg)](https://github.com/iGoogle-ink/gopay)
-[![](https://api.travis-ci.org/iGoogle-ink/gopay.svg?branch=master)]()
-[![](https://img.shields.io/badge/License-Apache_2-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0)
+![Author](https://img.shields.io/badge/author-Jerry-blue.svg)
+[![Golang](https://img.shields.io/badge/golang-1.11+-brightgreen.svg)](https://golang.org)
+[![Godoc](https://img.shields.io/badge/godoc-reference-informational.svg)](https://godoc.org/github.com/iGoogle-ink/gopay)
+![GitHub release (latest by date)](https://img.shields.io/github/v/release/iGoogle-ink/gopay)
+![Travis (.org)](https://img.shields.io/travis/iGoogle-ink/gopay)
+![License](https://img.shields.io/github/license/iGoogle-ink/gopay)
 
 ### 微信Client
 
@@ -282,7 +283,7 @@ timeStamp := strconv.FormatInt(time.Now().Unix(), 10)
 prepayId := "prepay_id=" + wxRsp.PrepayId   //此处的 wxRsp.PrepayId ,统一下单成功后得到
 //获取微信小程序支付的 paySign
 //    appId:APPID
-//    nonceStr:随字符串
+//    nonceStr:随字符串
 //    prepayId:统一下单成功后得到的值
 //    signType:签名方式,务必与统一下单时用的签名方式一致
 //    timeStamp:时间
@@ -295,7 +296,7 @@ timeStamp := strconv.FormatInt(time.Now().Unix(), 10)
 //注意:package 参数因为是固定值,无需开发者再传入
 //    appId:APPID
 //    partnerid:partnerid
-//    nonceStr:随字符串
+//    nonceStr:随字符串
 //    prepayId:统一下单成功后得到的值
 //    signType:签名方式,务必与统一下单时用的签名方式一致
 //    timeStamp:时间
@@ -307,7 +308,7 @@ timeStamp := strconv.FormatInt(time.Now().Unix(), 10)
 packages := "prepay_id=" + wxRsp.PrepayId   //此处的 wxRsp.PrepayId ,统一下单成功后得到
 //获取微信内H5支付 paySign
 //    appId:APPID
-//    nonceStr:随字符串
+//    nonceStr:随字符串
 //    packages:统一下单成功后拼接得到的值
 //    signType:签名方式,务必与统一下单时用的签名方式一致
 //    timeStamp:时间

+ 6 - 5
README_EN.md

@@ -7,11 +7,12 @@
 
 The Golang SDK for WeChat and AliPay
 
-[![](https://img.shields.io/badge/Author-Jerry-blue.svg)](https://www.gopay.ink)
-[![](https://img.shields.io/badge/Golang-1.11+-brightgreen.svg)](https://golang.org)
-[![](https://img.shields.io/badge/Version-1.3.2-blue.svg)](https://www.gopay.ink)
-[![](https://api.travis-ci.org/iGoogle-ink/gopay.svg?branch=master)]()
-[![](https://img.shields.io/badge/License-Apache_2-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0)
+![Author](https://img.shields.io/badge/author-Jerry-blue.svg)
+[![Golang](https://img.shields.io/badge/golang-1.11+-brightgreen.svg)](https://golang.org)
+[![Godoc](https://img.shields.io/badge/godoc-reference-informational.svg)](https://godoc.org/github.com/iGoogle-ink/gopay)
+![GitHub release (latest by date)](https://img.shields.io/github/v/release/iGoogle-ink/gopay)
+![Travis (.org)](https://img.shields.io/travis/iGoogle-ink/gopay)
+![License](https://img.shields.io/github/license/iGoogle-ink/gopay)
 
 ## WeChat Client
 

+ 1 - 1
alipay_client.go

@@ -406,7 +406,7 @@ func (this *aliPayClient) AliPaySystemOauthToken(body BodyMap) (aliRsp *AliPaySy
 		return nil, errors.New("code and refresh_token are not allowed to be null at the same time")
 	}
 
-	bytes, err = aliPaySystemOauthToken(this.AppId, this.privateKey, body, "alipay.system.oauth.token")
+	bytes, err = aliPaySystemOauthToken(this.AppId, this.privateKey, body, "alipay.system.oauth.token", this.isProd)
 	if err != nil {
 		return nil, err
 	}

+ 13 - 6
alipay_service_api.go

@@ -372,7 +372,7 @@ func AliPaySystemOauthToken(appId, privateKey, grantType, codeOrToken string) (r
 		body.Set("grant_type", "authorization_code")
 		body.Set("code", codeOrToken)
 	}
-	bs, err = aliPaySystemOauthToken(appId, privateKey, body, "alipay.system.oauth.token")
+	bs, err = aliPaySystemOauthToken(appId, privateKey, body, "alipay.system.oauth.token", true)
 	if err != nil {
 		return nil, err
 	}
@@ -390,7 +390,7 @@ func AliPaySystemOauthToken(appId, privateKey, grantType, codeOrToken string) (r
 }
 
 //向支付宝发送请求
-func aliPaySystemOauthToken(appId, privateKey string, body BodyMap, method string) (bytes []byte, err error) {
+func aliPaySystemOauthToken(appId, privateKey string, body BodyMap, method string, isProd bool) (bytes []byte, err error) {
 	//===============生成参数===================
 	body.Set("app_id", appId)
 	body.Set("method", method)
@@ -412,10 +412,17 @@ func aliPaySystemOauthToken(appId, privateKey string, body BodyMap, method strin
 
 	var url string
 	agent := HttpAgent()
-	//正式环境
-	url = zfb_base_url_utf8
-	//fmt.Println(url)
-	agent.Post(url)
+	if !isProd {
+		//沙箱环境
+		url = zfb_sanbox_base_url_utf8
+		//fmt.Println(url)
+		agent.Post(url)
+	} else {
+		//正式环境
+		url = zfb_base_url_utf8
+		//fmt.Println(url)
+		agent.Post(url)
+	}
 	_, bs, errs := agent.
 		Type("form-data").
 		SendString(urlParam).

+ 1 - 1
constant.go

@@ -4,7 +4,7 @@ const (
 	null       string = ""
 	TimeLayout string = "2006-01-02 15:04:05"
 	DateLayout string = "2006-01-02"
-	Version    string = "1.3.2"
+	Version    string = "1.3.3"
 	//微信
 	//===========================================================================================