Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Talk:Increase your revenue with In-App Purchase on Windows Phone 8

From Wiki
Jump to: navigation, search

Contents

Mca09528 - Crashes

Hi, I am using your code but it crashes on ListingInformation li = await Store.CurrentApp.LoadListingInformationAsync();

and shows me up an error...

first chance exception of type 'System.Exception' occurred in mscorlib.ni.dll

An exception of type 'System.Exception' occurred in mscorlib.ni.dll and wasn't handled before a managed/native boundary System.Exception: Exception from HRESULT: 0x805A0194

  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
  at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
  at BuyItemIAP.MainPage.<RenderStoreItems>d__1.MoveNext()
please help me and tell me,for testing We have to upload build? Or without uploading build we can test..

mca09528 07:25, 22 April 2013 (EEST)

EngDev - Crash also

I've the same problem

ListingInformation li = await Store.CurrentApp.LoadListingInformationAsync(); throw exception how to test that before upload and be live in store?

EngDev (talk) 11:10, 20 July 2013 (EEST)

SB Dev -

I tested the code provided in the article along with the description and it is working. You will get the mentioned exception if there is no complete Beta App submission for testing. Once I had the Private Beta published (as described in the article) the App would work. It would not work if I deployed the App from Visual Studio unless the AppID was updated in the WMAppManifest. It worked when downloaded from the Store though (Store submission automatically inserts the correct AppID).

So the article as is is correct and the example is working. The issue with requiring a Dev Center Account is also mentioned right in the beginning: "You need an active Windows Phone Dev Center Account before implementing In-App Purchase even for testing." I don't know how this could be made much clearer. The "ArticleNeedsUpdate" flag can be removed as far as I'm concerned.

SB Dev (talk) 20:24, 15 September 2013 (EEST)

Hamishwillee - Removed article needs update

Hi Oliver

Thanks so much for this testing. I removed the ArticleNeedsUpdate. I also added a "Warning" immediately below the text you identified explaining that the example code will crash if the account isn't created.

regards

H

hamishwillee (talk) 10:21, 16 September 2013 (EEST)

Nfsleo07 - How to check if in-app product bought or not

hi,

you said that to check if the in-app product has been bought or not , we have to use this line :

Store.CurrentApp.LicenseInformation.ProductLicenses[key].IsActive

But this line requires internet connection. How do I check everytime the app is launched that the product has been bought by the user or not without using internet connection?

nfsleo07 (talk) 22:26, 7 November 2013 (EET)

SB Dev -

Just to be sure - did you run into the issue or are you assuming that the call requires online connectivity?

Looking at this discussion for Win8: http://social.msdn.microsoft.com/Forums/windowsapps/de-DE/2e08c626-a1a6-41a5-a738-af2a812bfa63/checking-for-already-bought-in-app-purchases-while-user-is-offline?forum=winappswithcsharp which uses the same APIs as WP8 for this it seems that the system should cache all the required information so that it is still available even when the user goes offline later on. Still this might be different on WP8 - I didn't test it myself.

Another approach might be to store the license information after the purchase was completed (which can only happen online) and use that local value later on. For consumables that is the only way to do it. For durables this is discouraged by Microsoft themselves in this article http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj206949(v=vs.105).aspx#BKMK_Bestpractices (it's linked in the Wiki article as well).

Hope this helps. If not please let me know and I'll try it out (I'm not the original author though, so it might take some time as I would have to redeploy this through the Beta marketplace).

SB Dev (talk) 22:59, 7 November 2013 (EET)

Nfsleo07 - Reply

Hi Dev,

When i deployed my app and launched it without internet connectivity , i was getting this error:

first chance exception of type 'System.Exception' occurred in mscorlib.ni.dll

But if i repeated the above procedure with internet, i didnt get any errors.

Also, i wanted to ask that if I check the license using this statement:

CurrentApp.LicenseInformation.ProductLicenses[key].IsActive and not Store.CurrentApp.LicenseInformation.ProductLicenses[key].IsActive , will it still access the store to get the information?

Microsoft states that even if the user un-installs the app and installs it again, the in-app product(durable) purchased by the user should be given to him without any cost, but unfortunately I need internet for that.

If the user tries to open the app after uninstalling and reinstalling it without internet connectivity, the in-app product wont be available to the user till the user opens the app with internet connectivity. Im confused!

nfsleo07 (talk) 10:37, 8 November 2013 (EET)

SB Dev -

You deployed your App from Visual Studio? The problem is that when you deploy the App from Visual Studio there is no License for that App. That's why it failed. Did you try running it with connectivity and then later without? Alternatively did you try installing it from the Beta Marketplace and to run it without connection then?

Regular users can only install Apps while having a connection, so the Store should place the required license on the device. Trying to access it then shouldn't require an online connection (even if the App's first run is happening while offline - the required licensing information should be cached upon installation - similarily this should happen for In-App-Purchases).

