开发者

Android In-App-Billing RESTORE_TRANSACTIONS with empty JSON!

Hey folks, I am slightly modified the dungeons example for the Android In-App-Billing SDK article. I am having trouble with the RESTORE_TRANSACTIONS request. I first make a legitimate purchase and that goes fine, I get a call to onPurchaseStateChange with no issue. However, when I try to use RESTORE_TRANSACTIONS request, I was expecting to get a constructed verified list of purchases, but when I trace it, the JSON returned is verified just fine, but contains no transactions! Within Security.java in the Dungeons example you see this code in the verifyPurchase method开发者_StackOverflow中文版:

    if (Consts.DEBUG) {
        Log.d(TAG, "Parsing JSON object");
    }
    JSONObject jObject;
    JSONArray jTransactionsArray = null;
    int numTransactions = 0;
    long nonce = 0L;
    try {
        jObject = new JSONObject(signedData);

        // The nonce might be null if the user backed out of the buy page.
        nonce = jObject.optLong("nonce");
        jTransactionsArray = jObject.optJSONArray("orders");

        if (jTransactionsArray != null) {
            numTransactions = jTransactionsArray.length();
        }

        if (Consts.DEBUG) {
            Log.d(TAG, "JSON Array has " + numTransactions + " transactions");
        }
    } catch (JSONException e) {
        if (Consts.DEBUG) {
            Log.d(TAG, e.getMessage());
        }
        return null;
    }

Am I misunderstanding the purpose of the RESTORE_TRANSACTIONS? Isn't it supposed to return a verified list of purchases just like REQUEST_PURCHASE through the onPurchaseStateChange?


Nevermind, I have to look much closer. The RESTORE_TRANSACTIONS is meant to be used with MANAGED product ids. I was purchasing an UNMANAGED item.

http://developer.android.com/guide/market/billing/billing_admin.html#billing-purchase-type

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