diff --git a/src/Plugin.InAppBilling.Android/InAppBillingImplementation.cs b/src/Plugin.InAppBilling.Android/InAppBillingImplementation.cs index 0cfc483..df8a8f3 100644 --- a/src/Plugin.InAppBilling.Android/InAppBillingImplementation.cs +++ b/src/Plugin.InAppBilling.Android/InAppBillingImplementation.cs @@ -286,12 +286,9 @@ public async override Task PurchaseAsync(string productId, async Task PurchaseAsync(string productSku, string itemType, string payload, IInAppBillingVerifyPurchase verifyPurchase) { - if (tcsPurchase != null && !tcsPurchase.Task.IsCompleted) return null; - tcsPurchase = new TaskCompletionSource(); - Bundle buyIntentBundle = serviceConnection.Service.GetBuyIntent(3, Context.PackageName, productSku, itemType, payload); var response = GetResponseCodeFromBundle(buyIntentBundle); @@ -323,9 +320,13 @@ async Task PurchaseAsync(string productSku, string itemType, string pa throw new InAppBillingPurchaseException(PurchaseError.AlreadyOwned); } + var pendingIntent = buyIntentBundle.GetParcelable(RESPONSE_BUY_INTENT) as PendingIntent; - if (pendingIntent != null) - Context.StartIntentSenderForResult(pendingIntent.IntentSender, PURCHASE_REQUEST_CODE, new Intent(), 0, 0, 0); + if (pendingIntent == null) + throw new InAppBillingPurchaseException(PurchaseError.GeneralError); + + tcsPurchase = new TaskCompletionSource(); + Context.StartIntentSenderForResult(pendingIntent.IntentSender, PURCHASE_REQUEST_CODE, new Intent(), 0, 0, 0); var result = await tcsPurchase.Task;