-
Notifications
You must be signed in to change notification settings - Fork 69
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
Fix QIT warning in WooPay session endpoint #8760
Conversation
Test the buildOption 1. Jetpack Beta
Option 2. Jurassic Ninja - available for logged-in A12s🚀 Launch a JN site with this branch 🚀 ℹ️ Install this Tampermonkey script to get more options. Build info:
Note: the build is updated when a new commit is pushed to this PR. |
Size Change: 0 B Total Size: 1.25 MB ℹ️ View Unchanged
|
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 was able to test this in a few ways and confirmed that it all worked as expected. Some of the ways I tested this:
- Confirmed that adding the URL to the woopay session list allowed it to process the
determine_current_user_for_woopay
using the Cart Token. - Confirmed that within
get_init_session_request
the same$customer_id
was returned for each session through multiple attempts as well as through using Direct Checkout, Express Checkout, or OTP modal. - Confirmed that when testing from the sandbox the
has_valid_request_signature
was properly verifying or failing the requests.
This seems like a strong move to centralize this logic in one place and removes the warning about a dangerous function and instead uses the more recommended determine_current_user
filter.
Overall, everything tested well for me. I had one note about redundancy that you can share your opinion on, but it's not a blocker in my opinion.
@@ -89,31 +78,6 @@ public function check_permission() { | |||
return $this->is_request_from_woopay() && $this->has_valid_request_signature(); |
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.
These checks are redundant now, but considering leaving them in as they are low-cost and would prevent accidentally removing them from another place and leaving this open. It also satisfies the goal of having defined check permissions. Let me know what you think though about this redundancy?
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 agree with everything you said. This is now redundant, but better be redundant and safe than taking an unnecessary risk of leaving it open, especially with this redundancy being low-cost.
Fixes #8732.
Changes proposed in this Pull Request
This PR tweaks the WooPay session REST endpoint by replacing a
wp_set_current_user
approach with an existent approach designed specifically for WooPay.Testing instructions
Pre-requisites
npm run wp option update _wcpay_feature_woopay_direct_checkout 1
.Test: current approach to note current user and customer
develop
branch.2.1. Alternatively, you can comment this line. But if you're going down this path you'll need to build the assets:
npm run build:client
.Test: determine current user approach works as expected
2.1. Alternatively, you can comment this line. But if you're going down this path you'll need to build the assets:
npm run build:client
.Test: QIT warning has been fixed
npm run test:qit
.class-wc-rest-woopay-session-controller.php
#8732 is gone.npm run changelog
to add a changelog file, choosepatch
to leave it empty if the change is not significant. You can add multiple changelog files in one PR by running this command a few times.Post merge