丢失的购买促销用于应用内结算Api

时间:2014-01-20 11:20:56

标签: android in-app-purchase

我正在整合Android In-App Billing api。但我失去了purchaseToken,因为在某处抛出了异常。现在在API 3中,我不能在不消费购买产品的情况下重新购买它。我现在不能消费,因为我没有purchaseToken?怎么回头呢? 或者我可以以某种方式重置购买?

1 个答案:

答案 0 :(得分:0)

你可以通过查询购买来获得它。

以下是Google的一个示例:http://developer.android.com/google/play/billing/billing_integrate.html#billing-download

IabHelper.QueryInventoryFinishedListener mGotInventoryListener = new IabHelper.QueryInventoryFinishedListener() {
    public void onQueryInventoryFinished(IabResult result, Inventory inventory) {
        Log.d(TAG, "Query inventory finished.");

        // Have we been disposed of in the meantime? If so, quit.
        if (mHelper == null) return;

        // Is it a failure?
        if (result.isFailure()) {
            complain("Failed to query inventory: " + result);
            return;
        }

        Log.d(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().
         */

        // Do we have the premium upgrade?
        Purchase premiumPurchase = inventory.getPurchase(SKU_PREMIUM);
      ....

     //<- here you can consume your purchase

 }