Пример #1
0
        public static void Init()
        {
            if (initalized)
            {
                return;
            }


            _appLicenseInformation = new LicenseInformation
            {
                ExpirationDate  = DateTimeOffset.Now,
                IsActive        = true,
                IsTrial         = false,
                ProductLicenses = new Dictionary <string, ProductLicense>()
            };

            StateInformation = new MockReceiptState();

            initalized = true;

            string    mocklist_url = "http://iap.azurewebsites.net/GetProductsByAppID.php?id=" + CurrentApp.AppId;
            WebClient client       = new WebClient();

            client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(LoadListComplete);
            client.DownloadStringAsync(new Uri(mocklist_url));
        }
Пример #2
0
 public void Initialize()
 {
     if (Initialized == false)
     {
         if (StoreConfig.STORE_TEST_MODE)
         {
             SoomlaUtils.LogDebug(TAG, "WARNING You are running in Store Test Mode! Don't forget to disable the test mode before you publish the app.");
             SetupMockIAP();
             licInfosMock = MockCurApp.LicenseInformation;
         }
         else
         {
             licInfos = CurApp.LicenseInformation;
         }
         marketProductInfos = new Dictionary <string, MarketProductInfos>();
         //LoadListingInfo();
         Initialized = true;
     }
 }
Пример #3
0
        public static void Init()
        {
            if (initalized)
            {
                return;
            }


            _appLicenseInformation = new LicenseInformation
            {
                ExpirationDate  = DateTimeOffset.Now,
                IsActive        = true,
                IsTrial         = false,
                ProductLicenses = new Dictionary <string, ProductLicense>()
            };

            StateInformation = new MockReceiptState();

            initalized = true;
        }
Пример #4
0
        public static async Task <string> RequestProductPurchaseAsync(string ProductId, bool includeReceipt)
        {
            MockIAP.CheckIfInitialized();

            string receipt;

            if (!MockIAP.MockMode)
            {
                receipt = await Windows.ApplicationModel.Store.CurrentApp.RequestProductPurchaseAsync(ProductId, includeReceipt);

                // Now we refresh the license information post purchase.
                LicenseInformation = new LicenseInformation(Windows.ApplicationModel.Store.CurrentApp.LicenseInformation);
            }
            else
            {
                receipt = MockIAP.SimulatePurchase(ProductId, includeReceipt);
            }

            return(receipt);
        }
Пример #5
0
        public void Initialize()
        {
            if(Initialized==false)
            {
                if (StoreConfig.STORE_TEST_MODE)
                {
                    SoomlaUtils.LogDebug(TAG, "WARNING You are running in Store Test Mode! Don't forget to disable the test mode before you publish the app.");
                    SetupMockIAP();
                    licInfosMock = MockCurApp.LicenseInformation;

                }
                else
                {
                    licInfos = CurApp.LicenseInformation;
                }
                marketProductInfos = new Dictionary<string, MarketProductInfos>();
                //LoadListingInfo();
                Initialized = true;
            }
        }
Пример #6
0
        public static async Task<ListingInformation> LoadListingInformationAsync()
        {
            MockIAP.CheckIfInitialized();

            ListingInformation listingInformation;

            if (!MockIAP.MockMode)
            {
                Windows.ApplicationModel.Store.ListingInformation li = await Windows.ApplicationModel.Store.CurrentApp.LoadListingInformationAsync();
                listingInformation = new ListingInformation(li);

                LicenseInformation = new LicenseInformation(Windows.ApplicationModel.Store.CurrentApp.LicenseInformation);
            }
            else
            {
                listingInformation = MockIAP.GetListingInformation();
                listingInformation.ProductListings = MockIAP.allProducts;
            }

            return listingInformation;
        }
