wxpay

package
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 2, 2021 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const AppID = "wx037d3b26b2ba34b2"
View Source
const AppSecret = "fe3faa4e6f8abd87fa4621cb5ed5f725"
View Source
const EncodingAESKey = "egMWQnCkbuDd7u5GM7EJBnH8mISn5iwAorjRNnFx3dv"
View Source
const MchID = "1342120901"
View Source
const Token = "30e6e3b03bf7ec6d2ce56a50055e1cd1"

Variables

View Source
var VerifyCache = &struct {
	Component_access_token            string
	Component_access_token_expires_in int64
	Component_access_token_update     int64

	Pre_auth_code            string
	Pre_auth_code_expires_in int64
	Pre_auth_code_update     int64
}{}

Functions

func Decrypt

func Decrypt(text string) (bool, string)

* 对密文进行解密. * * @param text 需要解密的密文 * @return 解密得到的明文 * @throws AesException aes解密失败

func DecryptMsg

func DecryptMsg(msgSignature string, timeStamp string, nonce string, postData string) (bool, string)

func GetAccessToken

func GetAccessToken() string
func Api_create_preauthcode(component_access_token string) string {
	if time.Now().Unix()-VerifyCache.Pre_auth_code_update >= VerifyCache.Pre_auth_code_expires_in-10 || strings.EqualFold(VerifyCache.Pre_auth_code, "") {

		params := map[string]string{"component_appid": OpenAppID}
		jd, err := json.Marshal(params)
		glog.Error(err)
		fmt.Println(string(jd))
		buf := bytes.NewBuffer(make([]byte, 0))
		binary.Write(buf, binary.BigEndian, jd)
		resp, err := http.Post("https://api.weixin.qq.com/cgi-bin/component/api_create_preauthcode?component_access_token="+component_access_token, "application/json", buf)
		glog.Error(err)
		b, err := ioutil.ReadAll(resp.Body)
		glog.Error(err)
		fmt.Println(string(b))

		var respData = &struct {
			Pre_auth_code string `json:"pre_auth_code"`
			Expires_in    int64  `json:"expires_in"`
		}{}

		err = json.Unmarshal(b, respData)
		glog.Error(err)

		VerifyCache.Pre_auth_code = respData.Pre_auth_code
		VerifyCache.Pre_auth_code_expires_in = respData.Expires_in
		VerifyCache.Pre_auth_code_update = time.Now().Unix()
		fmt.Println(respData)

		return VerifyCache.Pre_auth_code
	} else {
		return VerifyCache.Pre_auth_code
	}
}

func GetTicket

func GetTicket() string

func GetWXJSConfig

func GetWXJSConfig(url string) (appId string, timestamp int64, nonceStr string, signature string)

func OrderJS

func OrderJS(OrderNo string, ShopName string, DetailJSON string, Host string, openid string, IP string, TotalMoney uint64)

Types

type AccessToken

type AccessToken struct {
	Access_token string
	Expires_in   int64
	Update       int64
}

type PushInfo

type PushInfo struct {
	AppId                 string `xml:AppId`
	CreateTime            int64  `xml:CreateTime`
	InfoType              string `xml:InfoType`
	ComponentVerifyTicket string `xml:ComponentVerifyTicket`
}

type Ticket

type Ticket struct {
	Ticket     string
	Expires_in int64
	Update     int64
}

type TokenXML

type TokenXML struct {
	AppId   string `xml:AppId`
	Encrypt string `xml:Encrypt`
}

type WXDetail

type WXDetail struct {
	Goods_detail []WXGoodsDetail `json:"goods_detail"`
}

type WXGoodsDetail

type WXGoodsDetail struct {
	Goods_id   string `json:"goods_id"`
	Goods_name string `json:"goods_name"`
	Quantity   string `json:"quantity"`
	Price      string `json:"price"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL