1

我正在查看查询拥有的项目,它不包括获取用户实际购买时可用的结帐订单 ID。有没有办法查询已经购买的订单ID?

4

2 回答 2

8

谷歌给出的例子(并在另一个答案中列出)有点错误。检索ownedItems捆绑包时,它不包含INAPP_DATA_SIGNATURE,而是包含INAPP_DATA_SIGNATURE_LIST.

这是您可以从ownedItems捆绑包中获得的密钥列表(尽管您可能不会一直获得所有这些密钥):

  • RESPONSE_CODE
  • INAPP_PURCHASE_ITEM_LIST
  • INAPP_PURCHASE_DATA_LIST
  • INAPP_DATA_SIGNATURE_LIST
  • INAPP_CONTINUATION_TOKEN

有关它们的描述,请参见此处

于 2013-01-21T20:42:15.303 回答
4

试试这个:

Bundle ownedItems = mService.getPurchases(3, getPackageName(), "inapp", null);

int response = ownedItems.getInt("RESPONSE_CODE");
if (response == 0) {
   ArrayList ownedSkus = 
      ownedItems.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");
   ArrayList purchaseDataList = 
      ownedItems.getStringArrayList("INAPP_PURCHASE_DATA_LIST");
   ArrayList signatureList = 
      ownedItems.getStringArrayList("INAPP_DATA_SIGNATURE");
   String continuationToken = 
      ownedItems.getString("INAPP_CONTINUATION_TOKEN");

   for (int i = 0; i < purchaseDataList.size(); ++i) {
       String purchaseData = purchaseDataList.get(i);
       JSONObject jpurchase = new JSONObject(purchaseData);
       String orderid = jpurchase.getString("orderId");
       Log.v(TAG,"ORDER ID :"+orderid ); 
   }
}

谢谢。

于 2013-01-10T16:23:12.403 回答