AdaptySDK-Flutter icon indicating copy to clipboard operation
AdaptySDK-Flutter copied to clipboard

Allow setting Android replacement mode when using AdaptyUI

Open agladyshev opened this issue 1 year ago • 2 comments

Hi there.

When updating subscriptions on Android, the platform requires explicitly stating Replacement Mode to determine how subscription change is handled. Currently, if the app offers the same subscription for, let's say, a week, a month or a year, and an active subscriber tries to change subscription using Adapty paywall, a new subscription would be purchased for full price and the user would have 2 active subscriptions.

According to docs, we can set AdaptyAndroidSubscriptionUpdateParameters? subscriptionUpdateParams, if makePurchase is called manually.

final result = await adapty.makePurchase( product: product, subscriptionUpdateParams: subscriptionUpdateParams, );

But there is not such option available using AdaptyUI().createPaywallView() and showing paywall from paywall builder. It would be great if we had an option to set this parameter globally or when creating specific paywall view, or alternatively, in paywall builder.

Please let me know if I'm missing anything!

agladyshev avatar Dec 04 '24 08:12 agladyshev

I think I might have misunderstood how different billing periods should be treated in Google Play. I have separate subscriptions instead of having multiple base plans for the same subscription. Still, in case of changing subscription to an entirely different one, the change described above might still be useful

agladyshev avatar Dec 04 '24 08:12 agladyshev

Hi @agladyshev! Thank you for the issue, we're going to introduce this parameter soon.

x401om avatar Dec 18 '24 19:12 x401om

@x401om Any news about it?

EliaTolin avatar Jul 14 '25 14:07 EliaTolin

@EliaTolin we are already on it.

x401om avatar Jul 17 '25 10:07 x401om

Since version 3.10.0, you can define the desired behavior for products. Use paywall.productIdentifiers to see which products are included in the paywall, then build a map from this array and pass it to the .createPaywallView() method.

Future<void> _createAndPresentPaywallView(AdaptyPaywall paywall) async {
  try {
    final view = await AdaptyUI().(
      paywall: paywall,
      productPurchaseParams: Map.fromEntries(
        paywall.productIdentifiers.map(
            (e) {
              final parameters = AdaptyPurchaseParametersBuilder()
                ..setSubscriptionUpdateParams(
                  AdaptyAndroidSubscriptionUpdateParameters(
                    "<OLD_SUB_VENDOR_PRODUCT_ID>",
                    AdaptyAndroidSubscriptionUpdateReplacementMode.chargeFullPrice,
                  ),
                );

              return MapEntry(e, parameters.build());
            },
          ),
        ),
      );

      await view.present();
    } on AdaptyError catch (e) {
      // handle the error
    } catch (e) {
      // handle the error
    }
  }

As part of AdaptyPurchaseParameters, you can define the subscriptionUpdateParams, isOfferPersonalized, obfuscatedAccountId, and obfuscatedProfileId parameters.

x401om avatar Aug 11 '25 10:08 x401om