|
|
@@ -360,7 +360,7 @@ func WebPayHwXiaoQiNotify(c *gin.Context) {
|
|
|
params := make(map[string]string)
|
|
|
if err := c.Request.ParseForm(); err != nil {
|
|
|
util.InfoF("parseForm falied")
|
|
|
- c.String(http.StatusOK, "FAILED")
|
|
|
+ c.String(http.StatusOK, "failed:order error")
|
|
|
return
|
|
|
}
|
|
|
util.DebugF("支付回调信息2:%v", c.Request.PostForm)
|
|
|
@@ -382,13 +382,13 @@ func WebPayHwXiaoQiNotify(c *gin.Context) {
|
|
|
b, err2 := VerifySignature(params, xiaoqiIoskey)
|
|
|
if err2 != nil || !b {
|
|
|
util.ErrorF("签名错误%v", err2)
|
|
|
- c.String(http.StatusOK, "FAILED")
|
|
|
+ c.String(http.StatusOK, "sign_data_verify_failed")
|
|
|
return
|
|
|
}
|
|
|
myData, err3 = DecryptDataToMap(params["encryp_data"], xiaoqiIoskey)
|
|
|
if err3 != nil {
|
|
|
util.ErrorF("解析encryp_data error:%v", err3)
|
|
|
- c.String(http.StatusOK, "FAILED")
|
|
|
+ c.String(http.StatusOK, "encryp_data_decrypt_failed")
|
|
|
return
|
|
|
}
|
|
|
} else {
|
|
|
@@ -396,18 +396,20 @@ func WebPayHwXiaoQiNotify(c *gin.Context) {
|
|
|
b, err2 := VerifySignature(params, xiaoqiAndroidkey)
|
|
|
if err2 != nil || !b {
|
|
|
util.ErrorF("签名错误%v", err2)
|
|
|
- c.String(http.StatusOK, "FAILED")
|
|
|
+ c.String(http.StatusOK, "sign_data_verify_failed")
|
|
|
return
|
|
|
}
|
|
|
myData, err3 = DecryptDataToMap(params["encryp_data"], xiaoqiAndroidkey)
|
|
|
if err3 != nil {
|
|
|
util.ErrorF("解析encryp_data error:%v", err3)
|
|
|
- c.String(http.StatusOK, "FAILED")
|
|
|
+ c.String(http.StatusOK, "encryp_data_decrypt_failed")
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- uid := myData["uid"]
|
|
|
+ util.ErrorF("xiaoqi mydata:%v", myData)
|
|
|
+
|
|
|
+ uid := params["game_role_id"]
|
|
|
cpOrderId := myData["game_orderid"]
|
|
|
if cpOrderId == "" {
|
|
|
if extras.CpOrderId != "" {
|
|
|
@@ -416,8 +418,19 @@ func WebPayHwXiaoQiNotify(c *gin.Context) {
|
|
|
util.ErrorF("mycard pay cporderId is nil extras:%v", extras)
|
|
|
}
|
|
|
}
|
|
|
- orderNo := myData["xiao7_goid"]
|
|
|
+ orderNo := params["xiao7_goid"]
|
|
|
payCurrency := myData["game_currency"]
|
|
|
+ //if payCurrency != "USD" {
|
|
|
+ // util.ErrorF("xiaoqi pay currency is not USD:%v", payCurrency)
|
|
|
+ // c.String(http.StatusOK, "failed:game_currency error")
|
|
|
+ // return
|
|
|
+ //}
|
|
|
+ server := params["game_area"]
|
|
|
+ if server != strconv.Itoa(service.GetServiceConfig().Node.Zone/2) {
|
|
|
+ util.ErrorF("xiaoqi pay server is not correct:%v", server)
|
|
|
+ c.String(http.StatusOK, "failed:game_area error")
|
|
|
+ return
|
|
|
+ }
|
|
|
payType := myData["game_currency"]
|
|
|
usdAmount := myData["pay_price"]
|
|
|
ntfData := &WebNotifyData{}
|
|
|
@@ -427,16 +440,25 @@ func WebPayHwXiaoQiNotify(c *gin.Context) {
|
|
|
ntfData.PayCurrency = payCurrency
|
|
|
ntfData.PayTime = uint64(util.GetTimeSeconds())
|
|
|
ntfData.PayChannel = "xiaoqi"
|
|
|
+ ntfData.Guid = myData["guid"]
|
|
|
+ ntfData.RoleName = params["game_role_name"]
|
|
|
+ roleId, _ := strconv.ParseUint(params["game_role_id"], 10, 64)
|
|
|
+ ntfData.GameRoleId = roleId
|
|
|
util.WarnF("paycallback uid=%v cpOrderNo=%v orderNo=%v payAmount=%v payCurrency=%v payType=%v usdAmount=%v",
|
|
|
uid, cpOrderId, orderNo, usdAmount, payCurrency, payType, usdAmount)
|
|
|
f64, err := strconv.ParseFloat(usdAmount, 32)
|
|
|
if err != nil {
|
|
|
fmt.Println("Error:", err)
|
|
|
+ c.String(http.StatusOK, "failed:order error")
|
|
|
return
|
|
|
}
|
|
|
- webPayNotify(ntfData, float32(f64), c)
|
|
|
+ s := webPayNotify(ntfData, float32(f64), c)
|
|
|
+ if s != "SUCCESS" {
|
|
|
+ c.String(http.StatusOK, s)
|
|
|
+ } else {
|
|
|
+ c.String(http.StatusOK, "success")
|
|
|
+ }
|
|
|
|
|
|
- c.String(http.StatusOK, "success")
|
|
|
}
|
|
|
|
|
|
// 使用公钥解密(对应 PHP 的 openssl_public_decrypt)
|
|
|
@@ -1302,6 +1324,8 @@ type WebNotifyData struct {
|
|
|
GameRoleId uint64
|
|
|
GoodsType uint64
|
|
|
GoodsID uint64
|
|
|
+ Guid string
|
|
|
+ RoleName string
|
|
|
}
|
|
|
|
|
|
func webPayNotify(webNtf *WebNotifyData, payAmount float32, c *gin.Context) string {
|
|
|
@@ -1318,7 +1342,7 @@ func webPayNotify(webNtf *WebNotifyData, payAmount float32, c *gin.Context) stri
|
|
|
//c.JSON(http.StatusOK, "FAILED")
|
|
|
|
|
|
//return "FAILED"
|
|
|
- return fmt.Sprintf("FAILED,cpOrderId=%v err=%v", webNtf.CpOrderId, err)
|
|
|
+ return "failed:game_orderid error"
|
|
|
}
|
|
|
|
|
|
payInfo := &serverproto.PayOrderSaveInfo{}
|
|
|
@@ -1331,6 +1355,18 @@ func webPayNotify(webNtf *WebNotifyData, payAmount float32, c *gin.Context) stri
|
|
|
return fmt.Sprintf("FAILED,cpOrderId=%v err=%v", webNtf.CpOrderId, err)
|
|
|
}
|
|
|
if payInfo.OrderState == int32(serverproto.PayOrderState_EPayOrderState_Gen) {
|
|
|
+ if payInfo.PayChannel != webNtf.Guid && payInfo.PayChannel != "xiaoqi" {
|
|
|
+ util.ErrorF("WebPayQuickNotify order channel error order=%v, webNtf=%v", payInfo, webNtf)
|
|
|
+ return "failed:guid error"
|
|
|
+ }
|
|
|
+ if payInfo.Uid != webNtf.GameRoleId {
|
|
|
+ util.ErrorF("WebPayQuickNotify order uid error order=%v, webNtf=%v", payInfo, webNtf)
|
|
|
+ return "failed:game_role_id error"
|
|
|
+ }
|
|
|
+ if payInfo.PayCurrency != webNtf.RoleName {
|
|
|
+ util.ErrorF("WebPayQuickNotify order role name error order=%v, webNtf=%v", payInfo, webNtf)
|
|
|
+ return "failed:game_role_name error"
|
|
|
+ }
|
|
|
//实际支付 == 订单的钱,否则为支付失败
|
|
|
//payAmount := int32(payAmount * 100) //该渠道是以分为单位(游戏以卢布为单位)
|
|
|
//服务器订单实际金额:
|
|
|
@@ -1340,12 +1376,12 @@ func webPayNotify(webNtf *WebNotifyData, payAmount float32, c *gin.Context) stri
|
|
|
} else {
|
|
|
payInfo.OrderState = int32(serverproto.PayOrderState_EPayOrderState_PayFailed)
|
|
|
util.ErrorF("uid=%v WebPayQuickNotify failed payAmount:%v order=%v", payInfo.Uid, payAmount, payInfo)
|
|
|
- return "FAILED"
|
|
|
+ return "failed:pay_price error"
|
|
|
}
|
|
|
payInfo.OrderProcessTime = util.GetTimeMilliseconds()
|
|
|
payInfo.SdkOrderId = webNtf.SdkOrderId //sdk订单id\
|
|
|
payInfo.PayMethod = webNtf.PayMethod
|
|
|
- payInfo.PayCurrency = webNtf.PayCurrency
|
|
|
+ payInfo.PayCurrency = webNtf.RoleName
|
|
|
payInfo.PayTime = webNtf.PayTime
|
|
|
payInfo.PayChannel = webNtf.PayChannel
|
|
|
|
|
|
@@ -1369,7 +1405,12 @@ func webPayNotify(webNtf *WebNotifyData, payAmount float32, c *gin.Context) stri
|
|
|
} else {
|
|
|
util.ErrorF("WebPayQuickNotify uid=%v state error state=%v", payInfo.Uid, payInfo.OrderState)
|
|
|
//return "FAILED"
|
|
|
- return fmt.Sprintf("FAILED,cpOrderId=%v state error=%v", webNtf.CpOrderId, payInfo.OrderState)
|
|
|
+ if payInfo.SdkOrderId == webNtf.SdkOrderId {
|
|
|
+ return "SUCCESS"
|
|
|
+ } else {
|
|
|
+ util.ErrorF("WebPayQuickNotify uid=%v order is completed but sdkOrderId not same order=%v,sdkOrderId=%v", payInfo.Uid, payInfo, webNtf.SdkOrderId)
|
|
|
+ return "failed:xiao7_goid error"
|
|
|
+ }
|
|
|
}
|
|
|
return "SUCCESS"
|
|
|
}
|