0
votes

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;
}
2
Sorry. the solution in that link is not solve my problem. I have upload my app to beta version and add product in-app purchase two weeks ago.mobile developer

2 Answers

1
votes

You have to be a tester for this app, so you have to be listed in the beta test (or join the Google+ group for the test) AND have to enable the beta test for your account by going to the link given in Google Play developer console.

Furthermore, your application has to be signed with the same certificate as the one in the Play Store beta test, so try it with the same apk that you uploaded to Google Play (e.g. not a debug version, but the release version you uploaded).

1
votes

Complete list of things required.

 Prerequisites:

AndroidManifest must include "com.android.vending.BILLING" permission.
APK is built in release mode.
APK is signed with the release certificate(s).
APK is uploaded to alpha/beta distribution channel (previously - as a draft) 
to the developer console at least once. (takes some time ~2h-24h).
IAB products are published and their status set to active.
Test account(s) is added in developer console.
Testing requirements:

Test APK has the same versionCode as the one uploaded to developer console.
Test APK is signed with the same certificate(s) as the one uploaded to 
dev.console.
Test account (not developer) - is the main account on the device.
Test account is opted-in as a tester and it's linked to a valid payment method.   

Original answer here