Merge branch 'dev_ios' into dev

This commit is contained in:
chenxi 2023-06-14 15:40:47 +08:00
commit d3bb4c3698
11 changed files with 172 additions and 77 deletions

View File

@ -109,6 +109,18 @@ function PayManager:getGiftConfigInfo(purchaseType, id)
return cfg[id]
end
function PayManager:getPackageRechargeId(purchaseType, id)
local cfgName = PayManager.PURCHARSE_TYPE_CONFIG[purchaseType]
if not cfgName then
return
end
local cfg = ConfigManager:getConfig(cfgName)
if not cfg or not cfg[id] then
return
end
return cfg[id].recharge_id
end
function PayManager:purchasePackage(id, purchaseType)
local cfgName = PayManager.PURCHARSE_TYPE_CONFIG[purchaseType]
if not cfgName then
@ -133,9 +145,12 @@ function PayManager:purchasePackage(id, purchaseType)
self:checkAndPay(productId, id, purchaseType, rechargeId)
end
function PayManager:requestRewards(purchaseToken, orderId, originOrderId, notShowRewardsBox)
self:sendMsgToServer(purchaseToken, orderId, function(binder, msgData)
function PayManager:requestRewards(purchaseToken, orderId, originOrderId, notShowRewardsBox, callback)
self:sendMsgToServer(purchaseToken, orderId, originOrderId, function(binder, msgData)
if msgData.status == 0 then
if Platform:isIosPlatform() then
SDKManager:delIosPayInfo(purchaseToken)
end
local showRewards = not notShowRewardsBox
if DataManager.TutorialData and DataManager.TutorialData:getIsInTutorial() then -- 引导时不弹
showRewards = false
@ -173,6 +188,7 @@ function PayManager:requestRewards(purchaseToken, orderId, originOrderId, notSho
if rechargeCfg then
BIReport:postPurchase(rechargeCfg.price, rechargeCfg.payId, originOrderId, orderId)
end
BIReport:postAdjustSimpleTrackEvent("rumq9q", {})
end
local data = {}
@ -198,6 +214,9 @@ function PayManager:requestRewards(purchaseToken, orderId, originOrderId, notSho
}
GFunc.showMessageBox(params)
end
if callback then
callback()
end
end)
end
@ -210,7 +229,7 @@ function PayManager:checkAndPay(productId, id, purchaseType, rechargeId)
if msgData.uuid and msgData.uuid ~= GConst.EMPTY_STRING then
local giftType = PayManager:getGiftType(purchaseType, id)
BIReport:postPayTurn(giftType, id, rechargeId)
SDKManager:pay(productId, msgData.uuid, rechargeId, giftType, id, function(purchaseToken, orderId, originOrderId)
SDKManager:pay(productId, msgData.uuid, rechargeId, giftType, purchaseType, id, function(purchaseToken, orderId, originOrderId)
if purchaseToken and orderId then
self:requestRewards(purchaseToken, orderId, originOrderId)
end
@ -234,12 +253,20 @@ function PayManager:checkAndPay(productId, id, purchaseType, rechargeId)
end)
end
function PayManager:sendMsgToServer(purchaseToken, orderId, callback)
function PayManager:sendMsgToServer(purchaseToken, orderId, originOrderId, callback)
local args = {
uuid = {orderId},
channel = SDKManager:getSDKPayType(),
pay_token = purchaseToken
}
if Platform:isIosPlatform() then
local purchaseTokenObj = json.decode(purchaseToken)
if purchaseTokenObj == nil then
return -- 解析错误
end
args.pay_token = purchaseTokenObj.Payload
else
args.pay_token = purchaseToken
end
if EDITOR_MODE then
args.channel = SDKManager.PAY_TYPE.DEBUG
end

View File

@ -87,7 +87,7 @@ end
function Platform:getPlatformStr()
if self.platformStr == nil then
if self:isIosPlatform() then
self.platformStr = "IOS"
self.platformStr = "iOS"
elseif self:isAndroidPlatform() then
self.platformStr = "Android"
else

View File

@ -166,14 +166,26 @@ function SDKManager:checkPay(productId, callback)
end
-- 支付
function SDKManager:pay(productId, orderId, rechargeId, giftType, giftId, callback)
SDKPayMgr:pay(productId, orderId, rechargeId, giftType, giftId, callback)
function SDKManager:pay(productId, orderId, rechargeId, giftType, purchaseType, giftId, callback)
SDKPayMgr:pay(productId, orderId, rechargeId, giftType, purchaseType, giftId, callback)
end
function SDKManager:doUncompletePay(callback)
SDKPayMgr:doUncompletePay(callback)
end
function SDKManager:getIosPayInfo(transactionID)
if SDKPayMgr.getIosPayInfo then
return SDKPayMgr:getIosPayInfo(transactionID)
end
end
function SDKManager:delIosPayInfo(transactionID)
if SDKPayMgr.delIosPayInfo then
return SDKPayMgr:delIosPayInfo(transactionID)
end
end
-- 支付相关接口 ********************************************************************** 结束
-- 获取设备语言

View File

@ -45,7 +45,7 @@ function SDKPayDefaultManager:checkPay(productId, callback)
end
-- 支付
function SDKPayDefaultManager:pay(productId, orderId, rechargeId, giftType, giftId, callback)
function SDKPayDefaultManager:pay(productId, orderId, rechargeId, giftType, purchaseType, giftId, callback)
callback("", orderId)
end

View File

@ -125,7 +125,10 @@ function SDKPayGoogleManager:reqPayReward(uncompleteList, productId, callback)
elseif uncompleteOrder.purchaseToken then
-- 去服务器验证
if uncompleteOrder.obfuscatedAccountId then
PayManager:requestRewards(uncompleteOrder.purchaseToken, uncompleteOrder.obfuscatedAccountId, uncompleteOrder.orderId, true)
PayManager:requestRewards(uncompleteOrder.purchaseToken, uncompleteOrder.obfuscatedAccountId, uncompleteOrder.orderId, true, function()
index = index + 1
handleOrder(uncompleteList[index])
end)
else
SDKManager:consumePurchase(uncompleteOrder.purchaseToken, function()
index = index + 1
@ -313,8 +316,8 @@ function SDKPayGoogleManager:checkPay(productId, callback)
end
-- 支付
function SDKPayGoogleManager:pay(productId, orderId, rechargeId, giftType, giftId, callback)
self:doGooglePay(productId, orderId, rechargeId, giftType, giftId, callback)
function SDKPayGoogleManager:pay(productId, orderId, rechargeId, giftType, purchaseType, giftId, callback)
self:doGooglePay(productId, orderId, rechargeId, giftType, purchaseType, giftId, callback)
end
-- 连接Google商店
@ -326,7 +329,7 @@ function SDKPayGoogleManager:connectGoogleStore(callback)
end)
end
function SDKPayGoogleManager:doGooglePay(productId, orderId, rechargeId, giftType, giftId, callback)
function SDKPayGoogleManager:doGooglePay(productId, orderId, rechargeId, giftType, purchaseType, giftId, callback)
local payType = PAY_TYPE_IN_APP
local rechargeCfg = ConfigManager:getConfig("recharge")[rechargeId]
if rechargeCfg.subscribe then

View File

@ -26,39 +26,44 @@ function SDKPayiOSManager:initPay(callback)
CS.BF.BFMain.Instance.SDKMgr.IosPaySDKMgr.buyCallback = function(isSuccess, result, errorStr)
if isSuccess then
-- if self.handleUncompleteIosOrder then
-- local payParams = self.iosPayInfos[result.transactionID]
-- local needConsumePurchase = true
-- if payParams ~= nil and payParams.order then
-- PayManager:requestRewards(result.receipt, payParams.order)
-- needConsumePurchase = false
-- end
-- if needConsumePurchase then
-- self:delIosPayInfo(result.transactionID)
-- self:delIosOrder(result.definition.id)
-- self:consumePurchase(result.definition.id)
-- BIReport:postPayFailed(result.definition.id, result.transactionID, nil, "error order")
-- end
-- else
-- -- 回调时机太早的话,就先保存起来,等后续补单的时候一起补
-- local order = self.iosOrders[result.definition.id]
-- if order then
-- self:saveIosPayInfo(result.transactionID, result.receipt, order, result.definition.id)
-- self:delIosOrder(result.definition.id)
-- else
-- -- 之前没有记录只能算掉单了
-- self:delIosPayInfo(result.transactionID)
-- self:delIosOrder(result.definition.id)
-- self:consumePurchase(result.definition.id)
-- BIReport:postPayFailed(result.definition.id, result.transactionID, nil, "not have order")
-- end
-- end
if self.handleUncompleteIosOrder then
local payParams = self.iosPayInfos[result.transactionID]
local needConsumePurchase = true
if payParams ~= nil and payParams.order then
PayManager:requestRewards(result.receipt, payParams.order, result.transactionID)
needConsumePurchase = false
end
if needConsumePurchase then
self:delIosPayInfo(result.transactionID)
self:delIosOrder(result.definition.id)
self:consumePurchase(result.definition.id)
local arr = string.split(payParams.order, "|")
local giftId = tonumber(arr[2])
local purchaseType = tonumber(arr[1])
local giftType = PayManager:getGiftType(purchaseType, giftId)
local rechargeId = PayManager:getPackageRechargeId(purchaseType, giftId)
BIReport:postPayFailed(result.definition.id, result.transactionID, rechargeId, "error order", giftType, giftId)
end
else
-- 回调时机太早的话,就先保存起来,等后续补单的时候一起补
local order = self.iosOrders[result.definition.id]
if order then
self:saveIosPayInfo(result.transactionID, result.receipt, order, result.definition.id)
self:delIosOrder(result.definition.id)
else
-- 之前没有记录只能算掉单了
self:delIosPayInfo(result.transactionID)
self:delIosOrder(result.definition.id)
self:consumePurchase(result.definition.id)
BIReport:postPayFailed(result.definition.id, result.transactionID, nil, "not have order")
end
end
else
-- if errorStr and errorStr ~= "" then
-- BIReport:postPayFailed(result.definition.id, result.transactionID, nil, errorStr)
-- else
-- BIReport:postPayFailed(result.definition.id, result.transactionID, nil, "1")
-- end
if errorStr and errorStr ~= "" then
BIReport:postPayFailed(result.definition.id, result.transactionID, nil, errorStr)
else
BIReport:postPayFailed(result.definition.id, result.transactionID, nil, "1")
end
end
end
@ -110,7 +115,10 @@ function SDKPayiOSManager:doUncompleteOrder(callback, productId)
end
-- 去服务器验证
if uncompleteOrder.order then
PayManager:requestRewards(uncompleteOrder.receipt, uncompleteOrder.order)
PayManager:requestRewards(uncompleteOrder.receipt, uncompleteOrder.order, uncompleteOrder.transactionID, true, function()
index = index + 1
handleOrder(uncompleteList[index])
end)
else
SDKManager:delIosPayInfo(uncompleteOrder.transactionID)
SDKManager:delIosOrder(uncompleteOrder.productId)
@ -227,8 +235,8 @@ function SDKPayiOSManager:checkPay(productId, callback)
end
-- 支付
function SDKPayiOSManager:pay(productId, orderId, rechargeId, giftType, giftId, callback)
self:doIosPay(productId, orderId, rechargeId, giftType, giftId, callback)
function SDKPayiOSManager:pay(productId, orderId, rechargeId, giftType, purchaseType, giftId, callback)
self:doIosPay(productId, orderId, rechargeId, giftType, purchaseType, giftId, callback)
end
-- sdk将已完成的订单消耗掉
@ -239,20 +247,20 @@ function SDKPayiOSManager:consumePurchase(token, callback)
end
end
function SDKPayiOSManager:doIosPay(productId, orderId, rechargeId, giftType, giftId, callback)
function SDKPayiOSManager:doIosPay(productId, orderId, rechargeId, giftType, purchaseType, giftId, callback)
self.blockTouch = true
UIManager:showWaitNet()
UIManager:showWaitPay()
CS.BF.BFMain.Instance.SDKMgr.IosPaySDKMgr.buyCallback = function(isSuccess, result, errorStr)
if self.blockTouch then
self.blockTouch = false
UIManager:hideWaitNet()
UIManager:hideWaitPay()
end
if isSuccess then
Logger.log("ios pay availableToPurchase = %s", result.availableToPurchase)
Logger.log("ios pay transactionID = %s", result.transactionID)
Logger.log("ios pay hasReceipt = %s", result.hasReceipt)
Logger.log("ios pay receipt = %s", result.receipt)
self:saveIosPayInfo(result.transactionID, result.receipt, orderId, productId)
self:saveIosPayInfo(result.transactionID, result.receipt, purchaseType .. "|" .. giftId, productId)
if callback then
callback(result.receipt, orderId, result.transactionID)
end
@ -265,7 +273,7 @@ function SDKPayiOSManager:doIosPay(productId, orderId, rechargeId, giftType, gif
end
self:delIosOrder(productId)
end
self:saveIosOrder(productId, orderId)
self:saveIosOrder(productId, purchaseType .. "|" .. giftId)
CS.BF.BFMain.Instance.SDKMgr.IosPaySDKMgr:Buy(productId, orderId)
end
@ -301,6 +309,16 @@ function SDKPayiOSManager:saveIosPayInfo(transactionID, receipt, order, productI
LocalData:save()
end
function SDKPayiOSManager:delIosPayInfo(transactionID)
self.iosPayInfos[transactionID] = nil
LocalData:setIosPayInfo(self.iosPayInfos)
LocalData:save()
end
function SDKPayiOSManager:getIosPayInfo(transactionID)
return self.iosPayInfos[transactionID]
end
function SDKPayiOSManager:saveIosOrder(productId, order)
self.iosOrders[productId] = order
LocalData:setIosOrders(self.iosOrders)

View File

@ -1,6 +1,6 @@
local recharge = {
[1]={
["payId"]="com.knight.connect.rpg.0.99dollar",
["payId"]="com.combo.heroes.puzzle.rpg.0.99dollar",
["price"]=0.99,
["price_cn"]=6,
["same_price"]=1,
@ -8,7 +8,7 @@ local recharge = {
["score"]=1
},
[2]={
["payId"]="com.knight.connect.rpg.1.99dollar",
["payId"]="com.combo.heroes.puzzle.rpg.1.99dollar",
["price"]=1.99,
["price_cn"]=12,
["same_price"]=2,
@ -16,7 +16,7 @@ local recharge = {
["score"]=2
},
[3]={
["payId"]="com.knight.connect.rpg.2.99dollar",
["payId"]="com.combo.heroes.puzzle.rpg.2.99dollar",
["price"]=2.99,
["price_cn"]=18,
["same_price"]=3,
@ -24,7 +24,7 @@ local recharge = {
["score"]=3
},
[4]={
["payId"]="com.knight.connect.rpg.3.99dollar",
["payId"]="com.combo.heroes.puzzle.rpg.3.99dollar",
["price"]=3.99,
["price_cn"]=24,
["same_price"]=4,
@ -32,7 +32,7 @@ local recharge = {
["score"]=4
},
[5]={
["payId"]="com.knight.connect.rpg.4.99dollar",
["payId"]="com.combo.heroes.puzzle.rpg.4.99dollar",
["price"]=4.99,
["price_cn"]=30,
["same_price"]=5,
@ -40,7 +40,7 @@ local recharge = {
["score"]=5
},
[6]={
["payId"]="com.knight.connect.rpg.5.99dollar",
["payId"]="com.combo.heroes.puzzle.rpg.5.99dollar",
["price"]=5.99,
["price_cn"]=38,
["same_price"]=6,
@ -48,7 +48,7 @@ local recharge = {
["score"]=6
},
[7]={
["payId"]="com.knight.connect.rpg.6.99dollar",
["payId"]="com.combo.heroes.puzzle.rpg.6.99dollar",
["price"]=6.99,
["price_cn"]=45,
["same_price"]=7,
@ -56,7 +56,7 @@ local recharge = {
["score"]=7
},
[8]={
["payId"]="com.knight.connect.rpg.7.99dollar",
["payId"]="com.combo.heroes.puzzle.rpg.7.99dollar",
["price"]=7.99,
["price_cn"]=52,
["same_price"]=8,
@ -64,7 +64,7 @@ local recharge = {
["score"]=8
},
[9]={
["payId"]="com.knight.connect.rpg.8.99dollar",
["payId"]="com.combo.heroes.puzzle.rpg.8.99dollar",
["price"]=8.99,
["price_cn"]=60,
["same_price"]=9,
@ -72,7 +72,7 @@ local recharge = {
["score"]=9
},
[10]={
["payId"]="com.knight.connect.rpg.9.99dollar",
["payId"]="com.combo.heroes.puzzle.rpg.9.99dollar",
["price"]=9.99,
["price_cn"]=68,
["same_price"]=10,
@ -80,7 +80,7 @@ local recharge = {
["score"]=10
},
[11]={
["payId"]="com.knight.connect.rpg.11.99dollar",
["payId"]="com.combo.heroes.puzzle.rpg.11.99dollar",
["price"]=11.99,
["price_cn"]=78,
["same_price"]=12,
@ -88,7 +88,7 @@ local recharge = {
["score"]=12
},
[12]={
["payId"]="com.knight.connect.rpg.14.99dollar",
["payId"]="com.combo.heroes.puzzle.rpg.14.99dollar",
["price"]=14.99,
["price_cn"]=98,
["same_price"]=15,
@ -96,7 +96,7 @@ local recharge = {
["score"]=15
},
[13]={
["payId"]="com.knight.connect.rpg.19.99dollar",
["payId"]="com.combo.heroes.puzzle.rpg.19.99dollar",
["price"]=19.99,
["price_cn"]=128,
["same_price"]=20,
@ -104,7 +104,7 @@ local recharge = {
["score"]=20
},
[14]={
["payId"]="com.knight.connect.rpg.24.99dollar",
["payId"]="com.combo.heroes.puzzle.rpg.24.99dollar",
["price"]=24.99,
["price_cn"]=168,
["same_price"]=25,
@ -112,7 +112,7 @@ local recharge = {
["score"]=25
},
[15]={
["payId"]="com.knight.connect.rpg.29.99dollar",
["payId"]="com.combo.heroes.puzzle.rpg.29.99dollar",
["price"]=29.99,
["price_cn"]=198,
["same_price"]=30,
@ -120,7 +120,7 @@ local recharge = {
["score"]=30
},
[16]={
["payId"]="com.knight.connect.rpg.49.99dollar",
["payId"]="com.combo.heroes.puzzle.rpg.49.99dollar",
["price"]=49.99,
["price_cn"]=328,
["same_price"]=50,
@ -128,7 +128,7 @@ local recharge = {
["score"]=50
},
[17]={
["payId"]="com.knight.connect.rpg.69.99dollar",
["payId"]="com.combo.heroes.puzzle.rpg.69.99dollar",
["price"]=69.99,
["price_cn"]=448,
["same_price"]=70,
@ -136,7 +136,7 @@ local recharge = {
["score"]=70
},
[18]={
["payId"]="com.knight.connect.rpg.99.99dollar",
["payId"]="com.combo.heroes.puzzle.rpg.99.99dollar",
["price"]=99.99,
["price_cn"]=648,
["same_price"]=100,
@ -144,7 +144,7 @@ local recharge = {
["score"]=100
},
[19]={
["payId"]="com.knight.connect.rpg.199.99dollar",
["payId"]="com.combo.heroes.puzzle.rpg.199.99dollar",
["price"]=199.99,
["price_cn"]=1298,
["same_price"]=200,

View File

@ -265,7 +265,8 @@ GConst.DOTWEEN_IDS = {
WAIT_NET = 4,
TUTORIAL = 5,
TASK_TOAST = 6,
BATTLE_UI = 7
BATTLE_UI = 7,
WAIT_PAY = 8
}
GConst.MESSAGE_BOX_TYPE = {

View File

@ -23,7 +23,6 @@ end
---- 登录界面资源加载完毕后调用
function LoginManager:loginGame()
-- adjust 打开应用事件识别码
BIReport:postAdjustSimpleTrackEvent("xbszrl", {})
ModuleManager.MaincityManager:firstEnterMainCity()
end

View File

@ -708,7 +708,7 @@ function NetManager:onReceive(msgId, data)
if NOT_PUBLISH then
Logger.printTable(responseData)
end
if pbData.rewards then
if pbData.err_code == GConst.ERROR_STR.SUCCESS and pbData.rewards then
local getType = receiveCallback.getType
if sendMsgName == "ActPayReq" then
getType = PayManager:getItemGetType(pbData.act_type, pbData.id)
@ -719,6 +719,13 @@ function NetManager:onReceive(msgId, data)
break
end
end
elseif sendMsgName == "AppStorePaidReq" then -- ios支付上报统一处理
if pbData.gift then
for _, gift in ipairs(pbData.gift) do
getType = PayManager:getItemGetType(gift.act_type, gift.id)
break
end
end
end
if EDITOR_MODE and not getType then
@ -727,7 +734,7 @@ function NetManager:onReceive(msgId, data)
GFunc.addRewards(pbData.rewards, getType)
end
if pbData.costs and not self:getNotAddCostsRsp(msgName) then
if pbData.err_code == GConst.ERROR_STR.SUCCESS and pbData.costs and not self:getNotAddCostsRsp(msgName) then
local getType = receiveCallback.getType
if sendMsgName == "ActPayReq" then
getType = PayManager:getItemGetType(pbData.mall_type, pbData.id)

View File

@ -753,6 +753,33 @@ function UIManager:getUICameraComponent()
return self.uiCamera:getComponent(GConst.TYPEOF_UNITY_CLASS.CAMERA)
end
function UIManager:showWaitPay()
if self.waitNetCount == 0 then
if self.waitPaySeq == nil then
local seq = DOTweenManager:createSeqWithIntId(GConst.DOTWEEN_IDS.WAIT_PAY)
seq:SetAutoKill(false)
seq:AppendInterval(1)
seq:AppendCallback(function()
self.netCanvas:setActive(true)
end)
self.waitPaySeq = seq
elseif not self.waitPaySeq:IsPlaying() then
self.waitPaySeq:Restart()
end
end
self.waitNetCount = self.waitNetCount + 1
self:disableTouch()
end
function UIManager:hideWaitPay()
self:hideWaitNet()
if self.waitNetCount <= 0 then
if self.waitPaySeq then
self.waitPaySeq:Pause()
end
end
end
function UIManager:showWaitNet(forceRestart)
if self.waitNetCount == 0 or forceRestart then
if self.waitNetSeq == nil then
@ -1190,7 +1217,8 @@ if NOT_PUBLISH then
[BaseUI.disableUITouch] = true,
[BaseScene.disableTouch] = true,
[UIManager.showLoading] = true,
[UIManager.showWaitNet] = true
[UIManager.showWaitNet] = true,
[UIManager.showWaitPay] = true
}
end
local currFunc = debug.getinfo(2, "f").func