112 lines
3.4 KiB
Go
112 lines
3.4 KiB
Go
package tonglianpayapi
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"net/http"
|
|
|
|
"git.rosy.net.cn/baseapi/utils"
|
|
)
|
|
|
|
const (
|
|
MsgTypeUnkown = 0 // 未知
|
|
MsgTypePay = "VSP501" // 支付结果回调 (微信
|
|
MsgTypeRefund = "VSP503" // 退款结果回调 (微信
|
|
MsgTypePayZFB = "VSP511" //支付宝
|
|
MsgTypeRefundZFB = "VSP513"
|
|
|
|
TrxStatusSuccess = "0000" // 交易成功
|
|
TrxStatusTransaction = "2000" // 支付中
|
|
TrxStatusTransaction2 = "2008" // 支付中
|
|
OnlinePayStatusSuccess = "SUCCESS"
|
|
OnlinePayStatusFail = "FAIL"
|
|
MisStatusSuccess = "Y0000" // 调用成功
|
|
)
|
|
|
|
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
|
|
}
|
|
|
|
// CallBackResultOnlinePay 扫码支付回调
|
|
type CallBackResultOnlinePay 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"`
|
|
Initamt string `json:"initamt"`
|
|
Chnldata string `json:"chnldata"`
|
|
Accttype string `json:"accttype"`
|
|
Bankcode string `json:"bankcode"`
|
|
Logonid string `json:"logonid"`
|
|
}
|
|
|
|
func (a *API) GetCallbackOnlinePayMsg(request *http.Request) (call *CallBackResultOnlinePay, 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
|
|
}
|