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.
138 lines
5.2 KiB
138 lines
5.2 KiB
|
1 year ago
|
package mlpay
|
||
|
|
|
||
|
|
import (
|
||
|
|
"fmt"
|
||
|
|
"server/util"
|
||
|
|
"sort"
|
||
|
|
"strings"
|
||
|
|
|
||
|
|
"github.com/liangdas/mqant/log"
|
||
|
|
)
|
||
|
|
|
||
|
|
const (
|
||
|
|
baseUrl = "https://api.lovetigervip.com"
|
||
|
|
payURL = "/pay/order"
|
||
|
|
payCallbackURL = "/mlpay/pay/callback"
|
||
|
|
withdrawURL = "/pay/withdraw"
|
||
|
|
withdrawCallbackURL = "/mlpay/withdraw/callback"
|
||
|
|
PartnerId = 1000100020003074
|
||
|
|
ApplicationId = 69
|
||
|
|
key = "83EF99E9E32C4B70832A4DB779BA01C7"
|
||
|
|
withdrawKey = "82BD667CE13049C4A881B52218A4F935"
|
||
|
|
)
|
||
|
|
|
||
|
|
type PayReq struct {
|
||
|
|
PartnerID int64 `json:"partnerId"`
|
||
|
|
ApplicationID int64 `json:"applicationId"`
|
||
|
|
PayWay int `json:"payWay"` // 支付方式ID 固定值 2
|
||
|
|
PartnerOrderNo string `json:"partnerOrderNo"`
|
||
|
|
Amount int64 `json:"amount"`
|
||
|
|
Currency string `json:"currency"`
|
||
|
|
Name string `json:"name"`
|
||
|
|
GameId int `json:"gameId"`
|
||
|
|
ClientIP string `json:"clientIp"`
|
||
|
|
NotifyURL string `json:"notifyUrl" encode:"1"`
|
||
|
|
Subject string `json:"subject"`
|
||
|
|
Body string `json:"body"`
|
||
|
|
CallbackUrl string `json:"callbackUrl" encode:"1"`
|
||
|
|
Extra string `json:"extra" encode:"1"`
|
||
|
|
Version string `json:"version"` // 接口版本号,固定:1.0
|
||
|
|
Sign string `json:"sign"`
|
||
|
|
}
|
||
|
|
|
||
|
|
type UserData struct {
|
||
|
|
UserName string `json:"userName"`
|
||
|
|
UserEmail string `json:"userEmail"`
|
||
|
|
UserPhone string `json:"userPhone"`
|
||
|
|
}
|
||
|
|
|
||
|
|
type PayResp struct {
|
||
|
|
Code string `json:"code"`
|
||
|
|
Msg string `json:"msg"`
|
||
|
|
Data string `json:"data"`
|
||
|
|
}
|
||
|
|
|
||
|
|
type PayData struct {
|
||
|
|
Amount string `json:"amount"`
|
||
|
|
MchOrder string `json:"mch_order"`
|
||
|
|
OrderNo string `json:"order_no"` // 平台订单号
|
||
|
|
PayLink string `json:"pay_link"` // 支付链接
|
||
|
|
Timestamp int64 `json:"timestamp"` // 时间戳
|
||
|
|
}
|
||
|
|
|
||
|
|
type PayCallbackReq struct {
|
||
|
|
Status int64 `json:"status" form:"status"` // 0失败 1成功
|
||
|
|
ApplicationID int64 `json:"applicationId" form:"applicationId"`
|
||
|
|
PayWay int64 `json:"payWay" form:"payWay"`
|
||
|
|
PartnerOrderNo string `json:"partnerOrderNo" form:"partnerOrderNo"` // 商户订单号
|
||
|
|
OrderNo string `json:"orderNo" form:"orderNo"` // 平台订单号
|
||
|
|
ChannelOrderNo string `json:"channelOrderNo" form:"channelOrderNo"` // 上游生成的代收号
|
||
|
|
Amount int64 `json:"amount" form:"amount"`
|
||
|
|
Sign string `json:"sign" form:"sign"`
|
||
|
|
}
|
||
|
|
|
||
|
|
type WithdrawReq struct {
|
||
|
|
PartnerID int64 `json:"partnerId"`
|
||
|
|
PartnerWithdrawNo string `json:"partnerWithdrawNo"`
|
||
|
|
Amount int64 `json:"amount"`
|
||
|
|
Currency string `json:"currency"`
|
||
|
|
GameId string `json:"gameId"`
|
||
|
|
NotifyURL string `json:"notifyUrl" encode:"1"`
|
||
|
|
ReceiptMode int `json:"receiptMode"` // currency=INR时收款方式0:UPI;1:IMPS;currency=BRL时收款方式 0:CPF;1:CNPJ;2:PHONE;3:EMAIL;4:EVP
|
||
|
|
AccountNumber string `json:"accountNumber" encode:"1"` // 收款账户(URLENCODE编码,计算签名使用编码前数值)
|
||
|
|
AccountName string `json:"accountName" encode:"1"` // 收款姓名(URLENCODE编码,计算签名使用编码前数值)
|
||
|
|
AccountPhone string `json:"accountPhone" encode:"1"` // 收款电话(URLENCODE编码,计算签名使用编码前数值)
|
||
|
|
AccountEmail string `json:"accountEmail" encode:"1"` // 收款邮箱(URLENCODE编码,计算签名使用编码前数值)
|
||
|
|
AccountExtra1 string `json:"accountExtra1"` // currency=INR时,收款特殊参数1(当receiptMode为1时,此参数必填)(IFSC CODE)
|
||
|
|
AccountExtra2 string `json:"accountExtra2"` // currency=INR时,收款特殊参数2(当receiptMode为1时,此参数在某些通道下必填,具体联系运营)(银行代码)
|
||
|
|
Version string `json:"version"` // 接口版本号,固定:1.0
|
||
|
|
Sign string `json:"sign"`
|
||
|
|
}
|
||
|
|
|
||
|
|
type WithdrawResp struct {
|
||
|
|
Code string `json:"code"`
|
||
|
|
Msg string `json:"msg"`
|
||
|
|
Data string `json:"data"`
|
||
|
|
}
|
||
|
|
|
||
|
|
type WithdrawData struct {
|
||
|
|
Amount string `json:"amount"`
|
||
|
|
MchOrder string `json:"mch_order"`
|
||
|
|
OrderNo string `json:"order_no"` // 平台订单号
|
||
|
|
Timestamp int64 `json:"timestamp"` // 时间戳
|
||
|
|
}
|
||
|
|
|
||
|
|
type WithdrawCallbackReq struct {
|
||
|
|
Status int64 `json:"status" form:"status"` // 0失败 1成功
|
||
|
|
ErrorMsg int64 `json:"errorMsg" form:"errorMsg" encode:"1"`
|
||
|
|
PartnerWithdrawNo string `json:"partnerWithdrawNo" form:"partnerWithdrawNo"` // 商户订单号
|
||
|
|
WithdrawNo string `json:"withdrawNo" form:"withdrawNo"` // 平台订单号
|
||
|
|
ChannelWithdrawNo string `json:"channelWithdrawNo" form:"channelWithdrawNo"` // 上游生成的代收号
|
||
|
|
Amount int64 `json:"amount" form:"amount"`
|
||
|
|
Sign string `json:"sign" form:"sign"`
|
||
|
|
}
|
||
|
|
|
||
|
|
func Sign(m map[string]interface{}, t int) 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 += "&"
|
||
|
|
}
|
||
|
|
if t == 0 {
|
||
|
|
signStr += "key=" + key
|
||
|
|
} else {
|
||
|
|
signStr += "key=" + withdrawKey
|
||
|
|
}
|
||
|
|
log.Debug("signStr:%v", signStr)
|
||
|
|
return strings.ToUpper(util.CalculateMD5(signStr))
|
||
|
|
}
|