Skip to content

Commit

Permalink
Fixup checking for null on tcsPurchase
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmontemagno committed Aug 20, 2020
1 parent a3ee722 commit fcf0fcf
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Plugin.InAppBilling/InAppBilling.android.cs
Expand Up @@ -203,6 +203,13 @@ public async override Task<InAppBillingPurchase> PurchaseAsync(string productId,
throw new InAppBillingPurchaseException(PurchaseError.ServiceUnavailable, "You are not connected to the Google Play App store.");
}

// If we have a current task and it is not completed then return null.
// you can't try to purchase twice.
if (tcsPurchase?.Task != null && !tcsPurchase.Task.IsCompleted)
{
return null;
}

switch (itemType)
{
case ItemType.InAppPurchase:
Expand All @@ -218,10 +225,7 @@ public async override Task<InAppBillingPurchase> PurchaseAsync(string productId,
}

async Task<InAppBillingPurchase> PurchaseAsync(string productSku, string itemType, IInAppBillingVerifyPurchase verifyPurchase)
{
var completed = tcsPurchase?.Task?.IsCompleted ?? false;
if (!completed)
return null;
{

var skuDetailsParams = SkuDetailsParams.NewBuilder()
.SetType(itemType)
Expand Down

0 comments on commit fcf0fcf

Please sign in to comment.