-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[in_app_purchase_storekit] Add Transaction.unfinished API and expose appAccountToken #10439
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] Add Transaction.unfinished API and expose appAccountToken #10439
Conversation
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 introduces two new features from StoreKit 2: the unfinishedTransactions() API and the exposure of appAccountToken on purchase details. The changes are additive, well-implemented, and follow the existing architecture. The implementation correctly spans native Swift code, pigeon interface updates, and Dart-side wrappers, complete with corresponding unit tests. This is a solid contribution that enhances the plugin's capabilities.
| @MainActor in | ||
| do { | ||
| let transactionsMsgs = await rawUnfinishedTransactions().map { | ||
| $0.convertToPigeon(receipt: nil) | ||
| } | ||
| completion(.success(transactionsMsgs)) | ||
| } |
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.
The do block is unnecessary here because rawUnfinishedTransactions() is a non-throwing function. While it doesn't cause a bug in this case, it's a good practice to avoid do-catch structures when no errors can be thrown and caught. If rawUnfinishedTransactions were to throw, the lack of a catch block would prevent the completion handler from being called on an error path. Removing the do block simplifies the code and makes it more robust.
@MainActor in
let transactionsMsgs = await rawUnfinishedTransactions().map {
$0.convertToPigeon(receipt: nil)
}
completion(.success(transactionsMsgs))|
This also partially solves #165355 |
…aseDetails This PR adds two new features to in_app_purchase_storekit for StoreKit 2: 1. SK2Transaction.unfinishedTransactions() - Queries only unfinished transactions, mirroring Apple's Transaction.unfinished API for better performance. 2. SK2PurchaseDetails.appAccountToken - Exposes the UUID that associates transactions with users in custom backend systems. Both features are additive and maintain full backward compatibility. Tests included for both features.
Previously returned nil for receipt data, now properly includes jwsRepresentation for server-side verification.
dabe171 to
fa16cac
Compare
Summary
Adds two new StoreKit 2 features to
in_app_purchase_storekit:SK2Transaction.unfinishedTransactions()- Queries only unfinished transactions for better performanceSK2PurchaseDetails.appAccountToken- Exposes user UUID for backend integrationMotivation
Transaction.unfinishedAPI.appAccountTokenalready exists when making purchases, but reading it back from transaction details was missing.Changes
unfinishedTransactions()Transaction.unfinishedAPIappAccountTokenproperty inSK2PurchaseDetailsBreaking Changes
None. Both features are additive and maintain full backward compatibility.