Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9017573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:18:38+00:00 2026-06-16T04:18:38+00:00

I tried the following code for in-app purchase. I’m using CurrentAppSimulator for testing purpose.

  • 0

I tried the following code for in-app purchase. I’m using CurrentAppSimulator for testing purpose.

private async void history_Click(object sender, RoutedEventArgs e)
{
    bool OK = true;

    // Get the license info
    // The next line is commented out for testing.
    // licenseInformation = CurrentApp.LicenseInformation;

    // The next line is commented out for production/release.       
    LicenseInformation licenseInformation = CurrentAppSimulator.LicenseInformation;
    if (!licenseInformation.ProductLicenses["PremiumFeatures"].IsActive)
    {
        try
        {
            // The customer doesn't own this feature, so 
            // show the purchase dialog.

            await CurrentAppSimulator.RequestProductPurchaseAsync("PremiumFeatures", false);
            // the in-app purchase was successful
            OK = true;
        }
        catch (Exception)
        {
            // The in-app purchase was not completed because 
            // an error occurred.
            OK = false;
        }
    }
    else
    {
        // The customer already owns this feature.
        OK = true;
    }

    if (OK)
    {
        Frame.Navigate(typeof(HistoryPage));
    }
}

However, the dialog keep pop up, every time I perform history_Click, even I choose S_OK. I expect licenseInformation.ProductLicenses["PremiumFeatures"].IsActive should changed to true, after I buy the PremiumFeatures.

enter image description here

I guess, perhaps when the in-app purchase was successful, I need to turn on IsActive flag, so that it will not show me purchase dialog again.

        // the in-app purchase was successful
        OK = true;
        // Compile error!!!
        licenseInformation.ProductLicenses["PremiumFeatures"].IsActive = true;

OK. Seems like IsActive is a read only field. So, may I know, what is the correct way to handle purchase successful case?

Update :

After looking at Trial app and in-app purchase sample, I realize having the following code can have IsActive changed from false to true automatically, after purchasing successful. (But why it works?)

    private async Task LoadInAppPurchaseProxyFileAsync()
    {
        StorageFolder proxyDataFolder = await Package.Current.InstalledLocation.GetFolderAsync("data");
        StorageFile proxyFile = await proxyDataFolder.GetFileAsync("in-app-purchase.xml");
        licenseChangeHandler = new LicenseChangedEventHandler(InAppPurchaseRefreshScenario);
        CurrentAppSimulator.LicenseInformation.LicenseChanged += licenseChangeHandler;
        await CurrentAppSimulator.ReloadSimulatorAsync(proxyFile);

        // setup application upsell message
        ListingInformation listing = await CurrentAppSimulator.LoadListingInformationAsync();
        var product1 = listing.ProductListings["product1"];
        var product2 = listing.ProductListings["product2"];
        Product1SellMessage.Text = "You can buy " + product1.Name + " for: " + product1.FormattedPrice + ".";
        Product2SellMessage.Text = "You can buy " + product2.Name + " for: " + product2.FormattedPrice + ".";
    }

However, the “Is already bought” status is not persistence. If I close the app and start it again, it will thought my “Premium Feature” to “is not bought yet”.

How am I suppose the make this behavior persistence?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T04:18:40+00:00Added an answer on June 16, 2026 at 4:18 am

    As far as I know it’s not automatically updated when you click OK. It only returns the correct status like it should do in the Windows Store.

    What I think is an option to do, but I haven’t implemented it myself is to use ReloadSimulatorAsync(proxyFile) method. Before you call this method you have to update the in-app-purchase.xml yourself save it and pass the file to the ReloadSimulatorAsync method.

    Personally I would use the manual update of the xml file. But I can’t Judge about that for your application / application flow.

    A good start for automating this process is the sample “In-app purchase” app which you can find here. If you look in the code file InAppPurchase.xaml.cs you will see already a bit of code for your own implementation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tried the following code .. btnRemoveItem.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View
In my app I am displaying Print option from UIButton using following code. UIPrintInfo*
I tried the following code for table layout in android without using xml file.
i tried the following code import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; import
I want to get script's origin filename in global functions. I tried following code,
I tried the following code tree. If I put the header file hello.h into
I tried the following code: import java.math.BigInteger; import org.apache.commons.codec.binary.Base32; import org.junit.Test; public class Sandbox
I tried the following code. Although I don't get any errors, it did not
I tried the following code from w3schools. When I enter letters in a input
I just tried the following code, but the result seems a little strange. It

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.