makePurchase method

Future<AdaptyProfile?> makePurchase({
  1. required AdaptyPaywallProduct product,
  2. AdaptyAndroidSubscriptionUpdateParameters? subscriptionUpdateParams,
  3. bool? isOfferPersonalized,
})

To make the purchase, you have to call this method. Read more on the Adapty Documentation

Parameters:

  • product: an AdaptyPaywallProduct object retrieved from the paywall.
  • subscriptionUpdateParams: an AdaptySubscriptionUpdateParameters object used to upgrade or downgrade a subscription (use for Android).
  • isOfferPersonalized: Specifies whether the offer is personalized to the buyer (use for Android).

Returns:

  • The AdaptyProfile object. This model contains info about access levels, subscriptions, and non-subscription purchases. Generally, you have to check only access level status to determine whether the user has premium access to the app.

Implementation

Future<AdaptyProfile?> makePurchase({
  required AdaptyPaywallProduct product,
  AdaptyAndroidSubscriptionUpdateParameters? subscriptionUpdateParams,
  bool? isOfferPersonalized,
}) async {
  final result = await _invokeMethodHandlingErrors<String>(Method.makePurchase, {
    Argument.product: json.encode(product.jsonValue),
    if (subscriptionUpdateParams != null) Argument.params: json.encode(subscriptionUpdateParams.jsonValue),
    if (isOfferPersonalized != null) Argument.isOfferPersonalized: isOfferPersonalized,
  });

  return (result == null) ? null : AdaptyProfileJSONBuilder.fromJsonValue(json.decode(result));
}