purchaseSubscriptionOption static method

  1. @Deprecated('Use purchase(PurchaseParams)')
Future<PurchaseResult> purchaseSubscriptionOption(
  1. SubscriptionOption subscriptionOption, {
  2. GoogleProductChangeInfo? googleProductChangeInfo,
  3. bool? googleIsPersonalizedPrice,
})

Google Play only.

Makes a purchase. Returns a PurchaseResult object. Throws a PlatformException if the purchase is unsuccessful. Check if PurchasesErrorHelper.getErrorCode is PurchasesErrorCode.purchaseCancelledError to check if the user cancelled the purchase.

subscriptionOption The SubscriptionOption you wish to purchase

googleProductChangeInfo Android and Google Play only. Optional GoogleProductChangeInfo you wish to change from containing the googleOldProductIdentifer and the optional prorationMode.

googleIsPersonalizedPrice Android and Google Play only. Optional boolean indicates personalized pricing on products available for purchase in the EU. For compliance with EU regulations. User will see "This price has been customize for you" in the purchase dialog when true. See https://developer.android.com/google/play/billing/integrate#personalized-price for more info.

Implementation

@Deprecated('Use purchase(PurchaseParams)')
static Future<PurchaseResult> purchaseSubscriptionOption(
  SubscriptionOption subscriptionOption, {
  GoogleProductChangeInfo? googleProductChangeInfo,
  bool? googleIsPersonalizedPrice,
}) async {
  if (defaultTargetPlatform != TargetPlatform.android) {
    throw UnsupportedPlatformException();
  }

  final prorationMode = googleProductChangeInfo?.prorationMode?.value;

  final purchaseResult =
      await _invokeReturningPurchaseResult('purchaseSubscriptionOption', {
    'productIdentifier': subscriptionOption.productId,
    'optionIdentifier': subscriptionOption.id,
    'googleOldProductIdentifier':
        googleProductChangeInfo?.oldProductIdentifier,
    'googleProrationMode': prorationMode,
    'googleIsPersonalizedPrice': googleIsPersonalizedPrice,
    'presentedOfferingIdentifier':
        subscriptionOption.presentedOfferingContext?.offeringIdentifier,
  });
  return purchaseResult;
}