You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
134 lines
4.7 KiB
134 lines
4.7 KiB
package grepay |
|
|
|
import ( |
|
"fmt" |
|
"server/config" |
|
"server/util" |
|
"sort" |
|
|
|
"github.com/liangdas/mqant/log" |
|
) |
|
|
|
const ( |
|
payURL = "https://api.metagopayments.com/cashier/pay.ac" |
|
payCallbackURL = "/grepay/pay/callback" |
|
withdrawURL = "https://payout.metagopayments.com/cashier/TX0001.ac" |
|
withdrawCallbackURL = "/grepay/withdraw/callback" |
|
orgNo = "8220800959" |
|
mid = "22081000002504" |
|
// key = "FF5D557F6AC9EF26212B482B23AD7F07" |
|
) |
|
|
|
type PayReq struct { |
|
Version string `json:"version"` |
|
OrgNo string `json:"orgNo"` |
|
CustId string `json:"custId"` |
|
CustOrderNo string `json:"custOrderNo"` |
|
TranType string `json:"tranType"` |
|
ClearType string `json:"clearType"` |
|
PayAmt int64 `json:"payAmt"` |
|
BackUrl string `json:"backUrl"` |
|
FrontUrl string `json:"frontUrl"` |
|
GoodsName string `json:"goodsName"` |
|
OrderDesc string `json:"orderDesc"` |
|
BuyIp string `json:"buyIp"` |
|
UserName string `json:"userName"` |
|
UserEmail string `json:"userEmail"` |
|
UserPhone string `json:"userPhone"` |
|
UserCitizenID string `json:"userCitizenId"` |
|
CountryCode string `json:"countryCode"` |
|
Currency string `json:"currency"` |
|
Sign string `json:"sign"` |
|
} |
|
|
|
type PayResp struct { |
|
OrgNo string `json:"orgNo"` |
|
CustId string `json:"custId"` |
|
Code string `json:"code"` // 000000 表示请求该接口正常 |
|
Msg string `json:"msg"` |
|
CustOrderNo string `json:"custOrderNo"` |
|
ContentType string `json:"contentType"` |
|
BusContent string `json:"busContent"` |
|
Sign string `json:"sign"` |
|
} |
|
|
|
type PayCallbackReq struct { |
|
Version string `json:"version" form:"version"` |
|
OrgNo string `json:"orgNo" form:"orgNo"` |
|
CustId string `json:"custId" form:"custId"` |
|
CustOrderNo string `json:"custOrderNo" form:"custOrderNo"` |
|
PrdOrdNo string `json:"prdOrdNo" form:"prdOrdNo"` |
|
OrdAmt string `json:"ordAmt" form:"ordAmt"` |
|
OrdTime string `json:"ordTime" form:"ordTime"` |
|
PayAmt string `json:"payAmt" form:"payAmt"` |
|
OrdStatus string `json:"ordStatus" form:"ordStatus"` // 00:未交易01:成功02:失败03:被拒绝04:处理中05:取消支付06:未支付07:已退款08:退款中 |
|
Sign string `json:"sign" form:"sign"` |
|
} |
|
|
|
type WithdrawReq struct { |
|
Version string `json:"version"` |
|
OrgNo string `json:"orgNo"` |
|
CustId string `json:"custId"` |
|
CustOrderNo string `json:"custOrdNo"` |
|
CasType string `json:"casType"` // 清算类型(请传数字编码)00(T0 结算)01(T1 结算)默认为00 |
|
Country string `json:"country"` |
|
Currency string `json:"currency"` |
|
CasAmt int64 `json:"casAmt"` |
|
DeductWay string `json:"deductWay"` |
|
CallBackUrl string `json:"callBackUrl"` |
|
Account string `json:"account"` |
|
PayoutType string `json:"payoutType"` // Card: 代付到银行卡UPI: 代付到UPI 账户 |
|
AccountName string `json:"accountName"` |
|
PayeeBankCode string `json:"payeeBankCode"` |
|
CardType string `json:"cardType"` // PayoutType为card时,填IMPS |
|
CnapsCode string `json:"cnapsCode"` // IFSC |
|
CardNo string `json:"cardNo"` |
|
UpiId string `json:"upiId"` |
|
Phone string `json:"phone"` |
|
Email string `json:"email"` |
|
Sign string `json:"sign"` |
|
} |
|
|
|
type WithdrawResp struct { |
|
OrgNo string `json:"orgNo"` |
|
OrdStatus string `json:"ordStatus"` // 00:未交易01:成功02:失败03:被拒绝04:处理中05:取消支付06:未支付07:已退款08:退款中 |
|
Code string `json:"code"` // 000000 表示请求该接口正常 |
|
Msg string `json:"msg"` |
|
CustId string `json:"custId"` |
|
CustOrderNo string `json:"custOrderNo"` |
|
CasOrdNo string `json:"casOrdNo"` |
|
CasAmt string `json:"casAmt"` |
|
CasTime string `json:"casTime"` |
|
Sign string `json:"sign"` |
|
} |
|
|
|
type WithdrawCallbackReq struct { |
|
OrgNo string `json:"orgNo" form:"orgNo"` |
|
CustId string `json:"custId" form:"custId"` |
|
CustOrderNo string `json:"custOrderNo" form:"custOrderNo"` |
|
PrdOrdNo string `json:"prdOrdNo" form:"prdOrdNo"` |
|
PayAmt int64 `json:"payAmt" form:"payAmt"` |
|
OrdStatus string `json:"ordStatus" form:"ordStatus"` // 00:未交易01:成功02:失败03:被拒绝04:处理中05:取消支付06:未支付07:已退款08:退款中 |
|
CasDesc string `json:"casDesc" form:"casDesc"` |
|
Sign string `json:"sign" form:"sign"` |
|
} |
|
|
|
func Sign(m map[string]interface{}) string { |
|
str := []string{} |
|
for i := range m { |
|
if i == "sign" { |
|
continue |
|
} |
|
str = append(str, i) |
|
} |
|
sort.Strings(str) |
|
signStr := "" |
|
for _, v := range str { |
|
mv := m[v] |
|
signStr += fmt.Sprintf("%v=%v", v, mv) |
|
signStr += "&" |
|
} |
|
signStr += "key=" + config.GetConfig().Pay.GrePay.Key |
|
log.Debug("signStr:%v", signStr) |
|
return util.CalculateMD5(signStr) |
|
}
|
|
|