diff --git a/Runtime/GuruIAP/Runtime/Code/IAPServiceBase.cs b/Runtime/GuruIAP/Runtime/Code/IAPServiceBase.cs
index 77aa8a4..0c1d4b3 100644
--- a/Runtime/GuruIAP/Runtime/Code/IAPServiceBase.cs
+++ b/Runtime/GuruIAP/Runtime/Code/IAPServiceBase.cs
@@ -196,6 +196,7 @@ namespace Guru
// 建立本地的商品信息列表
if (string.IsNullOrEmpty(item.Category)) item.Category = DefaultCategory;
_products[item.ProductId] = new ProductInfo(item);
+
}
}
// 调用插件初始化
@@ -231,16 +232,16 @@ namespace Guru
_googlePlayStoreExtensions.RestoreTransactions(OnRestoreHandle);
#endif
- foreach (var item in _storeController.products.all)
+ foreach (var product in _storeController.products.all)
{
- if (!item.availableToPurchase)
+ if (!product.availableToPurchase)
{
continue;
}
- if (_products.ContainsKey(item.definition.id))
+ if (_products.ContainsKey(product.definition.id))
{
- _products[item.definition.id].SetProduct(item);
+ _products[product.definition.id].SetProduct(product);
}
}
@@ -1048,7 +1049,89 @@ namespace Guru
#endregion
+ #region Subscription
+ private SubscriptionManager GetSubManager(string productName)
+ {
+ var product = GetProduct(productName);
+ if (product != null && product.definition.type == ProductType.Subscription)
+ {
+ return new SubscriptionManager(product, null);
+ }
+ return null;
+ }
+
+
+ public bool IsSubscriptionFreeTrail(string productName)
+ {
+ var smgr = GetSubManager(productName);
+ if (smgr != null)
+ {
+ return smgr.getSubscriptionInfo().isFreeTrial() == Result.True;
+ }
+ return false;
+ }
+
+
+ public bool IsSubscriptionCancelled(string productName)
+ {
+ var smgr = GetSubManager(productName);
+ if (smgr != null)
+ {
+ return smgr.getSubscriptionInfo().isCancelled() == Result.True;
+ }
+ return false;
+ }
+
+ public bool IsSubscriptionAvailable(string productName)
+ {
+ var smgr = GetSubManager(productName);
+ if (smgr != null)
+ {
+ return smgr.getSubscriptionInfo().isSubscribed() == Result.True;
+ }
+ return false;
+ }
+
+
+ public bool IsSubscriptionExpired(string productName)
+ {
+ var smgr = GetSubManager(productName);
+ if (smgr != null)
+ {
+ return smgr.getSubscriptionInfo().isExpired() == Result.True;
+ }
+ return false;
+ }
+
+
+ public bool IsSubscriptionAutoRenewing(string productName)
+ {
+ var smgr = GetSubManager(productName);
+ if (smgr != null)
+ {
+ return smgr.getSubscriptionInfo().isAutoRenewing() == Result.True;
+ }
+ return false;
+ }
+
+
+ ///
+ /// IntroductioryPrice Period
+ ///
+ ///
+ ///
+ public bool IsSubscriptionIntroductoryPricePeriod(string productName)
+ {
+ var smgr = GetSubManager(productName);
+ if (smgr != null)
+ {
+ return smgr.getSubscriptionInfo().isIntroductoryPricePeriod() == Result.True;
+ }
+ return false;
+ }
+
+ #endregion
}
}
\ No newline at end of file