@@ -19,7 +19,7 @@ public class IapManager : MonoBehaviour, IDetailedStoreListener
19
19
20
20
private IStoreController _controller ;
21
21
private IExtensionProvider _extensionProvider ;
22
- private bool IsInitialized { get ; set ; }
22
+ public static bool IsInitialized { get ; private set ; }
23
23
private IapSettings iapSettings ;
24
24
25
25
private void Awake ( )
@@ -65,7 +65,7 @@ void InitImpl()
65
65
builder . Configure < IGooglePlayConfiguration > ( ) ;
66
66
67
67
UnityPurchasing . Initialize ( this , builder ) ;
68
- IsInitialized = true ;
68
+
69
69
}
70
70
71
71
@@ -179,13 +179,14 @@ public void OnInitialized(IStoreController controller, IExtensionProvider extens
179
179
_controller = controller ;
180
180
_extensionProvider = extensions ;
181
181
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 ;
189
190
}
190
191
191
192
public void OnPurchaseFailed ( Product product , PurchaseFailureDescription failureDescription )
@@ -238,6 +239,12 @@ ProductType ConvertProductType(IapProductType iapProductType)
238
239
}
239
240
240
241
#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
+ }
241
248
242
249
private IapDataProduct InternalPurchaseProduct ( string id )
243
250
{
@@ -294,6 +301,8 @@ public static IapDataProduct PurchaseProduct(IapDataProduct product) =>
294
301
295
302
public static Product GetProduct ( string id ) => _instance . InternalGetProduct ( id ) ;
296
303
public static Product GetProduct ( IapDataProduct product ) => _instance . InternalGetProduct ( product ) ;
304
+ public static SubscriptionInfo GetSubscriptionInfo ( IapDataProduct iapDataProduct ) =>
305
+ _instance . InternalGetSubscriptionInfo ( iapDataProduct ) ;
297
306
#if UNITY_IOS
298
307
public static void RestorePurchase ( ) => _instance . InternalRestorePurchase ( ) ;
299
308
#endif
0 commit comments