PurchaseController
An abstract class for handling custom purchase flows and subscription management.
Implementing a custom PurchaseController is advanced functionality. Most developers should use the default purchase controller with RevenueCat integration.
For RevenueCat integration, see the Using RevenueCat guide instead of implementing a custom PurchaseController.
Purpose
Allows custom implementation of purchase flows, subscription validation, and cross-platform purchase handling.
Signature
abstract class PurchaseController {
Future<PurchaseResult> purchaseFromAppStore(String productId);
Future<PurchaseResult> purchaseFromGooglePlay(
String productId,
String? basePlanId,
String? offerId,
);
Future<RestorationResult> restorePurchases();
}Parameters
| Method | Parameters | Description |
|---|---|---|
purchaseFromAppStore | productId: String | Handles iOS App Store purchases. |
purchaseFromGooglePlay | productId: String, basePlanId: String?, offerId: String? | Handles Google Play Store purchases with optional base plan and offer. |
restorePurchases | None | Restores previous purchases across platforms. |
Returns / State
purchaseFromAppStoreandpurchaseFromGooglePlayreturnFuture<PurchaseResult>restorePurchasesreturnsFuture<RestorationResult>
Usage
For most use cases, use RevenueCat integration instead:
See the Using RevenueCat guide for complete setup instructions.
Custom implementation is only needed for advanced use cases where you have your own purchase handling system.
How is this guide?