1

I am using the following piece of code to check in my UWP-JS app if an in-app purchase is active:

(function () {
    // Initialization
    // var store_app = Windows.ApplicationModel.Store.CurrentApp;
    var store_app = Windows.ApplicationModel.Store.CurrentAppSimulator;
    var licenseInformation = store_app.licenseInformation;

    // Check for Product
    if (licenseInformation.productLicenses["product1"].isActive) {
        // do something
    } else {};
})();

when I debug this I get the following error for line 5:

0x803d0000 - JavaScript runtime error: The input data was not in the expected format or did not have the expected value.

I am following this Documentation

What am I doing wrong?

heroxav
  • 1,387
  • 1
  • 22
  • 65
  • You are copying the C# sample code but failing to translate it to JS. In JS, properties are camelCase. `if (licenseInformation.productLicenses["product1"].isActive)`. For more details see the [Windows Store JS sample app](https://github.com/Microsoft/Windows-universal-samples/blob/win10-1507/Samples/Store/js/js/scenario2-inAppPurchase.js#L44). – Raymond Chen Feb 23 '17 at 18:15
  • Another possibility is that your XML has an incorrect ExpirationDate. It should be in the form `2016-01-01T00:00:00.00Z`. – Raymond Chen Feb 23 '17 at 18:18
  • @RaymondChen Thank you for your hint! That does not fix the error though. Where should I specify that expiration date? – heroxav Feb 23 '17 at 19:01
  • Since you are using `CurrentAppSimulator`, the information comes from the XML files you pass to `reloadSimulatorAsync`. – Raymond Chen Feb 23 '17 at 20:16
  • Or there could be some other error in your XML. – Raymond Chen Feb 23 '17 at 20:21
  • @RaymondChen Do you mean `WindowsStoreProxy.xml`? I don't have a `` tag in there ... – heroxav Feb 23 '17 at 20:54
  • @RaymondChen Ah, thank you for the hint. Seems like Atom messed that file up. I just deleted it and VS created a new one automatically. Works now. – heroxav Feb 24 '17 at 10:45

1 Answers1

1

The Atom Editor messed the WindowsStoreProxy.xml file up.
I just deleted it and Visual Studio created a new file.

heroxav
  • 1,387
  • 1
  • 22
  • 65