diff --git a/packages/in_app_purchase/in_app_purchase/CHANGELOG.md b/packages/in_app_purchase/in_app_purchase/CHANGELOG.md index 728a85ebf487..2cd388006e8f 100644 --- a/packages/in_app_purchase/in_app_purchase/CHANGELOG.md +++ b/packages/in_app_purchase/in_app_purchase/CHANGELOG.md @@ -1,5 +1,6 @@ -## NEXT +## 3.2.0 +* Adds `countryCode` API. * Updates minimum supported SDK version to Flutter 3.13/Dart 3.1. * Updates support matrix in README to indicate that iOS 11 is no longer supported. * Clients on versions of Flutter that still support iOS 11 can continue to use this diff --git a/packages/in_app_purchase/in_app_purchase/lib/in_app_purchase.dart b/packages/in_app_purchase/in_app_purchase/lib/in_app_purchase.dart index c7a48b48dc22..1cb3beda4e1f 100644 --- a/packages/in_app_purchase/in_app_purchase/lib/in_app_purchase.dart +++ b/packages/in_app_purchase/in_app_purchase/lib/in_app_purchase.dart @@ -209,4 +209,20 @@ class InAppPurchase implements InAppPurchasePlatformAdditionProvider { InAppPurchasePlatform.instance.restorePurchases( applicationUserName: applicationUserName, ); + + /// 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() => InAppPurchasePlatform.instance.countryCode(); } diff --git a/packages/in_app_purchase/in_app_purchase/pubspec.yaml b/packages/in_app_purchase/in_app_purchase/pubspec.yaml index 2d5d3624ab72..3f31fcd2e414 100644 --- a/packages/in_app_purchase/in_app_purchase/pubspec.yaml +++ b/packages/in_app_purchase/in_app_purchase/pubspec.yaml @@ -2,11 +2,11 @@ name: in_app_purchase description: A Flutter plugin for in-app purchases. Exposes APIs for making in-app purchases through the App Store and Google Play. repository: https://github.com/flutter/packages/tree/main/packages/in_app_purchase/in_app_purchase issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+in_app_purchase%22 -version: 3.1.13 +version: 3.2.0 environment: - sdk: ^3.1.0 - flutter: ">=3.13.0" + sdk: ^3.2.3 + flutter: ">=3.16.6" flutter: plugin: @@ -21,9 +21,9 @@ flutter: dependencies: flutter: sdk: flutter - in_app_purchase_android: ^0.3.0 - in_app_purchase_platform_interface: ^1.0.0 - in_app_purchase_storekit: ^0.3.4 + in_app_purchase_android: ^0.3.4 + in_app_purchase_platform_interface: ^1.4.0 + in_app_purchase_storekit: ^0.3.14 dev_dependencies: flutter_test: diff --git a/packages/in_app_purchase/in_app_purchase/test/in_app_purchase_test.dart b/packages/in_app_purchase/in_app_purchase/test/in_app_purchase_test.dart index 58f7398add16..c4ed81988991 100644 --- a/packages/in_app_purchase/in_app_purchase/test/in_app_purchase_test.dart +++ b/packages/in_app_purchase/in_app_purchase/test/in_app_purchase_test.dart @@ -55,6 +55,14 @@ void main() { ]); }); + test('countryCode', () async { + final String country = await inAppPurchase.countryCode(); + expect(country, 'USA'); + expect(fakePlatform.log, [ + isMethodCall('countryCode', arguments: null), + ]); + }); + test('purchaseStream', () async { final bool isEmptyStream = await inAppPurchase.purchaseStream.isEmpty; expect(isEmptyStream, true); @@ -192,4 +200,10 @@ class MockInAppPurchasePlatform extends Fake log.add(const MethodCall('restorePurchases')); return Future.value(); } + + @override + Future countryCode() { + log.add(const MethodCall('countryCode')); + return Future.value('USA'); + } }