From fc0cc0fc4d3f250aec11a2823ccc6580513b4f21 Mon Sep 17 00:00:00 2001 From: stevewinn74 <69214831+stevewinn74@users.noreply.github.com> Date: Tue, 1 Sep 2020 21:26:29 +0200 Subject: [PATCH] Update InAppBilling.apple.cs Hopefully will return a Token for a restored purchase on iOS --- src/Plugin.InAppBilling/InAppBilling.apple.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Plugin.InAppBilling/InAppBilling.apple.cs b/src/Plugin.InAppBilling/InAppBilling.apple.cs index f0caf42..db632ca 100644 --- a/src/Plugin.InAppBilling/InAppBilling.apple.cs +++ b/src/Plugin.InAppBilling/InAppBilling.apple.cs @@ -505,15 +505,24 @@ public static InAppBillingPurchase ToIABPurchase(this SKPaymentTransaction trans if (p == null) return null; + string _purchaseToken = null; + if (String.IsNullOrEmpty(p.TransactionReceipt?.GetBase64EncodedString(NSDataBase64EncodingOptions.None))) + { + _purchaseToken = transaction.TransactionReceipt?.GetBase64EncodedString(NSDataBase64EncodingOptions.None); + } + else + { + _purchaseToken = p.TransactionReceipt?.GetBase64EncodedString(NSDataBase64EncodingOptions.None); + } - return new InAppBillingPurchase + return new InAppBillingPurchase { TransactionDateUtc = NSDateToDateTimeUtc(transaction.TransactionDate), Id = p.TransactionIdentifier, ProductId = p.Payment?.ProductIdentifier ?? string.Empty, State = p.GetPurchaseState(), - PurchaseToken = p.TransactionReceipt?.GetBase64EncodedString(NSDataBase64EncodingOptions.None) ?? string.Empty - }; + PurchaseToken = _purchaseToken + }; } static DateTime NSDateToDateTimeUtc(NSDate date)