The following forum(s) have migrated to Microsoft Q&A (Preview): Developing Universal Windows apps!
Visit Microsoft Q&A (Preview) to post new questions.

Learn More

 locked
In-app Purchasing with Phonegap RRS feed

  • Question

  • There’s Phonegap/Cordova plugin to support In-app-purchase on Appstore(iOS) and Google Play(Android), but no way to support Windows Store.
    How can we do In-app-purchase with phonegap/cordova for Windows Phone/Windows Store?
    Who know if Windows Store supports Javascript Web API to do In-app-purchase ?
    Thursday, February 26, 2015 10:21 AM

Answers

  • Hi fengshuiapps,

    If you want to use the WinRT API's directly in your Cordova based app, then all you need to do is to check for window.Windows property and then use the Windows Runtime classes you would normally do from a regular Windows Store/Phone Runtime apps.

    For example, this link: https://msdn.microsoft.com/en-us/library/windows/apps/hh694067.aspx talks about enabling in-app purchase for a Windows Store app which uses the Windows Runtime classes directly.

    In your case, you will need to use windows.Windows to access the entire Windows Runtime. There is no "intellisense" for getting the WinRT class information, but you should be able to access the classes at runtime.

    Something like this..

            if (window.Windows) { // this means you can use the Windows Runtime class information
                var license = window.Windows.ApplicationModel.Store.CurrentAppSimulator.licenseInformation;
                //...
                // you can now access license.expirationDate or license.isActive properties
                //...
            }

    Thanks,

    Prashant


    Windows Store Developer Solutions, follow us on Twitter: @WSDevSol|| Want more solutions? See our blog

    Thursday, February 26, 2015 6:43 PM

All replies

  • I'll ask our resident Cordova guy to check out this post.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Thursday, February 26, 2015 1:38 PM
  • Hi fengshuiapps,

    If you want to use the WinRT API's directly in your Cordova based app, then all you need to do is to check for window.Windows property and then use the Windows Runtime classes you would normally do from a regular Windows Store/Phone Runtime apps.

    For example, this link: https://msdn.microsoft.com/en-us/library/windows/apps/hh694067.aspx talks about enabling in-app purchase for a Windows Store app which uses the Windows Runtime classes directly.

    In your case, you will need to use windows.Windows to access the entire Windows Runtime. There is no "intellisense" for getting the WinRT class information, but you should be able to access the classes at runtime.

    Something like this..

            if (window.Windows) { // this means you can use the Windows Runtime class information
                var license = window.Windows.ApplicationModel.Store.CurrentAppSimulator.licenseInformation;
                //...
                // you can now access license.expirationDate or license.isActive properties
                //...
            }

    Thanks,

    Prashant


    Windows Store Developer Solutions, follow us on Twitter: @WSDevSol|| Want more solutions? See our blog

    Thursday, February 26, 2015 6:43 PM
  • Thanks for your answer. I have passed it on to the person doing the coding for me. Another question, I want to add that person as an user on my company account, but cannot find where to do that? Should I ask here or in another forum? 
    Tuesday, March 3, 2015 11:51 AM
  • Thanks, we got an answer from Prashant.

    Tuesday, March 3, 2015 11:52 AM