[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.
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.
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.
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.
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.
I think the style guide might be wrong now that we use dart format.
|
cc @LongCatIsLooong for the next step from triage meeting. |
2436de0 to
45cf639
Compare
This comment was marked as spam.
This comment was marked as spam.
|
cc @LouiseHsu from triage meeting |
…ansaction is pending / cancelled / unverified (flutter/packages#9627)
flutter/packages@34eec78...287739d 2025-09-29 engine-flutter-autoroll@skia.org Roll Flutter (stable) from d693b4b to ac4e799 (4 revisions) (flutter/packages#10124) 2025-09-29 magder@google.com Fix CODEOWNERS error (flutter/packages#10127) 2025-09-29 stuartmorgan@google.com [file_selector] Update Pigeon in Android implementation (flutter/packages#10126) 2025-09-29 31859944+LongCatIsLooong@users.noreply.github.com [In_app_purchase_storekit] Do not throw PigeonError when a transaction is pending / cancelled / unverified (flutter/packages#9627) 2025-09-29 stuartmorgan@google.com [video_player] Separate texture ID on Android (flutter/packages#10029) 2025-09-29 engine-flutter-autoroll@skia.org Roll Flutter from 6cc976e to 96fe3b3 (32 revisions) (flutter/packages#10125) 2025-09-29 43054281+camsim99@users.noreply.github.com [camera_android_camerax] Fix NV21 Format (flutter/packages#10022) 2025-09-29 engine-flutter-autoroll@skia.org Manual roll Flutter from b1a28bc to 6cc976e (4 revisions) (flutter/packages#10116) 2025-09-29 robert.odrowaz@leancode.pl [camera_avfoundation] Implementation swift migration - part 13 (flutter/packages#9930) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC flutter-ecosystem@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
flutter/packages@34eec78...287739d 2025-09-29 engine-flutter-autoroll@skia.org Roll Flutter (stable) from d693b4b to ac4e799 (4 revisions) (flutter/packages#10124) 2025-09-29 magder@google.com Fix CODEOWNERS error (flutter/packages#10127) 2025-09-29 stuartmorgan@google.com [file_selector] Update Pigeon in Android implementation (flutter/packages#10126) 2025-09-29 31859944+LongCatIsLooong@users.noreply.github.com [In_app_purchase_storekit] Do not throw PigeonError when a transaction is pending / cancelled / unverified (flutter/packages#9627) 2025-09-29 stuartmorgan@google.com [video_player] Separate texture ID on Android (flutter/packages#10029) 2025-09-29 engine-flutter-autoroll@skia.org Roll Flutter from 6cc976e to 96fe3b3 (32 revisions) (flutter/packages#10125) 2025-09-29 43054281+camsim99@users.noreply.github.com [camera_android_camerax] Fix NV21 Format (flutter/packages#10022) 2025-09-29 engine-flutter-autoroll@skia.org Manual roll Flutter from b1a28bc to 6cc976e (4 revisions) (flutter/packages#10116) 2025-09-29 robert.odrowaz@leancode.pl [camera_avfoundation] Implementation swift migration - part 13 (flutter/packages#9930) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC flutter-ecosystem@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
| details: "Product ID : \(id)"))) | ||
| sendTransactionUpdate( | ||
| transaction: verification.unsafePayloadValue, receipt: verification.jwsRepresentation) | ||
| case .pending, .userCancelled: |
There was a problem hiding this comment.
Both the pending and userCancelled states should be communicated to the upper layer via either the buyXXX method or the purchaseStream.
There was a problem hiding this comment.
await SK2Product.purchase(
purchaseParam.productDetails.id,
options: options,
);
// The result is ignored(maybe pending/userCanceled)!
return true;
flutter/packages@34eec78...287739d 2025-09-29 engine-flutter-autoroll@skia.org Roll Flutter (stable) from d693b4b to ac4e799 (4 revisions) (flutter/packages#10124) 2025-09-29 magder@google.com Fix CODEOWNERS error (flutter/packages#10127) 2025-09-29 stuartmorgan@google.com [file_selector] Update Pigeon in Android implementation (flutter/packages#10126) 2025-09-29 31859944+LongCatIsLooong@users.noreply.github.com [In_app_purchase_storekit] Do not throw PigeonError when a transaction is pending / cancelled / unverified (flutter/packages#9627) 2025-09-29 stuartmorgan@google.com [video_player] Separate texture ID on Android (flutter/packages#10029) 2025-09-29 engine-flutter-autoroll@skia.org Roll Flutter from 6cc976e to 96fe3b3 (32 revisions) (flutter/packages#10125) 2025-09-29 43054281+camsim99@users.noreply.github.com [camera_android_camerax] Fix NV21 Format (flutter/packages#10022) 2025-09-29 engine-flutter-autoroll@skia.org Manual roll Flutter from b1a28bc to 6cc976e (4 revisions) (flutter/packages#10116) 2025-09-29 robert.odrowaz@leancode.pl [camera_avfoundation] Implementation swift migration - part 13 (flutter/packages#9930) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC flutter-ecosystem@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Fixes flutter/flutter#169524
Pre-Review Checklist
[shared_preferences]pubspec.yamlwith 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.mdto 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