private async void BuyAndFulfillProduct1Button_Click(object sender, RoutedEventArgs e)
        {
            string offerId = OfferIdTextBox.Text;
            string displayPropertiesName = DisplayPropertiesNameTextBox.Text;
            var displayProperties = new ProductPurchaseDisplayProperties(displayPropertiesName);

            Log("Buying Product 1...", NotifyType.StatusMessage);
            try
            {
                PurchaseResults purchaseResults = await CurrentAppSimulator.RequestProductPurchaseAsync("product1", offerId, displayProperties);
                switch (purchaseResults.Status)
                {
                    case ProductPurchaseStatus.Succeeded:
                        GrantFeatureLocally("product1", purchaseResults.TransactionId);
                        FulfillProduct1("product1", purchaseResults);
                        break;
                    case ProductPurchaseStatus.NotFulfilled:
                        if (!IsLocallyFulfilled("product1", purchaseResults.TransactionId))
                        {
                            GrantFeatureLocally("product1", purchaseResults.TransactionId);
                        }
                        FulfillProduct1("product1", purchaseResults);
                        break;
                    case ProductPurchaseStatus.NotPurchased:
                        Log("Product 1 was not purchased.", NotifyType.StatusMessage);
                        break;
                }
            }
            catch (Exception)
            {
                Log("Unable to buy Product 1.", NotifyType.ErrorMessage);
            }
        }
 /// <summary>
 /// Requests the purchase of an in-app product. Additionally, calling this method displays the UI that is used to complete
 /// the transaction via the Windows Store.
 /// </summary>
 /// <param name="productId">Specifies the id of the in-app product.</param>
 /// <param name="offerId">
 /// The specific in-app feature or content within the large purchase catalog represented on the
 /// Windows Store by the productId. This value correlates with the content your app is responsible for fulfilling. The
 /// Windows Store only uses this value to itemize the PurchaseResults.
 /// </param>
 /// <param name="displayProperties">
 /// The name of the app feature or content offer that is displayed to the user at time of
 /// purchase.
 /// </param>
 /// <returns>The results of the in-app product purchase request.</returns>
 public static IAsyncOperation <PurchaseResults> RequestProductPurchaseAsync(string productId, string offerId,
                                                                             ProductPurchaseDisplayProperties displayProperties)
 {
     return(IsMockEnabled
         ? CurrentAppSimulator.RequestProductPurchaseAsync(productId, offerId, displayProperties)
         : CurrentApp.RequestProductPurchaseAsync(productId, offerId, displayProperties));
 }
Exemple #3
0
        private async void MakePurchaseRequest()
        {
            //<MakePurchaseRequest>
            string offerId = "1234";
            string displayPropertiesName = "MusicOffer1";
            var    displayProperties     = new ProductPurchaseDisplayProperties(displayPropertiesName);

            try
            {
                PurchaseResults purchaseResults = await CurrentAppSimulator.RequestProductPurchaseAsync(
                    "product1", offerId, displayProperties);

                switch (purchaseResults.Status)
                {
                case ProductPurchaseStatus.Succeeded:
                    // Grant the user their purchase here, and then pass the product ID and transaction ID
                    // to currentAppSimulator.reportConsumableFulfillment to indicate local fulfillment to
                    // the Windows Store.
                    break;

                case ProductPurchaseStatus.NotFulfilled:
                    // First check for unfulfilled purchases and grant any unfulfilled purchases from an
                    // earlier transaction. Once products are fulfilled pass the product ID and transaction
                    // ID to currentAppSimulator.reportConsumableFulfillment to indicate local fulfillment
                    // to the Windows Store.
                    break;

                case ProductPurchaseStatus.NotPurchased:
                    // Notify user that the purchase was not completed due to cancellation or error.
                    break;
                }
            }
            catch (Exception)
            {
                // Notify the user of the purchase error.
            }
            //</MakePurchaseRequest>
        }
