From 7bd9413a830a91cecb73a527236250e175f7a622 Mon Sep 17 00:00:00 2001 From: huyufei Date: Mon, 18 Mar 2024 15:19:44 +0800 Subject: [PATCH] =?UTF-8?q?update:=20Json=20=E8=A7=A3=E6=9E=90=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=20TryCatch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IPM/Scripts/Requests/AppleOrderRequest.cs | 37 +++++++++------ .../Scripts/Requests/GoogleOrderRequest.cs | 45 +++++++++++-------- 2 files changed, 49 insertions(+), 33 deletions(-) diff --git a/Runtime/GuruCore/Runtime/IPM/Scripts/Requests/AppleOrderRequest.cs b/Runtime/GuruCore/Runtime/IPM/Scripts/Requests/AppleOrderRequest.cs index 5674e13..e30c6cd 100644 --- a/Runtime/GuruCore/Runtime/IPM/Scripts/Requests/AppleOrderRequest.cs +++ b/Runtime/GuruCore/Runtime/IPM/Scripts/Requests/AppleOrderRequest.cs @@ -1,5 +1,7 @@ +using System; + namespace Guru { using System.Text; @@ -49,24 +51,31 @@ namespace Guru protected override void RequestSuccessCallBack(string response) { - ResponseData responseData = JsonUtility.FromJson>(response); - if (responseData != null && responseData.data != null) + try { - double usdPrice = responseData.data.usdPrice; - Analytics.Tch001IAPRev(usdPrice); - Analytics.Tch02IAPRev(usdPrice); - if (orderType == 0) + ResponseData responseData = JsonUtility.FromJson>(response); + if (responseData != null && responseData.data != null) { - AdjustService.TrackIAPPurchase(usdPrice, productId); - Analytics.IAPPurchase(usdPrice, productId); + double usdPrice = responseData.data.usdPrice; + Analytics.Tch001IAPRev(usdPrice); + Analytics.Tch02IAPRev(usdPrice); + if (orderType == 0) + { + AdjustService.TrackIAPPurchase(usdPrice, productId); + Analytics.IAPPurchase(usdPrice, productId); + } + else if (orderType == 1) + { + AdjustService.TrackSubPurchase(usdPrice, productId); + Analytics.SubPurchase(usdPrice, productId); + } } - else if (orderType == 1) - { - AdjustService.TrackSubPurchase(usdPrice, productId); - Analytics.SubPurchase(usdPrice, productId); - } - } + catch (Exception ex) + { + Analytics.LogCrashlytics(ex); + } + } } } \ No newline at end of file diff --git a/Runtime/GuruCore/Runtime/IPM/Scripts/Requests/GoogleOrderRequest.cs b/Runtime/GuruCore/Runtime/IPM/Scripts/Requests/GoogleOrderRequest.cs index 0833c66..9b48d43 100644 --- a/Runtime/GuruCore/Runtime/IPM/Scripts/Requests/GoogleOrderRequest.cs +++ b/Runtime/GuruCore/Runtime/IPM/Scripts/Requests/GoogleOrderRequest.cs @@ -1,3 +1,4 @@ +using System; using System.Text; using Guru.LitJson; using UnityEngine; @@ -48,31 +49,37 @@ namespace Guru protected override void RequestSuccessCallBack(string response) { - ResponseData responseData = JsonUtility.FromJson>(response); - if (responseData != null && responseData.data != null) + try { - // Analytics.Tch001IAPRev(responseData.data.usdPrice); - double usdPrice = responseData.data.usdPrice; - Analytics.Tch001IAPRev(usdPrice); - Analytics.Tch02IAPRev(usdPrice); + ResponseData responseData = JsonUtility.FromJson>(response); + if (responseData != null && responseData.data != null) + { + // Analytics.Tch001IAPRev(responseData.data.usdPrice); + double usdPrice = responseData.data.usdPrice; + Analytics.Tch001IAPRev(usdPrice); + Analytics.Tch02IAPRev(usdPrice); - string pid = ""; + string pid = ""; - if (!string.IsNullOrEmpty(productId)) - { - pid = productId; - AdjustService.TrackIAPPurchase(usdPrice, productId); // 上报 IAP 支付事件 - Analytics.IAPPurchase(usdPrice, pid); - } + if (!string.IsNullOrEmpty(productId)) + { + pid = productId; + AdjustService.TrackIAPPurchase(usdPrice, productId); // 上报 IAP 支付事件 + Analytics.IAPPurchase(usdPrice, pid); + } - if (!string.IsNullOrEmpty(subscriptionId)) - { - pid = subscriptionId; - AdjustService.TrackSubPurchase(usdPrice, productId); // 上报 订阅 支付事件 - Analytics.SubPurchase(usdPrice, productId); + if (!string.IsNullOrEmpty(subscriptionId)) + { + pid = subscriptionId; + AdjustService.TrackSubPurchase(usdPrice, productId); // 上报 订阅 支付事件 + Analytics.SubPurchase(usdPrice, productId); + } } } - + catch (Exception ex) + { + Analytics.LogCrashlytics(ex); + } }