update: 新增收据接口

feature/Inventory
huyufei 2024-01-19 20:45:10 +08:00
parent 79217aaaac
commit fa0861c770
1 changed files with 14 additions and 0 deletions

View File

@ -62,6 +62,7 @@ namespace Guru
public event Action<string> OnBuyStart;
public event Action<string, bool> OnBuyEnd;
public event Action<string, string> OnBuyFailed;
public event Action<string, string, bool> OnGetProductReceipt;
#if UNITY_IOS
/// <summary>
@ -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