Anyone started looking into in-apps purchases ?

Monkey Targets Forums/Android/Anyone started looking into in-apps purchases ?

Rushino(Posted 2012) [#1]
Hello there,

Anyone started looking into in-apps purchases ?


Hummelpups(Posted 2012) [#2]
New STar Soccer seems to be created in Monkey and has in app purchases


Xaron(Posted 2012) [#3]
NSS has this only for iOS. There is a tutorial for this for iOS but not for Android as far as I know.


benmc(Posted 2012) [#4]
It is quite overwhelming:

http://developer.android.com/guide/google/play/billing/billing_integrate.html


Xaron(Posted 2012) [#5]
Well yes, looks like some "deeper" integration is necessary.


Rushino(Posted 2012) [#6]
Darn. Not good lol


Xaron(Posted 2012) [#7]
Sooner or later I need that as well. I'll see what I can do here...


siread(Posted 2012) [#8]
I'm starting to wonder if something like the all-in-one GREE platform might be best if you are focusing on iOS and Android.


Xaron(Posted 2012) [#9]
I don't like it. I didn't like Openfeint before and don't like GREE.


MikeHart(Posted 2012) [#10]
I think using a cross platform solution would be the best choice. Be it GREE or something else.


Xaron(Posted 2012) [#11]
I don't know how Gree handles all that stuff? I mean especially Apple forces you to use their own InApp stuff.


Xaron(Posted 2012) [#12]
Oh and for GREE users must have an account there. Native InApp purchases work out of the box.

I once added Openfeint to my game and got a lot of mails because of that because a lot of people don't like that stuff. Same is true for Facebook connections. This stuff MUST be optional.


Rushino(Posted 2012) [#13]
I may have something that can help : https://github.com/robotmedia/AndroidBillingLibrary Its an android inapp purshase library.. so maybe we could find a way to integrate this in monkey. Who know ?


michaelcontento(Posted 2012) [#14]
Hi,

i've published games with IAP in the Google Play Store, iOS App Store and Amazon App Store. It's pretty easy and all required files are online:
* IAP Patch for Monkey (diff to v66)
* Payment module
* Amazon patch for the payment module

The first link is a patch for Monkey that introduce
#IN_APP_BILLING=false/true
which will add all required dependencies to the build. The second link is a slightly patched version of the payment module from my friend JochenHeizmann (and part of his framework Horizon). And the last link contains the native code that connects the payment module with the Amazon API.

All the best,
Michael

/Edit: Some links above are now dead but just follow this link, read the readme and have fun :)


Rushino(Posted 2012) [#15]
Your payment module look nice! I will get a look at it sometime.


rIKmAN(Posted 2013) [#16]
michaelcontento, all your links are dead and give 404's.

Are there any working links for info on the IAP stuff?


MikeHart(Posted 2013) [#17]
Look for the bono framework.


Soap(Posted 2013) [#18]
@michaelcontento

Could you publish the " IAP Patch for Monkey (diff to v66)" again? It seems to have been deleted. We are trying to get IAP working in an Android app and trying to figure out how to get the dependencies all working.


maverick69(Posted 2013) [#19]
Here is how I've done it:

1. I have put alle required IAP-Files int a seperate folder in the Monkey-Android Target called inappbilling (to have a look at it, you can download it here: https://dl.dropbox.com/u/5061704/inappbilling.zip)

Then I patched trans, by adding the following lines in src/trans/targets/android.monkey right before the line

If OPT_ACTION>=ACTION_BUILD


If GetCfgVar( "IN_APP_BILLING" )="1"
    Print "Copy in app billing..."
    DeleteDir "src/com/android", True
    DeleteDir "src/com/payment", True
    CopyDir "inappbilling", "src/com/", True
End


This fixes the problem that Monkey always recreates the src-folder in the android-target, and with this small fix it just copies the files over with each build (when I set the PreProcessor Constant IN_APP_BILLING).

After that you should be able to use my payment wrapper from Horizon or the one from Bono.


frank(Posted 2013) [#20]
Michael, thank you very much for making the monkey-wizard. However, could you give me an example of the in-app payment system?

I'm using about the same code as i'm using for iOS now (Probably better to just use your code for everything, but no examples, so I cannot get it working while I can get my own code working under iOS).

Sp maybe you can solve it and i'll make an example HelloWorld project of it and do a pull request for you?

What i'm doing is;

- When the user wants to buy I do ;

didPurchase = True
payment.Purchase(ANDROID_ADDCREDITS+purchaseIdx)

- Then in the Update method:

If didPurchase
If payment.IsProcessing
purchasing = True
Else If payment.IsPurchased(ANDROID_ADDCREDITS+purchaseIdx)
AddCoins(purchaseCount)
purchasing = False
didPurchase = False
End
End

However, the IsPurchased code is never reached. I use Unmanaged products (as people are buying credits, so managed would not make much sense imho).

(Edit: yes, purchaseIdx is the same in both cases and the receipt from Google for payment reaches my inbox after purchase, but the code is never triggered)

I had it first that if it's not processing anymore it's either purchased or cancelled, but after a number of test payments it seemed always cancelled (while it never was) and like said; isPurchased is never called.

I would be grateful if you can help me.

Edit: more info; onRequestPurchaseResponse is called with RESULT_OK, but statechanged never is called.

Edit: found some documentation (I went from monkey-wizard console output to the git of bono, git clone ; then it's easy to miss the payment docs), so I am doing things right but still it doesn't work. Seems a *lot* of people have the same issues. Will post my findings here if/when I have them. If anyone knows, please tell!


Supertino(Posted 2013) [#21]
I'll be looking into IAP this weekend following using Bono's code and instructions https://github.com/michaelcontento/bono/tree/master/src/payment I'll post on how I get on.


Supertino(Posted 2013) [#22]
Hum reading the documentation included with bono says it supports "Android API > 13" so that would be Gingerbread onward, that's a shame according to googles latest play store stats http://developer.android.com/about/dashboards/index.html, that's a good 40% of users excluded. Maybe its a mistake in the documentation? Think ill need to try this out tonight to see.


frank(Posted 2013) [#23]
I wrote an extensive debugging of my issue to the Google Android dev group, however they didn't place it yet (it' s moderated). I have no clue how to fix this and my app cannot be published because of it :( Very annoying. When I found out I'll tell here what I did wrong (if anything).


frank(Posted 2013) [#24]
Does someone has a working Monkey example which was actually tested? I tried the example from the docs (from michaelconto) and it gives me the same errors as my own app. So I'm probably doing something wrong but no-one seems to know what.

Edit: I found quite a lot of references to the issue I have (logs contain:

05-23 09:31:08.634: D/Finsky(20109): [1] MarketBillingService.sendResponseCode: Sending response RESULT_SERVICE_UNAVAILABLE for request 2805878185635938043 to com.bla.bla.

)

Some say it's blocked or whatever, but that cannot be true: I DO the payment, get a receipt via mail, get a RESULT_OK, just statechanged is never called with the final result that the item is purchased...


Supertino(Posted 2013) [#25]
Well I failed didn't even get as far as you Frank, failed at putting everything where it needs to go and to get it to compile without errors.

Even gave monkey-wizard a go but I just don't understand what it's meant to do and right now it's just one more thing I don't want to have to worry about.

Maybe cus I've been coding all day or I expect everything to work with no effort on my part but right now I am feeling like not using IAP on Android, though it does mean redesigning my game a little which I honestly don't want to do, I've done the demo/full version before and it's a headache for all concerned and not very popular.

Maybe a white knight will drop by and post a baby-step by baby-step "hello world" guide on how to implement Bono's IAP https://github.com/michaelcontento/bono/tree/master/src/payment Here's hoping.

Not to say I am not ungrateful to Bono and others who have done the hard-work.

I'll give a bash again tomorrow after a good reset.


frank(Posted 2013) [#26]
The use of the wizard is quite easy and, for me, a great help. He already did all of the changing and integration; it immediately compiles. That's why I was so happy at first :) Often when things compile they'll run as expected if they are modules. And like I said, it does run fine; it even processes an order, but it never receives the callback that this happened. Very frustrating.


Supertino(Posted 2013) [#27]
I cannot get monkey-wizard to work, I compile it normally as C++ target, run it in CMD (so I can see what is going on).

 path\to\build\main_winnt.exe Googlepayment path\to\my\build\android\folder 


Just get error;

 ERRO: Given targetdir path\to\my\build\android\folder/ does not exist 


it obviously does exist, doesn't matter where I move that target folder to wizard can never find it?!

But looking at what the googlepayment part does in terms of putting and patching files I've been doing all that correctly so I'll just continue doing it manually.

[EDIT]
Well spend all morning on this, just cannot get my head around this whole process. I can get it to compile now though I don't think it's doing what it needs to do, i'd expect the apk to be bigger with some extra files but it's not and when I install on a device it fails to starts. Going to finish the game and hope by then someone with the know-how and time post a definitive guide.


Xaron(Posted 2013) [#28]
Will look into this the next days...


Nobuyuki(Posted 2013) [#29]
monkey-wizard totally doesn't work outside of MacOS, there are some serious things wrong with it. Tried building in mingw env, but it doesn't seem to understand or parse certain folder syntax or something. It's pretty much useless anyway.

michaelcontento has outlined a few steps to get his module working without monkey-wizard, but the truth is that it's missing an important step (adding a copy command for the extra source code in build.xml) and the module won't work on anything beyond v66b anyway due to the fact the native code has outdated references in it!

I've submitted a trouble ticket for this issue, but I expect michael is in outer space somewhere rolling in his piles of money and will be indisposed to address the issue for the forseeable future.

I highly recommend that those of you with the capability, look seriously into google's in-app billing v3 and consider writing your own wrapper from scratch, and not bother with the bono module unless you're prepared for a glitchy, soon-to-be-depreciated headache. If you insist on using it, however, be sure to look up my ticket on bono's issue tracker for the workaround.


Supertino(Posted 2013) [#30]
A fresh look using latest monkey and the new V3 billing would be a dream.

Sadly I lack the know-how on most things outside of Monkey. I'll take a look at that work around Nobuyuki - for now I think I'll concentrate on completing the game and hope people with the knowledge and time will look into this.


Xaron(Posted 2013) [#31]
I will do that.


Supertino(Posted 2013) [#32]
I will do that.


I shall call my first child Xaron/ =D


Xaron(Posted 2013) [#33]
LOL. Don't do that. Call him Martin. ;)

I'll see what I can do. I need it for my projects as well for both Android and iOS (and probably Windows 8) so I will do it.


Supertino(Posted 2013) [#34]
Thanks Xaron, and just for you a sneek peek at my WIP game that would greatly benefit from IAP. I would rather not do the free(lite) and full version release, I don't think people accept that any more for mobile games. It's all with optional extras or nothing I think.




Xaron(Posted 2013) [#35]
That looks really sweet!

I agree, this classic lite/full might be a bit out of date... Will check that stuff now.


Supertino(Posted 2013) [#36]
Looks like v3 is easier to integrate it's all managed by Google services so no need for middleware api's etc. https://developers.google.com/events/io/sessions/324958374 at-least that's the jist I get from that video.

Xaron if\when you do get round to looking at this I am ofc happy to test this.


Xaron(Posted 2013) [#37]
Sure I'll implement that v3 thing. Looks much easier than v2.

All products are managed now, there is no difference anymore. And there is a new helper interface. Looks nice!

edit: Actually that looks straight forward! Working on it... Hang on!