@@ -12,7 +12,7 @@ namespace VirtueSky.Iap
1212 public class IapManager : MonoBehaviour , IDetailedStoreListener
1313 {
1414 public bool dontDestroyOnLoad = true ;
15- public static IapManager Instance ;
15+ private static IapManager _instance ;
1616 public static event Action < string > OnPurchaseSucceedEvent ;
1717 public static event Action < string > OnPurchaseFailedEvent ;
1818 public static event Action < Product > OnIapTrackingRevenueEvent ;
@@ -30,9 +30,9 @@ private void Awake()
3030 DontDestroyOnLoad ( this . gameObject ) ;
3131 }
3232
33- if ( Instance == null )
33+ if ( _instance == null )
3434 {
35- Instance = this ;
35+ _instance = this ;
3636 }
3737 else
3838 {
@@ -42,7 +42,7 @@ private void Awake()
4242
4343 private void OnDestroy ( )
4444 {
45- if ( Instance == this ) Instance = null ;
45+ if ( _instance == this ) _instance = null ;
4646 }
4747
4848 private void Start ( )
@@ -249,50 +249,67 @@ private static void AutoInitialize()
249249 }
250250 }
251251
252- #region API
252+ #region Internal API
253253
254- public IapDataProduct PurchaseProduct ( string id )
254+ private IapDataProduct InternalPurchaseProduct ( string id )
255255 {
256256 OnShowIapNativePopupEvent ? . Invoke ( true ) ;
257257 var product = iapSettings . GetIapProduct ( id ) ;
258258 PurchaseProductInternal ( product ) ;
259259 return product ;
260260 }
261261
262- public IapDataProduct PurchaseProduct ( IapDataProduct product )
262+ private IapDataProduct InternalPurchaseProduct ( IapDataProduct product )
263263 {
264264 OnShowIapNativePopupEvent ? . Invoke ( true ) ;
265265 PurchaseProductInternal ( product ) ;
266266 return product ;
267267 }
268268
269- public bool IsPurchasedProduct ( IapDataProduct product )
269+ private bool InternalIsPurchasedProduct ( IapDataProduct product )
270270 {
271271 if ( _controller == null ) return false ;
272272 return ConvertProductType ( product . iapProductType ) == ProductType . NonConsumable &&
273273 _controller . products . WithID ( product . Id ) . hasReceipt ;
274274 }
275275
276- public bool IsPurchasedProduct ( string id )
276+ private bool InternalIsPurchasedProduct ( string id )
277277 {
278278 if ( _controller == null ) return false ;
279279 return ConvertProductType ( iapSettings . GetIapProduct ( id ) . iapProductType ) == ProductType . NonConsumable &&
280280 _controller . products . WithID ( id ) . hasReceipt ;
281281 }
282282
283- public string LocalizedPriceProduct ( IapDataProduct product )
283+ private string InternalLocalizedPriceProduct ( IapDataProduct product )
284284 {
285285 if ( _controller == null ) return "" ;
286286 return _controller . products . WithID ( product . Id ) . metadata . localizedPriceString ;
287287 }
288288
289- public string LocalizedPriceProduct ( string id )
289+ private string InternalLocalizedPriceProduct ( string id )
290290 {
291291 if ( _controller == null ) return "" ;
292292 return _controller . products . WithID ( id ) . metadata . localizedPriceString ;
293293 }
294294
295295 #endregion
296+
297+ #region Public API
298+
299+ public static IapDataProduct PurchaseProduct ( string id ) => _instance . InternalPurchaseProduct ( id ) ;
300+
301+ public static IapDataProduct PurchaseProduct ( IapDataProduct product ) =>
302+ _instance . InternalPurchaseProduct ( product ) ;
303+
304+ public static bool IsPurchasedProduct ( IapDataProduct product ) => _instance . InternalIsPurchasedProduct ( product ) ;
305+ public static bool IsPurchasedProduct ( string id ) => _instance . InternalIsPurchasedProduct ( id ) ;
306+
307+ public static string LocalizedPriceProduct ( IapDataProduct product ) =>
308+ _instance . InternalLocalizedPriceProduct ( product ) ;
309+
310+ public static string LocalizedPriceProduct ( string id ) => _instance . InternalLocalizedPriceProduct ( id ) ;
311+
312+ #endregion
296313 }
297314}
298315
0 commit comments