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)
|
self:checkAndPay(productId, id, purchaseType, rechargeId)
|
||||||
end
|
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)
|
self:sendMsgToServer(purchaseToken, orderId, originOrderId, function(binder, msgData)
|
||||||
if msgData.status == 0 then
|
if msgData.status == 0 then
|
||||||
if Platform:isIosPlatform() then
|
|
||||||
SDKManager:delIosPayInfo(purchaseToken)
|
|
||||||
end
|
|
||||||
local showRewards = not notShowRewardsBox
|
local showRewards = not notShowRewardsBox
|
||||||
if DataManager.TutorialData and DataManager.TutorialData:getIsInTutorial() then -- 引导时不弹
|
if DataManager.TutorialData and DataManager.TutorialData:getIsInTutorial() then -- 引导时不弹
|
||||||
showRewards = false
|
showRewards = false
|
||||||
@ -189,14 +186,33 @@ function PayManager:requestRewards(purchaseToken, orderId, originOrderId, notSho
|
|||||||
end
|
end
|
||||||
BIReport:postAdjustSimpleTrackEvent("rumq9q", {})
|
BIReport:postAdjustSimpleTrackEvent("rumq9q", {})
|
||||||
end
|
end
|
||||||
|
|
||||||
-- 支付验证成功后消耗此订单
|
-- 支付验证成功后消耗此订单
|
||||||
if purchaseToken then
|
if CS.UnityEngine.Application.platform == CS.UnityEngine.RuntimePlatform.Android then
|
||||||
SDKManager:consumePurchase(purchaseToken)
|
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
|
end
|
||||||
elseif msgData.status == 1008 then -- 验证异常,但是需要消耗订单
|
elseif msgData.status == 1008 then -- 验证异常,但是需要消耗订单
|
||||||
if purchaseToken then
|
if CS.UnityEngine.Application.platform == CS.UnityEngine.RuntimePlatform.Android then
|
||||||
SDKManager:consumePurchase(purchaseToken)
|
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
|
end
|
||||||
Logger.logError("重复验证")
|
Logger.logError("重复验证")
|
||||||
else
|
else
|
||||||
@ -225,7 +241,7 @@ function PayManager:checkAndPay(productId, id, purchaseType, rechargeId)
|
|||||||
BIReport:postPayTurn(giftType, id, rechargeId)
|
BIReport:postPayTurn(giftType, id, rechargeId)
|
||||||
SDKManager:pay(productId, msgData.uuid, rechargeId, giftType, purchaseType, id, function(purchaseToken, orderId, originOrderId)
|
SDKManager:pay(productId, msgData.uuid, rechargeId, giftType, purchaseType, id, function(purchaseToken, orderId, originOrderId)
|
||||||
if purchaseToken and orderId then
|
if purchaseToken and orderId then
|
||||||
self:requestRewards(purchaseToken, orderId, originOrderId)
|
self:requestRewards(purchaseToken, orderId, originOrderId, productId)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
else -- 没有支付信息,直接发奖
|
else -- 没有支付信息,直接发奖
|
||||||
|
|||||||
@ -186,6 +186,12 @@ function SDKManager:delIosPayInfo(transactionID)
|
|||||||
end
|
end
|
||||||
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])
|
handleOrder(uncompleteList[index])
|
||||||
end)
|
end)
|
||||||
else
|
else
|
||||||
SDKManager:consumePurchase(uncompleteOrder.purchaseToken, function()
|
self:consumePurchase(uncompleteOrder.purchaseToken, function()
|
||||||
index = index + 1
|
index = index + 1
|
||||||
handleOrder(uncompleteList[index])
|
handleOrder(uncompleteList[index])
|
||||||
end)
|
end)
|
||||||
@ -392,76 +392,4 @@ function SDKPayGoogleManager:doUncompletePay(callback)
|
|||||||
end
|
end
|
||||||
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
|
return SDKPayGoogleManager
|
||||||
|
|||||||
@ -30,7 +30,7 @@ function SDKPayiOSManager:initPay(callback)
|
|||||||
local payParams = self.iosPayInfos[result.transactionID]
|
local payParams = self.iosPayInfos[result.transactionID]
|
||||||
local needConsumePurchase = true
|
local needConsumePurchase = true
|
||||||
if payParams ~= nil and payParams.order then
|
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
|
needConsumePurchase = false
|
||||||
end
|
end
|
||||||
if needConsumePurchase then
|
if needConsumePurchase then
|
||||||
@ -114,7 +114,7 @@ function SDKPayiOSManager:doUncompleteOrder(callback, productId)
|
|||||||
end
|
end
|
||||||
-- 去服务器验证
|
-- 去服务器验证
|
||||||
if uncompleteOrder.order then
|
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
|
index = index + 1
|
||||||
handleOrder(uncompleteList[index])
|
handleOrder(uncompleteList[index])
|
||||||
end)
|
end)
|
||||||
@ -239,8 +239,8 @@ function SDKPayiOSManager:pay(productId, orderId, rechargeId, giftType, purchase
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- sdk将已完成的订单消耗掉
|
-- sdk将已完成的订单消耗掉
|
||||||
function SDKPayiOSManager:consumePurchase(token, callback)
|
function SDKPayiOSManager:consumePurchase(productId, callback)
|
||||||
CS.BF.BFMain.Instance.SDKMgr.IosPaySDKMgr:ConsumePurchase(token)
|
CS.BF.BFMain.Instance.SDKMgr.IosPaySDKMgr:ConsumePurchase(productId)
|
||||||
if callback then
|
if callback then
|
||||||
callback(0)
|
callback(0)
|
||||||
end
|
end
|
||||||
@ -336,82 +336,4 @@ function SDKPayiOSManager:delIosOrder(productId)
|
|||||||
LocalData:save()
|
LocalData:save()
|
||||||
end
|
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
|
return SDKPayiOSManager
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user