fix: 修复 Android 支付初始化 Restore 后触发订单上报的 BUG

deeplink
胡宇飞 2024-03-12 15:05:06 +08:00
parent 203263769e
commit 9c3795227c
1 changed files with 10 additions and 2 deletions

View File

@ -32,6 +32,8 @@ namespace Guru
public bool IsInitialized => _storeController != null && _storeExtensionProvider != null;
private Product _curPurchasingProduct = null;
/// <summary>
/// 是否是首次购买
/// </summary>
@ -520,6 +522,8 @@ namespace Guru
Analytics.IAPClick(info?.Category??"none", product.definition.id);
Analytics.IAPImp(DefaultCategory, product.definition.id);
_curPurchasingProduct = product;
OnBuyStart?.Invoke(productName);
return (T)this;
}
@ -556,7 +560,11 @@ namespace Guru
PurchaseCount++; // 记录支付次数
Debug.Log($"############ ProcessPurchase: PurchaseCount:{PurchaseCount}");
if (_curPurchasingProduct != null)
{
_curPurchasingProduct = null; // 只有实际发生购买后才会有订单上报. 启动时的 Restore 操作自动调用支付成功. 这里做一个判定, 过滤掉订单的物品
ReportPurchaseResult(purchaseEvent); // 支付结果上报
}
var pp = purchaseEvent.purchasedProduct;
if ( pp == null || string.IsNullOrEmpty(pp.receipt))