-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[In_app_purchase_storekit] Do not throw PigeonError when a transaction is pending / cancelled / unverified #9627
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
base: main
Are you sure you want to change the base?
[In_app_purchase_storekit] Do not throw PigeonError when a transaction is pending / cancelled / unverified #9627
Conversation
message: "This transaction has been cancelled by the user.", | ||
details: "Product ID : \(id)"))) | ||
sendTransactionUpdate( | ||
transaction: verification.unsafePayloadValue, receipt: verification.jwsRepresentation) |
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.
According to the documentation unsafe
seems to mean that the transaction is potentially unverified.
/gemini review |
(Don't mind me, just testing out the newly enabled review bot on some of our open PRs to see how it does 🙂) |
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.
Code Review
This pull request modifies the in_app_purchase_storekit plugin to handle pending, cancelled, and unverified transactions without throwing PigeonErrors. It introduces a new unverified
case to the SK2ProductPurchaseResult
enum and updates the StoreKit2 implementation to return the corresponding SK2ProductPurchaseResult
in these scenarios.
static Future<bool> isIntroductoryOfferEligible(String productId) async { | ||
final bool result = await _hostApi.isIntroductoryOfferEligible(productId); | ||
|
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.
This function can be simplified for improved conciseness. The intermediate result
variable is unnecessary; the Future
from the _hostApi
call can be returned directly using Dart's arrow syntax (=>
).
static Future<bool> isIntroductoryOfferEligible(String productId) =>
_hostApi.isIntroductoryOfferEligible(productId);
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 can eliminate the unnecessary result
, but using =>
here would violate https://github.com/flutter/flutter/blob/master/docs/contributing/Style-guide-for-Flutter-repo.md#consider-using--for-short-functions-and-methods
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.
I think the style guide might be wrong now that we use dart format.
Fixes flutter/flutter#169524
Pre-Review Checklist
[shared_preferences]
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or I have commented below to indicate which version change exemption this PR falls under1.CHANGELOG.md
to add a description of the change, following repository CHANGELOG style, or I have commented below to indicate which CHANGELOG exemption this PR falls under1.///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.
Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2 ↩3