Exemple #4
0
        private async void BuyAndFulfillProduct1Button_Click(object sender, RoutedEventArgs e)
        {
            string offerId = OfferIdTextBox.Text;
            string displayPropertiesName = DisplayPropertiesNameTextBox.Text;
            var    displayProperties     = new ProductPurchaseDisplayProperties(displayPropertiesName);

            Log("Buying Product 1...", NotifyType.StatusMessage);
            try
            {
                PurchaseResults purchaseResults = await CurrentAppSimulator.RequestProductPurchaseAsync("product1", offerId, displayProperties);

                switch (purchaseResults.Status)
                {
                case ProductPurchaseStatus.Succeeded:
                    GrantFeatureLocally("product1", purchaseResults.TransactionId);
                    FulfillProduct1("product1", purchaseResults);
                    break;

                case ProductPurchaseStatus.NotFulfilled:
                    if (!IsLocallyFulfilled("product1", purchaseResults.TransactionId))
                    {
                        GrantFeatureLocally("product1", purchaseResults.TransactionId);
                    }
                    FulfillProduct1("product1", purchaseResults);
                    break;

                case ProductPurchaseStatus.NotPurchased:
                    Log("Product 1 was not purchased.", NotifyType.StatusMessage);
                    break;
                }
            }
            catch (Exception)
            {
                Log("Unable to buy Product 1.", NotifyType.ErrorMessage);
            }
        }
        private async void BuyAndFulfillProduct()
        {
            string offerId = OfferIdTextBox.Text;
            string displayPropertiesName = DisplayNameTextBox.Text;
            var    displayProperties     = new ProductPurchaseDisplayProperties(displayPropertiesName);

            rootPage.NotifyUser("Buying Product 1" + BuildOfferStringForDisplay(offerId) + "...", NotifyType.StatusMessage);
            try
            {
                PurchaseResults purchaseResults = await CurrentAppSimulator.RequestProductPurchaseAsync("product1", offerId, displayProperties);

                switch (purchaseResults.Status)
                {
                case ProductPurchaseStatus.Succeeded:
                    GrantFeatureLocally(purchaseResults.TransactionId);
                    FulfillProduct("product1", purchaseResults);
                    break;

                case ProductPurchaseStatus.NotFulfilled:
                    if (!IsLocallyFulfilled(purchaseResults.TransactionId))
                    {
                        GrantFeatureLocally(purchaseResults.TransactionId);
                    }
                    FulfillProduct("product1", purchaseResults);
                    break;

                case ProductPurchaseStatus.NotPurchased:
                    rootPage.NotifyUser("Product 1" + BuildOfferStringForDisplay(offerId) + " was not purchased.", NotifyType.StatusMessage);
                    break;
                }
            }
            catch (Exception)
            {
                rootPage.NotifyUser("Unable to buy Product 1" + BuildOfferStringForDisplay(offerId) + ".", NotifyType.ErrorMessage);
            }
        }
        private async void BuyAndFulfillProduct()
        {
            string offerId = OfferIdTextBox.Text;
            string displayPropertiesName = DisplayNameTextBox.Text;
            var displayProperties = new ProductPurchaseDisplayProperties(displayPropertiesName);

            rootPage.NotifyUser("Buying Product 1" + BuildOfferStringForDisplay(offerId) + "...", NotifyType.StatusMessage);
            try
            {
                PurchaseResults purchaseResults = await CurrentAppSimulator.RequestProductPurchaseAsync("product1", offerId, displayProperties);
                switch (purchaseResults.Status)
                {
                    case ProductPurchaseStatus.Succeeded:
                        GrantFeatureLocally(purchaseResults.TransactionId);
                        FulfillProduct("product1", purchaseResults);
                        break;
                    case ProductPurchaseStatus.NotFulfilled:
                        if (!IsLocallyFulfilled(purchaseResults.TransactionId))
                        {
                            GrantFeatureLocally(purchaseResults.TransactionId);
                        }
                        FulfillProduct("product1", purchaseResults);
                        break;
                    case ProductPurchaseStatus.NotPurchased:
                        rootPage.NotifyUser("Product 1" + BuildOfferStringForDisplay(offerId) + " was not purchased.", NotifyType.StatusMessage);
                        break;
                }
            }
            catch (Exception)
            {
                rootPage.NotifyUser("Unable to buy Product 1" + BuildOfferStringForDisplay(offerId) + ".", NotifyType.ErrorMessage);
            }
        }