From fa0861c77089f4f7b1b641b4f4533b75490d971b Mon Sep 17 00:00:00 2001 From: huyufei Date: Fri, 19 Jan 2024 20:45:10 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E6=96=B0=E5=A2=9E=E6=94=B6=E6=8D=AE?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Runtime/GuruIAP/Runtime/Code/IAPServiceBase.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Runtime/GuruIAP/Runtime/Code/IAPServiceBase.cs b/Runtime/GuruIAP/Runtime/Code/IAPServiceBase.cs index e4e1213..267cedb 100644 --- a/Runtime/GuruIAP/Runtime/Code/IAPServiceBase.cs +++ b/Runtime/GuruIAP/Runtime/Code/IAPServiceBase.cs @@ -62,6 +62,7 @@ namespace Guru public event Action OnBuyStart; public event Action OnBuyEnd; public event Action OnBuyFailed; + public event Action OnGetProductReceipt; #if UNITY_IOS /// @@ -509,6 +510,18 @@ namespace Guru PurchaseCount++; // 记录支付次数 Debug.Log($"############ ProcessPurchase: PurchaseCount:{PurchaseCount}"); ReportPurchaseResult(purchaseEvent); // 支付结果上报 + + var pp = purchaseEvent.purchasedProduct; + if ( pp == null || string.IsNullOrEmpty(pp.receipt)) + { + string msg = $"{Tag} --- Purchased product is null or has no receipt!!"; + Debug.LogError(msg); + Crashlytics.LogException(new Exception(msg)); + } + else + { + OnGetProductReceipt?.Invoke(pp.definition.id, pp.receipt, pp.appleProductIsRestored); + } string productName = info?.Name ?? "NULL"; LogI($"{Tag} --- OnPurchaseSuccess :: purchase count: {PurchaseCount} productName: {productName}"); @@ -626,6 +639,7 @@ namespace Guru // ----- 支付后的b_level上报逻辑 LogI($"--- Report b_level:[{blevel}] with product id:{args.purchasedProduct.definition.id} "); + #if UNITY_EDITOR // Editor 不做上报逻辑 #elif UNITY_ANDROID