Forum Libraries, Components, and Plugins


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Xamarin.InAppBilling: Price_Amount_Micros is always null

SongtiveSongtive LVMember ✭✭

I've just started using Xamarin.InAppBilling v2.2 and it looks pretty good but I can't figure out why Price_Amount_Micros is always null. Any ideas?


  • KMullinsKMullins USMember, Xamarin Team Xamurai

    Hi @songtv,

    There might have been a change to the Google Play Services API since the latest version was released. I'll need to take a look and ensure that the component and the API are still in sync.

    Thanks for pointing this out,


  • RobinHosRobinHos NLMember

    Hello @KMullins,

    Any idea when this will be fixed?


  • Hi @KMullins,

    do you have any updates?

  • MaksimIvanovMaksimIvanov USMember ✭✭


    Any updates on this?

  • cleardemoncleardemon USMember

    I just ran into this. A quick look via reflection seems to be a problem when deserializing from Google's response.

    It seems Price_Amount_Micros is defined as a string in the Product class, yet Google actually returns it as an integer in the JSON. Google's own documentation seems to suggest it is a string (i.e. a quoted number) in the JSON, but in reality, it doesn't appear to be (number is unquoted).

    Does the JSON deserializer try to make it a string from an integer and just sets it to null (or leaves it unset)?

  • cleardemoncleardemon USMember

    Well, just as a work around, you can do something like...

    micros = (int)(double.Parse(gItem.Price.Substring(1)) * 1000000.0);

    ... to get the same result. Depends if your IAPs are set up in a default currency that has a single symbol at the start (in my case a £).

  • DavidRihaDavidRiha USMember ✭✭
    edited March 2016

    @KMullins any progress in this bug? I can confirm what cleardemon said, JSON contains "price_amount_micros":49000000. I'd like to use the component and Price_Amount_Micros is crucial for my app. If you don't fix it, we can still use connection.Service.GetSkuDetails(...), just some more work to do for us.. Thanks :)

    long? micros = product["price_amount_micros"] as long?; does the trick

  • KorayAgdemirKorayAgdemir USMember ✭✭

    As this issue continues, workaround is like this for those who are searching for a solution.

        public async Task<string> GetProduct(string productId) {
            IList<string> productIds = new List<string>();
            Android.OS.Bundle bundle = new Android.OS.Bundle();
            bundle.PutStringArrayList("ITEM_ID_LIST", productIds);
            var skuDetails = serviceConnection.Service.GetSkuDetails(3, "<package_name>", ItemType.Product, bundle);
            int response = skuDetails.GetInt("RESPONSE_CODE");
            if (response == 0) {
                IList<string> responseList = skuDetails.GetStringArrayList("DETAILS_LIST");
                JSONObject obj = new JSONObject(responseList[0]);
                float price = obj.GetInt("price_amount_micros") / 1000000f;
                string currency = obj.GetString("price_currency_code");
                return (currency + price);
            } else {
                return null;
  • SpencerDubeSpencerDube CAMember

    Koray Agdemir thanks for the workaround on this. Not sure how this is still an issue in 2017, but I essentially used your code and built the Product class objects out of it. Essentially rewriting QueryInventoryAsync.

  • AndyMartin.6838AndyMartin.6838 USMember ✭✭
    edited March 2018

    Is there any chance you @KMullins will be converting this to a nuget package now that Components are deprecated? @KorayAgdemir Thank you for the code. That helped! I am a little confused why you made the function async.

  • KorayAgdemirKorayAgdemir USMember ✭✭

    @AndyMartin.6838 No problem! It has been so long, not sure why I made it async, i think i had it wrapped with Task.Run, might have removed it for this example.

Sign In or Register to comment.