Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[in_app_purchase] implement countryCode correctly #6636

Merged
merged 3 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.3.5

* Replaces `getCountryCode` with `countryCode`.

## 0.3.4+1

* Adds documentation for UserChoice and Alternative Billing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,14 @@ class InAppPurchaseAndroidPlatform extends InAppPurchasePlatform {
///
/// 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
Future<String> getCountryCode() async {
@override
Future<String> countryCode() async {
final BillingConfigWrapper billingConfig = await billingClientManager
.runWithClient((BillingClient client) => client.getBillingConfig());
return billingConfig.countryCode;
}

/// Use countryCode instead.
@Deprecated('Use countryCode')
Future<String> getCountryCode() => countryCode();
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: in_app_purchase_android
description: An implementation for the Android platform of the Flutter `in_app_purchase` plugin. This uses the Android BillingClient APIs.
repository: https://github.com/flutter/packages/tree/main/packages/in_app_purchase/in_app_purchase_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+in_app_purchase%22
version: 0.3.4+1
version: 0.3.5

environment:
sdk: ^3.1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -760,9 +760,12 @@ void main() {

when(mockApi.getBillingConfigAsync())
.thenAnswer((_) async => platformBillingConfigFromWrapper(expected));
final String countryCode = await iapAndroidPlatform.getCountryCode();
final String countryCode = await iapAndroidPlatform.countryCode();

expect(countryCode, equals(expectedCountryCode));
// Ensure deprecated code keeps working until removed.
expect(await iapAndroidPlatform.getCountryCode(),
equals(expectedCountryCode));
});
});
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.3.15

* Replaces `getCountryCode` with `countryCode`.

## 0.3.14

* Adds `countryCode` API.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,14 @@ class InAppPurchaseStoreKitPlatform extends InAppPurchasePlatform {
///
/// Uses the ISO 3166-1 Alpha-3 country code representation.
/// See: https://developer.apple.com/documentation/storekit/skstorefront?language=objc
Future<String?> getCountryCode() async {
return (await _skPaymentQueueWrapper.storefront())?.countryCode;
@override
Future<String> countryCode() async {
return (await _skPaymentQueueWrapper.storefront())?.countryCode ?? '';
}

/// Use countryCode instead.
@Deprecated('Use countryCode')
Future<String?> getCountryCode() => countryCode();
}

enum _TransactionRestoreState {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: in_app_purchase_storekit
description: An implementation for the iOS and macOS platforms of the Flutter `in_app_purchase` plugin. This uses the StoreKit Framework.
repository: https://github.com/flutter/packages/tree/main/packages/in_app_purchase/in_app_purchase_storekit
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+in_app_purchase%22
version: 0.3.14
version: 0.3.15

environment:
sdk: ^3.2.3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -576,8 +576,10 @@ void main() {
const String expectedCountryCode = 'CA';
fakeStoreKitPlatform.setStoreFrontInfo(
countryCode: expectedCountryCode, identifier: 'ABC');
final String? countryCode = await iapStoreKitPlatform.getCountryCode();
final String countryCode = await iapStoreKitPlatform.countryCode();
expect(countryCode, expectedCountryCode);
// Ensure deprecated code keeps working until removed.
expect(await iapStoreKitPlatform.countryCode(), expectedCountryCode);
});
});
}