diff --git a/godot-google-play-billing/src/main/java/org/godotengine/godot/plugin/googleplaybilling/utils/GooglePlayBillingUtils.java b/godot-google-play-billing/src/main/java/org/godotengine/godot/plugin/googleplaybilling/utils/GooglePlayBillingUtils.java index d4b7d58..8425a70 100644 --- a/godot-google-play-billing/src/main/java/org/godotengine/godot/plugin/googleplaybilling/utils/GooglePlayBillingUtils.java +++ b/godot-google-play-billing/src/main/java/org/godotengine/godot/plugin/googleplaybilling/utils/GooglePlayBillingUtils.java @@ -76,17 +76,19 @@ public static Dictionary convertProductDetailsToDictionary(ProductDetails detail } List subscriptionOfferDetailsList = details.getSubscriptionOfferDetails(); - if (subscriptionOfferDetailsList != null && !subscriptionOfferDetailsList.isEmpty()) { - ArrayList subscriptionOfferDetailsDictionaryList = new ArrayList<>(); + Dictionary subscriptionOfferDetailsDictionaryContainer = new Dictionary(); + int subscriptionOfferIndex = 1; for (ProductDetails.SubscriptionOfferDetails subscriptionOfferDetails : subscriptionOfferDetailsList) { Dictionary subscriptionOfferDetailsDictionary = new Dictionary(); subscriptionOfferDetailsDictionary.put("offer_token", subscriptionOfferDetails.getOfferToken()); subscriptionOfferDetailsDictionary.put("offer_tags", subscriptionOfferDetails.getOfferTags()); - ArrayList pricingPhasesDictionaryList = new ArrayList<>(); - for (ProductDetails.PricingPhase pricingPhase : subscriptionOfferDetails.getPricingPhases().getPricingPhaseList()) { + Dictionary pricingPhasesDictionaryContainer = new Dictionary(); + List pricingPhasesList = subscriptionOfferDetails.getPricingPhases().getPricingPhaseList(); + for (int i = 0; i < pricingPhasesList.size(); i++) { + ProductDetails.PricingPhase pricingPhase = pricingPhasesList.get(i); Dictionary pricingPhasesDictionary = new Dictionary(); pricingPhasesDictionary.put("billing_cycle_count", pricingPhase.getBillingCycleCount()); pricingPhasesDictionary.put("billing_period", pricingPhase.getBillingPeriod()); @@ -94,15 +96,15 @@ public static Dictionary convertProductDetailsToDictionary(ProductDetails detail pricingPhasesDictionary.put("price_amount_micros", pricingPhase.getPriceAmountMicros()); pricingPhasesDictionary.put("price_currency_code", pricingPhase.getPriceCurrencyCode()); pricingPhasesDictionary.put("recurrence_mode", pricingPhase.getRecurrenceMode()); - pricingPhasesDictionaryList.add(pricingPhasesDictionary); + pricingPhasesDictionaryContainer.put("pricingPhase_" + (i + 1), pricingPhasesDictionary); } - subscriptionOfferDetailsDictionary.put("pricing_phases", pricingPhasesDictionaryList); - - subscriptionOfferDetailsDictionaryList.add(subscriptionOfferDetailsDictionary); + subscriptionOfferDetailsDictionary.put("pricing_phases", pricingPhasesDictionaryContainer); + subscriptionOfferDetailsDictionaryContainer.put("subscriptionOffer_" + subscriptionOfferIndex, subscriptionOfferDetailsDictionary); + subscriptionOfferIndex++; } - dictionary.put("subscription_offer_details", subscriptionOfferDetailsDictionaryList); + dictionary.put("subscription_offer_details", subscriptionOfferDetailsDictionaryContainer); } return dictionary;