-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[in_app_purchase] Implementation of platform interface #3781
Conversation
packages/in_app_purchase/in_app_purchase_platform_interface/CHANGELOG.md
Outdated
Show resolved
Hide resolved
...es/in_app_purchase/in_app_purchase_platform_interface/lib/src/errors/purchase_exception.dart
Outdated
Show resolved
Hide resolved
...es/in_app_purchase/in_app_purchase_platform_interface/lib/src/errors/purchase_exception.dart
Outdated
Show resolved
Hide resolved
.../in_app_purchase/in_app_purchase_platform_interface/lib/src/types/in_app_purchase_error.dart
Outdated
Show resolved
Hide resolved
...in_app_purchase/in_app_purchase_platform_interface/lib/src/types/in_app_purchase_source.dart
Outdated
Show resolved
Hide resolved
packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/types/purchase_status.dart
Outdated
Show resolved
Hide resolved
packages/in_app_purchase/in_app_purchase_platform_interface/pubspec.yaml
Outdated
Show resolved
Hide resolved
...ges/in_app_purchase/in_app_purchase_platform_interface/lib/src/in_app_purchase_platform.dart
Outdated
Show resolved
Hide resolved
...ges/in_app_purchase/in_app_purchase_platform_interface/lib/src/in_app_purchase_platform.dart
Outdated
Show resolved
Hide resolved
...ges/in_app_purchase/in_app_purchase_platform_interface/lib/src/in_app_purchase_platform.dart
Outdated
Show resolved
Hide resolved
9bf96ec
to
208b93d
Compare
...es/in_app_purchase/in_app_purchase_platform_interface/lib/src/errors/purchase_exception.dart
Outdated
Show resolved
Hide resolved
...ges/in_app_purchase/in_app_purchase_platform_interface/lib/src/in_app_purchase_platform.dart
Outdated
Show resolved
Hide resolved
.../in_app_purchase/in_app_purchase_platform_interface/lib/src/types/in_app_purchase_error.dart
Show resolved
Hide resolved
...ges/in_app_purchase/in_app_purchase_platform_interface/lib/src/in_app_purchase_platform.dart
Outdated
Show resolved
Hide resolved
...ges/in_app_purchase/in_app_purchase_platform_interface/lib/src/in_app_purchase_platform.dart
Outdated
Show resolved
Hide resolved
...ges/in_app_purchase/in_app_purchase_platform_interface/lib/src/in_app_purchase_platform.dart
Outdated
Show resolved
Hide resolved
...pp_purchase/in_app_purchase_platform_interface/lib/src/types/purchase_verification_data.dart
Outdated
Show resolved
Hide resolved
...pp_purchase/in_app_purchase_platform_interface/lib/src/types/purchase_verification_data.dart
Outdated
Show resolved
Hide resolved
packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/types/purchase_details.dart
Outdated
Show resolved
Hide resolved
packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/types/purchase_param.dart
Outdated
Show resolved
Hide resolved
packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/types/purchase_status.dart
Outdated
Show resolved
Hide resolved
...pp_purchase/in_app_purchase_platform_interface/lib/src/types/purchase_verification_data.dart
Outdated
Show resolved
Hide resolved
...rchase/in_app_purchase_platform_interface/lib/src/types/query_purchase_details_response.dart
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed offline, we are going to add a InAppPurchaseExtend
and InAppPurchaseExtendProvider
to the platform interface so Platform specific code can extend features.
CC @stuartmorgan @mvanbeusekom
Please comment with better name for these 2 classes if you can think of any :)
/// | ||
/// `autoConsume` is provided as a utility and will instruct the plugin to | ||
/// automatically consume the product after a succesful purchase. | ||
/// `autoConsume` is `true` by default. On iOS comsumable products are |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should remove the iOS related doc here and make sure it is documented in the plugin.
/// * [buyNonConsumable], for buying a non consumable product or | ||
/// subscription. | ||
/// * [restorePurchases], for restoring non consumable products. | ||
/// * [consumePurchase], for manually consuming products on Android. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[consumePurchase] is not part of the platform interface, let's remove this line
How about s/Extend/Additions/ (It would need to be Extension to be the right part of speech, but that's a potentially confusing term given Dart's extension methods) |
3e1c57f
to
3d6e5fe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM % some doc nits
platform-specific behavior, and when you register your plugin, set the default | ||
`InAppPurchasePlatform` by calling | ||
`InAppPurchasePlatform.setInstance(MyPlatformInAppPurchase())`. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's also add doc for how to add additional features in a platform
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
/// The interface that platform implementations must implement when they want to | ||
/// provide platform specific in_app_purchase features. | ||
abstract class InAppPurchaseAddition { | ||
/// The instance containing the platform specific in_app_purchase features. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a code example of how a platform can add "Addition".
Something like:
class InAppPurchaseSomeStoreAddition extends InAppPurchaseAddition {
void someMethod() {}
}
class InAppPurchaseSomeStorePluginWeb {
static void registerWith() {
InAppPurchaseAddition = InAppPurchaseSomePlatformAddition();
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
The publishable check failed due to some tooling bug, which is fixed on master. Rebase should resolve the issue |
69f289f
to
d86ac55
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
We will hold off publishing the platform interface until we integrated with the plugin and made sure everything works. Please keep the "needs-publishing" label on |
* master: (397 commits) [in_app_purchase] Implementation of platform interface (flutter#3781) [google_sign_in] Add todo WRT correctly setting X-Goog-AuthUser header (flutter#3819) [tools] fix version check command not working for new packages (flutter#3818) [camera] android-rework part 1: Base classes to support Android Camera features (flutter#3795) fix MD (flutter#3815) Path provider windows crash fix (flutter#3814) [local_auth] docs update (flutter#3103) Update PULL_REQUEST_TEMPLATE.md (flutter#3801) [quick_actions] handle cold start on iOS correctly (flutter#3811) Replace path_provider_linux widget tests with simple unit tests (flutter#3812) [sensors] format dart code based on the new dart formatter (flutter#3809) [google_sign_in] Fix "pick account" on iOS (flutter#3805) [image_picker_platform_interface] Added pickMultiImage (flutter#3782) [in_app_purchase] Added currency code and numerical price to product detail model. (flutter#3794) [local_auth] Fix iOS crash when no localizedReason (flutter#3780) Fix and update version checks (flutter#3792) [in_app_purchase] Configured example app to use StoreKit Testing on iOS 14 (flutter#3772) [local_auth] Unnecessary reassignment in example removed (flutter#2983) [flutter_webview] Fix `allowsInlineMediaPlayback` ignored on iOS (flutter#3791) Switch script/tools over to the new analysis options (flutter#3777) ...
* master: (79 commits) Fix grammatical error in contributing guide (flutter#3217) [google_sign_in_web] fix README typos. [tool] combine run and runAndExitOnError (flutter#3827) [camera] android-rework part 2: Android auto focus feature (flutter#3796) [in_app_purchase_platform_interface] Added additional fields to ProductDetails (flutter#3826) Move all null safety packages' min dart sdk to 2.12.0 (flutter#3822) [path_provider_*] code cleanup: sort directives (flutter#3823) [in_app_purchase] Implementation of platform interface (flutter#3781) [google_sign_in] Add todo WRT correctly setting X-Goog-AuthUser header (flutter#3819) [tools] fix version check command not working for new packages (flutter#3818) [camera] android-rework part 1: Base classes to support Android Camera features (flutter#3795) fix MD (flutter#3815) Path provider windows crash fix (flutter#3814) [local_auth] docs update (flutter#3103) Update PULL_REQUEST_TEMPLATE.md (flutter#3801) [quick_actions] handle cold start on iOS correctly (flutter#3811) Replace path_provider_linux widget tests with simple unit tests (flutter#3812) [sensors] format dart code based on the new dart formatter (flutter#3809) [google_sign_in] Fix "pick account" on iOS (flutter#3805) [image_picker_platform_interface] Added pickMultiImage (flutter#3782) ...
* upstream/master: (383 commits) Add implement and registerWith method to plugins (flutter#3833) Update third_party license checking (flutter#3844) [tool] add `all` and `dry-run` flags to publish-plugin command (flutter#3776) Re-add bin/ to flutter_plugin_tools (flutter#3839) switch from using 'tuneup' to analyze to 'dart analyze' (flutter#3837) [in_app_purchase] Federated iOS implementation (flutter#3832) Prep the tools for publishing (flutter#3836) [in_app_purchase] Make PurchaseDetails.status mandatory (flutter#3831) Fix grammatical error in contributing guide (flutter#3217) [google_sign_in_web] fix README typos. [tool] combine run and runAndExitOnError (flutter#3827) [camera] android-rework part 2: Android auto focus feature (flutter#3796) [in_app_purchase_platform_interface] Added additional fields to ProductDetails (flutter#3826) Move all null safety packages' min dart sdk to 2.12.0 (flutter#3822) [path_provider_*] code cleanup: sort directives (flutter#3823) [in_app_purchase] Implementation of platform interface (flutter#3781) [google_sign_in] Add todo WRT correctly setting X-Goog-AuthUser header (flutter#3819) [tools] fix version check command not working for new packages (flutter#3818) [camera] android-rework part 1: Base classes to support Android Camera features (flutter#3795) fix MD (flutter#3815) ...
Defines a common platform interface for the in_app_purchase plugin.
in_app_platform_interface
section of issue [in_app_purchase] Migrate plugin to federated architecture flutter#78525NOTE:
As part of the
in_app_purchase_platform_interface
we will be replacing the following methods:Future<BillingResultWrapper> completePurchase(PurchaseDetails)
method is replaced by theFuture<void> finishPurchase(PurchaseDetails)
method. The newfinishPurchase
method will no longer return the Android specificBillingResultWrapper
, instead it will complete the future successfully if thefinishPurchase
executed successfully or throw an instance of thePurchaseException
when an error occurred. ThePurchaseException
should be implemented per platform to indicate if developers should retry based on platform specific error codes;Future<QueryPurchaseDetailsResponse> queryPastPurchases({String? applicationUserName})
method is replaced by theFuture<void> restorePurchases({String? applicationUserName})
method. The newrestorePurchases
will no longer return a list of restored purchases but instead emits each purchase on the newpurchaseStream
with the specificPurchaseStatus.restored
status;Stream<List<PurchaseDetails>> get purchaseUpdatedStream
is replaced by theStream<List<PurchaseDetails>> get purchaseStream
property. The newpurchaseStream
should no longer filter out purchases with thePurchaseStatus.restored
status, but instead emit those as well, giving developers the change to validate the receipt, deliver the content and finish the purchase correctly.The existing Android and iOS implementations should mark the above methods as deprecated and should provide implementation for the new methods.
If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.
Pre-launch Checklist
[shared_preferences]
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.