Reputation: 15976
I have followed the steps for in app billing:
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
Upvotes: 13
Views: 8531
Reputation: 2326
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();
}
}
Upvotes: 31
Reputation: 18725
Unfortunately, it looks like if you change the API to 1, subscriptions are disabled. So, this does in fact get rid of the 'item not found' error, but makes subscriptions non-functional (they must be available in API 2 only).
So, back to the drawing board. I am going to refactor the code to return API 1, for non-subscription requests, and API 2 for all others. Seems like a somewhat in-elegant solution.
Upvotes: 0
Reputation: 62519
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.
Upvotes: 3
Reputation: 549
I experienced that same behavior. Many posts I have read have stated that it is simply a server-side error and there is nothing you can do about it.
However, I decided to get an older copy of the InApp Billing sample code
from a friend of mine, and now I no longer experience the item not found error
prior to displaying the buy screen.
This leads me to believe that there is something wrong with the way that the server request is being assembled in the more recent copy of the InApp Billing sample code
.
I haven't had a chance to analyze the differences between the old sample code and the new sample code.
But all I can tell you is that if you can get an older copy of the sample code, then you will no longer experience the problem you are having.
Upvotes: 0
Reputation: 2804
Item not found Error occurs when your Product id (in apk file) does not match with the product id (written in Products List in market account).
And if you are using "android.test.purchased" then you need not to upload your apk.
And 1 thing which is most important, you have to add your "public key" in your code. This step must either use your Android example or your own app code.
See this link for public key:
http://developer.android.com/guide/market/billing/billing_integrate.html
Upvotes: 0