Question

I'm looking at querying owned items, and it doesn't include getting Checkout order IDs that are available when user actually makes a purchase. Is there no way to query the order ID for a purchase that have already been made?

Was it helpful?

Solution 2

Try this:

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 ); 
   }
}

Thanks.

OTHER TIPS

The example given by Google (and listed in another answer) is slightly wrong. When retrieving the ownedItems bundle, it does not contain INAPP_DATA_SIGNATURE but rather INAPP_DATA_SIGNATURE_LIST.

This is the list of keys you can get from the ownedItems bundle (though you may not get all of them all the time):

  • RESPONSE_CODE
  • INAPP_PURCHASE_ITEM_LIST
  • INAPP_PURCHASE_DATA_LIST
  • INAPP_DATA_SIGNATURE_LIST
  • INAPP_CONTINUATION_TOKEN

See here for descriptions of them.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top