Skip to content

Commit

Permalink
Return info of first sub into default info for simplicity
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmontemagno committed Jun 3, 2023
1 parent 1c6009c commit 252979f
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/Plugin.InAppBilling/Converters.android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 252979f

Please sign in to comment.