jamesmontemagno / InAppBillingPlugin

Cross-platform In App Billing Plugin for .NET
MIT License
668 stars 153 forks source link

Unable to 'buy' in Android on version 8.0.5 #646

Closed rezamohamed closed 2 weeks ago

rezamohamed commented 2 weeks ago

Bug Information

Version Number of Plugin: 8.0.5 Device Tested On: Android (physical device) Simulator Tested On: Version of VS: Rider 2024.3 Version of Maui: 8.0.93 Versions of other things you are using:

Steps to reproduce the Behavior

The in-app purchasing was working just fine, but since a few days ago, I have been unable to 'buy' an in-app product or subscription from the Google Play Console (while testing). No code has changed, and nothing in the Google Play Console has changed.

When I debug the exception, this is what I get:

Plugin.InAppBilling.InAppBillingPurchaseException: Unable to process purchase.
   at Plugin.InAppBilling.InAppBillingImplementation.ParseBillingResult(BillingResult result, Boolean ignoreInvalidProducts) in D:\a\1\s\src\Plugin.InAppBilling\InAppBilling.android.cs:line 496
   at Plugin.InAppBilling.InAppBillingImplementation.PurchaseAsync(String productSku, String itemType, String obfuscatedAccountId, String obfuscatedProfileId, String subOfferToken, CancellationToken cancellationToken) in D:\a\1\s\src\Plugin.InAppBilling\InAppBilling.android.cs:line 411
   at Plugin.InAppBilling.InAppBillingImplementation.PurchaseAsync(String productId, ItemType itemType, String obfuscatedAccountId, String obfuscatedProfileId, String subOfferToken, CancellationToken cancellationToken) in D:\a\1\s\src\Plugin.InAppBilling\InAppBilling.android.cs:line 347

I have verified on Google Play Console that all the items are available and active.

Expected Behavior

User should be able to purchase subscriptions and in-app products.

Actual Behavior

The message on the device is:

Error
The item you were attempting to purchase could not be found.

Code snippet

this is my InAppBill service/purchase method

    public async Task<InAppBillingPurchase> PurchaseAsync(string productId, ItemType itemType)
    {
        InAppBillingPurchase purchase = null;

        try
        {
            //await billing.ConnectAsync();

            // Prevent starting a new connection if one is already in progress
            if (_isConnecting)
            {
                // Return immediately or handle this case gracefully (e.g., show a loading indicator)
                return null;
            }

            _isConnecting = true; // Mark as connecting

            // Connect to billing service if not already connected
            if (!_isBillingConnected)
            {
                await billing.ConnectAsync();
                _isBillingConnected = true;
                _isConnecting = false; // Mark as no longer connecting
            }

            if (billing == null)
                throw new Exception("Not connected to the billing service");

            purchase = await billing.PurchaseAsync(productId, itemType); //, "payload");

            //await billing.DisconnectAsync();
        }
        finally
        {
            //await billing.DisconnectAsync();

            // Disconnect only if we were connected
            if (_isBillingConnected)
            {
                await billing.DisconnectAsync();
                _isBillingConnected = false;
            }

            _isConnecting = false; // Mark as no longer connecting
        }

        return purchase;
    }

Screenshots

Could there be a change in the Google Play API since I see this message now when I go to the Monetize section?

CleanShot 2024-11-13 at 11 03 21@2x

rezamohamed commented 2 weeks ago

This is a my bad - I discarded a previous release track, as such it had deleted the Testers. I had to add the Testers back into the current release.