-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[in_app_purchase] Add play country code api #5941
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
Merged
auto-submit
merged 25 commits into
flutter:main
from
reidbaker:i141627-country-code-api
Jan 31, 2024
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
5be7c0a
Intial add of country code, no tests
reidbaker 5d6f1cc
Add tests for getBillingConfig
reidbaker e19b644
Formating
reidbaker 3f5a4e3
Manipulate data in translator class instead of impl
reidbaker 337a7d7
Add dart side code to call getBillingConfig and conversion tests
reidbaker 99af529
Correct null test to include empty country code, fix non null billing…
reidbaker fdc42cd
move buildBillingConfigMap to the class that uses it
reidbaker 88ccd2a
Merge branch 'main' into i141627-country-code-api
reidbaker 036e2f2
Write documentation and remove todos, remove unused import
reidbaker 91950f3
Analyzer warnings
reidbaker 7d4af42
Merge branch 'main' into i141627-country-code-api
reidbaker 5cd0acb
java format warnings
reidbaker 894473c
Version code change
reidbaker e33f22c
Restore in app purchase instructions in example readme from bad PR ht…
reidbaker 1dc004b
Update packages/in_app_purchase/in_app_purchase_android/android/src/m…
reidbaker 319ffe7
Add example app code that shows country code in UI rename addition ap…
reidbaker 28e95ad
Remove "Demonstrates how to use" verbiage since that is confusing whi…
reidbaker 3c263a8
Merge branch 'main' into i141627-country-code-api
reidbaker 4cd74ec
Merge branch 'main' into i141627-country-code-api
reidbaker d7934fc
Remove changes to ios readme
reidbaker 5252d6e
Readme link to signing docs and changelog verbiage update
reidbaker 5e363fc
Restore getCountryCode tests
reidbaker 62477c4
Use run with client since BillingConfigWrapper uses a billing result
reidbaker a514dc1
Merge branch 'main' into i141627-country-code-api
reidbaker f047aac
Use run with client since BillingConfigWrapper uses a billing result
reidbaker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
...chase/in_app_purchase_android/lib/src/billing_client_wrappers/billing_config_wrapper.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:json_annotation/json_annotation.dart'; | ||
|
||
import '../../billing_client_wrappers.dart'; | ||
|
||
// WARNING: Changes to `@JsonSerializable` classes need to be reflected in the | ||
// below generated file. Run `flutter packages pub run build_runner watch` to | ||
// rebuild and watch for further changes. | ||
part 'billing_config_wrapper.g.dart'; | ||
|
||
/// The error message shown when the map represents billing config is invalid from method channel. | ||
/// | ||
/// This usually indicates a serious underlining code issue in the plugin. | ||
@visibleForTesting | ||
const String kInvalidBillingConfigErrorMessage = | ||
'Invalid billing config map from method channel.'; | ||
|
||
/// Params containing the response code and the debug message from the Play Billing API response. | ||
@JsonSerializable() | ||
@BillingResponseConverter() | ||
@immutable | ||
class BillingConfigWrapper implements HasBillingResponse { | ||
/// Constructs the object with [responseCode] and [debugMessage]. | ||
const BillingConfigWrapper( | ||
{required this.responseCode, this.debugMessage, this.countryCode = ''}); | ||
|
||
/// Constructs an instance of this from a key value map of data. | ||
/// | ||
/// The map needs to have named string keys with values matching the names and | ||
/// types of all of the members on this class. | ||
factory BillingConfigWrapper.fromJson(Map<String, dynamic>? map) { | ||
if (map == null || map.isEmpty) { | ||
return const BillingConfigWrapper( | ||
responseCode: BillingResponse.error, | ||
debugMessage: kInvalidBillingConfigErrorMessage, | ||
); | ||
} | ||
return _$BillingConfigWrapperFromJson(map); | ||
} | ||
|
||
/// Response code returned in the Play Billing API calls. | ||
@override | ||
final BillingResponse responseCode; | ||
|
||
/// Debug message returned in the Play Billing API calls. | ||
/// | ||
/// Defaults to `null`. | ||
/// This message uses an en-US locale and should not be shown to users. | ||
@JsonKey(defaultValue: '') | ||
final String? debugMessage; | ||
|
||
/// https://developer.android.com/reference/com/android/billingclient/api/BillingConfig#getCountryCode() | ||
@JsonKey(defaultValue: '') | ||
final String countryCode; | ||
|
||
@override | ||
bool operator ==(Object other) { | ||
if (other.runtimeType != runtimeType) { | ||
return false; | ||
} | ||
|
||
return other is BillingConfigWrapper && | ||
other.responseCode == responseCode && | ||
other.debugMessage == debugMessage && | ||
other.countryCode == countryCode; | ||
} | ||
|
||
@override | ||
int get hashCode => Object.hash(responseCode, debugMessage, countryCode); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.