How to switch from Trial to In App Purchases in UWP?

Global Delight 1 Reputation point
2019-11-18T12:09:12.19+00:00

My app has currently only Trial and Full License. I want to remove having trial and make the app free but handle full license features with in app purchases and as well having some other in app purchases. That means I created an in app purchase called "full version" and i want user to buy this in order to access all features of the app.
I decided to create a durable in app purchase as "full version" to handle it myself. My Question here is I have already people purchased full version of the app using trial/full version handled by Microsoft Store.
How can I get that information and give users who already purchased the full version?

Universal Windows Platform (UWP)
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Roy Li - MSFT 31,681 Reputation points Microsoft Vendor
    2019-11-19T04:40:21.763+00:00

    Hello,​

    Welcome to our Microsoft Q&A platform!

    >>My Question here is I have already people purchased full version of the app using trial/full version handled by Microsoft Store. How can I get that information and give users who already purchased the full version?

    You might need to do some extra work on this. After you cancel the trial/full mode of your app, you might need to check the license of the app using the StoreContext class in the Windows.Services.Store namespace to see if the customer needs to purchase the durable add-on or not.
    You could use the following code:

    StoreContext context = StoreContext.GetDefault();  
    StoreAppLicense appLicense = await context.GetAppLicenseAsync();  
    

    In the StoreAppLicense object you get, you could get the full license data via the ExtendedJsonData property. Its template is here: Schema for StoreAppLicense and StoreLicense.
    Then you could check the isActive, isTrial or expiration parameter to check if the current user is a trial before.