Пример #7
0
        public static async Task <ListingInformation> LoadListingInformationAsync()
        {
            MockIAP.CheckIfInitialized();

            ListingInformation listingInformation;

            if (!MockIAP.MockMode)
            {
                Windows.ApplicationModel.Store.ListingInformation li = await Windows.ApplicationModel.Store.CurrentApp.LoadListingInformationAsync();

                listingInformation = new ListingInformation(li);

                LicenseInformation = new LicenseInformation(Windows.ApplicationModel.Store.CurrentApp.LicenseInformation);
            }
            else
            {
                listingInformation = MockIAP.GetListingInformation();
                listingInformation.ProductListings = MockIAP.allProducts;
            }

            return(listingInformation);
        }
Пример #8
0
        private async void DoPurchase(string productId)
        {
            try
            {
                bool licenceActiv = false;
                if (StoreConfig.STORE_TEST_MODE)
                {
                    // Kick off purchase; don't ask for a receipt when it returns
                    await MockCurApp.RequestProductPurchaseAsync(productId, false);

                    licInfosMock = MockCurApp.LicenseInformation;
                    licenceActiv = licInfosMock.ProductLicenses[productId].IsActive;
                }
                else
                {
                    // Kick off purchase; don't ask for a receipt when it returns
                    await CurApp.RequestProductPurchaseAsync(productId, false);

                    licInfos     = CurApp.LicenseInformation;
                    licenceActiv = licInfos.ProductLicenses[productId].IsActive;
                }

                if (licenceActiv)
                {
                    OnItemPurchasedCB(productId);
                }
                else
                {
                    SoomlaUtils.LogDebug(TAG, "Purchase cancelled " + productId);
                    OnItemPurchaseCancelCB(productId, false);
                }
            }
            catch (Exception ex)
            {
                // When the user does not complete the purchase (e.g. cancels or navigates back from the Purchase Page), an exception with an HRESULT of E_FAIL is expected.
                SoomlaUtils.LogDebug(TAG, ex.Message);
                OnItemPurchaseCancelCB(productId, true);
            }
        }
Пример #9
0
        public static async Task<string> RequestProductPurchaseAsync(string ProductId, bool includeReceipt)
        {
            MockIAP.CheckIfInitialized();

            string receipt;

            if (!MockIAP.MockMode)
            {
                receipt = await Windows.ApplicationModel.Store.CurrentApp.RequestProductPurchaseAsync(ProductId, includeReceipt);

                // Now we refresh the license information post purchase.
                LicenseInformation = new LicenseInformation(Windows.ApplicationModel.Store.CurrentApp.LicenseInformation);
            }
            else
            {
                receipt = MockIAP.SimulatePurchase(ProductId, includeReceipt);
            }

            return receipt;
        }
Пример #10
0
        private async void DoPurchase(string productId)
        {
            try
            {
                bool licenceActiv = false;
                if (StoreConfig.STORE_TEST_MODE)
                {
                    // Kick off purchase; don't ask for a receipt when it returns
                    await MockCurApp.RequestProductPurchaseAsync(productId, false);
                    licInfosMock = MockCurApp.LicenseInformation;
                    licenceActiv = licInfosMock.ProductLicenses[productId].IsActive;
                }
                else
                {
                    // Kick off purchase; don't ask for a receipt when it returns
                    await CurApp.RequestProductPurchaseAsync(productId, false);
                    licInfos = CurApp.LicenseInformation;
                    licenceActiv = licInfos.ProductLicenses[productId].IsActive;
                }

                if (licenceActiv)
                {
                    
                    OnItemPurchasedCB(productId);
                }
                else
                {
                    SoomlaUtils.LogDebug(TAG,"Purchase cancelled " + productId);
                    OnItemPurchaseCancelCB(productId, false);
                }


            }
            catch (Exception ex)
            {
                // When the user does not complete the purchase (e.g. cancels or navigates back from the Purchase Page), an exception with an HRESULT of E_FAIL is expected.
                SoomlaUtils.LogDebug(TAG,ex.Message);
                OnItemPurchaseCancelCB(productId, true);
            }
        }