Skip to content

Commit 8956aed

Browse files
committed
fix: revert to OpenIAP standard method names
- Use getAvailablePurchases instead of getActivePurchases to match OpenIAP spec - Keep getPurchaseHistories as per OpenIAP spec - Update examples to use correct method names
1 parent 255820b commit 8956aed

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

example/lib/src/screens/available_purchases_screen.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class _AvailablePurchasesScreenState extends State<AvailablePurchasesScreen> {
6666

6767
try {
6868
// Load available purchases (non-consumed)
69-
final availablePurchases = await _iap.getActivePurchases();
69+
final availablePurchases = await _iap.getAvailablePurchases();
7070

7171
// Load purchase history
7272
final purchaseHistory = await _iap.getPurchaseHistories();
@@ -94,7 +94,7 @@ class _AvailablePurchasesScreenState extends State<AvailablePurchasesScreen> {
9494
});
9595

9696
try {
97-
final restored = await _iap.getActivePurchases();
97+
final restored = await _iap.getAvailablePurchases();
9898
setState(() {
9999
_availablePurchases = restored;
100100
});

example/lib/src/screens/debug_purchases_screen.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class _DebugPurchasesScreenState extends State<DebugPurchasesScreen> {
3636
await Future<void>.delayed(const Duration(seconds: 1));
3737

3838
// Get all available purchases
39-
final purchases = await _iap.getActivePurchases();
39+
final purchases = await _iap.getAvailablePurchases();
4040

4141
setState(() {
4242
_purchases = purchases;

lib/flutter_inapp_purchase.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,9 +376,9 @@ class FlutterInappPurchase
376376
await requestPurchase(request: request, type: type);
377377
}
378378

379-
/// Get non-consumed purchases (active purchases that haven't been finished)
380-
/// Returns purchases that are still pending acknowledgment or consumption
381-
Future<List<iap_types.Purchase>> getActivePurchases() async {
379+
/// Get all available purchases (OpenIAP standard)
380+
/// Returns non-consumed purchases that are still pending acknowledgment or consumption
381+
Future<List<iap_types.Purchase>> getAvailablePurchases() async {
382382
if (!_isInitialized) {
383383
throw iap_types.PurchaseError(
384384
code: iap_types.ErrorCode.eNotInitialized,
@@ -417,7 +417,7 @@ class FlutterInappPurchase
417417
} catch (e) {
418418
throw iap_types.PurchaseError(
419419
code: iap_types.ErrorCode.eServiceError,
420-
message: 'Failed to get active purchases: ${e.toString()}',
420+
message: 'Failed to get available purchases: ${e.toString()}',
421421
platform: iap_types.getCurrentPlatform(),
422422
);
423423
}

0 commit comments

Comments
 (0)