Upgrade/Downgrade/Cross-grade RevenueCat/Android

I would like to start a discussion about RevenueCat on Android. On iOS, when users swap a subscription, the subscription management (cancel old, start new, etc.) happens automatically. However, on Android, it doesn't.

If a user is subscribed to subscription A and then subscribes to subscription B, the user will actually be subscribed to two subscriptions simultaneously. I am still in the testing phase, but this could mean that the user gets charged double after the subscription timeframe has passed (e.g. gets charged for both subscription A and subscription B after one month).

Even if the user doesn't get charged double it is still creating problems as the user doesn't get the benefits of upgrades/downgrades on the subscription - if the user upgrades, the user should only be charged for the upgrade (upgradePrice - currentPrice) for the remaining month.

Now, Google (Android) does have solutions for this using their Proration modes. The "best" proration mode, or I would say the most commonly used is the PurchasesProrationMode.immediateWithTimeProration. This handles upgrades/downgrades/cross-grades as you would expect. However, this isn't implementable as easily in FF as you do have to custom code it.

Now I tried coding it in the custom actions builder, but haven't had any luck. So I wonder if anyone has had any experience with this and if so if they can help me build this and further spark a conversion for the community. My current code (having some issues with the "_model" I believe):

import 'package:purchases_flutter/purchases_flutter.dart'; // For RevenueCat
import '/flutter_flow/revenue_cat_util.dart'
    as revenue_cat; // Your custom RevenueCat utility

Future<bool> subscriptionChangeOnAndroid(String desiredPackage) async {
  // Add your function code here!

  // Now we perform the purchase with the specified proration mode.
  _model.isPurchaseSuccessful = await revenue_cat.purchasePackage(
      desiredPackage,
      upgradeProrationMode: PurchasesProrationMode
          .immediateWithTimeProration // this line is important for the swap logic
      );

  return isPurchaseSuccessful;
}
4
5 replies