HomeНаука и техникаRelated VideosMore From: Rafał Stępień

The simplest way to implement and test Android In-App billing

243 ratings | 26697 views
This is solution how to implement In-App purchase with only few minutes without generating Google Console License Key. Video contains also method to create test in app purchase and reset it for testing and debuging. Here is a link to the library: https://github.com/anjlab/android-inapp-billing-v3
Html code for embedding videos on your blog
Text Comments (208)
Simone Biliato (1 day ago)
I successfully followe your tutorial and tried to do an effective payment using my personal google account. The payment was successful but I didn't receive the money. Is there something missing?
Jonathan Svendsen (2 days ago)
Hi where can I download the test app you created ? :)
Raghuchandra H C (4 days ago)
i have a request, how to get the details of inapp purchase or how to verify that the user has bought the inapp purchase example: if [email protected] have bought inapp purchase named "remove.ads" purchase then how to check whether [email protected] have bought this purchase or not please reply
Raghuchandra H C (3 days ago)
+Rafał Stępień that was my idea too, but i was searching for the code for restoring purchase, i got it now. anyways thanks fr the reply.
Rafał Stępień (4 days ago)
So the most appropriate thing would be storing such information on the user device, e.g. user is busing something, then you will receive onSuccess callback. In such callback you can add to file or db information that such user bought your inapp. "verify that the user has bought the inapp purchase" - please review comments, I already answered this question :)
TwoStarII (12 days ago)
If someone buys, is there a unique key or something returned to eg: onSuccessfulPurchase (this is just an example method I made up) which I can use to update user's account on an external database so that I am able to see which users purchased and which did not so that I can keep ads, limit features etc for those not having this key?
Rafał Stępień (9 days ago)
+TwoStarII no problem, happy to help, good luck with your project :)
TwoStarII (11 days ago)
+Rafał Stępień SPOT ON! you're the best!
Rafał Stępień (11 days ago)
Hi, I don't know about a unique id (maybe you will be able to get it from purchase object) - but In my perspective it wouldn't be useful. To check if user bought already something use isPurchased method. Simple as it is - just let google keep data about it, and don't make redundancy :)
Ravinder Pal Singh (2 months ago)
Hi Rafał , Please tell...How to get every time Subscption renew details( new data time of Subscption )? please reply ASAP
Rafał Stępień (2 months ago)
Ravinder Pal Singh according to the library documentation you can only check if auto renew option is set to true or false.
Ravinder Pal Singh (2 months ago)
I mean to say if user alrady buy subscription plan. I need information of auto renews subscription details like new expired date and purchase time. Purchase state
Rafał Stępień (2 months ago)
Ravinder Pal Singh Hi I’m not sure I understand correctly what is your goal. Could you be more precisely?
Gumangan Raffy (2 months ago)
Now how do I implement this with free and paid project. This in app billing will show on free and by purchasing they will get the paid app?
Gumangan Raffy (2 months ago)
Can you make video for that. Upgrading free to premium using in app.
Rafał Stępień (2 months ago)
Yes, you need to implement this logic in your application, if you get confirmation that purchase was successful unlock paid options.
Manasvi Pundir (2 months ago)
auto renew is not possible in this liberary.
NBA MIXTAPE3 (3 months ago)
when i purchase an item how do i change the purchase amount from $0.99 to a different number
Raghuchandra H C (3 days ago)
just change the price of template that u r using in the app, that's it
Rafał Stępień (2 months ago)
NBA MIXTAPE3  happy to help!
Rafał Stępień (3 months ago)
no problem :)
NBA MIXTAPE3 (3 months ago)
Rafał Stępień thanks
Rafał Stępień (3 months ago)
When you put your digital product in Google Developer console it will require a price, on the application side, you will have to download this information and show it to a user. Thank that you can change the price of the item without updating whole app.
Arturo Mucino (3 months ago)
Thanks for the vid. how can i transition to other activity once the purchase is made? should i put something like this: Intent i=new Intent(getApplicationContext(),otheractivity.class); startActivity(i); somewhere?
misakozelk (3 months ago)
Does the library still works? I made it same as in tutorial but it does not show anything, it just initialize the library but the test payment does not show.
Rafał Stępień (3 months ago)
yeap thats correct, dive into app lifecycle for the more info ;) https://developer.android.com/guide/components/activities/activity-lifecycle
misakozelk (3 months ago)
It worked on button but not just in onCreate
misakozelk (3 months ago)
Does it work with android.test.purchased ? In my app with code same as in video the billing processor initialize but nothing else happen. Idk where is the problem.
Rafał Stępień (3 months ago)
Yeap, last week it was working :) I've created special facebook group for asking additional questions so u can send me more information there: https://www.facebook.com/groups/485381788583271/?source_id=1646506748763337 I will try to help you :)
Vergil Studios (3 months ago)
hi Rafal thx for the great code. But it gives error onBillingError when i just changed merchantId and licensekey.. Do you know why can it be ? thx a lot
Rafał Stępień (3 months ago)
Vergil Studios  No problem, happy coding :) powodzenia!
Vergil Studios (3 months ago)
exactly as you said, it works perfect now. Thanks many times czesc xd
Rafał Stępień (3 months ago)
Hi, thanks for the opinion. My idea is to use loadOwnedPurchasesFromGoogle method, and debug if this method is invoking correctly. Make sure if SKU's are provided correctly (must be the same like in Google Console). If will still have a problem, just let me know :)
Janani Natarajan (3 months ago)
Please upload a video for updated google in-app billing api.
Rafał Stępień (3 months ago)
It's for production also, you just need to set real SKU ids :)
Janani Natarajan (3 months ago)
I have to use the updated google play in app billing library. My suggestion is.. you can upload a video on it.
Janani Natarajan (3 months ago)
This is for test implementation. For real implementation, what should I do ?
Rafał Stępień (3 months ago)
Janani Natarajan have u tried this solution? Recently I’ve used this lib in a one project and it’s working perfectly
KaizerZord (4 months ago)
does android.text.purchase still work? I got the Google Play dialog Box but it says "Error retrieving information from server DF-AA-20
Bryan Ibrahim (2 months ago)
You saved my life. Thanks!
Rafał Stępień (4 months ago)
It should be android.test.purchased ;) not android.text.purchase
Jan Klinge (4 months ago)
Just a little Tip: use WIN + O to Override
Rafał Stępień (4 months ago)
Thanks! I didn't know that :)
Volodymyr T (4 months ago)
Nice video! Rafał, how did you learn English?
Rafał Stępień (4 months ago)
Thank you! I've been learning English since I was 7 (20 years right now), moreover, I'm the programmer so I have to be able to communicate in English. Creating movies like this also helps :)
Azhar Bobat (4 months ago)
This video is underrated. I spent a whole day trying to implement it and this video makes it so easy. Thank you! I have a question though. Does it matter that the above library is not the official way as shown by the developer.android.com site?
Rafał Stępień (4 months ago)
Thank you very much for the opinion! I felt the same 2 years ago, and decided to create the movie :) The library is still updated, and under the hood its use official library from Android, but in much more nice format.
Aditya Kumar (4 months ago)
how to change purchase amount ? reply ASAP !!!!
Rafał Stępień (4 months ago)
You have to handle it by your own logic - right now you don't have options like these via InApp library, simply create in app purchase as consumable and in your app try to invoke purchase multiple times, hope I helped
Rafał Stępień (4 months ago)
thanks for the idea, I will put it on my list
Aditya Kumar (4 months ago)
and also make a vid on how to handle these things on play store, like product id, in-app products, managed vs unmanaged etc!
Aditya Kumar (4 months ago)
Rafał Stępień I guess, consumePurchase is used to consume the current purchase not change the price rate! am asking how to change price according to quality or quantity?
Rafał Stępień (4 months ago)
oh God, fast fast...give me a second... maybe try to use consumePurchase? take a look at consumables: https://developer.android.com/google/play/billing/api#managingconsumables please response ASAP!
Himanshu Appspool (5 months ago)
When User brought product then after app is unistall and User install again app so how can i identify in splash activity user is already brought user ????
Rafał Stępień (5 months ago)
take a look on onPurchaseHistoryRestored method in https://github.com/anjlab/android-inapp-billing-v3 readme
Jetkite (5 months ago)
After purchase, when I uninstall and install the app again bp.isPurchased returns false. When I exit the app and restart again it comes back with true. Any solution?
Rafał Stępień (3 months ago)
just take a look on consumePurchase method on documentation site https://github.com/anjlab/android-inapp-billing-v3
Steven Galloway (3 months ago)
So what if i need the user to make the purchase multiple times?
Rafał Stępień (3 months ago)
Nope, history of the purchase is stored on Google database, if a customer will click the button, he/she will get the info that is already bought. However, if you remove and install app again you have to restore purchase information from Google with this method: loadOwnedPurchasesFromGoogle. Information about transaction is stored in a local storage so, after restarting the app purchase history will be still there
Steven Galloway (3 months ago)
Does that mean user will be able to buy content multiple times and on each time get the popup asking for purchase?
Rafał Stępień (5 months ago)
Everything is fine :) Your app should be on Play store to have "normal" purchases. If you would like to remove test purchase use the method from 13 minute from Video
Jetkite (5 months ago)
Can we use the library commercially in our app?
Rafał Stępień (5 months ago)
You're welcome :)
Jetkite (5 months ago)
Thank you!
Rafał Stępień (5 months ago)
It's based on Apache 2 license, so yes y can. Detailed info can be found here: https://resources.whitesourcesoftware.com/blog-whitesource/top-10-apache-license-questions-answered
RAMIZ THEBA (5 months ago)
can we dived month and yearly pay for the app
Rafał Stępień (5 months ago)
You have to make your own logic for this case
Laxman parlapelly (5 months ago)
Hi Gerat job man.. nice video, but i need to add in app purchase in cordova based android app. /Can u tell me how can we process on cordova?
Rafał Stępień (5 months ago)
qote from the site: "This plugin allows In-App Purchases to be made from Cordova and PhoneGap applications"
Laxman parlapelly (5 months ago)
I want how to add Android Pay plugin in cordova , Steplen .. is it android pay and in-app purchase both are same??
Rafał Stępień (5 months ago)
Hmm maybe something like this can help you: https://github.com/j3k0/cordova-plugin-purchase but I've not tested this library before, maybe it can help you :)
Simay Fal (6 months ago)
I dont know why you dont copy paste the code in front of you and made us to wait you to write .. Are you trying your new keyboard or ?
Simay Fal (5 months ago)
you are so kind.. thank you for your good understanding .. Otherwise your tutorial is perfect and clear :) Subscribed
Rafał Stępień (6 months ago)
Thanks for the feedback, it was one of my first movies, I know that more valuable is working on prepare code. Moreover I'm not copy-paste type of guy ;)
kadir yapar (6 months ago)
hello Rafal, thanks for this video. I tried your "adb Shell pm clear" code but it did not work for me. it gives this error: 'adb' is not recognized as an internal or external command,operable program or batch file. can you help me about this
Rafał Stępień (6 months ago)
kadir yapar hi, thanks for watching, yeah its pretty common situation, you need to add adb location to environment variables, depending on your OS nad localization this path will be different, cheers ;)
Sourav Kumar (8 months ago)
Thanks..Can i use this for upgrading/downgrading subscriptions also?
Rafał Stępień (8 months ago)
Sourav Kumar Its just depends on your implementation, library can give you boolean information if user has subscription or not. So I think you should create next subscription product and validate user permissions by checking bought subscriptions.
Sourav Kumar (8 months ago)
Hey,I want to upgrade a user subscription from a 5$/mnth plan to 10$/mnth plan while his ongoin plan is still not over.I want to implement a method like getBuyIntentExtraParams() in the app.Can i achieve it using this library?
Rafał Stępień (8 months ago)
Sourav Kumar hi, what do you mean upgrading? I think it will be totally different SKU, so the simplest way would be subscribe to another package and simulate upgrade.
Em Pru (8 months ago)
*THANK YOU SO MUCH!!!*
Rafał Stępień (8 months ago)
Eme Usani you're welcome
vivek soni (8 months ago)
Visualization is not clear
Rafał Stępień (8 months ago)
Hi, what do you mean?
RawDNACoders PurePeace (9 months ago)
I am so thankful for you Rafal. Thank you for sharing this with us. It worked and now I am moving to add into my app! Thanks again you rock!
Magix iZiBeat (10 months ago)
Where to find the license key in the google console?
Magix iZiBeat (10 months ago)
Why not work on emulator api 22?
Rafał Stępień (10 months ago)
InApp purchase doesn't work on emulator at all, take a look on that post: https://stackoverflow.com/questions/26100032/how-to-test-in-app-billing-on-an-emulator
suraj singh (10 months ago)
Hi thanks for very simple tutorial, i did same as you did but nothing happens after my click.
Alfonso Tesone (9 months ago)
how did you solve it?
suraj singh (10 months ago)
solved it though thanks for such simple tutorial looking forward to see more of your tutorials.
Rafał Stępień (10 months ago)
Hi, could you be more specify? Maybe add some Log info to make sure if button was clicked :)
Smokey (10 months ago)
This worked great! But i have one question, once i test bought it then try to buy it again it keeps saying the onProductPurchased() payment success text. i want it to be a purchase that you can keep on buying over and over. could you help me with that? Thanks!
Rafał Stępień (10 months ago)
Hi, somebody else asked that question already, look on comments below. You should use consume function
Devangi Chhatbar (10 months ago)
Nice tutorial but facing issues when using for Subscription. did not get any response in onProductPurchased(). Needs some suggestions to solve it.
Peter Sitemba (3 months ago)
Did you ever solve this?
Emre Yüz (10 months ago)
What about subscription? How can i implement?
Peter Sitemba (3 months ago)
OnProductPurchased not called when using subscriptions. Any ideas?
Emre Yüz (10 months ago)
Thanks for reply, now I update my app on google play and trying to buy another phone it gaves an error "Correct this card information or try a different card"
Rafał Stępień (10 months ago)
Instead of bp.purchase use bp.subscribe method :)
Shailesh Limbadiya (10 months ago)
Nice tutorial, You done great Job. Save my day and time. Thank you.....................( ^_- )
Rafał Stępień (10 months ago)
Thanks! Glad to help you :)
Lennart M. (11 months ago)
hey thank you very much. It worked really good for me. But i have one problem: i want to sell coins and i want that the user can buy coins again and again. But I can only purchase once. How can i buy one product more than one time/how can I consume it the most easy way?
Joan Colmenero (11 months ago)
Hello Rafał Stępień, I've implemented the code, but I don't get why if I click on PURCHASE it says "The item you requested is not available for purchase", but if I put DETAILS it sais the product and its price... you know why? I put a Toast to check if it's returning true the purchase method and it says TRUE, but doesn't show to me the product with title.
Joan Colmenero (11 months ago)
Rafał Stępień Where I get the developer payload code from google play console? I want to make a fake purchases, I mean to now have to pay to see if it really works, I mean I've created the products on Google Play Console, it shows on my app, but I have to pay to know if it works what's next.. so I'd like to see if I can use other option to pay with fakeVisa or something, thanks :D
Joan Colmenero (11 months ago)
Thanks I found the problem, can you tell me why is the purpose of MERCHANT_ID? And where I can find it? I have an id like : 056343.... is this ID? And I have to put it here? bp = new BillingProcessor(this, LICENSE_KEY,MERCHANT_ID, new BillingProcessor.IBillingHandler() { If I want to make a fake purchases is that possible with that library? Thanks!
Rafał Stępień (11 months ago)
Hi, are you sure you are using android.test.purchased as SKU id? Try also to remove app from smartphone and install once again, instant run may cause problems. Regards
Hagen Brooks (1 year ago)
Is there any advantages using google's new billing library instead?
Rafał Stępień (1 year ago)
Hi I'm not familiar with Google Play Billing library yet, it's seems like similar level of complexity :)
Hagen Brooks (1 year ago)
Testing like this will no longer work, Google now requires you to use a alpha version for testing in app purchases.
M Musa (1 year ago)
Sir can it be used to add subscription for apps also, I need one for that
Thoriq Anwar (1 year ago)
how to change the androd.test.purchased into real product?
Gumangan Raffy (2 months ago)
Register to Google Play Console
Rafał Stępień (1 year ago)
Hi just change android.test.purchased with correct identifier from Google Console
Nelson K (1 year ago)
Great tutorial. Are you planning to post more? :)
Rafał Stępień (1 year ago)
Thanks! Yeah, just give me hint what you need :)
Taimoor Suleman (1 year ago)
Hi, Need a full step by step tutorial .For real in app purchases..
Hagen Brooks (1 year ago)
Taimoor Suleman this is a full step by step tutorial, the only difference betweeb this and real purchase is you have to enter your appId
YSNFTM YKILICKAYA (1 year ago)
Thanks for this video. I did everything as in video. But there is a problem. First time buying screen appears and succesfully done. And second time i put buy button, buyin screen does not appear and isPurchased method return true. I give game coins firstProduct.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { bp.purchase(InAppPurchaseActivity.this,firstpro); if(bp.isPurchased(firstpro)) { addCoinsFirstProduct(); } } });
Jared Johnson (11 months ago)
In order to have renewable purchases you need to consume the purchases. https://github.com/anjlab/android-inapp-billing-v3 Look at the link he is using and scroll down to where it talks about this.
YSNFTM YKILICKAYA (1 year ago)
I am still lookig for solve about this problem.
Ege Dogan Dursun (1 year ago)
i experience the same problem
YSNFTM YKILICKAYA (1 year ago)
OK, i see one transaction in google developer console. Somehow, I did this third times too after first click.
Rafał Stępień (1 year ago)
Hi, everything works as designed. When you buy something at first time you have new dialog - otherwise if product is already bought you just get information from isPurchased method that user already has that item and it's unnecessary to show it once again.
[ ؜ٴٴ] (1 year ago)
mogles po polsku mowic debilu
[ ؜ٴٴ] (1 year ago)
napisz po polsku
Rafał Stępień (1 year ago)
I'm trying to learn new languages at any occasion, so if you have problem with my video try to use Google translate.
When I'm clicking the button, nothing happens? Why does it work for u, but doesn't work for me? By what reason I don't have any results?
CyberHatter (7 months ago)
I think the answer is not actual anymore but moving the bp initializer right to the start of onCreate() worked for me. Like this: super.onCreate(savedInstanceState); setContentView(R.layout.activity_current_tasks); bp = new BillingProcessor(this, null, this); bp.initialize();
Not(((
TheSima (1 year ago)
Did u fix that problem? I have some :'c
Matan Issler (1 year ago)
I implemented it successfully!!!! thanks
Hany Abdoun (1 year ago)
thanks for the video , i have q please i am trying to make sql database for my game and i want to know how to make sure that someone actually make a successful purchase like if the a massage i can get from google play or something to confirm me that ? and thanks again.
Rafał Stępień (1 year ago)
Hi, thanks for opinion! I'm storing these kind of information in smth like shared preferences: https://developer.android.com/training/basics/data-storage/shared-preferences.html In my opinion is one of the simplest way to store small data.
AdventuresOfMarc (1 year ago)
Damn it's the simplest way to implement dat! Thank You Rafał for this amazing tutorial btw. Jestem z Polski też, także duży kciuk w górę i sub :)
Rafał Stępień (1 year ago)
Cześć, dzięki wielkie za opinie i wsparcie z PL! :)
DieMainClass (1 year ago)
Hi, nice Video, just one little question. Can I test the in app purchase without a Google Developer Account?
DieMainClass (1 year ago)
Ok thank you for your fast answer
Rafał Stępień (1 year ago)
Hi, thank you for your opinion! As you can see I didn't provide anywhere my own credentials or developer ID. So yeah I believe you can test your App without Google Dev Account. If you would like to create your own products you have to provide full hash from Google Developer site. Regards, Rafal
Gerardo Mendez (1 year ago)
Nice video man, it helped me a lot. A question off topic, What program do you use to emulate your real device on the computer? Thank you
Rafał Stępień (1 year ago)
Hi, thanks for your opinion! It's real device but screen is streamed by software called Vysor from smartophone to PC. Cheers
Malik Hassham (1 year ago)
Hi bro how to consume the already bought product i mean if i want to buy the same product again how do i do it?
Malik Hassham (1 year ago)
Thanks brother i have gone through comments and found the solution you already told someone thanks a lot :)
Rafał Stępień (1 year ago)
Hi. take a look on section: Consume Purchased Products You need to invoke that line of code: bp.consumePurchase("YOUR PRODUCT ID FROM GOOGLE PLAY CONSOLE HERE");
Oscar Castaneda Munoz (1 year ago)
how do you register a purchase in the server??
Rafał Stępień (1 year ago)
Could you be more specify? What server do you mean? If you invoke something like this: bp.purchase(YOUR_ACTIVITY, "YOUR PRODUCT ID FROM GOOGLE PLAY CONSOLE HERE"); it will connect with google servers and store that information for users.
Cagsan Ozbek (1 year ago)
Rafal, thanks for a really great tutorial. Your english accent is really good and your actions are very clean and easily understandable. I have a question. What is that last terminal thing ? Can you explain about it, is it a must ? What is it for ? Thanks!
Rafał Stępień (8 months ago)
Hi thank you very much for the feedback, the last command will remove all test purchases - so you will be able to test it once again.
Mohsin Qazi (1 year ago)
I did all this but when I click on the button it says google play store has stopped
Mohsin Qazi (1 year ago)
my problem too was solved by uploading app to production and with real product id instead of "android.test.purchased". I agree, it is frustrating and took me a couple of days to figure out the problem.
raul barragan (1 year ago)
Im not sure what happen with "android.test.purchased" but it doesn't work. I create my own In App Product on the google play console and upload my app to production and it works. Is a little bit frustrating because you have to test on a production environment.
Mohsin Qazi (1 year ago)
the log is useless, I have been trying to figure out what's wrong but so far the log is not helpful. it crashes on android.test.purchased haven't tried it on a real item yet but with freedom/lucky patcher the test purchase go through but without those apps the play store crashes
raul barragan (1 year ago)
I have the same problem. This is my log. data= null on handler. 07-31 13:29:23.931 16938-17040/com.asere.pagosgoogleplay D/libGLESv1: DTS_GLAPI : DTS is not allowed for Package : com.asere.pagosgoogleplay 07-31 13:29:23.961 16938-16938/com.asere.pagosgoogleplay I/Timeline: Timeline: Activity_idle id: [email protected] time:16487037 07-31 13:29:25.451 16938-16938/com.asere.pagosgoogleplay D/ViewRootImpl: ViewPostImeInputStage processPointer 0 07-31 13:29:25.541 16938-16938/com.asere.pagosgoogleplay D/ViewRootImpl: ViewPostImeInputStage processPointer 1 07-31 13:29:39.711 16938-16938/com.asere.pagosgoogleplay I/Choreographer: Skipped 850 frames! The application may be doing too much work on its main thread. 07-31 13:29:40.261 16938-16938/com.asere.pagosgoogleplay V/ActivityThread: updateVisibility : ActivityRecord{7e79c2 [email protected] {com.asere.pagosgoogleplay/com.asere.pagosgoogleplay.MainActivity}} show : true 07-31 13:29:51.131 16938-16938/com.asere.pagosgoogleplay E/iabv3: handleActivityResult: data is null! 07-31 13:29:53.891 16938-16938/com.asere.pagosgoogleplay I/Timeline: Timeline: Activity_idle id: [email protected] time:16516964
Rafał Stępień (1 year ago)
Could you post some more information, any log or additional information will be appreciated :)
Hello Sir, I followed this tutorial but I'm now having the errorCode 101 https://github.com/anjlab/android-inapp-billing-v3/issues/292 How can I solve this problem? I appreciate your help.
Palestine.
Cagsan Ozbek (1 year ago)
Where are you from ?
The error code comes from the overridden method onBillingError. The problem was because my country is not supported in Play. The code worked fine When I changed my country. Thanks for your help.
Rafał Stępień (1 year ago)
Hi, could you send me where exactly you have such issue? Which line of code? Please make sure you have connected Google account on your smartphone. Cheers, Rafal
adn benz (1 year ago)
noooob auestion eroor Error:(1760, 3) error: cannot find symbol variable bp
Rafał Stępień (1 year ago)
Could you send us some code? I believe you have to verify scope of variable is it declared as a member of the class?
Ibuyim San (1 year ago)
How can i make the following line bp.pruchase(this, "") work in another class other than MainActivity class?
Rafał Stępień (1 year ago)
You are sure you want to do that? You can pass MainActivity class via parameter or just use that library in other activity
YSNFTM YKILICKAYA (1 year ago)
if my app has multiple products what can we do ?
Daniyyel Touboul (10 months ago)
how can you pass a toast for 1st SKU and then another unique toast for diffrent SKU?
Rafał Stępień (1 year ago)
Hi, your products are represented as SKU - id which uniquely represents products in Google panel. To purchase something you are invoking: bp.purchase(YOUR_ACTIVITY, SKU_ID) for buying something else you can use code like this: bp.purchase(YOUR_ACTIVITY, ANOTHER_SKU_ID) That's all!
An_Arj _Art (1 year ago)
Hi thanks sir..... iam an icon pack maker..Iam using icon showcase template from github... can u make tutorial of adding in appbilling in icon showcase template.... i want it on icon request section ..for 4 icon requests costs 1$ and 8 icons request costs 2$... is this possible...Please make a video tutorials......Thanks..
Leonardo Francisco (1 year ago)
Can you do that in Games? Or Unity 5 ??
Rafał Stępień (1 year ago)
What do you mean games? If you are implementing game in Android (Java) code will be the same, in case of Unity you can try to port library to C# or just look for another one ;)
Matt Pocock (1 year ago)
This was fantastic. Thanks!
ARN DNA (1 year ago)
Hi, how to implement in-app purchase to remove ad-mob interstitial ads? Thanks!
sunil vishwakarma (1 year ago)
amazing integrated only in 15 minutes
JoLu (1 year ago)
How I check if someone already bought the item?
Red Creative Studios (24 days ago)
do u mean bp.getPurchaseListingDetails("YOUR PRODUCT ID FROM GOOGLE PLAY CONSOLE HERE");
Oleg ZBS (1 month ago)
Google is responsible for dealing with purchases, so when someone makes a purchase google stores this data on its side.
Masud Parvez (10 months ago)
@Noel Diaz how they will know it's already purchasis??
Cagsan Ozbek (1 year ago)
@noel is it also works on test purchasis ?
Noel Diaz (1 year ago)
bp.isPurchased(productID) returns a boolean
Noel Diaz (1 year ago)
I have searched a lot of tutorial, this seems the simplest. I have one question, if someone buys something, where I can check how much money im making or specify where to get paid?
Marc S (1 year ago)
You create a boolean variable like bAds and set it to true. If you buy anything you can set this variable to false and save it to external storage ;) And then you can check your bAds variable and don't launch ad-mob interstitial if the variable is false!
ARN DNA (1 year ago)
Hi, how to implement in-app purchase to remove ad-mob interstitial ads? Thanks!
Rafał Stępień (1 year ago)
Thanks, I also had many problem with it, so I'm glad I could help you! :)
Noel Diaz (1 year ago)
Yes I figured that out... man keep it up this is by far the best tutorial, on this topic, I have beem trying to implement IAP for a long time and always just gived up, took me a few minutes with this video. Gratz
Rafał Stępień (1 year ago)
Hi, you have something like Google developer console (there is also Android app for that)
Radoslav Apostolov (1 year ago)
Fast and clearly explained. Good work for the video! The library looks great too.
Rafał Stępień (1 year ago)
Thank you very much for your opinion!
Muhammad Usman Aslam (1 year ago)
really nice Very helpful for me. Is this code is enough for my product? I mean if i have to add more code for my application? if i have to add more please provide me sample app for monthly subscription not google sample that is crashing i tried several times. Thanks
Muhammad Usman Aslam (1 year ago)
Thank You very Much for your Help. I hope it will work fine for me. Thank you again I appreciated you struggle. Keep making more and more videos like this.
Rafał Stępień (1 year ago)
Hi, I'm glad I could help you! In your case you need to provide valid Developer ID in Billing processor constructor and add inapps in Developer console panel - thats should be all. If you are implementing monthly subscription just remember to use this method: getSubscriptionListingDetails() instead of getPurchaseListingDetails() I've made simple application based on this tutorial: https://play.google.com/store/apps/details?id=com.traffii.inaapp.inapptest&pageId=102345657634504276601
solitarionotturno (1 year ago)
Where must we insert: repositories { mavenCentral()} togheter repositories { jcenter()} or delete jcenter and insert mavenCentral? Thanks.
Rafał Stępień (1 year ago)
You don't need to modify this section, just use standard Android pre-defines
solitarionotturno (1 year ago)
Can you tell me if the in-app billing code must be inside the app or separated?
Rafał Stępień (1 year ago)
Hi, yeah in-app billing code must be inside the app, you can get it from Google Play Developer Console
Sweetie Apps (1 year ago)
Really nice video. I have a question: how to restore the purchase if the user changes or format the device?
Lorenzo Pezzi (7 months ago)
Hi, i have same problem. wich is the code of reload info purchase?
Rafał Stępień (1 year ago)
Hi try to install this app and check: https://play.google.com/store/apps/details?id=com.traffii.inaapp.inapptest is it working as you want. When the activity starts you should download from Google server information about already bought items and refresh your view.
Theme For Launcher (1 year ago)
A very good tutorial. But I have the same problem. If I deleted the app after the purchase and installed it again. The purchase is not restored. (I tested the alpha versions in the Google developer console). How can I solve this problem? What code and where I need to add?
Rafał Stępień (1 year ago)
Thank for your opinion! In-apps are bounded to the google account. When user login to the different device and install your application, everything will be restored. I've created simple application to test it, cheers ;) : https://play.google.com/store/apps/details?id=com.traffii.inaapp.inapptest
Jooyoon Byun (1 year ago)
not able to purchase again when I click button again :(
Renatinha Swatcen (1 year ago)
in my case the bp.consumePurchase("android.test.purchased") does nothing when added inside the onclick function. but I notice it resets the stored purshased information, so after call this I can purshase the same item again using bp.purchase. I'm using bp.consumePurchase inside void onProductPurchased (after toast success) so this way user can buy the same item again. I don't know if it is right, but it was the way I found since bp.consumePurchase does nothing besides resettiing the purchased item.
Rafał Stępień (1 year ago)
If user buy something by in-app mechanism, information about transaction is stored in Google servers. In case you want add posibility to buy multiple times our in-app you should use consumables items: e.g. bp.consumePurchase("YOUR PRODUCT ID FROM GOOGLE PLAY CONSOLE HERE");
Jooyoon Byun (1 year ago)
yeah but do we have to do that manually every time after purchasing? what if the user wants to purchase twice or more?
Rafał Stępień (1 year ago)
Hi, if you want to test it once again you have to clear purchased items by typing adb shell pm clear com.android.vending in terminal and then re-run your application
MLG Pro (1 year ago)
I was waiting for a video like this for ages , thank you so so so much for posting this !!!! Keep it up man !
Rafał Stępień (1 year ago)
Thank you very much for your feedback :) I hope it will simplify InApp billing implementation!

Would you like to comment?

Join YouTube for a free account, or sign in if you are already a member.