-
Notifications
You must be signed in to change notification settings - Fork 121
[In-app Purchases] Improve transaction handling logic #8124
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
Conversation
You can test the changes from this Pull Request by:
|
|
Code looks good and tests well, just a small question there. |
| do { | ||
| try await self?.handleCompletedTransaction(result) | ||
| // Wait until the purchase finishes | ||
| _ = await self.pauseTransactionListener.values.contains(false) |
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.
With this approach it can happen that we handle the same transaction twice right, sending a duplicated order? Even if the backend ignores duplicated requests, it would be nice to prevent sending the same requests twice.
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 that is fine. Since we aren't using the App Store Server API v2 yet, we aren't really sending "a transaction" to the API. We send the app receipt, which might not have even changed between requests, and use Apple's verifyReceipt endpoint response to get the list of transactions.
I think dealing with potential duplicate requests is something we need to live with, and this PR doesn't change that. It only ensures that if a duplicate transaction happens, it happens in the right order.
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.
Thanks for your answer @koke. It's a pity that we cannot prevent at the moment sending duplicate requests in a simple way for now, but we can live with that.
|
Looks good to me and tests well, only that comment that we talked about. Thanks for this @koke! Now the whole implementation is much more robust 🎉 |
Closes: #8121
Description
This PR intends to improve some of the transaction handling logic:
product_purchasederror, it means that we have already sent that transaction before and there's an order for it. So now we treat this case as a success instead of a failureTesting instructions
Pausing transaction listenerandResuming transaction listenermessages in the console while the purchase is happeningSending transaction to APImessage in the console followed byExisting order found for transaction ##### on site #####, ignoring. The app should show no alert with an error (unless the API call failed for another reason)RELEASE-NOTES.txtif necessary.