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.
89 lines
3.6 KiB
89 lines
3.6 KiB
using Sog;
|
|
using ProtoCSStruct;
|
|
|
|
namespace Game
|
|
{
|
|
public static class IAPPaySvc
|
|
{
|
|
// 由于目前每次请求都会产生新的订单号, 针对IAP的短信支付, 需要修改逻辑支持
|
|
// 可以限制同一时间只存在一笔待支付订单
|
|
public static void OnPaySuccessReq(PlayerOnGame player, ref CSPayGoogleSuccessReq payReq, bool gmTestPay)
|
|
{
|
|
//预先校验一下订单号
|
|
string orderId = payReq.OrderId.GetString();
|
|
|
|
//苹果的支付这个orderId有可能为空,在用非信用卡支付的时候,比如短信
|
|
if(string.IsNullOrEmpty(orderId))
|
|
{
|
|
//这里面是itemId
|
|
if(payReq.Signature.IsEmpty() == false)
|
|
{
|
|
//for (int i = 0; i < player.RoleData.PayData.PayItemRecord.Count; i++)
|
|
//{
|
|
// ref var oneRecord = ref player.RoleData.PayData.PayItemRecord[i];
|
|
// if (oneRecord.ItemId.Equals(payReq.Signature.GetPtr())
|
|
// && false == oneRecord.OrderIdReq.IsEmpty())
|
|
// {
|
|
// player.Debug("IAPPaySvc.OnPaySuccessReq uid {0}, orderid is null ! find orderId {1} by itemId {2} "
|
|
// , player.UserID, oneRecord.OrderIdReq, payReq.Signature);
|
|
|
|
// payReq.OrderId = oneRecord.OrderIdReq;
|
|
// orderId = oneRecord.OrderIdReq.GetString();
|
|
// break;
|
|
// }
|
|
//}
|
|
}
|
|
}
|
|
|
|
//获取payItemId
|
|
int itemId = PayUtils.GetItemIdFromOrderId(orderId);
|
|
if (itemId == 0)
|
|
{
|
|
player.Error("IAPPaySvc.OnPaySuccessReq uid {0}, GetItemIdFromOrderId failed, orderId {1}"
|
|
, player.UserID, itemId);
|
|
return;
|
|
}
|
|
|
|
PayDiamondDesc desc = PayCommSvc.GetPayDiamondDesc(itemId);
|
|
if (desc == null)
|
|
{
|
|
player.Error("IAPPaySvc.OnPaySuccessReq invalid itemid {0} uid {1}", itemId, payReq.Uid);
|
|
return;
|
|
}
|
|
|
|
CSPayGoogleSuccessRes csRes = new CSPayGoogleSuccessRes {Uid = player.UserID, Ret = -1};
|
|
csRes.OrderId.SetString(orderId);
|
|
csRes.ItemID = itemId;
|
|
|
|
//这个订单号是不是这个用户的
|
|
long uidInOrderId = PayUtils.GetUidFromOrderId(orderId);
|
|
if (player.UserID != uidInOrderId)
|
|
{
|
|
player.Error("IAPPaySvc.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;
|
|
}
|
|
|
|
|
|
SSPayGoogleSuccessReq ssReq = new SSPayGoogleSuccessReq();
|
|
ssReq.Uid = player.UserID;
|
|
ssReq.PurchaseData = payReq.PurchaseData;
|
|
ssReq.Signature = payReq.Signature;
|
|
ssReq.OrderId.SetString(orderId);
|
|
ssReq.PayType = (uint)PayType.IAP;
|
|
ssReq.ItemID = itemId;
|
|
ssReq.GmTestPay = gmTestPay;
|
|
|
|
GameBillLogUtils.LogPayGoogleSuccessReq(ref ssReq);
|
|
|
|
player.Debug("IAPPaySvc.ProcessPayGoogleSuccessReq uid {0} PurchaseData {1} Signature {2}"
|
|
, payReq.Uid, ssReq.PurchaseData, ssReq.Signature);
|
|
|
|
GameServerUtils.GetPacketSender().SendToWorldServer((int)SSGameMsgID.PayGoogleSuccessReq, ref ssReq, player.UserID);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|