- Home /
in app purchase android
hey ,
i am trying to implement in app purchase in my android game,the game currently has 20 levels what i am trying to do is, when the user downloads the game from the market(the game would be free)the first 10 levels will be unlocked(from the starting) but to play the next 10 levels the user has to pay some amount of money(in app purchase).
i dont want a 10 level add on package sort of thing,when the game is first time downloaded from the market it will have all the 20 levels in it but 10 levels will be locked(by a simple loop condition).
my idea of implementing this was,
i would create a gui button for the purchase and trigger a event with playerprefs(by suppose setting a int value to 1)and then in eclipse(i used the following link to convert the game into an eclipse supportable format http://unity3d.com/support/documentation/Manual/Android-Integrating%20Unity%20With%20Eclipse.html ) i heard we can get the playerprefs event called in eclipse and then in eclipse i can do the entire coding related the purchase(i am not concerned about the coding in eclipse regarding purchase as i have done that many times for my non unity apps) but what concerning me is that how will i return a confirmation to unity that the purchase is complete and i can unlock the levels in the game.
i dont know what i am thinking is feasible or not...any suggestion on how this could be implemented or how i could a return a confirmation back to unity about the completion of the purchase.
i would also appreciate any new idea for implementing this..
Thanks in advance
Answer by maxgreen · Sep 23, 2012 at 06:57 PM
You might want to check out the free Soomla Store plugin on the Asset Store.
It's also an open source project on Github, and they have a sample app there as well, with properly documented code.
Answer by Voxel-Busters · Aug 09, 2015 at 10:33 PM
This can be setup with some little effort. Create a gameobject and add a class with a method. On purchase successful in Android, Call
UnityPlayer.UnitySendMessage(UnityDefines.NATIVE_BINDING_EVENT_LISTENER, methodName, message);
Where UnityDefines.NATIVE_BINDING_EVENT_LISTENER is the name of gameObject. Message needs to be a string and you need to convert your purchase info to a string format so that you can parse back in unity.
You can try Cross Platform Native Plugins for a smoother and quick solution. It provides necessary callbacks with very easy setup and lots more features.
Answer by One Platform Foundation · Feb 06, 2014 at 09:50 PM
No need to compile OpenIAB from sources anymore.
OpenIAB also can be found in Asset Store or download from Releases on GitHub
Answer by ddfire · Nov 07, 2011 at 07:05 PM
hi i think the best choice is make an activity outside unity, call it for the in-app billing and using a native plug in check a database or preferences. you only need to check it when the user want to load level 11... or any level above 10... hope this help. please post what did you do. thanks David
@ddfire : that what i asked in my question ....how to proceed about this....even i know i have to make a plugin for this,i have a suggestion for u please read the question carefully before posting a answer.
@CrazyBoy, i think you did not understand my answer... again simplified... make an activity to handle in-app puchace... make a plugin to read sharedprefs so you use your own activity to sell and the plugin to check if the user had bougth the new levels.
@CrazyBoy i dont know why i got a -1 the answer is clear... the native plugin check in shared preferences for a boolean and return it to unity... i think you do not understand about progra$$anonymous$$g.
Answer by PolityAI · Jul 04, 2012 at 09:01 AM
I've written an in app billing plugin for android, currently it is half-price for a limited amount of time! Please find it at http://www.platoevolved.com/blog/unity-plugins/
Your answer
Follow this Question
Related Questions
Free android plugin for in-app purchase 3 Answers
In App plugins free 1 Answer
In-App-Purchases not working (Android) 1 Answer
How to add .properties files to apk root programmatically? 2 Answers