So many ideas, so little time.

Adobe AIR In-app Purchase native extensions

I have spent some time searching for free extensions for all the possible platforms and would like to share my results.
Also, I made my own in-app purchase extension for Android, as I couldn’t find a good and free one.

1. In-app Purchase for Blackberry Playbook.
There is an extension that comes with BlackBerry SDK for Adobe AIR.
API docs: http://developer.blackberry.com/air/apis/playbook/net/rim/blackberry/payment/PaymentSystem.html

2. In-app Purchase for iOS.
In-app purchase extension comes with Adobe Gaming SDK

3. In-app Purchase for Amazon Kindle.
It comes with Amazon SDK: https://developer.amazon.com/sdk/in-app-purchasing/documentation/adobe.html

4. In-app Purchase for Android.
I have found two extensions:
First is free extension from Freshplanet, but it is outdated.
Second is from Milkman for $50.
So, I have decide to make my own. 🙂
You can find it here: Adobe AIR In-app Purchase native extension for Android

Hope, it will help someone in its mobile app development.

З.Ы.: InAppPurchase ANE for Android works.
I have made it for myself, but shared (including the source code) with everyone for free.
Please be respectful, if you want me to answer your questions. Thank you.

66 comments to “Adobe AIR In-app Purchase native extensions”

  1. Danish Ajaib says:

    Hi,
    Does this ANE work for AIR 23.0? the ane gets initialized successfully
    but when I tap on the button that calls the iap.purchase(id, type) method, nothing happens.

  2. toonchopper says:

    Hi! Thanks for your efforts. The extension was working fine until recently. Now my app freezes whenever I initialize (init(key)) the InAppPurchase instance. Anything to do with Google Play’s updated security requirements?

    Cheers.

  3. Andrey says:

    Подскажите пожалуйста, почему перед вызовом метода consumed нужно обязательно вызывать метод restore? (иначе ошибка из библиотеки “you must do restore first”) В справке гугла, как я понял, сказано, что неоходимо после каждой покупки вызывать только consumed, restore необязательно?..

    • pozirk says:

      restore восстанавливает список уже совершённых ранее покупок пользователем, либо получает детали о существующих предметах для покупки из базы данных.

  4. Vincent says:

    Good job for the android ANE, and thank you
    i was strugling with the one of freshplanet, and got problems with the consumation of product. Your version runs also faster (for showing the dialog box)
    Cheers

  5. Fomonster says:

    All works fine!
    I use air 3.9. Just follow readme, setup merchant account and sell items with id.
    Thanks for nice API.

  6. Sergey says:

    Can somebody repack the ANE for last Air 16.0
    If yes, please send on Saliery_@mail.ru

    • pozirk says:

      You do NOT need to repack ANE.
      Read instructions first!

      • Sergey says:

        If i disconnect internet initialization of InAppPurchase return INIT_ERROR ???
        For me they return INIT_SUCCESS…

        I wanna understand where i made error…

        • Sergey says:

          Don’t know why, but when i update Air SDK (from 15 to 16) ane. works good))))
          Thanks a lot.

        • Sergey says:

          One questions
          _iap.consume(“my.product.id”); – this function restore already purchase product and then you may purchase it once more with _iap.purchase(“my.product.id”, InAppPurchaseDetails.TYPE_INAPP); ???

  7. Linda Gattino says:

    Hi i need help
    I’m trying to use this ane but when i test it and click a button to purchase nothing happens…. I’m testing it on the device with usb cable

    thanks so much

  8. Dmitriy says:

    Many thanks for your ANE!
    One question.
    How I can check curent status of payment of user?

    My code:
    var purchase:InAppPurchaseDetails = _iap.getPurchaseDetails(“my.product.id”);
    debagTextField.text += “\r _purchaseState= ” + purchase._purchaseState // 0 – purchased 1 – canceled 2 – refunded

    Because was displaying always status 1 (purchased). I canceled purchase, refunded it, but status still 0

  9. Arif says:

    Thanks for your great work 🙂

  10. Monster Brain games says:

    Thanks a lot for Android-IAP. Maybe someday i might donate you 😉

  11. Hin says:

    Hi Pozirk

    Your ANE works very well ! Great Job Pozirk !
    The only question I need to ask you is that the function onIAPPurchaseSuccess is fired once the Google Play payment screen is shown, before the actual payment went through. Is there another event listener that is only fired ONLY UPON SUCCESSFUL GOOGLE PLAY PAYMENT ? I think you will have provided for such a listener, so I must have missed out something ?

    Once again, thanks for your good work !
    And hope to hear your reply soon.
    -Hin

    • pozirk says:

      Hi Hin!

      This event worked fine for me and fired when it should.
      My code only fires events, when Google IAP fires.
      So, check your code.

    • Hin says:

      Hi again Pozirk,

      I went through my code and every eventlistener for in-app purchase works except onIAPPurchaseSuccess which is fired immediately when the Google Play payment screen is shown instead of after SUCCESSFUL payment. However, I am only testing it in the Google Play test environment. Could it be that only in the production environment then it will work ?

      Thank you once again and

  12. Dan Zen says:

    Thanks – got it working. I posted an instruction page in the Flash to Mobile Facebook group if anyone is interested on how to install and test, etc. I can’t seem to put the link in this comment…

  13. MX says:

    Hi Pozirk,

    First of all, thank you for this great component. I have one problem with it. When I want to execute init() method where I put license key, I’ve got error message and it doesn’t work. I’m getting:

    ArgumentError: Error #3500: The extension context does not have a method with the name init.
    at flash.external::ExtensionContext/_call()
    at flash.external::ExtensionContext/call()

    Do you know what could be the reason?

  14. Dan Zen says:

    Hi Pozirk – thanks for your work on the AndroidInAppPurchase ANE – just trying it out. I am using AIR 3.9 and I see your note about recompiling. I tried editing and running the build.bat file but in there you are looking for a android\InAppPurchase\bin directory and that did not come with your zip. I will continue on as it may work without recompiling – not sure. If you could please post the bin folder with its files – or let me know if I am missing something – that would be great. Thanks.

  15. Jaime says:

    I have the License Extension working without problems. But when i try to add this extension it all functions without errors but the init event:

    _iap = new InAppPurchase();

    _iap.addEventListener(InAppPurchaseEvent.INIT_SUCCESS, onInitSuccess);
    _iap.addEventListener(InAppPurchaseEvent.INIT_ERROR, onInitError);

    _iap.init(licenseID);

    None of the events work.

    I have added the extension ID properly as well.
    And added the permissions in the application.xml (I have more so maybe there is some conflict?

    ….

    com.pozirk.LicenseChecker
    com.pozirk.AndroidInAppPurchase
    com.pozirk.ads.AdMob
    eu.alebianco.air.extensions.analytics.NativeGATracker
    com.milkmangames.extensions.GoogleGames

  16. junlas says:

    I come from China, thank you very much for your ANE, I returned to the Chinese, to show I have been to. thank you!

    非常的感谢!用起来非常爽。:)

  17. niceday says:

    nice work!!!

  18. Galaxia says:

    Hello Pozirk,
    Nice ANE, able to use it after 30 min of download and get to the point “User is not eligible for this purchase”.
    Probably your ANE is working and I just need some work on the google setting part.

    Very easy to use ane if you have implemented other ane before.
    I think people not able to use it as their first ane because the README miss out the extensions part in the xml:

    com.pozirk.AndroidInAppPurchase

    Just a suggestion.

    Happy weekend

  19. JC says:

    Hello Pozirk,
    thanks for the ANE.

    You may help me with some questions:
    I noticed that whatever I use as LICENSE KEY in .init(), listener init_succes is always fired. That means the LICENSE is checked only when executing IAP operation (purchase, restore, …) is this right?

    I ask this because my problem is that the ANE never finds my item, so I would like to know if it could be a license issue…

    • JC says:

      Oh boy, I finally found what I was doing wrong.
      The problem was that I was testing using Run / Debug from Flash Builder.
      Whereas the “Export Release Build” signed version of the apk must be used (with same certificate used on the Store, sounds logic….).
      So the first step is ok, I keep going 🙂

      Thx again for your work, Pozirk.

  20. Mihail says:

    Hello, thank you for and! But I tried it for two days… And when I make purchase, none listener called.. Neither error, nor success and already owned listeners.. I see “Payment successfull” on the screen of my device, but I can’t change game currency amount without listener called. Maybe you know smth about it..

  21. codemonkey says:

    Thank you very much for your Android ANE, I was struggling for a few days with the freshplanet version which does not seem to support Google Billing API3. Your version was fully implemented in my project within 2 hours of downloading.

  22. pozirk says:

    Andrew, you don’t have ANE connected to your project, google how do to that.

    Darson, most likely the same problem, debug and google first before asking the questions.

  23. Darson says:

    First of all – thanks for taking effor in making this component.

    Second – I’m having touble using it in my project. My program crashes when i call “init” method of “InAppPurchase” object.

    Can you give me some tips on proper use of your component?

    Thanks in advance!

  24. Andrew says:

    Hi, thanks for your work on the in-app purchase extension for android. I am trying to use it, but I’m having some trouble. I have everything set up as instructed in the readme file, but when I try to initialize the in-app purchase it always comes up that _ctx is null. I’m really not sure what I’m doing wrong, so any advice would be appreciated.
    Thanks again.

  25. Amit says:

    Is there a good example implementation file just like in Amazon and iOS (Adobe Gaming SDK), bundles
    Somehow i didnt find any example except some line of code in read me.txt

    Thanks in advance
    Amit

  26. pozirk says:

    SWC was ignored by git, I have added it.
    But you can always build an SWC by yourself using AS3 source code.

  27. Max says:

    Thanks for you work on the ANE for Android in-app purchase. I’ve been trying to implement it into an app I am creating in Flash Builder, but I get a Native Extension Error when I try to run the project that leads to a runtime VerifyError saying that the InAppPurchase class could not be found. As per your instructions in the readme file, I added the “InAppPurchase.ane” file to my project, but I couldn’t find a .swc file anywhere. I don’t have much experience working with ane’s or swc’s so I’m not really sure what to do about this problem, so any advice would be appreciated. Thanks again for the ANE!

Leave a comment