How do I get IAP working properly on Android

0 favourites
  • 12 posts
From the Asset Store
_______ Huge collection of metal fixtures ________
  • I submit this topic because I face an IAP product purchase failure problem.

    I use IAP object and Cocoonjs export. In Ludei portal, in-app purchases Google base-64 signature is correctly copied into Ludei store configuration. I created two in app products on Google developer platform, and use the assigned IDs inside C2 project. The two digital goods are of the handled type (one-time purchase, remembered by Google Play). My Cocoonjs project is exported as apk release unsigned, than I sign the app with my private key, align it and send as published-for-testers beta app to Google. I try it from Google Play install.

    Even though store listing is received, when i click on a shop button made to trigger the purchase attempt, it doesn't seem to even try to launch, it gives instant failure message (a service message I put in the code for debugging purposes). This seems to happen whether in test mode or not. This is quite frustrating because Google needs hours to publish the new beta, so I can test it once per day. I can't understand why this happens, but saw I'm not the only one experiencing difficulties. My game is ready for publishing, except for this point, and it is mandatory that I use this 'freemium' approach at least on Android.

    Any suggestions?

    Has anybody succeeded in making things work with IAP object? Or do I need Cocoonjs object?

    My game works perfectly for Blackberry 10 too (supported by IAP object but not from CocoonJs object of course - and purchases not yet tested there).

    Thank you very much.

  • zorida

    Hello Zorida, thank you for publishing this! I am having the same problem as you are..

    Just Post a Bug Report to Ashley and he will fix it!!

    Click on the link to make a bug report, and be sure to fill it out properly so he will fix it more quickly for you...

    https://www.scirra.com/forum/bugs_f151

    Thanks!!!

  • Thank you very much STARTECHSTUDIOS , now i managed to make IAP work for Android and going to publish for that platform, but still having trouble with Blackberry 10; it seems it only supports Blackberry Webworks SDK 1.0, not 2.0, for anyone being interested. If you're in trouble, pm me with your mail address (so that I can send you an image attachment) and perhaps I can give you some advice, even though today I publish on Android and I'm quite in the middle of a hurricane

  • zorida What did you did to fix it? I am also interested in IAP and Android.

    Thanks

  • zorida I know it's a long shot but making a tutorial out of this will help quite a bit of C2 users (including myself)

  • OK guys, I'm working on it, but I don't think about posting an official tutorial, I can only say what worked for me, since I'm not so experienced. Within a couple of days It will be here and hope it will be helpful...

  • Hello...

    I'm using IAP objects for Android only. Honestly I did not try CocoonJS but the event flow shown on Scirra site about CocoonJs tutorial appears to be almost identical. So, in short, i strongly recommend to read that tutorial carefully and try to apply the same steps, but using the IAP plugin.

    Before going to C2, it is mandatory that you have a Google developer account, with the app added, and have at least an in-app purchase created inside the Google play account, and I believe the in-app product must be set to published. Here I use a 'managed' product type of digital good on Google side, which, to keep it simple, means "pay once, keep forever", because Google will keep track of your purchase. Feel free to try the other digital good type option (the so called unmanaged or consumable good).

    You may also want to set up your Google merchant / Wallet with your bank account, so that the purchase flow can be for real (and you may refund the purchases almost instantly as you receive the notification).

    Whan your app is ready for testing, be sure to publish your alpha or beta version to make the beta testing available for users of a google group you've previously created.

    Note: if you are the app developer (i.e. you use the same gmail account of the developer), when you make a purchase request through the IAP, A google play lightbox will appear over your app, telling you that you can't buy your own products - Yes, it is quite idiot, security paranoia I suppose, but the full purchasing process may be made only via another device if that is the case. However I can tell that if this lightbox does appear, it is very likely taht the purchases are already ok, and you then have to care about minor things (like handling what happens after purchase was made, for example saving a local variable to keep track of the purchase if you like to - if you don't, you have to ask google play for owned products every time, so every time you don't have a working internet connection, you would risk to roll back to the 'free' version of your app)

    I managed to get it work on test mode set to false on IAP official plugin, but I believe it should work in test mode too.

    First of all, you should ensure that, as soon as possible in the start of layout, you add your products with the Add product action (mine are one-time purchase, the 'managed type', i haven't checked the unmanaged/consumable digital goods yet) and ONLY in a sub process (so that you can be sure it is done after the first step) call the Request store listing action.

    Under On store listing success, you can finally check if a product is owned by the user with Has product condition. Here I believe it is mandatory to use product ID or SKU code you set in your (Google) developer board settings. I don't know if you are forced to call the products accordingly in the Add product actions on start of layout, but I think so.

    The third screenshot is more about trying to handle all possible error conditions, one per event. One should consider to have one or more text objects showing whatever is happening (I made a message function "showInfo" for that, passing it some particular text everytime). The advantage of IAP object is that it's able to capture a nice amount of different problems. These error events worked like a charm for me. For example, if you are yourself the game publisher, Google for some weird reasons won't let you buy anything (!) and show a popup box over your app telling that you can't buy. When you close it, IAP raises a product purchase failed fatal error...

    Note: checking the Is store available with IAP requires that you add the Trigger Once while true condition, otherwise it seems to trigger at every tick/fps!

    You can then associate a button click to the purchase action and see what happens. You might want to store in a webstorage variable the purchase success, so that, even without internet connection, the purchase is 'saved' and persistent. I did it when IAP finds that a product is purchased, but this is just a way (it is because I call it inside the request store listing for a second time after a user buys something).

    Roughly, these are the blocks around which the IAP's are set.

    Please ignore the other platform checking and other actions, it was the true code inside my app, and it must be updated.

  • zorida thank you..I was always afraid of IAP....now I have 1 fear less

  • Ahahah... glad to hear... to me, the most boring thing is you have to test, say, twice a day because Google takes 'hours' to update... and packaging the app every time is not lightning fast...

  • Hey this is AWESOME info

    I 2nd the notion for a Tutorial!

    It would really help us C2 newbies out

    thanks again!

  • does this work for ios too?let me know how things are turning out

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks for the detailed explanation. I do have a problem to restore products

    what is weird that "on restore purchases success" triggers even when i dont have the purchased product.

    what is the most efficient method to check if a product was purchased (in the past) ?

    Thanks

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)