Fix: 修复恢复购买后, 由于调用了ProcessPurchase 回调而上报了预期外的 iap_ret_true 和 first_iap 等事件
parent
426b0028fd
commit
c341374748
|
|
@ -531,7 +531,6 @@ namespace Guru
|
|||
Analytics.IAPClick(_curProductCategory, product.definition.id);
|
||||
Analytics.IAPImp(_curProductCategory, product.definition.id);
|
||||
|
||||
|
||||
OnBuyStart?.Invoke(productName);
|
||||
return (T)this;
|
||||
}
|
||||
|
|
@ -555,23 +554,22 @@ namespace Guru
|
|||
string productId = purchaseEvent.purchasedProduct.definition.id;
|
||||
ProductInfo info = GetInfoById(productId);
|
||||
bool success = false;
|
||||
|
||||
string productName = "";
|
||||
if (null != info)
|
||||
{
|
||||
success = true;
|
||||
productName = info.Name;
|
||||
SetIsIAPUser(success); // 设置用户属性标记
|
||||
|
||||
// 只有实际发生购买后才会有订单上报. 启动时的 Restore 操作自动调用支付成功. 这里做一个判定, 过滤掉订单的物品
|
||||
if (_curPurchasingProduct != null)
|
||||
{
|
||||
ReportPurchaseResult(purchaseEvent); // 订单上报
|
||||
|
||||
// 真实购买后上报对应的事件
|
||||
if (IsFirstIAP) Analytics.FirstIAP(info.Id, info.Price, info.CurrencyCode); // 上报首次支付打点
|
||||
Analytics.ProductIAP(info.Id,info.Id, info.Price, info.CurrencyCode);
|
||||
Analytics.IAPRetTrue(_curProductCategory, info.Id, info.Price, info.CurrencyCode, info.Type, info.IsFree);
|
||||
success = true;
|
||||
|
||||
SetIsIAPUser(success); // 设置用户属性标记
|
||||
}
|
||||
|
||||
PurchaseCount++; // 记录支付次数
|
||||
// Debug.Log($"############ ProcessPurchase: PurchaseCount:{PurchaseCount}");
|
||||
if (_curPurchasingProduct != null)
|
||||
{
|
||||
// 只有实际发生购买后才会有订单上报. 启动时的 Restore 操作自动调用支付成功. 这里做一个判定, 过滤掉订单的物品
|
||||
ReportPurchaseResult(purchaseEvent); // 支付结果上报
|
||||
}
|
||||
|
||||
var pp = purchaseEvent.purchasedProduct;
|
||||
|
|
@ -586,12 +584,18 @@ namespace Guru
|
|||
OnGetProductReceipt?.Invoke(pp.definition.id, pp.receipt, pp.appleProductIsRestored);
|
||||
}
|
||||
|
||||
string productName = info?.Name ?? "NULL";
|
||||
LogI($"{Tag} --- OnPurchaseSuccess :: purchase count: {PurchaseCount} productName: {productName}");
|
||||
PurchaseCount++; // 记录支付次数
|
||||
}
|
||||
else
|
||||
{
|
||||
string msg = $"{Tag} --- Purchased end, but can't find ProductInfo with ID: {productId}";
|
||||
Debug.LogError(msg);
|
||||
Analytics.LogCrashlytics(new Exception(msg));
|
||||
}
|
||||
|
||||
OnPurchaseOver(success, productName); // 支付成功处理逻辑
|
||||
OnBuyEnd?.Invoke(productName, success);
|
||||
|
||||
OnPurchaseOver(success, productName); // 支付成功处理逻辑
|
||||
ClearCurPurchasingProduct(); // 清除购买缓存
|
||||
|
||||
return PurchaseProcessingResult.Complete; // 直接Consume 掉当前的商品
|
||||
|
|
|
|||
Loading…
Reference in New Issue