Skip to content

Commit 2c11117

Browse files
committed
Fixed issue with the price showing the description instead of the actual price
1 parent b55b0be commit 2c11117

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

app/src/main/java/games/moisoni/google_inapp_billing/JavaSampleActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public void onProductsFetched(@NonNull List<ProductInfo> productDetails) {
9292

9393
for (ProductInfo productInfo : productDetails) {
9494
product = productInfo.getProduct();
95-
price = productInfo.getPrice();
95+
price = productInfo.getOneTimePurchaseOfferPrice();
9696

9797
if (product.equalsIgnoreCase("consumable_id_1")) {
9898
//TODO - do something

app/src/main/java/games/moisoni/google_inapp_billing/KotlinSampleActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class KotlinSampleActivity : AppCompatActivity() {
8989

9090
for (productInfo in productDetails) {
9191
product = productInfo.product
92-
price = productInfo.price
92+
price = productInfo.oneTimePurchaseOfferPrice
9393

9494
if (product.equals("consumable_id_1", ignoreCase = true)) {
9595
//TODO - do something

google-iab/src/main/java/games/moisoni/google_iab/models/ProductInfo.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,17 @@ public class ProductInfo {
1212
private final ProductDetails productDetails;
1313

1414
private final String product;
15-
private final String price;
1615
private final String description;
1716
private final String title;
1817
private final String type;
1918
private final String name;
2019
private final ProductDetails.OneTimePurchaseOfferDetails oneTimePurchaseOfferDetails;
2120
private final List<ProductDetails.SubscriptionOfferDetails> subscriptionOfferDetails;
2221

23-
2422
public ProductInfo(SkuProductType skuProductType, ProductDetails productDetails) {
2523
this.skuProductType = skuProductType;
2624
this.productDetails = productDetails;
2725
this.product = productDetails.getProductId();
28-
this.price = productDetails.getDescription();
2926
this.description = productDetails.getDescription();
3027
this.title = productDetails.getTitle();
3128
this.type = productDetails.getProductType();
@@ -46,10 +43,6 @@ public String getProduct() {
4643
return product;
4744
}
4845

49-
public String getPrice() {
50-
return price;
51-
}
52-
5346
public String getDescription() {
5447
return description;
5548
}
@@ -66,6 +59,14 @@ public String getName() {
6659
return name;
6760
}
6861

62+
public String getOneTimePurchaseOfferPrice() {
63+
return getOneTimePurchaseOfferDetails().getFormattedPrice();
64+
}
65+
66+
public String getSubscriptionOfferPrice(int selectedOfferIndex, int selectedPricingPhaseIndex) {
67+
return getSubscriptionOfferDetails().get(selectedOfferIndex).getPricingPhases().getPricingPhaseList().get(selectedPricingPhaseIndex).getFormattedPrice();
68+
}
69+
6970
public ProductDetails.OneTimePurchaseOfferDetails getOneTimePurchaseOfferDetails() {
7071
return oneTimePurchaseOfferDetails;
7172
}

0 commit comments

Comments
 (0)