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.
76 lines
2.9 KiB
76 lines
2.9 KiB
using Sog;
|
|
using ProtoCSStruct;
|
|
|
|
namespace Game
|
|
{
|
|
public static class GooglePaySvc
|
|
{
|
|
public static void OnPaySuccessReq(PlayerOnGame player, ref CSPayGoogleSuccessReq payReq, bool gmTestPay)
|
|
{
|
|
// 英雄支付不能由客户端发起支付成功的消息
|
|
PayType payType = PlayerPayUtil.GetPlayerPayType(player);
|
|
if (payType != PayType.Google)
|
|
{
|
|
player.Error("GooglePaySvc.OnPaySuccessReq uid {0} invalid pay type {1}", player.UserID, payType);
|
|
return;
|
|
}
|
|
|
|
//预先校验一下订单号
|
|
string orderId = Sog.Crypto.GooglePaySecurity.GetOrderIdFromPurchaseData(payReq.PurchaseData.GetString());
|
|
if (orderId == null)
|
|
{
|
|
player.Error("GooglePaySvc.OnPaySuccessReq uid {0}, GetOrderIdFromPurchaseData failed", player.UserID);
|
|
return;
|
|
}
|
|
|
|
//获取payItemId
|
|
int itemId = PayUtils.GetItemIdFromOrderId(orderId);
|
|
if (itemId == 0)
|
|
{
|
|
player.Error("GooglePaySvc.OnPaySuccessReq uid {0}, GetItemIdFromOrderId failed, orderId {1}"
|
|
, player.UserID, orderId);
|
|
return;
|
|
}
|
|
|
|
PayDiamondDesc desc = PayCommSvc.GetPayDiamondDesc(itemId);
|
|
if (desc == null)
|
|
{
|
|
player.Error("GooglePaySvc.OnPaySuccessReq invalid itemid {0} uid {1}", itemId, payReq.Uid);
|
|
return;
|
|
}
|
|
|
|
CSPayGoogleSuccessRes csRes = new CSPayGoogleSuccessRes {Ret = -1, Uid = player.UserID};
|
|
csRes.OrderId.SetString(orderId);
|
|
csRes.ItemID = itemId;
|
|
|
|
//这个订单号是不是这个用户的
|
|
long uidInOrderId = PayUtils.GetUidFromOrderId(orderId);
|
|
if(player.UserID != uidInOrderId)
|
|
{
|
|
player.Error("GooglePaySvc.OnPaySuccessReq uid {0}, orderId {1}, uid not match uid in orderId is {2}"
|
|
, player.UserID, orderId, uidInOrderId);
|
|
|
|
player.SendToClient((int)CSGameMsgID.PayGoogleSuccessRes, ref csRes);
|
|
|
|
return;
|
|
}
|
|
|
|
|
|
ref SSPayGoogleSuccessReq ssReq = ref CSStructPool<SSPayGoogleSuccessReq>.Instance.GetObjRef();
|
|
ssReq.Uid = player.UserID;
|
|
ssReq.PurchaseData = payReq.PurchaseData;
|
|
ssReq.Signature = payReq.Signature;
|
|
ssReq.OrderId.SetString(orderId);
|
|
ssReq.PayType = (int)PayType.Google;
|
|
ssReq.ItemID = desc.itemID;
|
|
ssReq.GmTestPay = gmTestPay;
|
|
|
|
GameBillLogUtils.LogPayGoogleSuccessReq(ref ssReq);
|
|
|
|
player.Debug("GooglePaySvc.OnPaySuccessReq uid {0} PurchaseData {1} Signature {2}"
|
|
, payReq.Uid, ssReq.PurchaseData, ssReq.Signature);
|
|
|
|
GameServerUtils.GetPacketSender().SendToWorldServer((int)SSGameMsgID.PayGoogleSuccessReq, ref ssReq, player.UserID);
|
|
}
|
|
}
|
|
}
|
|
|