Android Billing Library is an open-source Android library to work with Android Market’s in-app billing service.
The library provides high-level functions (as simply as requestPurchase(“android.example.purchased”)) for the full in-app billing specification, in addition to an obfuscated transaction database that is automatically populated and can be easily queried. The code also works as an example in-app billing implementation.
This is our third open-source contribution, with more to come shortly. If you’re interested in in-app billing, we invite you to fork the code on github and contribute with issues or pull requests.
Hi, you say in the readme that this should not be used for production code. I was wondering – what are the known issues with it? In other words, why shouldn’t it be used for production code?
We think the library needs a few months in the open before considering it stable.
That said, using it should be better than starting from scratch.
If you find any issues, please report them on github. We will try to fix them ASAP.
Thanks.
Hi,
I would like to develop two-in-one application. By default, user downloads Free version. If he presses some button in the app and pay, then application should become Paid version.
Now I need to write a lot of code to get it.
Will your library help me?
What I want to have – just one boolean variable (user paid or not), which I will check in my code. Everything else should be handled by library.
Ideally, if requested in the code, if internet connection is available, application should check if user really paid (or this is hacked version of the application).
@Andrey Yes, this is exactly what this library is for.
Thanks. Is there any simple code to check?
AbstractBillingActivity should be a good place to start.
Thanks. But actually some example would be quite helpful…
Please see my question – http://stackoverflow.com/questions/6573973/how-to-use-android-billing-library
Thank you
Also I am not quite clear where to input my key.
OK, looks like I’ve got how to use that – in my class I should use
extends AbstractBillingActivityinstead ofextends Activity(it is a little bit tricky with PreferenceActivity – I had to modify AbstractBillingActivity).Still have the question about the key.
This looks very good! I’m glad to see developers outside Google extending the in-app billing API.
That being said, you might want to consider licensing this under something other than (L)GPL. Normally I’m not one to nit over license choice. However, many in-app billing developers need to manually obfuscate their code for security, and needing to release their obfuscated source would largely negate these efforts.
You might also want to register your purchase DB with the Android backup framework (http://developer.android.com/guide/topics/data/backup.html) so that unmanaged purchases can be restored if a user wipes their phone.
Need help with the next item.
Let’s say I’ve requested purchase of the item:
requestPurchase(ANDROID_MARKET_ITEM);then I’ve enabled some ‘paid function’ in my application at
onPurchaseExecuted. What should I do then? Should I store ‘purchased status’ in my database? Or, is it done automatically? ()If I call
restoreTransactions, will it callonPurchaseExecuted? Or, how can I understand if user paid or not?@Trevor Thanks for the feedback!
Yes, we’re considering changing the license for this particular library.
And using the Android backup framework is a great suggestion!
@Andrey Yes, you can query the database or handle it yourself.
restoreTransactionswill populate the database and callonPurchaseSomethingaccordingly.It would be better if we moved the more technical discussions to github, or stackoverflow. We will reply much faster in github.
This is just great, exactly what I needed, will check it ASAP. And yes I need it for production code
.
@mi6x3m Gald to help! The library is getting better with user contributions. Hopefully it will be considered production ready soon.
Hello,
Great work; I love what you’ve done so far. Since there’s been some new work done on this in the path month, would you consider the library ready for production at this point, or have you heard of any apps using it successfully?
Either way, it’s probably better than what I could do from scratch, so if I end up using it in production, I’ll try to give you some feedback.
While we haven’t receive any major complaints, there’s a few known bugs and improvement points. As you mentioned, we do believe that it’s better than starting from scratch, but we don’t consider it production-ready yet. If you use it, test, test, test, test.
Please consider the alternative library : android-test-billing to test the In-App billing on the emulator.
This library is used in the project Horer – horaires de RER trains.
In comparison to the “Android Billing Library”, this is not a high-level library, but just an implementation of the In-App Billing API, which works the same way as the real API.
I used this app for in app billing. In app billing implemented in paid version of this application simply change your product id to file and in app billing will start working in to your application. Instruction included in the package.
http://www.preproject.com/projectDetail.asp?projectID=244
I’ve a simple question.
how to test it ?
I uploaded the apk to the market and add my gmail as a test account and when trying to buy it, it’s appear the product with “add payment method”.
how to sell it, I’m a test account, i wondering…
thanx
Where exactly to I put the line?
requestPurchase(“application_package”);
I have the library installed had have imported the net.robotmedia.billing.helper.AbstractBillingActivity to my starting activity where I am trying to put it but does not work. I cannot figure out where that line needs to go where it will not cause an error. If it has something to do with sub-classing I need an example because I an not sure what you are referring to. thanks
Can someone please tell me where/how I need to implement the call to use this
I have the library installed but cannot figure out where and how this line of code needs to be implemented:
requestPurchase(“com.example.item”)
I know I need to replace what is in quotes with my application’s package name but where/how exactly do I do it
thanks
Alan
I think i’ve implemented everything just fine,
the purchase window pops up and I can click
on buy, but then it is saying “Authorizing Purchase”
for ever and then it fails. The purchase is listed
in the google checkout account as “Cancelled”
with the reason “Reason: Took too long to deliver”.
After this i receive the
com.android.vending.billing.IN_APP_NOTIFY
but it’s of course not in the state “purchased”.
Any ideas?
Great lib! I was searching for something like that
I just have a little issue, when I request a purchase for the first time, only a black screen appears. Then if a press back and re-request, it works fine.
Is that a known issue?
Thanks!
Thanks Tr4x!
Would you mind asking this question on https://github.com/robotmedia/AndroidBillingLibrary/issues so other developers can benefit from it?
Best!
For Alan:
The key is that you extend your activity class with AbstractBillingActivity as follows, then you can directly use the magic line
package com.shariq.inapp;
import net.robotmedia.billing.BillingController;
import net.robotmedia.billing.BillingRequest.ResponseCode;
import net.robotmedia.billing.helper.AbstractBillingActivity;
import net.robotmedia.billing.model.Transaction.PurchaseState;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
public class ShariqInAppActivity extends AbstractBillingActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
findViewById(R.id.button1).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
requestPurchase(“com.saltish”);
//magic line
}
});
}
@Override
public byte[] getObfuscationSalt() {
// TODO Auto-generated method stub
return null;
}
@Override
public String getPublicKey() {
// TODO Auto-generated method stub
return null;
}
@Override
public void onBillingChecked(boolean supported) {
// TODO Auto-generated method stub
}
@Override
public void onPurchaseStateChanged(String itemId, PurchaseState state) {
// TODO Auto-generated method stub
}
@Override
public void onRequestPurchaseResponse(String itemId, ResponseCode response) {
// TODO Auto-generated method stub
}
}