At least for now my assumption is that the issue you're seeing is due to the App being deployed for debugging purposes from Visual Studio instead of through the Store.

I will try to check your scenario over the weekend and tell you what I find out.

SB Dev (talk) 14:57, 8 November 2013 (EET)

SB Dev -

So, I just deployed the App through the Beta Store distribution. I then disconnected my phone from Wifi and the Mobile Data Connection. Running the App still showed me the IAP products that were available for purchase. Trying to do a purchase gave me a message that the connection to the store could not be established - no crash.

I then established the connection again an purchased as durable product. Disconnecting again and it still showed up in the App as purchased. I then uninstalled the App.

I reconnected, installed the App from the Store, and disconnected again. Upon first launch after the reinstallation the IAP product still showed up as purchased inside the App (even though it had never run with connectivity after the reinstallation).

In short - running an umodified version of this sample everything worked as intended. Therefore all necessary licensing information is cached on the device upon installation.

Make sure that you are either using the Beta Store submission for final testing of this behavior. For development testing (when deploying through Visual Studio instead of the store) I'd suggest to stay online.

Hope this helps you with the whole issue.

SB Dev (talk) 19:39, 10 November 2013 (EET)

Harsha crash - Messing confirmation to Microsoft Servers

I stumbled upon this article and saw an that the method ButtonBuyNow_Clicked is primarily for durables, there should be a ReportProductFulfillment send to Microsoft's servers to complete the purchase in case of consumables. (I think all items are durables here, this article could use some consumable prod. info too)

the consumables method could be private async void ButtonBuyNow_Clicked(object sender, RoutedEventArgs e)

       {
           Button btn = sender as Button;

           string key = btn.Tag.ToString();

           if (!Store.CurrentApp.LicenseInformation.ProductLicenses[key].IsActive)
           {
               ListingInformation li = await Store.CurrentApp.LoadListingInformationAsync();
               string pID = li.ProductListings[key].ProductId;

               string receipt = await Store.CurrentApp.RequestProductPurchaseAsync(pID, false);

               if (CurrentApp.LicenseInformation.ProductLicenses[key].IsActive)
               {
                   CurrentApp.ReportProductFulfillment(key); // should be done for consumables
                   RenderStoreItems();
               }
           }
}

harsha_crash (talk) 14:51, 24 February 2014 (EET)

Msramkrish - Very well written article, Thanks!

This is an excellent article, well written, step by step covering all required aspects. Thanks for it. Only thing that may add to it can be the coverage of durable and consumables. Great!

msramkrish (talk) 13:40, 24 March 2014 (EET)

Shyam.tinwar - error while debugging app

I read you article and it helped me adding in app purchase to my existing app.

But if I Change ProductID in WMAppManifest.xml then I will no more able to debug my app on phone. As I run my app it will throw error message that port a specified communication resources(port) is already in use by another application. But app will be deployed to phone and I can see and test the code but will not be able to debug app.

1) So changing the product id is just for testing or while submission also we need to have product id in WMAppManifest.xml file? 2) If I change it to default product id and upload a update of app, will store guys will update the product id in app automatically while download.

3) Is it possible get rid of above error and still have app id as product id in app manifest.

shyam.tinwar (talk) 15:43, 5 June 2014 (EEST)

SB Dev -

It's not my article, I've only debugged several issues that people have been seeing with it.

As for the error you describe - I have not seen that happen so far. I'd suggest to open a thread on the forums. Others have been using IAP in production (I only worked with this sample) and might have come across it before.

When an App goes through the Store the WMAppManifest will automatically be updated by the store to include the store's ID.

Given that it's working for me with the sample I'd guess that it's definitely possible to Debug with the changed Product ID. Is it possible that you have a copy of your App with the original Product ID on the device and that this interferes with Debugging when deploying with the changed one? Or do you perhaps have the production copy of the App on the device (so deploying the Debug version with the changed ID means that two Apps with the same ID reside on the phone). I'd just uninstall all versions of the App from the test device and try again.

SB Dev (talk) 16:51, 5 June 2014 (EEST)

Purushothamctr.b - Durable Products are not showing up in App

Hi,

I have implemented the In App purchase feature for my app, I have added few Consumable Products and few Durable Products ( with life time set to 1 month). But in my App all my Consumable Products are showing up but no Durable Products are showing. So I went through the MSDN Site and I got below info

http://msdn.microsoft.com/library/windows/apps/jj206721

Important Note: If you select a Product lifetime value other than Forever, the product will only be available to users who are running Windows Phone 8.1 or newer.

If they are limiting this feature for only Windows Phone 8.1 or later, then what about the user of Windows Phone 8...? Is there any solution for this problem.

Regards,

Purushotham B.

purushothamctr.b (talk) 16:37, 17 July 2014 (EEST)

 
×