Skip to content

Commit

Permalink
Update InAppBilling.apple.cs
Browse files Browse the repository at this point in the history
Hopefully will return a Token for a restored purchase on iOS
  • Loading branch information
stevewinn74 committed Sep 1, 2020
1 parent 65e4426 commit fc0cc0f
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/Plugin.InAppBilling/InAppBilling.apple.cs
Expand Up @@ -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)
Expand Down

0 comments on commit fc0cc0f

Please sign in to comment.