Example #1
0
        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);
        }
Example #2
0
        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.");
          }
        }
Example #3
0
        public void onConsumeFinished(Purchase purchase, IabResult result) {
          Log.e(TAG, "Consumption finished. Purchase: " + purchase + ", result: " + result);

          // We know this is the "gas" sku because it's the only one we
          // consume,
          // so we don't check which sku was consumed. If you have more than
          // one
          // sku, you probably should check...
          if (result.isSuccess()) {
            // successfully consumed, so we apply the effects of the item in
            // our
            // game world's logic, which in our case means filling the gas
            // tank a bit
            Log.e(TAG, "支付成功");
            payMent.onSucess(item);
            finish();
          } else {
            Log.e(TAG, "支付失败");
            mHelper.consumeAsync(purchase, mConsumeFinishedListener);
            complain("Error while consuming: " + result);
          }
          Log.e(TAG, "End consumption flow.");
        }