MAUI: Plugin.InAppBilling.InAppBillingPurchaseException: Unable to process purchase. at Plugin.InAppBilling.InAppBillingImplementation

Sreejith Sreenivasan 1,001 Reputation points
2024-06-14T03:34:43.46+00:00

I am getting below exception when I try to pay for a subscription for play store.

Plugin.InAppBilling.InAppBillingPurchaseException: Unable to process purchase. at Plugin.InAppBilling.InAppBillingImplementation.ParseBillingResult(BillingResult result, Boolean ignoreInvalidProducts) at Plugin.InAppBilling.InAppBillingImplementation.PurchaseAsync(String productSku, String itemType, String obfuscatedAccountId, String obfuscatedProfileId, String subOfferToken) at Plugin.InAppBilling.InAppBillingImplementation.PurchaseAsync(String productId, ItemType itemType, String obfuscatedAccountId, String obfuscatedProfileId, String subOfferToken)

Screenshot:

Screenshot_20240612_201556

I have created 3 subscriptions on the play store and activated it. My app was in draft state, so I published a new build on internal testing. But when I try to pay for the subscription I am getting above exception.

My Code:

UserDialogs.Instance.ShowLoading("");
if (IsBusy)
    return;

IsBusy = true;
try
{
    // check internet first with Essentials
    if (Connectivity.NetworkAccess != NetworkAccess.Internet)
        return;

    // connect to the app store api
    var connected = await CrossInAppBilling.Current.ConnectAsync();
    if (!connected)
        return;

    UserDialogs.Instance.HideHud();
    //try to make purchase, this will return a purchase, empty, or throw an exception
    var purchase = await CrossInAppBilling.Current.PurchaseAsync(productId, ItemType.Subscription);

    if (purchase == null)
    {
        //nothing was purchased
        return;
    }

    if (purchase.State == PurchaseState.Purchased)
    {
        Debug.WriteLine("Purchase successfull");
        Debug.WriteLine("Purchase token:>>" + purchase.PurchaseToken);
        Debug.WriteLine("Purchase id:>>" + purchase.Id);
        
    }
    else
    {
        throw new InAppBillingPurchaseException(PurchaseError.GeneralError);
    }
}
catch (InAppBillingPurchaseException purchaseEx)
{
    // Handle all the different error codes that can occure and do a pop up
    Debug.WriteLine("purchaseEx:>>" + purchaseEx);
}
catch (Exception ex)
{
    // Handle a generic exception as something really went wrong
    Debug.WriteLine("exception:>>" + ex);
}
finally
{
    await CrossInAppBilling.Current.DisconnectAsync();
    IsBusy = false;
}

Under manifest added the below permission:

<uses-permission android:name="com.android.vending.BILLING" />

Also added the below meta-data code:

<meta-data
  android:name="com.google.android.play.billingclient.version"
  android:value="6.0.1" />

Do I miss any other set up for the proper working of this? Is the subscriptions needs to published on anywhere? I have activated it. And my app is not published yet, it is only in draft state.

Developer technologies | .NET | .NET MAUI
{count} votes

Accepted answer
  1. Anonymous
    2024-06-14T05:45:45.93+00:00

    My app was in draft state, so I published a new build on internal testing. But when I try to pay for the subscription I am getting above exception.

    Did you have accepted the test program invitation in the google play console? If not, please refer to these steps to enable the test program invitation

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.