diff --git a/packages/in_app_purchase/in_app_purchase_platform_interface/CHANGELOG.md b/packages/in_app_purchase/in_app_purchase_platform_interface/CHANGELOG.md index 6baaa7f722dd6..11d14d945e752 100644 --- a/packages/in_app_purchase/in_app_purchase_platform_interface/CHANGELOG.md +++ b/packages/in_app_purchase/in_app_purchase_platform_interface/CHANGELOG.md @@ -1,5 +1,6 @@ -## NEXT +## 1.4.0 +* Adds `getCountryCode` API. * Updates minimum supported SDK version to Flutter 3.13/Dart 3.1. ## 1.3.7 @@ -39,7 +40,7 @@ ## 1.3.0 -* Added new `PurchaseStatus` named `canceled` to distinguish between an error and user cancellation. +* Added new `PurchaseStatus` named `canceled` to distinguish between an error and user cancellation. ## 1.2.0 diff --git a/packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/in_app_purchase_platform.dart b/packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/in_app_purchase_platform.dart index 18c6828b11d16..7fd34538025ac 100644 --- a/packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/in_app_purchase_platform.dart +++ b/packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/in_app_purchase_platform.dart @@ -194,4 +194,21 @@ abstract class InAppPurchasePlatform extends PlatformInterface { /// [PurchaseDetails.verificationData]. Future restorePurchases({String? applicationUserName}) => throw UnimplementedError('restorePurchases() has not been implemented.'); + + /// Returns the user's country. + /// + /// Android: + /// Returns Play billing country code based on ISO-3166-1 alpha2 format. + /// + /// See: https://developer.android.com/reference/com/android/billingclient/api/BillingConfig + /// See: https://unicode.org/cldr/charts/latest/supplemental/territory_containment_un_m_49.html + /// + /// iOS: + /// Returns the country code from SKStoreFrontWrapper. + /// + /// See: https://developer.apple.com/documentation/storekit/skstorefront?language=objc + /// + /// + Future countryCode() => + throw UnimplementedError('countryCode() has not been implemented.'); } diff --git a/packages/in_app_purchase/in_app_purchase_platform_interface/pubspec.yaml b/packages/in_app_purchase/in_app_purchase_platform_interface/pubspec.yaml index a85144696cf89..35fc0488d9d0d 100644 --- a/packages/in_app_purchase/in_app_purchase_platform_interface/pubspec.yaml +++ b/packages/in_app_purchase/in_app_purchase_platform_interface/pubspec.yaml @@ -4,7 +4,7 @@ repository: https://github.com/flutter/packages/tree/main/packages/in_app_purcha issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+in_app_purchase%22 # NOTE: We strongly prefer non-breaking changes, even at the expense of a # less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes -version: 1.3.7 +version: 1.4.0 environment: sdk: ^3.1.0 diff --git a/packages/in_app_purchase/in_app_purchase_platform_interface/test/in_app_purchase_platform_test.dart b/packages/in_app_purchase/in_app_purchase_platform_interface/test/in_app_purchase_platform_test.dart index 0a79e99041d66..5ae13ade1bbc6 100644 --- a/packages/in_app_purchase/in_app_purchase_platform_interface/test/in_app_purchase_platform_test.dart +++ b/packages/in_app_purchase/in_app_purchase_platform_interface/test/in_app_purchase_platform_test.dart @@ -119,6 +119,18 @@ void main() { throwsUnimplementedError, ); }); + + test( + 'Default implementation of countryCode should throw unimplemented error', + () { + final ExtendsInAppPurchasePlatform inAppPurchasePlatform = + ExtendsInAppPurchasePlatform(); + + expect( + () => inAppPurchasePlatform.countryCode(), + throwsUnimplementedError, + ); + }); }); group('$InAppPurchasePlatformAddition', () {