In-App-Billing Error

195 views Asked by At

I am trying to include in-app-bulling to my app. I should mention that I have activated the product ID in my Google play developer console, but I have not published the app. I am trying to test the in-app purchases in my device before uploading my final apk. The Error appears when I tap on the button that initiates launchPurchaseFlow method there is an error. (when I go to Google Play Store and try to download any app it does not ask me for any authentification, it just downloads the app): enter image description here

This is the code in my onOptionsItemSelected method where I am calling the launchPurchasedFlow method.

public boolean onOptionsItemSelected(MenuItem item) {
 if(id == R.id.action_remove_adds){
        mHelper.launchPurchaseFlow(this,SKU_REMOVE_ADDS,1,mPurchasedFinishedListener,"");
    }

    return super.onOptionsItemSelected(item);
}

this is my mPurchasedFinishedListener code:

private IabHelper.OnIabPurchaseFinishedListener mPurchasedFinishedListener = new IabHelper.OnIabPurchaseFinishedListener() {
    @Override
    public void onIabPurchaseFinished(IabResult result, Purchase purchase) {
        if (result.isFailure()) {
            Log.d(TAG, "Error purchasing: " + result);
            return;
        }
        else if (purchase.getSku().equals(SKU_REMOVE_ADDS)) {
            // consume the gas and update the UI
        }
    }
};

and this is my onActicity result code:

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    Log.d(TAG, "onActivityResult(" + requestCode + "," + resultCode + "," + data);

    // Pass on the activity result to the helper for handling
    if (!mHelper.handleActivityResult(requestCode, resultCode, data)) {
        // not handled, so handle it ourselves (here's where you'd
        // perform any handling of activity results not related to in-app
        // billing...
        super.onActivityResult(requestCode, resultCode, data);
    }
    else {
        Log.d(TAG, "onActivityResult handled by IABUtil.");
    }
}
1

There are 1 answers

2
Santiago On BEST ANSWER

in-app purchase only works for published apps, upload in alpha or beta and you can test it.

This is because Google need to know the apk version code for enable the IAB, if the version code is not in Google Play, Google won't activate the purchase because the apk is not registered.