Dungeons.java actually has a bug in it. Let me explain:
/**
* Called when a button is pressed.
*/
@Override
public void onClick(View v) {
if (v == mBuyButton) {
if (Consts.DEBUG) {
Log.d(TAG, "buying: " + mItemName + " sku: " + mSku);
}
if (mManagedType != Managed.SUBSCRIPTION &&
// ** The following line is a bug when requestPurchase() returns true, which evaluates as !true which is false, and then makes the if statement false
!mBillingService.requestPurchase(mSku, Consts.ITEM_TYPE_INAPP, mPayloadContents)) {
showDialog(DIALOG_BILLING_NOT_SUPPORTED_ID);
// ** Which then ends up running this else if, meaning it will try to purchase a subscription
} else if (!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();
}
}
Rather it should be written like this:
/**
* Called when a button is pressed.
*/
@Override
public void onClick(View v) {
if (v == mBuyButton) {
if (Consts.DEBUG) {
Log.d(TAG, "buying: " + mItemName + " sku: " + mSku);
}
// We need this statement to evaluate to true on a Non-Subscription such as a Managed or Unmanaged Purchase
if (mManagedType != Managed.SUBSCRIPTION) {
// If the following errors out, show an error dialog. However, it should not make the previous if statement false
if( !mBillingService.requestPurchase(mSku, Consts.ITEM_TYPE_INAPP, mPayloadContents)) {
showDialog(DIALOG_BILLING_NOT_SUPPORTED_ID);
}
}
// This if statement gets run accidentally without the bug fix, thus trying to buy your "SKU" as a "subscription", which is totally wrong!
else if (!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();
}
}
Original issue reported on code.google.com by elje...@gmail.com on 29 Nov 2012 at 8:49
Original issue reported on code.google.com by
elje...@gmail.com
on 29 Nov 2012 at 8:49