Skip to content

Commit 0dd8de2

Browse files
authored
[in_app_purchase_platform_interface] Adds countryCode API (#6548)
Original pr #6540 Related to flutter/flutter#141627
1 parent 76c4a3d commit 0dd8de2

File tree

4 files changed

+33
-3
lines changed

4 files changed

+33
-3
lines changed

packages/in_app_purchase/in_app_purchase_platform_interface/CHANGELOG.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
## NEXT
1+
## 1.4.0
22

3+
* Adds `getCountryCode` API.
34
* Updates minimum supported SDK version to Flutter 3.13/Dart 3.1.
45

56
## 1.3.7
@@ -39,7 +40,7 @@
3940

4041
## 1.3.0
4142

42-
* Added new `PurchaseStatus` named `canceled` to distinguish between an error and user cancellation.
43+
* Added new `PurchaseStatus` named `canceled` to distinguish between an error and user cancellation.
4344

4445
## 1.2.0
4546

packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/in_app_purchase_platform.dart

+17
Original file line numberDiff line numberDiff line change
@@ -194,4 +194,21 @@ abstract class InAppPurchasePlatform extends PlatformInterface {
194194
/// [PurchaseDetails.verificationData].
195195
Future<void> restorePurchases({String? applicationUserName}) =>
196196
throw UnimplementedError('restorePurchases() has not been implemented.');
197+
198+
/// Returns the user's country.
199+
///
200+
/// Android:
201+
/// Returns Play billing country code based on ISO-3166-1 alpha2 format.
202+
///
203+
/// See: https://developer.android.com/reference/com/android/billingclient/api/BillingConfig
204+
/// See: https://unicode.org/cldr/charts/latest/supplemental/territory_containment_un_m_49.html
205+
///
206+
/// iOS:
207+
/// Returns the country code from SKStoreFrontWrapper.
208+
///
209+
/// See: https://developer.apple.com/documentation/storekit/skstorefront?language=objc
210+
///
211+
///
212+
Future<String> countryCode() =>
213+
throw UnimplementedError('countryCode() has not been implemented.');
197214
}

packages/in_app_purchase/in_app_purchase_platform_interface/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ repository: https://github.com/flutter/packages/tree/main/packages/in_app_purcha
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.3.7
7+
version: 1.4.0
88

99
environment:
1010
sdk: ^3.1.0

packages/in_app_purchase/in_app_purchase_platform_interface/test/in_app_purchase_platform_test.dart

+12
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,18 @@ void main() {
119119
throwsUnimplementedError,
120120
);
121121
});
122+
123+
test(
124+
'Default implementation of countryCode should throw unimplemented error',
125+
() {
126+
final ExtendsInAppPurchasePlatform inAppPurchasePlatform =
127+
ExtendsInAppPurchasePlatform();
128+
129+
expect(
130+
() => inAppPurchasePlatform.countryCode(),
131+
throwsUnimplementedError,
132+
);
133+
});
122134
});
123135

124136
group('$InAppPurchasePlatformAddition', () {

0 commit comments

Comments
 (0)