forked from shenghui0779/sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
reply.go
36 lines (30 loc) · 832 Bytes
/
reply.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package mch
import "encoding/xml"
// CDATA XML CDATA section which is defined as blocks of text that are not parsed by the parser, but are otherwise recognized as markup.
type CDATA string
// MarshalXML encodes the receiver as zero or more XML elements.
func (c CDATA) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
return e.EncodeElement(struct {
string `xml:",cdata"`
}{string(c)}, start)
}
// Reply 回复支付结果
type Reply struct {
XMLName xml.Name `xml:"xml"`
ReturnCode CDATA `xml:"return_code"`
ReturnMsg CDATA `xml:"return_msg"`
}
// ReplyOK 回复成功
func ReplyOK() *Reply {
return &Reply{
ReturnCode: ResultSuccess,
ReturnMsg: "OK",
}
}
// ReplyFail 回复失败
func ReplyFail(msg string) *Reply {
return &Reply{
ReturnCode: ResultFail,
ReturnMsg: CDATA(msg),
}
}