mService.consumePurchase(3, packageName, purchaseToken) always returns RESULT_DEVELOPER_ERROR = 5 - invalid arguments provided to the API

风流意气都作罢 提交于 2019-11-28 10:16:34

The purchase token is different from the SKU itself, instead, you should retrieve the purchaseToken via code such as:

// Note the null is the continueToken you may not get all of the purchased items
// in one call - check ownedItems.getString("INAPP_CONTINUATION_TOKEN") for 
// the next continueToken and re-call with that until you don't get a token
Bundle ownedItems = service.getPurchases(3, getPackageName(), "inapp", null);
// Check response
int responseCode = ownedItems.getInt("RESPONSE_CODE");
if (responseCode != 0) {
   throw new Exception("Error");
}
// Get the list of purchased items
ArrayList<String> purchaseDataList = 
    ownedItems.getStringArrayList("INAPP_PURCHASE_DATA_LIST");
for (String purchaseData : purchaseDataList) {
    JSONObject o = new JSONObject(purchaseData);
    String purchaseToken = o.optString("token", o.optString("purchaseToken"));
    // Consume purchaseToken, handling any errors
    mService.consumePurchase(3, getPackageName(), purchaseToken);
}

I just found that if you add more than 20 items to ITEM_ID_LIST for getSkuDetails then it will return RESULT_DEVELOPER_ERROR too.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!