You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
984 B

package wxminipay
import (
"recook/tools"
"strconv"
"strings"
"time"
)
type AppCreateOrderResult struct {
AppID string `xml:"appid" json:"appid"`
Package string `xml:"package" json:"package"`
NonceStr string `xml:"noncestr" json:"noncestr"`
Timestamp string `xml:"timestamp" json:"timestamp"`
Sign string `xml:"sign" json:"sign"`
}
func (*AppCreateOrderResult) GetSignResult(d *CreateOrderResult) *AppCreateOrderResult {
timestamp := strconv.FormatInt(time.Now().Unix(), 10)
signStr := "appId=" + AppID
signStr = signStr + "&" + "nonceStr=" + d.NonceStr
signStr = signStr + "&" + "package=" + "prepay_id=" + d.PrepayID
signStr = signStr + "&" + "signType=MD5"
signStr = signStr + "&" + "timeStamp=" + timestamp
signStr = signStr + "&key=" + APIKey
r := &AppCreateOrderResult{
AppID: AppID,
Package: "prepay_id=" + d.PrepayID,
NonceStr: d.NonceStr,
Timestamp: timestamp,
Sign: strings.ToUpper(tools.MD5(signStr)),
}
return r
}