58 lines
1.5 KiB
Go
58 lines
1.5 KiB
Go
package tonglianpayapi
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"net/http"
|
|
|
|
"git.rosy.net.cn/baseapi/utils"
|
|
)
|
|
|
|
const (
|
|
MsgTypeUnkown = 0 // 未知
|
|
MsgTypePay = "VSP501" // 支付结果回调
|
|
MsgTypeRefund = "VSP503" // 退款结果回调
|
|
|
|
TrxStatusSuccess = "0000"
|
|
)
|
|
|
|
type CallBackResult struct {
|
|
AppID string `json:"appID"`
|
|
OuttrxID string `json:"outtrxID"`
|
|
TrxCode string `json:"trxCode"`
|
|
TrxID string `json:"trxID"`
|
|
TrxAmt string `json:"trxAmt"`
|
|
TrxDate string `json:"trxDate"`
|
|
PayTime string `json:"payTime"`
|
|
ChnlTrxID string `json:"chnlTrxID"`
|
|
TrxStatus string `json:"trxStatus"`
|
|
CusID string `json:"cusID"`
|
|
TermNo string `json:"termNo"`
|
|
TermBatchid string `json:"termBatchid"`
|
|
TermTraceno string `json:"termTraceno"`
|
|
TermAuthno string `json:"termAuthno"`
|
|
TermRefnum string `json:"termRefnum"`
|
|
TrxReserved string `json:"trxReserved"`
|
|
SrcTrxid string `json:"srcTrxid"`
|
|
CusorderID string `json:"cusorderID"`
|
|
Acct string `json:"acct"`
|
|
Fee string `json:"fee"`
|
|
SignType string `json:"signType"`
|
|
Cmid string `json:"cmid"`
|
|
Chnlid string `json:"chnlid"`
|
|
Sign string `json:"sign"`
|
|
}
|
|
|
|
func (a *API) GetCallbackMsg(request *http.Request) (call *CallBackResult, err error) {
|
|
data, err := ioutil.ReadAll(request.Body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
values, err := utils.HTTPBody2Values(data, false)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
mapData := utils.URLValues2Map(values)
|
|
utils.Map2StructByJson(mapData, &call, false)
|
|
return call, err
|
|
}
|