none
Windows 8 Store App, how do I test in-app purchase?

    Question

  • My app is created with Javascript. I need to support in-app purchase for feature unlocking.

    From the documentation, it looks really simple. However, when I tries to implement it. I noticed that after returning S_OK from CurrentAppSimulator.requestProductPurchaseAsyncCurrentAppSimulator.licenseInformation.productLicenses.lookup(main.licenseName).isActive won't be changed to true.

    Then I discovered this answer CurrentAppSimulator.RequestProductPurchaseAsync purchasing simulation , mentioning something about calling RequestAppPurchaseAsync once beforerequestProductPurchaseAsync. I did, and this way, I saw the Store popup twice. And after choosingS_OK twice, isActive is set to true. However, this status is not persistent. Running this app (by pressing F5 to debug) the second time will clear this flag and the entire purchase procedure has to be run again.

    The answer also mentioned only about "correct simulation" but said nothing about whether this procedure is correct for live store app. I currently have a Windows Store developer account configured for in-app purchase, but binaries are not uploaded yet. When I try purchase with CurrentApp I got the message that the product is no longer available from Windows Store.

    I'd like some viable options to make sure that my in-app purchase is correctly implemented.


    • Edited by He Shiming Monday, April 15, 2013 3:37 AM
    Monday, April 15, 2013 3:36 AM

Answers

  • Hi He,

    The one answer you quoted is misleading.

    You cannot use the debugger when trying to inspect values as it can prevent the UI from coming up for purchasing in some cases.

    You can only persist simulator information if you write to the license XML file yourself.  If you do not write the changes it will not persist.

    See: http://msdn.microsoft.com/en-us/library/windows/apps/hh694065.aspx

    CurrentAppSimulator gets test-specific licensing info from an XML file called "WindowsStoreProxy.xml", located in <installation_folder>\Microsoft\Windows Store\ApiData. If this path and file don't exist, you must create them, either during installation or at run-time. If you try to access the CurrentAppSimulator.LicenseInformation property without WindowsStoreProxy.xml present in that specific location, you will get an error.

    This is a great walkthrough of in app purchasing:

    http://msdn.microsoft.com/en-us/library/windows/apps/hh694067.aspx

    You probably will not need to inspect the receipts as outlined in the article after that.

    -Jeff


    Jeff Sanders (MSFT)

    Monday, April 15, 2013 8:01 PM
    Moderator
  • The CurrentAppSimulator's state is loaded from your proxy file (WindowsStoreProxy.xml in your case, but you can pass any valid file to CurrentAppSimulator.ReloadSimulatorAsync). It does not persist changes back to that file: any simulated purchases are good only while the app is still running.

    The actual values used are set by your proxy file. You can set them by editing the file in your favorite text or XML editor. The schema is documented in the CurrentAppSimulator remarks.

    If you look at the Trial app and in-app purchase sample you will see that it loads several different proxy files to allow testing different scenarios.

    The CurrentApp class doesn't use the proxy file. It loads and saves real data to the store.

    --Rob

    • Marked as answer by He Shiming Tuesday, April 16, 2013 4:42 AM
    Tuesday, April 16, 2013 1:40 AM
    Owner

All replies

  • Hi He,

    The one answer you quoted is misleading.

    You cannot use the debugger when trying to inspect values as it can prevent the UI from coming up for purchasing in some cases.

    You can only persist simulator information if you write to the license XML file yourself.  If you do not write the changes it will not persist.

    See: http://msdn.microsoft.com/en-us/library/windows/apps/hh694065.aspx

    CurrentAppSimulator gets test-specific licensing info from an XML file called "WindowsStoreProxy.xml", located in <installation_folder>\Microsoft\Windows Store\ApiData. If this path and file don't exist, you must create them, either during installation or at run-time. If you try to access the CurrentAppSimulator.LicenseInformation property without WindowsStoreProxy.xml present in that specific location, you will get an error.

    This is a great walkthrough of in app purchasing:

    http://msdn.microsoft.com/en-us/library/windows/apps/hh694067.aspx

    You probably will not need to inspect the receipts as outlined in the article after that.

    -Jeff


    Jeff Sanders (MSFT)

    Monday, April 15, 2013 8:01 PM
    Moderator
  • Hi Jeff. Thanks but you didn't answer my question.

    I asked how to test in-app purchase. The walkthrough http://msdn.microsoft.com/en-us/library/windows/apps/hh694067.aspx is pretty bad as it doesn't work.

    And I have to say I didn't care much about the simulator, though I'm shocked that the simulator works pretty far from the real one.

    If the other post was misleading, are you saying just calling CurrentAppSimulator.requestProductPurchaseAsync once will make 'isActive' true upon successful purchase? In other words my implementation is correct?

    I cannot find anything about WindowsStoreProxy.xml on msdn. In the answer I got here: http://stackoverflow.com/questions/15999604/windows-8-store-app-how-do-i-test-in-app-purchase/16017581?noredirect=1#16017581 , it says I'm supposed to modify this file (programmatically?) myself. How is this supposed to work?


    • Edited by He Shiming Monday, April 15, 2013 10:59 PM
    Monday, April 15, 2013 10:50 PM
  • The CurrentAppSimulator's state is loaded from your proxy file (WindowsStoreProxy.xml in your case, but you can pass any valid file to CurrentAppSimulator.ReloadSimulatorAsync). It does not persist changes back to that file: any simulated purchases are good only while the app is still running.

    The actual values used are set by your proxy file. You can set them by editing the file in your favorite text or XML editor. The schema is documented in the CurrentAppSimulator remarks.

    If you look at the Trial app and in-app purchase sample you will see that it loads several different proxy files to allow testing different scenarios.

    The CurrentApp class doesn't use the proxy file. It loads and saves real data to the store.

    --Rob

    • Marked as answer by He Shiming Tuesday, April 16, 2013 4:42 AM
    Tuesday, April 16, 2013 1:40 AM
    Owner
  • Thank you for the clarification, the sample actually does match the documentation. I'm glad that CurrentApp takes care of everything.
    Tuesday, April 16, 2013 4:41 AM