purchaseProduct static method
Future<CustomerInfo>
purchaseProduct(
- String productIdentifier, {
- UpgradeInfo? upgradeInfo,
- PurchaseType type = PurchaseType.subs,
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
static Future<CustomerInfo> purchaseProduct(
String productIdentifier, {
UpgradeInfo? upgradeInfo,
PurchaseType type = PurchaseType.subs,
}) async {
final prorationMode = upgradeInfo?.prorationMode;
final customerInfo = await _invokeReturningCustomerInfo('purchaseProduct', {
'productIdentifier': productIdentifier,
'oldSKU': upgradeInfo?.oldSKU,
'prorationMode': prorationMode?.index,
'type': describeEnum(type)
});
return customerInfo;
}