From 27676042fb214ca432230a230d750e86ff8d8edd Mon Sep 17 00:00:00 2001 From: chenxi Date: Wed, 14 Jun 2023 17:36:22 +0800 Subject: [PATCH 1/3] =?UTF-8?q?ios=20=E6=94=AF=E4=BB=98=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/common/sdk_pay_ios_manager.lua | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/lua/app/common/sdk_pay_ios_manager.lua b/lua/app/common/sdk_pay_ios_manager.lua index e016700f..5b5c1b8a 100644 --- a/lua/app/common/sdk_pay_ios_manager.lua +++ b/lua/app/common/sdk_pay_ios_manager.lua @@ -37,9 +37,8 @@ function SDKPayiOSManager:initPay(callback) 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 giftId = tonumber(payParams.giftId) + local purchaseType = tonumber(payParams.purchaseType) local giftType = PayManager:getGiftType(purchaseType, giftId) local rechargeId = PayManager:getPackageRechargeId(purchaseType, giftId) BIReport:postPayFailed(result.definition.id, result.transactionID, rechargeId, "error order", giftType, giftId) @@ -48,7 +47,7 @@ function SDKPayiOSManager:initPay(callback) -- 回调时机太早的话,就先保存起来,等后续补单的时候一起补 local order = self.iosOrders[result.definition.id] if order then - self:saveIosPayInfo(result.transactionID, result.receipt, order, result.definition.id) + self:saveIosPayInfo(result.transactionID, result.receipt, order.order, result.definition.id, order.purchaseType, order.giftId) self:delIosOrder(result.definition.id) else -- 之前没有记录只能算掉单了 @@ -260,7 +259,7 @@ function SDKPayiOSManager:doIosPay(productId, orderId, rechargeId, giftType, pur 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, purchaseType .. "|" .. giftId, productId) + self:saveIosPayInfo(result.transactionID, result.receipt, orderId, productId, purchaseType, giftId) if callback then callback(result.receipt, orderId, result.transactionID) end @@ -273,7 +272,7 @@ function SDKPayiOSManager:doIosPay(productId, orderId, rechargeId, giftType, pur end self:delIosOrder(productId) end - self:saveIosOrder(productId, purchaseType .. "|" .. giftId) + self:saveIosOrder(productId, orderId, purchaseType, giftId) CS.BF.BFMain.Instance.SDKMgr.IosPaySDKMgr:Buy(productId, orderId) end @@ -298,12 +297,14 @@ end function SDKPayiOSManager:checkPurchaseOrder(result, productId, callback) end -function SDKPayiOSManager:saveIosPayInfo(transactionID, receipt, order, productId) +function SDKPayiOSManager:saveIosPayInfo(transactionID, receipt, order, productId, purchaseType, giftId) self.iosPayInfos[transactionID] = { order = order, receipt = receipt, transactionID = transactionID, - productId = productId + productId = productId, + purchaseType = purchaseType, + giftId = giftId } LocalData:setIosPayInfo(self.iosPayInfos) LocalData:save() @@ -319,8 +320,12 @@ function SDKPayiOSManager:getIosPayInfo(transactionID) return self.iosPayInfos[transactionID] end -function SDKPayiOSManager:saveIosOrder(productId, order) - self.iosOrders[productId] = order +function SDKPayiOSManager:saveIosOrder(productId, order, purchaseType, giftId) + self.iosOrders[productId] = { + order = order, + purchaseType = purchaseType, + giftId = giftId + } LocalData:setIosOrders(self.iosOrders) LocalData:save() end From fb18182d6ab1d50dc150be9b4a1bcc6a04d5ca06 Mon Sep 17 00:00:00 2001 From: chenxi Date: Wed, 14 Jun 2023 18:43:04 +0800 Subject: [PATCH 2/3] =?UTF-8?q?ios=20=E6=94=AF=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/common/pay_manager.lua | 36 +++++++--- lua/app/common/sdk_manager.lua | 6 ++ lua/app/common/sdk_pay_google_manager.lua | 74 +------------------ lua/app/common/sdk_pay_ios_manager.lua | 86 ++--------------------- 4 files changed, 37 insertions(+), 165 deletions(-) diff --git a/lua/app/common/pay_manager.lua b/lua/app/common/pay_manager.lua index 68228074..7fe4f7e4 100644 --- a/lua/app/common/pay_manager.lua +++ b/lua/app/common/pay_manager.lua @@ -145,12 +145,9 @@ function PayManager:purchasePackage(id, purchaseType) self:checkAndPay(productId, id, purchaseType, rechargeId) end -function PayManager:requestRewards(purchaseToken, orderId, originOrderId, notShowRewardsBox, callback) +function PayManager:requestRewards(purchaseToken, orderId, originOrderId, productId, 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 @@ -189,14 +186,33 @@ function PayManager:requestRewards(purchaseToken, orderId, originOrderId, notSho end BIReport:postAdjustSimpleTrackEvent("rumq9q", {}) end - -- 支付验证成功后消耗此订单 - if purchaseToken then - SDKManager:consumePurchase(purchaseToken) + if CS.UnityEngine.Application.platform == CS.UnityEngine.RuntimePlatform.Android then + if purchaseToken then + SDKManager:consumePurchase(purchaseToken) + end + elseif CS.UnityEngine.Application.platform == CS.UnityEngine.RuntimePlatform.IPhonePlayer then + if productId then + SDKManager:consumePurchase(productId) + SDKManager:delIosOrder(productId) + end + if originOrderId ~= "gm" then + SDKManager:delIosPayInfo(originOrderId) + end end elseif msgData.status == 1008 then -- 验证异常,但是需要消耗订单 - if purchaseToken then - SDKManager:consumePurchase(purchaseToken) + if CS.UnityEngine.Application.platform == CS.UnityEngine.RuntimePlatform.Android then + if purchaseToken then + SDKManager:consumePurchase(purchaseToken) + end + elseif CS.UnityEngine.Application.platform == CS.UnityEngine.RuntimePlatform.IPhonePlayer then + if productId then + SDKManager:consumePurchase(productId) + SDKManager:delIosOrder(productId) + end + if originOrderId ~= "gm" then + SDKManager:delIosPayInfo(originOrderId) + end end Logger.logError("重复验证") else @@ -225,7 +241,7 @@ function PayManager:checkAndPay(productId, id, purchaseType, rechargeId) BIReport:postPayTurn(giftType, id, rechargeId) SDKManager:pay(productId, msgData.uuid, rechargeId, giftType, purchaseType, id, function(purchaseToken, orderId, originOrderId) if purchaseToken and orderId then - self:requestRewards(purchaseToken, orderId, originOrderId) + self:requestRewards(purchaseToken, orderId, originOrderId, productId) end end) else -- 没有支付信息,直接发奖 diff --git a/lua/app/common/sdk_manager.lua b/lua/app/common/sdk_manager.lua index 94e67e2b..8be68ca1 100644 --- a/lua/app/common/sdk_manager.lua +++ b/lua/app/common/sdk_manager.lua @@ -186,6 +186,12 @@ function SDKManager:delIosPayInfo(transactionID) end end +function SDKManager:delIosOrder(productId) + if SDKPayMgr.delIosOrder then + return SDKPayMgr:delIosOrder(productId) + end +end + -- 支付相关接口 ********************************************************************** 结束 -- 获取设备语言 diff --git a/lua/app/common/sdk_pay_google_manager.lua b/lua/app/common/sdk_pay_google_manager.lua index e0768cde..c163590f 100644 --- a/lua/app/common/sdk_pay_google_manager.lua +++ b/lua/app/common/sdk_pay_google_manager.lua @@ -130,7 +130,7 @@ function SDKPayGoogleManager:reqPayReward(uncompleteList, productId, callback) handleOrder(uncompleteList[index]) end) else - SDKManager:consumePurchase(uncompleteOrder.purchaseToken, function() + self:consumePurchase(uncompleteOrder.purchaseToken, function() index = index + 1 handleOrder(uncompleteList[index]) end) @@ -392,76 +392,4 @@ function SDKPayGoogleManager:doUncompletePay(callback) end end --- 第一步向服务器验证订单号 --- function SDKPayGoogleManager:_checkPurchaseOrder(result, productId, callback) --- -- SDKPayGoogleManager:saveOrderId(result.orderId) --- if DataManager.PlayerData:isInPermanentOrders(result.obfuscatedAccountId) then --- return --- end --- local params = {} --- params.receipt = {} --- params.receipt.packageName = Platform:getIdentifier() --- params.receipt.productId = productId --- params.receipt.purchaseToken = result.purchaseToken --- params.receipt.subscription = false - --- CS.BF.BFMain.Instance.ParseClientMgr:SetLuaCheckPurchaseOrderCallback(function (msg) --- local serverResult = json.decode(msg) --- local _result = serverResult.result --- Logger.printTable(serverResult) --- if _result and _result.data then --- if _result.code == 0 then --- -- SDKPayGoogleManager:delOrderId(_result.data.orderId) --- SDKPayGoogleManager:saveOrderId(_result.data.obfuscatedExternalAccountId, params) --- SDKPayGoogleManager:checkPurchaseConsume(_result.data.obfuscatedExternalAccountId, params, callback) --- -- if callback then --- -- callback(_result.data.purchaseToken, _result.data.obfuscatedAccountId, _result.data.orderId) --- -- end --- elseif _result.code == 137 then --- -- SDKPayGoogleManager:delOrderId(_result.data.orderId) --- SDKPayGoogleManager:consumePurchase(_result.data.purchaseToken) --- else --- -- @TODO 重试 --- end --- end - --- end) --- CS.BF.BFMain.Instance.ParseClientMgr:CheckPurchaseGPOrder(json.encode(params)) --- end - --- 第二步向服务器申请消耗订单 --- function SDKPayGoogleManager:checkPurchaseConsume(orderId, params, callback, callback1) --- if not orderId or not params then --- return --- end --- CS.BF.BFMain.Instance.ParseClientMgr:SetLuaCheckPurchaseConsumeCallback(function (msg) --- local serverResult = json.decode(msg) --- local _result = serverResult.result --- Logger.printTable(serverResult) --- if _result and _result.data then --- if _result.code == 0 or _result.code == 137 then --- SDKPayGoogleManager:delOrderId(orderId) --- SDKPayGoogleManager:savePermanentOrderId(orderId) --- if callback then --- callback(_result.data.purchaseToken, _result.data.obfuscatedExternalAccountId, _result.data.orderId) --- else - -- PayManager:requestRewards(_result.data.purchaseToken, orderId) --- SDKPayGoogleManager:consumePurchase(_result.data.purchaseToken) --- if callback1 then --- callback1() --- end --- end --- -- elseif _result.code == 137 then --- -- SDKPayGoogleManager:delOrderId(orderId) --- -- SDKPayGoogleManager:consumePurchase(_result.data.purchaseToken) --- else --- -- @TODO 重试 --- end --- end - --- end) --- CS.BF.BFMain.Instance.ParseClientMgr:CheckPurchaseGPConsume(json.encode(params)) --- end - --- 支付相关接口 ********************************************************************** 结束 return SDKPayGoogleManager diff --git a/lua/app/common/sdk_pay_ios_manager.lua b/lua/app/common/sdk_pay_ios_manager.lua index 5b5c1b8a..aa4eb425 100644 --- a/lua/app/common/sdk_pay_ios_manager.lua +++ b/lua/app/common/sdk_pay_ios_manager.lua @@ -30,7 +30,7 @@ function SDKPayiOSManager:initPay(callback) local payParams = self.iosPayInfos[result.transactionID] local needConsumePurchase = true if payParams ~= nil and payParams.order then - PayManager:requestRewards(result.receipt, payParams.order, result.transactionID) + PayManager:requestRewards(result.receipt, payParams.order, result.transactionID, payParams.productId) needConsumePurchase = false end if needConsumePurchase then @@ -114,7 +114,7 @@ function SDKPayiOSManager:doUncompleteOrder(callback, productId) end -- 去服务器验证 if uncompleteOrder.order then - PayManager:requestRewards(uncompleteOrder.receipt, uncompleteOrder.order, uncompleteOrder.transactionID, true, function() + PayManager:requestRewards(uncompleteOrder.receipt, uncompleteOrder.order, uncompleteOrder.transactionID, uncompleteOrder.productId, true, function() index = index + 1 handleOrder(uncompleteList[index]) end) @@ -239,8 +239,8 @@ function SDKPayiOSManager:pay(productId, orderId, rechargeId, giftType, purchase end -- sdk将已完成的订单消耗掉 -function SDKPayiOSManager:consumePurchase(token, callback) - CS.BF.BFMain.Instance.SDKMgr.IosPaySDKMgr:ConsumePurchase(token) +function SDKPayiOSManager:consumePurchase(productId, callback) + CS.BF.BFMain.Instance.SDKMgr.IosPaySDKMgr:ConsumePurchase(productId) if callback then callback(0) end @@ -336,82 +336,4 @@ function SDKPayiOSManager:delIosOrder(productId) LocalData:save() end --- 第一步向服务器验证订单号 --- function SDKPayiOSManager:checkPurchaseIOSOrder(result, productId, callback) --- Logger.printTable(result) --- Logger.log(productId) --- local orderId = DataManager.PlayerData:getIosOrderId(result.transactionID) --- if not orderId then --- return --- end --- if DataManager.PlayerData:isInPermanentOrders(result.transactionID) then --- return --- end --- local params = {} --- -- params.receipt.packageName = Platform:getIdentifier() --- -- params.receipt.productId = productId --- params.receipt = result.receipt --- params.transaction_id = result.transactionID - --- CS.BF.BFMain.Instance.ParseClientMgr:SetLuaCheckPurchaseIOSOrderCallback(function (msg) --- local serverResult = json.decode(msg) --- local _result = serverResult.result --- Logger.printTable(serverResult) --- -- 后端返回latest_receipt_info --- if _result and _result.data then --- if _result.code == 0 then --- SDKPayiOSManager:saveOrderId(result.transactionID, params) --- -- 第二次验证 --- SDKPayiOSManager:checkPurchaseConsume(result, params, callback) --- elseif _result.code == 137 then --- -- SDKPayiOSManager:delOrderId(_result.data.orderId) --- -- 消耗订单 --- -- SDKPayiOSManager:consumePurchase(_result.data.purchaseToken) --- else --- -- @TODO 重试 --- end --- end - --- end) --- CS.BF.BFMain.Instance.ParseClientMgr:CheckPurchaseIOSOrder(json.encode(params)) --- end - --- 第二步向服务器申请消耗订单 --- function SDKPayiOSManager:checkPurchaseConsume(result, params, callback, callback1) --- if not result or not params then --- return --- end --- local orderId = DataManager.PlayerData:getIosOrderId(result.transactionID) --- if not orderId then --- return --- end --- CS.BF.BFMain.Instance.ParseClientMgr:SetLuaCheckPurchaseIOSConsumeCallback(function (msg) --- local serverResult = json.decode(msg) --- local _result = serverResult.result --- Logger.printTable(serverResult) --- if _result and _result.data then --- if _result.code == 0 then --- -- 处理本地存储订单 --- SDKPayiOSManager:delIosOrderId(result.transactionID) --- SDKPayiOSManager:delOrderId(result.transactionID) --- SDKPayiOSManager:savePermanentOrderId(result.transactionID) --- if callback then --- callback(result.receipt, orderId, result.transactionID) --- else --- -- SDKPayiOSManager:consumePurchase(_result.data.purchaseToken) - -- PayManager:requestRewards(_result.data.purchaseToken, orderId) --- if callback1 then --- callback1() --- end --- end --- elseif _result.code == 137 then --- else --- -- @TODO 重试 --- end --- end - --- end) --- CS.BF.BFMain.Instance.ParseClientMgr:CheckPurchaseIOSConsume(json.encode(params)) --- end --- 支付相关接口 ********************************************************************** 结束 return SDKPayiOSManager From 119d9c8e2208fd523f0e995f4d5a53752e0348d9 Mon Sep 17 00:00:00 2001 From: chenxi Date: Wed, 14 Jun 2023 18:56:18 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E9=9A=90=E7=A7=81=E6=94=BF=E7=AD=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/ui/game_setting/game_setting_ui.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/app/ui/game_setting/game_setting_ui.lua b/lua/app/ui/game_setting/game_setting_ui.lua index 5a073e7c..51465489 100644 --- a/lua/app/ui/game_setting/game_setting_ui.lua +++ b/lua/app/ui/game_setting/game_setting_ui.lua @@ -166,11 +166,11 @@ function GameSettingUI:_addListeners() end) self.uiMap["game_setting_ui.bg.tx_1"]:addClickListener(function() - GFunc.openUrl("http://agileliongames.com/AgileLionGames%27sPrivacyPolicy.html") + GFunc.openUrl("https://perfeggsgame.com/tos.html") end) self.uiMap["game_setting_ui.bg.tx_2"]:addClickListener(function() - GFunc.openUrl("http://agileliongames.com/AgileLionGames%27sPrivacyPolicy.html") + GFunc.openUrl("https://perfeggsgame.com/pp.html") end) end