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

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

336 ratings | 35507 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 (238)
Vinay Sharma (2 days ago)
no dialog box appearing upon clicking floating button..
Jeff L Gaol (4 days ago)
BEST TUTORIAL!!!!! Easy to understand.
Rafał Stępień (3 days ago)
thanks! :)
iTching bRains. (4 days ago)
I implemented it in another activity apart from the main activity but it is not any dialog box of skus.why?
iTching bRains. (3 days ago)
+Rafał Stępień yes I did..but it's not showing up. Do I have to write additional code for Dialog box creation,containing skus?
Rafał Stępień (3 days ago)
Make sure you've implemented onActivityResult method
Leendert V (1 month ago)
command in the terminal don't work, what can i do instead?
Audric Pazzaglia (1 month ago)
where put price ?
Rafał Stępień (1 month ago)
Audric Pazzaglia you should put a price in a Google Play Console. Prices are downloaded directly from google servers.
Smart Mobile Developer (2 months ago)
Thanks for the video, mr. Rafał it was very useful. I'm a this coin will spend. I can keep sharedpreferences locally, or I can keep a backend like the firebase server at certain intervals. to see the number of coins that the user owns, even if the factory defaults for the number of coins that the user is staying at I'm connected to the firebase. device id, imei deserve rights, I do not know the emaili used during the sale. email list can be received. but this also requires extra permission. Even if the user returns to factory settings without login or authentication, what should I do to continue the coin when he re-installs the application. request what is the best practice for the number of coins that the user is staying in for the application, what are our suggestions
timemake (3 months ago)
Hi, Thanks for the wonderful tutorial! If you can add one more tutorial how to get product Id and license Key it would be the best in-app tutorial. Thanks!
Rafał Stępień (3 months ago)
timemake Hi and thanks for the feedback, I have such video in my todo list. Stay tuned:)
Weedy Beats (3 months ago)
Doesn't work! DF-AA-20
riwjin (3 months ago)
I don't think this framework includes server-side purchase verification (developer payload handling) and subscription activation.
Rafał Stępień (3 months ago)
Whole purchase mechanism is done via Google inside Android, they are handling whole buying procedure etc., the library is responsible for invoking "a low level" code to the Google Billing API
Athaariq Ardiansyah (3 months ago)
I like this simplicity, but I'm afraid getting trapped 😅
Rafał Stępień (3 months ago)
you mean getting trapped because of being too simple? :P
pramod deore (4 months ago)
Hi Rafal Stepien, first of all thanks for this wonderful tutorial. In sample application i tried your tutorial and its works fine for bp.purchase(activity, productId). But now i want to implement subscribe so what parameter i have to use as SUBSCRIPTION ID for testing (I mean for purchase we used android.test.purchased so here i want testing parameter for SUBSCRIPTION ID)Thanks in advance
Tarık Bulanık (5 months ago)
boolean isAvailable = BillingProcessor.isIabServiceAvailable(context); if(!isAvailable) { // continue } Is this correct returns the opposite value in my device
Tarık Bulanık (4 months ago)
+Rafał Stępień boolean isAvailable = BillingProcessor.isIabServiceAvailable(context); if(isAvailable) { // If Google Play Store is installed // continue //Otherwise I get this error.('java.lang.String com.anjlab.android.iab.v3.SkuDetails.priceText' on a null object reference) But this error disappears when I check it true }
Rafał Stępień (4 months ago)
if you still have this problem, try to make an issue on project site: https://github.com/anjlab/android-inapp-billing-v3/issues I haven't used this method before
DNA Mobile Applications (5 months ago)
Alright so I've spent all day on this, as my game has 3 bundles that the player can buy. Now I have everything working, but not sure if I'm calling the listOwnedProducts or loadOwnedPurchases incorrectly, but I want each bundle to only be consumed once so the player can reuse the bundle if they die or start a new game. For some reason sometimes it doesn't work some times it does but not sure if that's because I'm changing code around. Should I use consumePurchase at any time in this case or just loadOwnedPurchasesFromGoogle? Not a lot on the internet to explain.. Hope someone responds, thank you.
DNA Mobile Applications (5 months ago)
Figured it out nevermind, so if you use consume it will consume that purchase to the point that you have to buy it again and again, whereas loadOwnedPurchasesFromGoogle is used to do just that so throw an if statement if (bp.isPurchased(productid)){ code ex. give player 100 coins forever} Almost 12 hours of trial an error and breaks of course trying to understand this, great work though as I used this for my Base Fire Droid Battles game but you have to rebuy items in this game. Take care!
el jhoni XD (5 months ago)
No entiendo ni jota
Rafał Stępień (5 months ago)
Lo siento mucho, que yo mejorar?
별자리TV (5 months ago)
I meet the same problem in 12:00, how to solve the problem in real app to let user buy again?
Akbar Umar (5 months ago)
just add your sdkpath/platform-tools (you can see ur sdkpath directory in settings/appearance & behavior/system settings/android sdk) in system environment variables, then restart cmd, goto your android project directory then type "adb shell pm clear com.android.vending" without quotation mark. :D
Azizul Haq (6 months ago)
I am alway getting "Something went wrong". Error Code 101. Gradle version 3.2.1. Any idea what went wrong?
Azizul Haq (6 months ago)
Yes I have one connected account. I signed out and ran the program. Then signed in and ran. Same result.
Rafał Stępień (6 months ago)
Hmm maybe it's your problem with google account, do you have any connected in your phone? Try to refresh them
Simone Biliato (6 months 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 (6 months ago)
Hi where can I download the test app you created ? :)
Raghuchandra H C (6 months 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 (6 months 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ń (6 months 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 (6 months 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ń (6 months ago)
+TwoStarII no problem, happy to help, good luck with your project :)
TwoStarII (6 months ago)
+Rafał Stępień SPOT ON! you're the best!
Rafał Stępień (6 months 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 (8 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ń (8 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 (8 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ń (8 months ago)
Ravinder Pal Singh Hi I’m not sure I understand correctly what is your goal. Could you be more precisely?
Gumangan Raffy (8 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?
DNA Mobile Applications (5 months ago)
+Gumangan Raffy Basically make the full app but set items not enabled unless the user pays for the full version. It'd be the same app with only limited items until purchased.
Gumangan Raffy (8 months ago)
Can you make video for that. Upgrading free to premium using in app.
Rafał Stępień (8 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 (9 months ago)
auto renew is not possible in this liberary.
Zulfukar El Masri (9 months ago)
when i purchase an item how do i change the purchase amount from $0.99 to a different number
Raghuchandra H C (6 months ago)
just change the price of template that u r using in the app, that's it
Rafał Stępień (9 months ago)
NBA MIXTAPE3  happy to help!
Rafał Stępień (9 months ago)
no problem :)
Zulfukar El Masri (9 months ago)
Rafał Stępień thanks
Rafał Stępień (9 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 (9 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?
peter kagera (1 month ago)
Intent i = new Intent (yourCurrentClass.this, otherActivity.class); startActivity(i);
Michael Kozel (9 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ń (9 months ago)
yeap thats correct, dive into app lifecycle for the more info ;) https://developer.android.com/guide/components/activities/activity-lifecycle
Michael Kozel (9 months ago)
It worked on button but not just in onCreate
Michael Kozel (9 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ń (9 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 (9 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ń (9 months ago)
Vergil Studios  No problem, happy coding :) powodzenia!
Vergil Studios (9 months ago)
exactly as you said, it works perfect now. Thanks many times czesc xd
Rafał Stępień (9 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 (9 months ago)
Please upload a video for updated google in-app billing api.
Rafał Stępień (9 months ago)
It's for production also, you just need to set real SKU ids :)
Janani Natarajan (9 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 (9 months ago)
This is for test implementation. For real implementation, what should I do ?
Rafał Stępień (9 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 (10 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
Rassy (9 months ago)
You saved my life. Thanks!
Rafał Stępień (10 months ago)
It should be android.test.purchased ;) not android.text.purchase
Jan Klinge (10 months ago)
Just a little Tip: use WIN + O to Override
Rafał Stępień (10 months ago)
Thanks! I didn't know that :)
Volodymyr T (10 months ago)
Nice video! Rafał, how did you learn English?
Rafał Stępień (10 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 (10 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ń (10 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 (11 months ago)
how to change purchase amount ? reply ASAP !!!!
Rafał Stępień (11 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ń (11 months ago)
thanks for the idea, I will put it on my list
Aditya Kumar (11 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 (11 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ń (11 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 (11 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ń (11 months ago)
take a look on onPurchaseHistoryRestored method in https://github.com/anjlab/android-inapp-billing-v3 readme
Jetkite (11 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?
DNA Mobile Applications (5 months ago)
+Rafał Stępień So what I'm understanding from this is that if I put a button for example to call bp.loadOwnedPurchasesFromGoogle(); then in onPUrchaseHIstoryRestored call setText button to restore purchases, then if button equals restore purchases what should I call at that point, onConsume or just the code to give the player the items they bought? I may have just answered my own question but insight would be helpful :)
Rafał Stępień (9 months ago)
just take a look on consumePurchase method on documentation site https://github.com/anjlab/android-inapp-billing-v3
Steven Galloway (9 months ago)
So what if i need the user to make the purchase multiple times?
Rafał Stępień (9 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 (9 months ago)
Does that mean user will be able to buy content multiple times and on each time get the popup asking for purchase?
Jetkite (11 months ago)
Can we use the library commercially in our app?
Rafał Stępień (11 months ago)
You're welcome :)
Jetkite (11 months ago)
Thank you!
Rafał Stępień (11 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 (11 months ago)
can we dived month and yearly pay for the app
Rafał Stępień (11 months ago)
You have to make your own logic for this case
Laxman parlapelly (1 year 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ń (11 months ago)
qote from the site: "This plugin allows In-App Purchases to be made from Cordova and PhoneGap applications"
Laxman parlapelly (11 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ń (11 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 (1 year 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 (1 year ago)
you are so kind.. thank you for your good understanding .. Otherwise your tutorial is perfect and clear :) Subscribed
Rafał Stępień (1 year 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 (1 year 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ń (1 year 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 (1 year ago)
Thanks..Can i use this for upgrading/downgrading subscriptions also?
Rafał Stępień (1 year 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 (1 year 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ń (1 year 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 (1 year ago)
*THANK YOU SO MUCH!!!*
Rafał Stępień (1 year ago)
Eme Usani you're welcome
vivek soni (1 year ago)
Visualization is not clear
Rafał Stępień (1 year ago)
Hi, what do you mean?
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 (1 year ago)
Where to find the license key in the google console?
Magix iZiBeat (1 year ago)
Why not work on emulator api 22?
Rafał Stępień (1 year 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 (1 year ago)
Hi thanks for very simple tutorial, i did same as you did but nothing happens after my click.
Alfonso Tesone (1 year ago)
how did you solve it?
suraj singh (1 year ago)
solved it though thanks for such simple tutorial looking forward to see more of your tutorials.
Rafał Stępień (1 year ago)
Hi, could you be more specify? Maybe add some Log info to make sure if button was clicked :)
Smokey (1 year 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ń (1 year ago)
Hi, somebody else asked that question already, look on comments below. You should use consume function
Devangi Chhatbar (1 year ago)
Nice tutorial but facing issues when using for Subscription. did not get any response in onProductPurchased(). Needs some suggestions to solve it.
Sitemba (9 months ago)
Did you ever solve this?
Emre Yüz (1 year ago)
What about subscription? How can i implement?
Sitemba (9 months ago)
OnProductPurchased not called when using subscriptions. Any ideas?
Emre Yüz (1 year 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ń (1 year ago)
Instead of bp.purchase use bp.subscribe method :)
Shailesh Limbadiya (1 year ago)
Nice tutorial, You done great Job. Save my day and time. Thank you.....................( ^_- )
Rafał Stępień (1 year ago)
Thanks! Glad to help you :)
Lennart M. (1 year 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 (1 year 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 (1 year 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 (1 year 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ń (1 year 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
Support (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 (8 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 Yiap (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
YSN FTM (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 (1 year 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.
YSN FTM (1 year ago)
I am still lookig for solve about this problem.
Ege Dogan Dursun (1 year ago)
i experience the same problem
YSN FTM (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 (1 year 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ń (1 year 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
YSN FTM (1 year ago)
if my app has multiple products what can we do ?
Daniel Toubul (1 year 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 (2 years ago)
This was fantastic. Thanks!
ARN DNA (2 years ago)
Hi, how to implement in-app purchase to remove ad-mob interstitial ads? Thanks!
sunil vishwakarma (2 years ago)
amazing integrated only in 15 minutes
JoLu (2 years ago)
How I check if someone already bought the item?
Red Creative Studios (7 months ago)
do u mean bp.getPurchaseListingDetails("YOUR PRODUCT ID FROM GOOGLE PLAY CONSOLE HERE");
Oleg ZBS (8 months ago)
Google is responsible for dealing with purchases, so when someone makes a purchase google stores this data on its side.
Masud Parvez (1 year 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 (2 years ago)
bp.isPurchased(productID) returns a boolean
Noel Diaz (2 years 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 (2 years ago)
Hi, how to implement in-app purchase to remove ad-mob interstitial ads? Thanks!
Rafał Stępień (2 years ago)
Thanks, I also had many problem with it, so I'm glad I could help you! :)
Noel Diaz (2 years 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ń (2 years ago)
Hi, you have something like Google developer console (there is also Android app for that)
Radoslav Apostolov (2 years ago)
Fast and clearly explained. Good work for the video! The library looks great too.
Rafał Stępień (2 years ago)
Thank you very much for your opinion!
Muhammad Usman Aslam (2 years 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 (2 years 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ń (2 years 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 (2 years ago)
Where must we insert: repositories { mavenCentral()} togheter repositories { jcenter()} or delete jcenter and insert mavenCentral? Thanks.
Rafał Stępień (2 years ago)
You don't need to modify this section, just use standard Android pre-defines
solitarionotturno (2 years ago)
Can you tell me if the in-app billing code must be inside the app or separated?
Rafał Stępień (2 years ago)
Hi, yeah in-app billing code must be inside the app, you can get it from Google Play Developer Console
Sweetie Apps (2 years ago)
Really nice video. I have a question: how to restore the purchase if the user changes or format the device?
Lorenzo Pezzi (1 year ago)
Hi, i have same problem. wich is the code of reload info purchase?
Rafał Stępień (2 years 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 (2 years 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ń (2 years 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 (2 years 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ń (2 years 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 (2 years 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ń (2 years 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
RED AZRAEL (2 years 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ń (2 years 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.