12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- package wechat
- import "encoding/xml"
- type PapPay struct {
- XMLName xml.Name `xml:"xml"`
- AppID string `xml:"appid"`
- MchID string `xml:"mch_id"`
- NonceStr string `xml:"nonce_str"`
- Sign string `xml:"sign"`
- Body string `xml:"body"`
- Detail string `xml:"detail"`
- Attach string `xml:"attach"`
- OutTradeNo string `xml:"out_trade_no"`
- TotalFee int `xml:"total_fee"`
- SpbillCreateIP string `xml:"spbill_create_ip"`
- NotifyURL string `xml:"notify_url"`
- ContractID string `xml:"contract_id"`
- OpenID string `xml:"openid"`
- Mobile string `xml:"mobile"`
- Creid string `xml:"creid"`
- Timestamp int `xml:"timestamp"`
- }
- func PapPayApply(config WePayConfig, order PapPay) (reply WePayReply, err error) {
- m := make(map[string]interface{})
- m["appid"] = order.AppID
- m["mch_id"] = order.MchID
- m["nonce_str"] = order.NonceStr
- m["body"] = order.Body
- m["detail"] = order.Detail
- m["attach"] = order.Attach
- m["out_trade_no"] = order.OutTradeNo
- m["total_fee"] = order.TotalFee
- m["spbill_create_ip"] = order.SpbillCreateIP
- m["notify_url"] = order.NotifyURL
- m["trade_type"] = `PAP`
- m["contract_id"] = order.ContractID
- m["openid"] = order.OpenID
- m["mobile"] = order.Mobile
- m["creid"] = order.Creid
- m["timestamp"] = order.Timestamp
- var data []byte
- order.Sign = Sign(m, config.Key)
- if data, err = xml.Marshal(order); err != nil {
- return
- }
- reply, err = post(WePayHost+WePayURLPapPay, data)
- return
- }
|