1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-07 12:30:27 +00:00

Fix can't get all info if user purchases many items and not consumed

This commit is contained in:
volzhs
2016-06-26 02:37:50 +09:00
parent f53e7efefe
commit f26f181ba9

View File

@@ -149,31 +149,22 @@ public class PaymentsManager {
try { try {
PaymentsCache pc = new PaymentsCache(Godot.getInstance()); PaymentsCache pc = new PaymentsCache(Godot.getInstance());
// Log.d("godot", "requestPurchased for " + activity.getPackageName()); String continueToken = null;
Bundle bundle = mService.getPurchases(3, activity.getPackageName(), "inapp",null);
/* do {
for (String key : bundle.keySet()) { Bundle bundle = mService.getPurchases(3, activity.getPackageName(), "inapp", continueToken);
Object value = bundle.get(key);
Log.d("godot", String.format("%s %s (%s)", key, value.toString(), value.getClass().getName()));
}
*/
if (bundle.getInt("RESPONSE_CODE") == 0) { if (bundle.getInt("RESPONSE_CODE") == 0) {
final ArrayList<String> myPurchases = bundle.getStringArrayList("INAPP_PURCHASE_DATA_LIST"); final ArrayList<String> myPurchases = bundle.getStringArrayList("INAPP_PURCHASE_DATA_LIST");
final ArrayList<String> mySignatures = bundle.getStringArrayList("INAPP_DATA_SIGNATURE_LIST"); final ArrayList<String> mySignatures = bundle.getStringArrayList("INAPP_DATA_SIGNATURE_LIST");
if (myPurchases == null || myPurchases.size() == 0) { if (myPurchases == null || myPurchases.size() == 0) {
// Log.d("godot", "No purchases!");
godotPaymentV3.callbackPurchased("", "", ""); godotPaymentV3.callbackPurchased("", "", "");
return; return;
} }
// Log.d("godot", "# products are purchased:" + myPurchases.size()); for (int i = 0; i < myPurchases.size(); i++) {
for (int i=0;i<myPurchases.size();i++)
{
try { try {
String receipt = myPurchases.get(i); String receipt = myPurchases.get(i);
@@ -181,7 +172,6 @@ public class PaymentsManager {
String sku = inappPurchaseData.getString("productId"); String sku = inappPurchaseData.getString("productId");
String token = inappPurchaseData.getString("purchaseToken"); String token = inappPurchaseData.getString("purchaseToken");
String signature = mySignatures.get(i); String signature = mySignatures.get(i);
// Log.d("godot", "purchased item:" + token + "\n" + receipt);
pc.setConsumableValue("ticket_signautre", sku, signature); pc.setConsumableValue("ticket_signautre", sku, signature);
pc.setConsumableValue("ticket", sku, receipt); pc.setConsumableValue("ticket", sku, receipt);
@@ -192,8 +182,10 @@ public class PaymentsManager {
} catch (JSONException e) { } catch (JSONException e) {
} }
} }
} }
continueToken = bundle.getString("INAPP_CONTINUATION_TOKEN");
Log.d("godot", "continue token = " + continueToken);
} while (!TextUtils.isEmpty(continueToken));
} catch (Exception e) { } catch (Exception e) {
Log.d("godot", "Error requesting purchased products:" + e.getClass().getName() + ":" + e.getMessage()); Log.d("godot", "Error requesting purchased products:" + e.getClass().getName() + ":" + e.getMessage());
} }