Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In App Billing: Item not found

I have followed the steps for in app billing:

  1. Installed demo app
  2. Published an in-app product
  3. NOT published the app itself

Although I CAN buy the item, there is a curious warning "item not found" that I have to dismiss before I can go to the buy screen.

AND this log error:

E/Volley(1384): [157] BasicNetwork.performRequest: Unexpected response code 500 for https://android.clients.google.com/fdfe/details?doc=subs:com.testorooney.testo:sword_001
like image 902
hunterp Avatar asked May 27 '12 15:05

hunterp


People also ask

Why is my in-app purchase not working?

If you haven't received an in-app item you bought, try closing and restarting the app or game you're using. Tap Apps or Manage applications (depending on your device, this may be different). Tap the app you used to make your in-app purchase.

Why can't I make in-app purchases Samsung?

If you experience trouble making a purchase, follow the steps below: Make sure in-app purchase options are set correctly on your device. Play Store > Payment Methods. Close the game from the background and restart it.

What does app mean in billing?

In-app billing refers to in-app purchases that are made directly from within a mobile application on Google's Android platform.


2 Answers

This is NOT a server side bug. The bug is in the onClick for the Purchase button in the Dungeons class of the sample application.

The supplied method has a bug in the if {} else if {} statement where it causes the mBillingService.requestPurchase to be called twice, when the selected item is not a subscription item (mManagedType != Managed.SUBSCRIPTION). So the same item will be requested twice, once with an item type of "inapp" (which is the valid request) and immediately after that with an item type of "subs" (which is incorrect and it shows "item not found").

Here is the buggy code:

if (mManagedType != Managed.SUBSCRIPTION &&
                    !mBillingService.requestPurchase(mSku, Consts.ITEM_TYPE_INAPP, mPayloadContents)) {
                showDialog(DIALOG_BILLING_NOT_SUPPORTED_ID);
            } else if (!mBillingService.requestPurchase(mSku, Consts.ITEM_TYPE_SUBSCRIPTION, mPayloadContents)) {
                // Note: mManagedType == Managed.SUBSCRIPTION
                showDialog(DIALOG_SUBSCRIPTIONS_NOT_SUPPORTED_ID);
            }

To fix this, add mManagedType == Managed.SUBSCRIPTION to the else if above.

Here is how the function should look:

@Override
    public void onClick(View v) {
        if (v == mBuyButton) {
            if (Consts.DEBUG) {
                Log.d(TAG, "buying: " + mItemName + " sku: " + mSku);
            }

            if (mManagedType != Managed.SUBSCRIPTION &&
                    !mBillingService.requestPurchase(mSku, Consts.ITEM_TYPE_INAPP, mPayloadContents)) {
                showDialog(DIALOG_BILLING_NOT_SUPPORTED_ID);
            } else if (mManagedType == Managed.SUBSCRIPTION && !mBillingService.requestPurchase(mSku, Consts.ITEM_TYPE_SUBSCRIPTION, mPayloadContents)) {
                // Note: mManagedType == Managed.SUBSCRIPTION
                showDialog(DIALOG_SUBSCRIPTIONS_NOT_SUPPORTED_ID);
            }
        } else if (v == mEditPayloadButton) {
            showPayloadEditDialog();
        } else if (v == mEditSubscriptionsButton) {
            editSubscriptions();
        }
    }
like image 118
Dimitar Darazhanski Avatar answered Oct 05 '22 17:10

Dimitar Darazhanski


i have this same error when installing the dungeons example and also when applying the code sample to my project. I noticed that if i go to makerequestbundle and change the API_VERSION to 1 then i can do inapp managed purchases without this error.

The other thing i noticed is that subscriptions execute without this error if left on API_VERSION 2.

Im wondering if this is a server side bug as i've looked at the code and cant find the issue. My product IDs are all matching etc.

like image 20
j2emanue Avatar answered Oct 05 '22 19:10

j2emanue