[Solved] In-App purchase in Windows Store Apps? (8.1)

Hi community,

I was having problems getting In-App purchase working in my game on the Windows Store App (8.1) platform, but I think I got it working. Wanted to post my solution in case it helps anybody.

Normally I try to make all the 'async' APIs run synchronously by using the "Task.Run(async () => { my function }).Wait()" code, however in WP8, the marketplace would not appear unless I ran it like this:

                System.Windows.Deployment.Current.Dispatcher.BeginInvoke(
                    async () =>
                    {
                        try
                        {
                            string receipt = await CurrentApp.RequestProductPurchaseAsync(productListing.ProductId, true);

All Windows examples have the purchasing done from the UI thread.. it seems like the dispatcher has to be used when trying to make a purchase, so I also imitated this in my WSA implementation.

#elif NETFX_CORE
        Task.Run(
            async () =>
            {
                await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(
                    CoreDispatcherPriority.Normal,
                    async () =>
                    {
                    PurchaseResults result = await CurrentApp.RequestProductPurchaseAsync(productID);
                    switch(result.Status)
                    {
                    case ProductPurchaseStatus.Succeeded:
                        await CurrentApp.ReportConsumableFulfillmentAsync(productID, result.TransactionId);
                        OnPurchaseDismissed(productID);
                        break;
                    case ProductPurchaseStatus.NotFulfilled:
                        InAppPurchaseManager.Instance.CheckUnfulfilledConsumables();
                        await CurrentApp.ReportConsumableFulfillmentAsync(productID, result.TransactionId);
                        OnPurchaseDismissed(productID);
                        break;
                    }
                });
            }).Wait();
#else

Now its trying to reach out to marketplace, but fails since my app isn't listed. But at least its getting the marketplace involved.. I think it will work after I update/re-list my game.

The SOOMLA Store in-app purchase plugin just released an updated version that supports Windows Phone 8 in-app purchases out of the box.