Xamarin InAppBilling showing ItemUnavailable for purchase on Android

Viewed 52

I'm implementing the InAppBilling plugin in my Xamarin Forms 5 app for auto-renewing subscriptions.

I have the "subscriptions" set up on Google Play and they're active. When I ask for a list of subscription items, I get the list fine but when I try make a purchase, I get the following error that indicates the item is not available.

enter image description here

enter image description here

I'm running this on a real device connected to my laptop via USB. Any idea what I'm doing wrong?

Here's my purchase subscription method which is directly from documentation here:

public async Task<bool> Subscribe(string productId)
{
   var billing = CrossInAppBilling.Current;
   try
   {
       var connected = await billing.ConnectAsync();
       if (!connected)
           return false;

       //check purchases
       var purchase = await billing.PurchaseAsync(productId, ItemType.Subscription);

       //possibility that a null came through.
       if (purchase == null)
       {
           //did not purchase
           return false;
       }
       else
       {
           //purchased!
           if (Device.RuntimePlatform == Device.Android)
           {
               // Must call AcknowledgePurchaseAsync else the purchase will be refunded
               //await billing.AcknowledgePurchaseAsync(purchase.PurchaseToken);
           }
           return true;
       }
   }
   catch (InAppBillingPurchaseException purchaseEx)
   {
       //Billing Exception handle this based on the type
       throw new Exception("Error: " + purchaseEx);
   }
   catch (Exception ex)
   {
       //Something else has gone wrong, log it
       throw new Exception();
   }
   finally
   {
       await billing.DisconnectAsync();
   }
}

As I mentioned before, I see the subscription items available and active on Google Play. I also made sure, I'm getting them from "Subscriptions" and NOT "In-App Products". I'm using the ID that I copy and paste from the "Product ID" column on Google Play Console -- see below:

enter image description here

Any idea what the issue here may be?

0 Answers
Related