Browse Source

add SetCountry

Jerry 7 years ago
parent
commit
4a20849fd0
1 changed files with 20 additions and 1 deletions
  1. 20 1
      wechat_params.go

+ 20 - 1
wechat_params.go

@@ -12,6 +12,25 @@ import (
 	"strings"
 )
 
+type Country int
+
+//设置支付国家(默认:中国国内)
+//    根据支付地区情况设置国家
+//    country:<China:中国国内,SoutheastAsia:东南亚,Other:其他国家>
+func (this *weChatClient) SetCountry(country Country) (client *weChatClient) {
+	switch country {
+	case China:
+		this.baseURL = wx_base_url_ch
+	case SoutheastAsia:
+		this.baseURL = wx_base_url_hk
+	case Other:
+		this.baseURL = wx_base_url_us
+	default:
+		this.baseURL = wx_base_url_ch
+	}
+	return this
+}
+
 //本地通过支付参数计算Sign值
 func getLocalSign(apiKey string, signType string, body BodyMap) (sign string) {
 	signStr := sortWeChatSignParams(apiKey, body)
@@ -75,7 +94,7 @@ func getSanBoxSignKey(mchId, nonceStr, sign string) (key string, err error) {
 	reqXml := generateXml(reqs)
 	//fmt.Println("req:::", reqXml)
 	_, byteList, errorList := HttpAgent().
-		Post(wxURL_SanBox_GetSignKey).
+		Post(wx_SanBox_GetSignKey).
 		Type("xml").
 		SendString(reqXml).EndBytes()
 	if len(errorList) > 0 {