Skip to content

Commit

Permalink
https://github.com/jamesmontemagno/InAppBillingPlugin/issues/125
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreiMisiukevich committed Mar 6, 2018
1 parent 52833c0 commit 06a7c77
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/Plugin.InAppBilling.Android/InAppBillingImplementation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,12 +286,9 @@ public async override Task<InAppBillingPurchase> PurchaseAsync(string productId,

async Task<Purchase> PurchaseAsync(string productSku, string itemType, string payload, IInAppBillingVerifyPurchase verifyPurchase)
{

if (tcsPurchase != null && !tcsPurchase.Task.IsCompleted)
return null;

tcsPurchase = new TaskCompletionSource<PurchaseResponse>();

Bundle buyIntentBundle = serviceConnection.Service.GetBuyIntent(3, Context.PackageName, productSku, itemType, payload);
var response = GetResponseCodeFromBundle(buyIntentBundle);

Expand Down Expand Up @@ -323,9 +320,13 @@ async Task<Purchase> 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<PurchaseResponse>();
Context.StartIntentSenderForResult(pendingIntent.IntentSender, PURCHASE_REQUEST_CODE, new Intent(), 0, 0, 0);

var result = await tcsPurchase.Task;

Expand Down

0 comments on commit 06a7c77

Please sign in to comment.