Reputation: 33579
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?
Upvotes: 1
Views: 3457
Reputation: 1876
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.
Upvotes: 8
Reputation: 13415
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.
Upvotes: 4