Meta

Desktop Bridge helps developers gradually migrate traditional apps to the Universal Windows Platform (UWP). The In-App Purchase (IAP) in Windows Store is an important scenario to monetize the converted apps. When working with developers on this scenario, I notice certain obstacles are in common，for example:

a. Porting old .Net or unmanaged applications to use the IAP UWP APIs.

Many converted Win32 Desktop apps were developed in unmanaged code or old .NET version which cannot directly call current UWP Store APIs, in order to eliminate this gap, I create an .Net IAP Wrapper library. This wrapper will finally leverage DLLEXPORT nuget package to export function entries, which can be used by different kinds of Apps easily.

Create an IAP Wrapper Project:

1. Create a Win32 .NET class library project. The target frame work can be 4.6.1. I uses VS2017 as a quick start.

4. The store ID used as parameter is the 12 characters of your add-on on your developer portal, not product display name.

Use IAPWRAPPER in .Net 2.0 Winform app

1. Add DLLImport statement and call the Purchase function:

2. Build the app, and put IAPWRAPPER.dll into the output folder. Run the app, and trigger the purchase, we can see default purchase windows pops up (depends on your account setting, authentication window may occur as well,):

Use IAPWRAPPER in .Net 4.6 WPF app

1. Add DLLImport and call purchase function:

2. Build the app, and put IAPWRAPPER.dll into the output folder. Run the app, it will show up the same purchase window.

Use IAPWRAPPER in C++ Win32 app

1. Use LoadLibrary and GetProcAddress to

2. Run the app, it will show up the same purchase window.

Use IAPWRAPPER in UNITY Win32 app

1. Put IAPWrapper into the Assets\Plugins folder

2. Add DLLImport and Purchase function as below:

3. Build the app as Win32 app, and run it.

Here I mainly explained how to quickly integrate the essential Windows IAP function to different kinds of Win32 Apps. You may expand your IAPWrapper for more specific usage scenarios, checking licensing, trail status, enumerate add-ons, etc. Can refer to: