From 252979f064c134cbd68fe471a66696b375de7c3f Mon Sep 17 00:00:00 2001 From: James Montemagno Date: Fri, 2 Jun 2023 20:33:24 -0700 Subject: [PATCH] Return info of first sub into default info for simplicity --- src/Plugin.InAppBilling/Converters.android.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Plugin.InAppBilling/Converters.android.cs b/src/Plugin.InAppBilling/Converters.android.cs index 889fc54..adc2bc9 100644 --- a/src/Plugin.InAppBilling/Converters.android.cs +++ b/src/Plugin.InAppBilling/Converters.android.cs @@ -17,9 +17,9 @@ internal static InAppBillingPurchase ToIABPurchase(this Purchase purchase) Signature = purchase.Signature, IsAcknowledged = purchase.IsAcknowledged, Payload = purchase.DeveloperPayload, - ProductId = purchase.Skus.FirstOrDefault(), + ProductId = purchase.Products?.FirstOrDefault(), Quantity = purchase.Quantity, - ProductIds = purchase.Skus, + ProductIds = purchase.Products, PurchaseToken = purchase.PurchaseToken, TransactionDateUtc = DateTimeOffset.FromUnixTimeMilliseconds(purchase.PurchaseTime).DateTime, ObfuscatedAccountId = purchase.AccountIdentifiers?.ObfuscatedAccountId, @@ -44,9 +44,9 @@ internal static InAppBillingPurchase ToIABPurchase(this PurchaseHistoryRecord pu OriginalJson = purchase.OriginalJson, Signature = purchase.Signature, Payload = purchase.DeveloperPayload, - ProductId = purchase.Skus.FirstOrDefault(), + ProductId = purchase.Products?.FirstOrDefault(), Quantity = purchase.Quantity, - ProductIds = purchase.Skus, + ProductIds = purchase.Products, PurchaseToken = purchase.PurchaseToken, TransactionDateUtc = DateTimeOffset.FromUnixTimeMilliseconds(purchase.PurchaseTime).DateTime, State = PurchaseState.Unknown, @@ -74,15 +74,17 @@ internal static InAppBillingProduct ToIAPProduct(this ProductDetails product) RecurrenceMode = p.RecurrenceMode }).ToList() }).ToList(); + + var firstSub = subs?.FirstOrDefault()?.PricingPhases?.FirstOrDefault(); return new InAppBillingProduct { Name = product.Title, Description = product.Description, - CurrencyCode = oneTime?.PriceCurrencyCode, - LocalizedPrice = oneTime?.FormattedPrice, + CurrencyCode = oneTime?.PriceCurrencyCode ?? firstSub?.PriceCurrencyCode, + LocalizedPrice = oneTime?.FormattedPrice ?? firstSub?.FormattedPrice, ProductId = product.ProductId, - MicrosPrice = oneTime?.PriceAmountMicros ?? 0, + MicrosPrice = oneTime?.PriceAmountMicros ?? firstSub?.PriceAmountMicros ?? 0, AndroidExtras = new InAppBillingProductAndroidExtras { SubscriptionOfferDetails = subs