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