|
@@ -0,0 +1,88 @@
|
|
|
+
|
|
|
+
|
|
|
+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
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+POST
|
|
|
+<xml>
|
|
|
+<mch_id>10000098</mch_id>
|
|
|
+<appid>wxcbda96de0b165486</appid>
|
|
|
+<nonce_str>5K8264ILTKCH16CQ2502SI8ZNMTM67VS</nonce_str>
|
|
|
+<sign>C380BEC2BFD727A4B6845133519F3AD6</sign>
|
|
|
+<body>水电代扣</body>
|
|
|
+<out_trade_no>217752501201407033233368018</out_trade_no>
|
|
|
+<total_fee>888</total_fee>
|
|
|
+<spbill_create_ip>8.8.8.8</spbill_create_ip>
|
|
|
+<notify_url>http:
|
|
|
+<contract_id>Wx15463511252015071056489715</contract_id>
|
|
|
+</xml>
|
|
|
+
|
|
|
+Return
|
|
|
+<xml>
|
|
|
+<return_code><![CDATA[SUCCESS]]></return_code>
|
|
|
+<return_msg><![CDATA[OK]]></return_msg>
|
|
|
+<appid><![CDATA[wxcbda96de0b165486]]></wxappid>
|
|
|
+<mch_id><![CDATA[10000098]]></mch_id>
|
|
|
+<nonce_str><![CDATA[IITRi8Iabbblz1Jc]]></nonce_str>
|
|
|
+<sign><![CDATA[E1EE61A91C8E90F299DE6AE075D60A2D]]></sign>
|
|
|
+<result_code><![CDATA[SUCCESS]]></result_code>
|
|
|
+
|
|
|
+</xml>
|
|
|
+
|