iedc-go/vendor/gopkg.in/chanxuehong/wechat.v2/mch/pay/closeorder.go
2023-03-03 03:12:15 +08:00

40 lines
1.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package pay
import (
"gopkg.in/chanxuehong/wechat.v2/mch/core"
"gopkg.in/chanxuehong/wechat.v2/util"
)
// CloseOrder 关闭订单.
func CloseOrder(clt *core.Client, req map[string]string) (resp map[string]string, err error) {
return clt.PostXML(core.APIBaseURL()+"/pay/closeorder", req)
}
type CloseOrderRequest struct {
XMLName struct{} `xml:"xml" json:"-"`
// 必选参数
OutTradeNo string `xml:"out_trade_no"` // 商户系统内部订单号
// 可选参数
NonceStr string `xml:"nonce_str"` // 随机字符串不长于32位。NOTE: 如果为空则系统会自动生成一个随机字符串。
SignType string `xml:"sign_type"` // 签名类型目前支持HMAC-SHA256和MD5默认为MD5
}
// CloseOrder2 关闭订单.
func CloseOrder2(clt *core.Client, req *CloseOrderRequest) (err error) {
m1 := make(map[string]string, 8)
m1["out_trade_no"] = req.OutTradeNo
if req.NonceStr != "" {
m1["nonce_str"] = req.NonceStr
} else {
m1["nonce_str"] = util.NonceStr()
}
if req.SignType != "" {
m1["sign_type"] = req.SignType
}
_, err = CloseOrder(clt, m1)
return
}