-
Notifications
You must be signed in to change notification settings - Fork 10.8k
WPS Migration: Authorize payment #60044
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
WPS Migration: Authorize payment #60044
Conversation
Testing GuidelinesHi @annemirasol , Apart from reviewing the code changes, please make sure to review the testing instructions (Guide) and verify that relevant tests (E2E, Unit, Integration, etc.) have been added or updated as needed. Reminder: PR reviewers are required to document testing performed. This includes:
|
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.
Pull Request Overview
This PR implements authorization support for PayPal Orders v2 API, allowing merchants to authorize payments instead of immediately capturing them. The key change enables a two-step payment flow where orders are initially authorized and later captured when the merchant changes the order status.
- Adds new REST API endpoints for payment authorization and capturing authorized payments
- Implements webhook handling for
PAYMENT.AUTHORIZATION.CREATED
events - Modifies the payment flow to support both authorize and capture actions based on payment intent
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
class-wc-rest-paypal-webhooks-proxy-controller.php | Adds webhook forwarding for PAYMENT.AUTHORIZATION.CREATED events |
class-wc-rest-paypal-proxy-controller.php | Implements new endpoints for authorizing payments and capturing authorized payments |
class-wc-gateway-paypal-webhook-handler.php | Adds processing logic for authorization webhooks and updates payment flow to handle both authorize/capture actions |
class-wc-gateway-paypal-request.php | Refactors payment processing to support both authorization and capture, adds method to capture previously authorized payments |
class-wc-gateway-paypal.php | Updates the capture payment method to use Orders v2 API when enabled |
...woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-paypal-proxy-controller.php
Outdated
Show resolved
Hide resolved
...woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-paypal-proxy-controller.php
Outdated
Show resolved
Hide resolved
plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-request.php
Outdated
Show resolved
Hide resolved
...ns/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-webhook-handler.php
Outdated
Show resolved
Hide resolved
Test using WordPress PlaygroundThe changes in this pull request can be previewed and tested using a WordPress Playground instance. Test this pull request with WordPress Playground. Note that this URL is valid for 30 days from when this comment was last updated. You can update it by closing/reopening the PR or pushing a new commit. |
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.
Not necessarily blocking -- we can choose to tackle in a follow-up -- but for delayed capture I am getting the following log entry twice, when I manually capture the payment (by setting it to Processing). The payment gets captured successfully though.
[28-Jul-2025 21:32:35 UTC] (Proxy) PayPal capture authorized payment response: Array
(
[name] => UNPROCESSABLE_ENTITY
[message] => The requested action could not be performed, semantically incorrect, or failed business validation.
[debug_id] => f678251ca5471
[details] => Array
(
[0] => Array
(
[issue] => AUTHORIZATION_ALREADY_CAPTURED
[description] => Authorization has already been captured.
)
)
[links] => Array
(
[0] => Array
(
[href] => https://developer.paypal.com/docs/api/payments/v2/#error-AUTHORIZATION_ALREADY_CAPTURED
[rel] => information_link
[encType] => application/json
)
)
)
...ns/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-webhook-handler.php
Outdated
Show resolved
Hide resolved
It doesn't work for me either, and I don't see the "capture" event in my developer dashboard. I suggest we document and ask our integration engineer. |
Sorry, I introduced some bad formatting when I merged in the testmode PR. |
Hi @Mayisha! Your PR contains REST API changes. Please consider updating the REST API documentation if your changes affect the public API. Changed API files:
|
Submission Review Guidelines:
Changes proposed in this Pull Request:
Payment action
is set toAuthorize
, we will send a request to theauthorize_url
instead ofcapture_url
which is received in theCHECKOUT.ORDER.APPROVED
webhook event.on-hold
.on-hold
toprocessing
orcompleted
. The same has been implemented for the new flow.PAYMENT.CAPTURE.COMPLETED
webhook which is already covered in the code.Closes PAYPAL-48
Screenshots or screen recordings:
How to test the changes in this Pull Request:
Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:
on-hold
.Authorized
.processing
.Authorized
.Note
PAYMENT.CAPTURE.COMPLETED
webhook, which is already covered in the code.Changelog entry
Changelog Entry Details
Significance
Type
Message
Changelog Entry Comment
Comment