checkPlatformSubscription method
PurchaseParam
checkPlatformSubscription({
- required ProductDetails productDetails,
- String? oldProductId,
- ReplacementMode? replacementMode,
Checks the purchase parameter for Android and IOS platform. For Android It checks the old subscription to determine if the user is upgrading or downgrading the subscription.
IOS handles this internally.
*productDetails
: Previous Purchased product.
Returns *PurchaseParam: purchase product details.
Implementation
PurchaseParam checkPlatformSubscription(
{required ProductDetails productDetails,
String? oldProductId,
ReplacementMode? replacementMode}) {
if (Platform.isAndroid) {
final GooglePlayPurchaseDetails? oldSubscription =
getOldPurchaseDetails(productDetails);
return GooglePlayPurchaseParam(
productDetails: productDetails,
changeSubscriptionParam: (oldSubscription != null)
? ChangeSubscriptionParam(
oldPurchaseDetails: oldSubscription,
replacementMode:
replacementMode ?? ReplacementMode.chargeFullPrice,
)
: null,
);
} else {
return PurchaseParam(productDetails: productDetails);
}
}