我无法在应用结算中消费?

时间:2017-01-13 14:53:53

标签: android android-billing

我有一个测试版应用谷歌播放。我可以买一次物品但是当我想再次购买它时说:

  

你已经拥有这个项目

我买不到一个。我想我不能消费;我搜索了但我无法解决这个问题。

我添加了我的代码:

    mHelper = new IabHelper(this, apiKey);

    mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
        public void onIabSetupFinished(IabResult result) {
            if (!result.isSuccess()) {
                Log.d(TAG, "In-app Billing setup failed: " +
                        result);
            } else {
                Log.d(TAG, "In-app Billing is set up OK");
                mHelper.enableDebugLogging(true, TAG);
            }
        }
    });

和其他人......

 @Override
protected void onActivityResult(int requestCode, int resultCode,
                                Intent data) {
    if (!mHelper.handleActivityResult(requestCode,
            resultCode, data)) {
        super.onActivityResult(requestCode, resultCode, data);
    }
}

public void consumeItem() {
    mHelper.queryInventoryAsync(mReceivedInventoryListener);
}

IabHelper.QueryInventoryFinishedListener mReceivedInventoryListener
        = new IabHelper.QueryInventoryFinishedListener() {
    public void onQueryInventoryFinished(IabResult result,
                                         Inventory inventory) {

        if (result.isFailure()) {
            // Handle failure
        } else {
            mHelper.consumeAsync(inventory.getPurchase(ITEM_SKU),
                    mConsumeFinishedListener);
        }
    }
};

IabHelper.OnConsumeFinishedListener mConsumeFinishedListener =
        new IabHelper.OnConsumeFinishedListener() {
            public void onConsumeFinished(Purchase purchase,
                                          IabResult result) {

                if (result.isSuccess()) {

                    // Satın alma başarılı ise burada satın alma sonrası işlemleri yapabiliriz.

                  //  consume(ITEM_SKU);

                    MacListesi mac = new MacListesi(getApplicationContext());
                    mac.kayitekle("SaidHoca");
                    finish();
                    startActivity(getIntent());

                } else {
                    // handle error
                }


            }
        };

IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener
        = new IabHelper.OnIabPurchaseFinishedListener() {
    public void onIabPurchaseFinished(IabResult result, Purchase purchase) {
        if (result.isFailure()) {
            Log.d(TAG, "Error purchasing: " + result);
            return;
        } else if(purchase.getSku().equals(ITEM_SKU)) {
            consumeItem();
            consume(ITEM_SKU);
            MacListesi mac = new MacListesi(getApplicationContext());
            mac.kayitekle("SaidHoca");
            finish();
            startActivity(getIntent());

        }
    }
};


public void buyItem(View v) {
    mHelper.launchPurchaseFlow(this, ITEM_SKU, 10001,
            mPurchaseFinishedListener, "");
}




@Override
protected void onDestroy() {
    super.onDestroy();
    Log.d(TAG, "Destroying helper.");
    if (mHelper != null) {
        try {
            mHelper.dispose();
        } catch (IllegalArgumentException ex) {
            ex.printStackTrace();
        } finally {
        }
    }
    mHelper = null;
}

在哪里我必须消费购买不止一件物品?

0 个答案:

没有答案