/// <summary> /// Visible only for unit testing. /// Do NOT call this method. /// </summary> public static void _internal_doInitialise(Biller biller, BillerFactory factory) { Unibiller.biller = biller; biller.onBillerReady += (success) => { if (onBillerReady != null) { if (success) { // Download manager needs Unibill to be initialised to get purchase receipts. downloadManager = factory.instantiateDownloadManager (biller); downloadManager.onDownloadCompletedEvent += onDownloadCompletedEvent; downloadManager.onDownloadFailedEvent += onDownloadFailedEvent; downloadManager.onDownloadProgressedEvent += onDownloadProgressedEvent; onBillerReady(biller.State == Unibill.Impl.BillerState.INITIALISED ? UnibillState.SUCCESS : UnibillState.SUCCESS_WITH_ERRORS); } else { onBillerReady(UnibillState.CRITICAL_ERROR); } } }; biller.onPurchaseCancelled += _onPurchaseCancelled; biller.onPurchaseComplete += _onPurchaseComplete; biller.onPurchaseFailed += _onPurchaseFailed; biller.onPurchaseRefunded += _onPurchaseRefunded; biller.onTransactionsRestored += _onTransactionsRestored; biller.Initialise(); }
/// <summary> /// Initialise Unibill. /// Before calling this method, ensure you have subscribed to onBillerReady to /// ensure you receive Unibill's initialisation response. /// This method should be called once as soon as your Application launches. /// </summary> public static void Initialise() { if (Unibiller.biller == null) { var mgr = new RemoteConfigManager(new UnityResourceLoader(), new UnityPlayerPrefsStorage(), new UnityLogger(), UnityEngine.Application.platform); var config = mgr.Config; var o = new GameObject (); var util = o.AddComponent<UnityUtil> (); var factory = new BillerFactory (new UnityResourceLoader (), new UnityLogger (), new UnityPlayerPrefsStorage (), new RawBillingPlatformProvider (config), config, util); Biller b = factory.instantiate (); _internal_doInitialise(b, factory); } }