0

In the internal tests with credit card always valid everything works perfectly. When I test a beta version using a real credit card, i can become a subscriber and unsubscribe. When I try to subscribe again I get the error:

io.flutter.plugins.firebase.crashlytics.FlutterError: PlatformException(4, One or more of the arguments provided are invalid., {code: 4, message: One or more of the arguments provided are invalid., readableErrorCode: PurchaseInvalidError, readable_error_code : PurchaseInvalidError, underlyingErrorMessage: Error updating purchases. DebugMessage: Invalid SKU details.. ErrorCode: 5., userCancelled: false}, null). Error thrown PURCHASE_SUBSCRIBE.
       at StandardMethodCodec.decodeEnvelope(message_codecs.dart:607)
       at MethodChannel._invokeMethod(platform_channel.dart:167)
       at Purchases._invokeReturningMap(purchases_flutter.dart:701)
       at Purchases._invokeReturningCustomerInfo(purchases_flutter.dart:685)
       at Purchases.purchasePackage(purchases_flutter.dart:280)
       at PurchaseService.subscribe(purchase_service.dart:64)
       at _PremiumPageState._subscribe(premium_page.dart:382)

Code triggered when entering the app and when logging in:

Future load() async {
    User? usuario = FirebaseAuth.instance.currentUser;
    await purchases.Purchases.setDebugLogsEnabled(kDebugMode ? true : false);
    late PurchasesConfiguration configuration;

    if (usuario != null && usuario.uid.isNotEmpty) {
      if (Platform.isAndroid) {
        configuration = purchases.PurchasesConfiguration("xxxxxxxxxxxxxxx")
              ..appUserID = usuario.uid;
      } else if (Platform.isIOS) {
        configuration = purchases.PurchasesConfiguration("yyyyyyyyyyyyyyy")
              ..appUserID = usuario.uid;
      }

      await Purchases.configure(configuration);
      var customerInfo = await Purchases.getCustomerInfo();
      final entitlements = customerInfo.entitlements.active;
      setIsPremium(entitlements.isNotEmpty ? true : false);//mobx
    }
}

When choosing a subscription plan:

Future subscribe(purchases.Package package) async {
    try {
      final purchaseInfo = await purchases.Purchases.purchasePackage(package);
      final entitlements = purchaseInfo.entitlements.active;
      setIsPremium(entitlements.isNotEmpty ? true : false);//mobx
    } on Exception catch (ex, stack) {
      await FirebaseCrashlytics.instance
          .recordError(ex, stack);
    }
}

Can anyone tell me if this is a strange behavior only in beta tests, or can it happen in the production release?

0 Answers0