我在测试我的应用时遇到问题.我有2个项目,用户可以购买.几天前我不知道我应该消费购买.今天我每次尝试买一件物品时都会收到代码7(物品已经拥有),因为我没有消耗它.我可以做些什么来消费旧的购买?
添加:
这两个项目都在开发人员控制台中“未受管理”
解决方法
我试图用错误的令牌消费.这段代码对我有帮助.
Bundle ownedItems = mService.getPurchases(3,context.getPackageName(),"inapp",null); int response = ownedItems.getInt("RESPONSE_CODE"); if (response == 0) { ArrayList<String> ownedSkus = ownedItems.getStringArrayList("INAPP_PURCHASE_ITEM_LIST"); ArrayList<String> purchaseDataList = ownedItems.getStringArrayList("INAPP_PURCHASE_DATA_LIST"); //ArrayList<String> signatureList = ownedItems.getStringArrayList("INAPP_DATA_SIGNATURE"); //String continuationToken = ownedItems.getString("INAPP_CONTINUATION_TOKEN"); for (int i = 0; i < purchaseDataList.size(); ++i) { try { String purchaseData = purchaseDataList.get(i); JSONObject jo = new JSONObject(purchaseData); final String token = jo.getString("purchaseToken"); String sku = null; if (ownedSkus != null) sku = ownedSkus.get(i); consume(sku,token,purchaseData); } catch (JSONException e) { e.printStackTrace(); } } }