purchaseProduct static method
- @Deprecated('Use purchaseStoreProduct')
- String productIdentifier,
- {UpgradeInfo? upgradeInfo,
- PurchaseType type = PurchaseType.subs}
It is now recommended to use Purchases.purchaseStoreProduct to make a purchase with a StoreProduct if you can.
Makes a purchase. Returns a CustomerInfo
object. Throws a
PlatformException if the purchase is unsuccessful.
Check if PurchasesErrorHelper.getErrorCode is
PurchasesErrorCode.purchaseCancelledError to check if the user cancelled
the purchase.
productIdentifier
The product identifier of the product you want to
purchase.
upgradeInfo
Android only. Optional UpgradeInfo you wish to upgrade from
containing the oldSKU and the optional prorationMode.
type
If the product is an Android INAPP, this needs to be
PurchaseType.INAPP otherwise the product won't be found.
PurchaseType.Subs by default. This parameter only has effect in Android.
Implementation
@Deprecated('Use purchaseStoreProduct')
static Future<CustomerInfo> purchaseProduct(
String productIdentifier, {
UpgradeInfo? upgradeInfo,
PurchaseType type = PurchaseType.subs,
}) async {
final prorationMode = upgradeInfo?.prorationMode;
final customerInfo = await _invokeReturningCustomerInfo('purchaseProduct', {
'productIdentifier': productIdentifier,
'type': type.name,
'googleOldProductIdentifier': upgradeInfo?.oldSKU,
'googleProrationMode': prorationMode?.index,
'googleIsPersonalizedPrice': null,
'presentedOfferingIdentifier': null,
});
return customerInfo;
}