Skip to content

Commit e51cc1d

Browse files
authored
[in_app_purchase]IAP/platform interface add cancel status (flutter#4093)
1 parent 0362219 commit e51cc1d

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

packages/in_app_purchase/in_app_purchase_platform_interface/CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.3.0
2+
3+
* Added new `PurchaseStatus` named `canceled` to distinguish between an error and user cancellation.
4+
15
## 1.2.0
26

37
* Added `toString()` to `IAPError`
@@ -12,4 +16,4 @@
1216

1317
## 1.0.0
1418

15-
* Initial open-source release.
19+
* Initial open-source release.

packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/types/purchase_status.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,9 @@ enum PurchaseStatus {
2626
/// the purchase by calling the `completePurchase` method. More information on
2727
/// verifying purchases can be found [here](https://pub.dev/packages/in_app_purchase#restoring-previous-purchases).
2828
restored,
29+
30+
/// The purchase has been canceled.
31+
///
32+
/// Update your UI to indicate the purchase is canceled.
33+
canceled,
2934
}

packages/in_app_purchase/in_app_purchase_platform_interface/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ repository: https://github.com/flutter/plugins/tree/master/packages/in_app_purch
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+in_app_purchase%22
55
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
66
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
7-
version: 1.2.0
7+
version: 1.3.0
88

99
environment:
1010
sdk: ">=2.12.0 <3.0.0"

packages/in_app_purchase/in_app_purchase_platform_interface/test/src/types/product_details_test.dart

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import 'package:flutter_test/flutter_test.dart';
66
import 'package:in_app_purchase_platform_interface/in_app_purchase_platform_interface.dart';
7+
import 'package:in_app_purchase_platform_interface/src/types/purchase_status.dart';
78

89
void main() {
910
group('Constructor Tests', () {
@@ -27,4 +28,22 @@ void main() {
2728
expect(productDetails.currencySymbol, r'$');
2829
});
2930
});
31+
32+
group('PurchaseStatus Tests', () {
33+
test('PurchaseStatus should contain 5 options', () {
34+
const List<PurchaseStatus> values = PurchaseStatus.values;
35+
36+
expect(values.length, 5);
37+
});
38+
39+
test('PurchaseStatus enum should have items in correct index', () {
40+
const List<PurchaseStatus> values = PurchaseStatus.values;
41+
42+
expect(values[0], PurchaseStatus.pending);
43+
expect(values[1], PurchaseStatus.purchased);
44+
expect(values[2], PurchaseStatus.error);
45+
expect(values[3], PurchaseStatus.restored);
46+
expect(values[4], PurchaseStatus.canceled);
47+
});
48+
});
3049
}

0 commit comments

Comments
 (0)