In app purchases in Microsoft Store

In app purchases in Microsoft Store
0

I seem to be chasing my tail following links while trying to figure out how to implement IAP from a cocos2d-x 3.17.2 app (not using Cocos Creator) from the Microsoft Store. The Microsoft store only supports Windows 10, which is fine with me. 3.17.2 only builds Win32 apps, which is also fine with me. And Microsoft provides a way to package a Win32 app as an MSIX package from Visual Studio 2017 for use in their store here. But the only current documentation I can find for implementing IAP from the Microsoft Store seems to require that it be a UWP app, here, which is not the same as a Win32 app. A user named ImagnGames on this discussion board has shown a somewhat kludgy way to re-introduce Win10 projects into Cocos2d-x, but I’m not sure if that will get me any closer to being able to build a UWP app, or if that’s really required for IAP. So if anyone else has gone down this rat hole, I would appreciate any wisdom you could impart!

Check if these help at all:

https://github.com/microsoft/DesktopBridgeToUWP-Samples/tree/master/Samples/StoreSample

C++ code here too:
https://github.com/Microsoft/Windows-universal-samples/tree/win10-1507/Samples/Store

You may need to write a C++/CLI library to handle this, which you can link to your own app.

1 Like

Given the communication in this topic, I think a more straightforward way to get IAP working in the Microsoft Store could be to revert to using proj.win10 in Cocos2d-x v3.15.1. Has anyone else tried going this route?

I’m not sure what the project type has to do with getting IAP working, so regardless of Win32 or Win10 app types, in the end you still need to interface with the code required to process the IAP. In all likelihood you would still need to use C++/CLI.

Getting IAP working in the Microsoft Store for a desktop application is not simple. Here’s what I’ve learned. For starters, you need a good understanding of the C++ syntax for: lambda functions, templates, and C++/CX (the successor to C++/CLI which is now obsolete). Much of the Microsoft documentation features sample code written in C#, so it’s important to download Microsoft’s “Store” samples from github, (as recommended by R101 earlier in this discussion) so you can find the equivalent C++/CX code. To use cocos2d-x in win32 mode requires using the Microsoft Desktop Bridge, which I was unable to get working by following Microsoft’s online documentation. Using cocos2d-x in win10 mode is more straightforward, but since the latest versions of cocos2d-x have dropped the proj.win10 directory, you need to either use cocos2d-x v3.15.1(the last version to support proj.win10), or try to follow roots’s suggestions for getting proj.win10 working in cocos2d-x v3.17. You will need to open and read dozens of web pages provided by Microsoft describing add-ons (their term for in-app purchases), and configuring your app’s properties in the latest version of Visual Studio (either 2017 or 2019 will work) and in the Microsoft Partner Dashboard. Rather than creating a separate library to communicate with the Microsoft Store, you can create and make calls from your program into a cpp source file included with your project, as long as you avoid symbol conflicts by not including any cocos2d-x #include’s in your cpp file that uses C++/CX to talk to the store.