I am trying to test In App purchases for my android app:
I already read the android developer sites about testing and I already have worked successfully with the play stores build in test/fake product-items like android.test.purchased, android.test.canceled ...
Now I would like to test In App purchases with my own real products. Therefore I have specified my own products in the Google Play Store Developer Console.I also have added test account in LICENSE TESTING then I have published the app in beta. the version number and build number of the app publish in beta is the same to the app that I install on android device for testing.
I have compare base64EncodedPublicKey and is the same to Base64-encoded RSA public key to the app in the console.
Android device that I am using to purchase the item. I have reset the google play to have only one account that is the account that has been added already for testing in Android console. And I have added the test account to for the beta app that i have published. then I have download the app to my device.
My question is: i have already make everything as I read the android guideline and some tutorial. but why when I click button to buy the item, I have this error: This version of the application is not configured for billing through google play. check the help center for more information.
I have publish my app nearly two weak ago. but i still got this error.
Here is my code:
@Override
protected void onStart() {
super.onStart();
//Toast.makeText(DetailActivity.this, "On Start", Toast.LENGTH_SHORT).show();
String base64EncodedPublicKey ="";
mHelper = new IabHelper(this, base64EncodedPublicKey);
mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
@Override
public void onIabSetupFinished(IabResult result) {
if (!result.isSuccess()) {
Log.d(TAG, "In-app Billing setup failed: " + result);
Toast.makeText(DetailActivity.this, "Fail", Toast.LENGTH_SHORT).show();
} else {
Log.d(TAG, "In-app Billing is set up OK");
Toast.makeText(DetailActivity.this, "Success", Toast.LENGTH_SHORT).show();
}
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode,
Intent data)
{
if (!mHelper.handleActivityResult(requestCode,resultCode, data)) {
super.onActivityResult(requestCode, resultCode, data);
}
}
public void buyMethod(View v){
//mHelper.launchPurchaseFlow(this, ITEM_SKU, 10001, mPurchaseFinishedListener, "storyone");
mHelper.queryInventoryAsync(mGotInventoryListener);
}
//make purchase payment
IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener
= new IabHelper.OnIabPurchaseFinishedListener() {
public void onIabPurchaseFinished(IabResult result, Purchase purchase)
{
if (result.isFailure()) {
Log.d(TAG, "Error purchasing: " + result);
Toast.makeText(DetailActivity.this, "Buy Fail", Toast.LENGTH_SHORT).show();
return;
}
else if (purchase.getSku().equals(ITEM_SKU)) {
//
Toast.makeText(DetailActivity.this, "Buy Success", Toast.LENGTH_SHORT).show();
}
}
};
//check use has already make payment
IabHelper.QueryInventoryFinishedListener mGotInventoryListener
= new IabHelper.QueryInventoryFinishedListener() {
public void onQueryInventoryFinished(IabResult result,
Inventory inventory) {
if (result.isFailure()) {
// handle error here
}
else {
// does the user have the premium upgrade?
boolean mIsPremium = inventory.hasPurchase(ITEM_SKU);
if (mIsPremium){
Toast.makeText(DetailActivity.this, "You already buy this product", Toast.LENGTH_SHORT).show();
}else{
Toast.makeText(DetailActivity.this, "Not Yet buy this product", Toast.LENGTH_SHORT).show();
mHelper.launchPurchaseFlow(DetailActivity.this, ITEM_SKU, 10001, mPurchaseFinishedListener, "storyone");
}
// update UI accordingly
}
}
};
@Override
public void onDestroy() {
super.onDestroy();
if (mHelper != null) mHelper.dispose();
mHelper = null;
}