Skip to main content
Question

PlatformException on cancelled purchase (Android, physical device)

  • March 20, 2025
  • 1 reply
  • 8 views

Forum|alt.badge.img

Hi!

I get a platform exception when a user cancels the purchas of an in-app product. I cannot catch the exception. Physical device, product is correctly setup, afaik.
 

Error:

PlatformException (PlatformException(1, Purchase was cancelled., {code: 1, message: Purchase was cancelled., readableErrorCode: PurchaseCancelledError, readable_error_code: PurchaseCancelledError, underlyingErrorMessage: Error updating purchases. DebugMessage: . ErrorCode: USER_CANCELED., userCancelled: true}, null))


 

try {

      final customerInfo = await Purchases.purchasePackage(currentPackage!);

      // Check if the product was successfully purchased by verifying active subscriptions.

      if (customerInfo.activeSubscriptions.contains(revenueCatProduct)) {

        markAsPurchased();

      }

    } on PlatformException catch (e) {

      bool isCancelled = false;

      if (e.details is Map) {

        final Map details = e.details as Map;

        if (details['userCancelled'] == true ||

            (details['readableErrorCode'] != null &&

                details['readableErrorCode'].toString().toLowerCase() ==

                    'purchasecancellederror')) {

          isCancelled = true;

        }

      }

      if (e.message != null && e.message!.toLowerCase().contains('cancel')) {

        isCancelled = true;

      }

 

      if (isCancelled) {

        debugPrint("Purchase cancelled by user.");

      } else {

        errorMessage = "Purchase failed: ${e.message}";

      }

    } catch (e) {

      errorMessage = "Purchase failed: $e";

    } finally {

      isPurchasing = false;

      notifyListeners();

    }

Forum|alt.badge.img
  • New Member
  • March 20, 2025

I have the same error, when using an entitlement, instead of referencing the product: cancelling the transaction crashes revenue cat. It seems to be similar to this error here: 

 

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings