@@ -19,7 +19,7 @@ public class IapManager : MonoBehaviour, IDetailedStoreListener
1919
2020 private IStoreController _controller ;
2121 private IExtensionProvider _extensionProvider ;
22- private bool IsInitialized { get ; set ; }
22+ public static bool IsInitialized { get ; private set ; }
2323 private IapSettings iapSettings ;
2424
2525 private void Awake ( )
@@ -65,7 +65,7 @@ void InitImpl()
6565 builder . Configure < IGooglePlayConfiguration > ( ) ;
6666
6767 UnityPurchasing . Initialize ( this , builder ) ;
68- IsInitialized = true ;
68+
6969 }
7070
7171
@@ -179,13 +179,14 @@ public void OnInitialized(IStoreController controller, IExtensionProvider extens
179179 _controller = controller ;
180180 _extensionProvider = extensions ;
181181
182- #if UNITY_ANDROID && ! UNITY_EDITOR
183- foreach ( var product in _controller . products . all )
184- {
185- if ( product != null && ! string . IsNullOrEmpty ( product . transactionID ) )
186- _controller . ConfirmPendingPurchase ( product ) ;
187- }
188- #endif
182+ // #if UNITY_ANDROID && !UNITY_EDITOR
183+ // foreach (var product in _controller.products.all)
184+ // {
185+ // if (product != null && !string.IsNullOrEmpty(product.transactionID))
186+ // _controller.ConfirmPendingPurchase(product);
187+ // }
188+ // #endif
189+ IsInitialized = true ;
189190 }
190191
191192 public void OnPurchaseFailed ( Product product , PurchaseFailureDescription failureDescription )
@@ -238,6 +239,12 @@ ProductType ConvertProductType(IapProductType iapProductType)
238239 }
239240
240241 #region Internal API
242+ private SubscriptionInfo InternalGetSubscriptionInfo ( IapDataProduct product )
243+ {
244+ if ( _controller == null || ConvertProductType ( product . iapProductType ) != ProductType . Subscription || ! _controller . products . WithID ( product . Id ) . hasReceipt ) return null ;
245+ var subscriptionManager = new SubscriptionManager ( InternalGetProduct ( product ) , null ) ;
246+ return subscriptionManager . getSubscriptionInfo ( ) ;
247+ }
241248
242249 private IapDataProduct InternalPurchaseProduct ( string id )
243250 {
@@ -294,6 +301,8 @@ public static IapDataProduct PurchaseProduct(IapDataProduct product) =>
294301
295302 public static Product GetProduct ( string id ) => _instance . InternalGetProduct ( id ) ;
296303 public static Product GetProduct ( IapDataProduct product ) => _instance . InternalGetProduct ( product ) ;
304+ public static SubscriptionInfo GetSubscriptionInfo ( IapDataProduct iapDataProduct ) =>
305+ _instance . InternalGetSubscriptionInfo ( iapDataProduct ) ;
297306#if UNITY_IOS
298307 public static void RestorePurchase ( ) => _instance . InternalRestorePurchase ( ) ;
299308#endif
0 commit comments