public void onQueryInventoryFinished(IabResult result, Inventory inventory) { Log.e(TAG, "Query inventory finished."); if (result.isFailure()) { complain("Failed to query inventory: " + result); finish(); return; } Log.e(TAG, "Query inventory was successful."); /* * Check for items we own. Notice that for each purchase, we check * the developer payload to see if it's correct! See * verifyDeveloperPayload(). */ // Check for gas delivery -- if we own gas, we should fill up the // tank // immediately Purchase purchase = inventory.getPurchase(item); if (purchase != null && verifyDeveloperPayload(purchase)) { Log.d(TAG, "We have gas. Consuming it."); mHelper.consumeAsync(inventory.getPurchase(item), mConsumeFinishedListener); return; } // Do we have the premium upgrade? SkuDetails item1SkuDetail = inventory.getSkuDetails(item); Log.e(TAG, "item1SkuDetail is " + item1SkuDetail); mHelper.launchPurchaseFlow(Pay.this, item, 100, mPurchaseFinishedListener); }
public void onIabPurchaseFinished(IabResult result, Purchase purchase) { Log.e(TAG, "Purchase finished: " + result + ", purchase: " + purchase); if (result.isFailure()) { complain("Error purchasing: " + result); finish(); return; } if (!verifyDeveloperPayload(purchase)) { complain("Error purchasing. Authenticity verification failed."); finish(); return; } Log.e(TAG, "Purchase successful."); if (purchase.getSku().equals(item)) { // bought 1/4 tank of gas. So consume it. mHelper.consumeAsync(purchase, mConsumeFinishedListener); // bought the premium upgrade! Log.e(TAG, "Purchase is SKU_JieShuo_SHAIDAO. Congratulating user."); } }