purchaseStoreProduct static method

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

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.

storeProduct The StoreProduct you want 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 isPersonalizedPrice 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> purchaseStoreProduct(
  StoreProduct storeProduct, {
  GoogleProductChangeInfo? googleProductChangeInfo,
  bool? googleIsPersonalizedPrice,
}) async {
  final prorationMode = googleProductChangeInfo?.prorationMode?.value;
  final purchaseResult =
    await _invokeReturningPurchaseResult('purchaseProduct', {
      'productIdentifier': storeProduct.identifier,
      'type': storeProduct.productCategory?.name,
      'googleOldProductIdentifier':
          googleProductChangeInfo?.oldProductIdentifier,
      'googleProrationMode': prorationMode,
      'googleIsPersonalizedPrice': googleIsPersonalizedPrice,
      'presentedOfferingIdentifier':
          storeProduct.presentedOfferingContext?.offeringIdentifier,
    });

  return purchaseResult;
}