Allow Cart-Session to Update the ec_token#4136
Closed
mmaymo wants to merge 7 commits into
Closed
Conversation
danieldudzic
reviewed
Mar 5, 2026
|
|
||
| use WooCommerce\PayPalCommerce\StoreSync\Schema\PayPalCart; | ||
|
|
||
| class UpdatedCartWithTokenResponse extends CartResponse { |
Collaborator
There was a problem hiding this comment.
There seems to be a filename typo — UpdatedCartWithTokenRespones.php instead of UpdatedCartWithTokenRespone.php.
danieldudzic
reviewed
Mar 5, 2026
danieldudzic
requested changes
Mar 5, 2026
danieldudzic
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for working on this! Just a few points to address, and should be good to go 🙌
Co-authored-by: Danny Dudzic <d.dudzic@syde.com>
Co-authored-by: Danny Dudzic <d.dudzic@syde.com>
mmaymo
marked this pull request as ready for review
April 29, 2026 10:50
mmaymo
requested review from
AlexP11223,
Dinamiko,
Narek13,
hmouhtar and
stracker-phil
as code owners
April 29, 2026 10:50
danieldudzic
requested changes
Apr 30, 2026
danieldudzic
left a comment
Collaborator
There was a problem hiding this comment.
@mmaymo Thanks for working on this. We need just one more change, I think.
Co-authored-by: Danny Dudzic <d.dudzic@syde.com>
…-session-to-update-the-ec-oken
Collaborator
|
I had to rewrite this PR (actually Claude did) as this PR had a significant drift from the epic code already. Thanks for the research and PR, it was very helpful to understand the problem and re-apply it to the current epic code! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Allow PUT /merchant-cart/{id} to create PayPal orders when needed
Per PayPal spec, the PUT endpoint can create a new ec_token when the cart doesn't have one (e.g., POST validation failed) or the existing token expired.
update_cart_session() now accepts optional $ec_token parameter. When provided, replaces stored token; when null, preserves existing.
ReplaceCartEndpoint checks if cart needs a new token (empty or expired) and calls order_manager->create_order() if the cart is valid. New token is passed to session handler and included in response.
Added UpdatedCartWithTokenResponse for PUT responses that include a new token. payment_method.token is only present in response when a new token was actually created.
Files:
AgenticSessionHandler.php - optional $ec_token param
AgenticRestEndpoint.php - pass token through store_local_cart()
ReplaceCartEndpoint.php - token creation logic
ResponseFactory.php - new cart_with_token() method
UpdatedCartWithTokenResponse.php - new response class
Behavior:
POST with invalid items → no token created
PUT to fix items → token created, included in response
PUT on cart with valid token → token preserved, not in response
Checkout → only reads existing token, never creates