You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-06 12:20:30 +00:00
Fix can't get all info if user purchases many items and not consumed
This commit is contained in:
@@ -145,43 +145,33 @@ public class PaymentsManager {
|
|||||||
}.consumeItAll();
|
}.consumeItAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void requestPurchased(){
|
public void requestPurchased() {
|
||||||
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);
|
||||||
JSONObject inappPurchaseData = new JSONObject(receipt);
|
JSONObject inappPurchaseData = new JSONObject(receipt);
|
||||||
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,9 +182,11 @@ public class PaymentsManager {
|
|||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}catch(Exception e){
|
continueToken = bundle.getString("INAPP_CONTINUATION_TOKEN");
|
||||||
|
Log.d("godot", "continue token = " + continueToken);
|
||||||
|
} while (!TextUtils.isEmpty(continueToken));
|
||||||
|
} 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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user