123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- package wechat
- import "encoding/xml"
- type Entrust struct {
- XMLName xml.Name `xml:"xml"`
- AppID string `xml:"appid"`
- MchID string `xml:"mch_id"`
- PlanID string `xml:"plan_id"`
- ContractCode string `xml:"contract_code"`
- RequestSerial int64 `xml:"request_serial"`
- Name string `xml:"contract_display_account"`
- NotifyURL string `xml:"notify_url"`
-
- Sign string `xml:"sign"`
- Timestamp int `xml:"timestamp"`
- IP string `xml:"clientip"`
-
- }
- func H5Entrust(config WePayConfig, order Entrust) (reply WePayReply, err error) {
- m := make(map[string]interface{})
- m["appid"] = order.AppID
- m["mch_id"] = order.MchID
- m["plan_id"] = order.PlanID
- m["contract_code"] = order.ContractCode
- m["request_serial"] = order.RequestSerial
- m["contract_display_account"] = order.Name
- m["notify_url"] = order.NotifyURL
- m["ver"] = `1.0`
- m["timestamp"] = order.Timestamp
- m["clientip"] = order.IP
- var data []byte
- order.Sign = Sign(m, config.Key)
- if data, err = xml.Marshal(order); err != nil {
- return
- }
- reply, err = post(WePayHost+WePayURLPapayEntrust, data)
- return
- }
|