diff --git a/lua/app/common/pay_manager.lua b/lua/app/common/pay_manager.lua index 61fe559d..9acf822c 100644 --- a/lua/app/common/pay_manager.lua +++ b/lua/app/common/pay_manager.lua @@ -136,6 +136,9 @@ end function PayManager:requestRewards(purchaseToken, orderId, originOrderId, notShowRewardsBox) self:sendMsgToServer(purchaseToken, orderId, 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 @@ -204,7 +207,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 @@ -229,15 +232,34 @@ function PayManager:checkAndPay(productId, id, purchaseType, rechargeId) end function PayManager:sendMsgToServer(purchaseToken, orderId, callback) - local args = { - uuid = {orderId}, - channel = SDKManager:getSDKPayType(), - pay_token = purchaseToken - } - if EDITOR_MODE then - args.channel = SDKManager.PAY_TYPE.DEBUG + if Platform:isIosPlatform() then + local payParams = SDKManager:getIosPayInfo(purchaseToken) + if not payParams or not payParams.order then + return -- 支付错误 + end + local info = string.split(payParams.order, "|") + local gift_type = tonumber(info[1]) + local gift_id = tonumber(info[2]) + if not gift_id or not gift_id then + return -- 解析错误 + end + local args = { + id = gift_id, + act_type = gift_type, + pay_token = purchaseToken + } + self:sendMessage(ProtoMsgType.FromMsgEnum.AppStorePaidReq, args, {}, callback) + else + local args = { + uuid = {orderId}, + channel = SDKManager:getSDKPayType(), + pay_token = purchaseToken + } + if EDITOR_MODE then + args.channel = SDKManager.PAY_TYPE.DEBUG + end + self:sendMessage(ProtoMsgType.FromMsgEnum.ActPaidResultReq, args, {}, callback) end - self:sendMessage(ProtoMsgType.FromMsgEnum.ActPaidResultReq, args, {}, callback) end return PayManager \ No newline at end of file diff --git a/lua/app/common/sdk_manager.lua b/lua/app/common/sdk_manager.lua index 5707f474..94e67e2b 100644 --- a/lua/app/common/sdk_manager.lua +++ b/lua/app/common/sdk_manager.lua @@ -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 + -- 支付相关接口 ********************************************************************** 结束 -- 获取设备语言 diff --git a/lua/app/common/sdk_pay_default_manager.lua b/lua/app/common/sdk_pay_default_manager.lua index 924a07ac..67b66ced 100644 --- a/lua/app/common/sdk_pay_default_manager.lua +++ b/lua/app/common/sdk_pay_default_manager.lua @@ -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 diff --git a/lua/app/common/sdk_pay_google_manager.lua b/lua/app/common/sdk_pay_google_manager.lua index 1925a878..89217f8e 100644 --- a/lua/app/common/sdk_pay_google_manager.lua +++ b/lua/app/common/sdk_pay_google_manager.lua @@ -313,8 +313,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 +326,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 diff --git a/lua/app/common/sdk_pay_ios_manager.lua b/lua/app/common/sdk_pay_ios_manager.lua index 8709471b..117d2893 100644 --- a/lua/app/common/sdk_pay_ios_manager.lua +++ b/lua/app/common/sdk_pay_ios_manager.lua @@ -227,8 +227,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,7 +239,7 @@ 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() CS.BF.BFMain.Instance.SDKMgr.IosPaySDKMgr.buyCallback = function(isSuccess, result, errorStr) @@ -252,7 +252,7 @@ function SDKPayiOSManager:doIosPay(productId, orderId, rechargeId, giftType, gif 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 @@ -301,6 +301,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) diff --git a/lua/app/net/net_manager.lua b/lua/app/net/net_manager.lua index 272d14ae..9bc51ae2 100644 --- a/lua/app/net/net_manager.lua +++ b/lua/app/net/net_manager.lua @@ -702,7 +702,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) @@ -713,6 +713,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 @@ -721,7 +728,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)