ios 支付
This commit is contained in:
parent
27676042fb
commit
fb18182d6a
@ -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 -- 没有支付信息,直接发奖
|
||||
|
||||
@ -186,6 +186,12 @@ function SDKManager:delIosPayInfo(transactionID)
|
||||
end
|
||||
end
|
||||
|
||||
function SDKManager:delIosOrder(productId)
|
||||
if SDKPayMgr.delIosOrder then
|
||||
return SDKPayMgr:delIosOrder(productId)
|
||||
end
|
||||
end
|
||||
|
||||
-- 支付相关接口 ********************************************************************** 结束
|
||||
|
||||
-- 获取设备语言
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user