Skip to content

WPS Migration: address settings parity - #60017

Merged
Mayisha merged 6 commits into
feature/paypal-wps-migrationfrom
task/paypal-address-parity
Jul 28, 2025
Merged

Mayisha merged 6 commits into
feature/paypal-wps-migrationfrom
task/paypal-address-parity

Conversation

@Mayisha

@Mayisha Mayisha commented Jul 25, 2025 •

Copy link
Copy Markdown
Contributor

Submission Review Guidelines:

Changes proposed in this Pull Request:

This PR achieves feature parity for Shipping Details and Address Override options in the PayPal settings page.

Shipping Details: If this box is checked (yes) we send the shipping address to PayPal, otherwise we send the billing address
Address override: If this box is checked (yes), address sent from the merchant site is used as the shipping address. Shopper can not select another address from the PP modal.

Towards PAYPAL-46

How to test the changes in this Pull Request:

Basic setup

  1. You will need a Business sandbox account (merchant) and a Personal sandbox account (shopper).
  2. Set the deprecated PayPal gateway feature flag, and set the Orders v2 migration flag:
wp option patch update woocommerce_paypal_settings _should_load 'yes'
wp option patch update woocommerce_paypal_settings use_orders_v2 'yes'
  1. Go to WooCommerce > Settings > Payments > and enable PayPal Standard.
  2. Configure PayPal Standard's settings:
  • For PayPal email, enter your merchant sandbox account email.
  • Check Enable PayPal sandbox
  • Check Enable logging (optional, for logging)
  • For Payment action, select Capture
  1. To enable end-to-end testing, add the PayPal API client and secret (used by the feature branch's test proxy):
wp option update wc_paypal_api_client_id <YOUR-PAYPAL-CLIENT>
wp option update wc_paypal_api_client_secret <YOUR-PAYPAL-CLIENT-SECRET>

Testing the changes

  1. As an admin, go to WooCommerce > Settings > Payments > and enable PayPal Standard.
  2. Test this branch with different values of Shipping details and Address override. Following is a table of expected behavior based on the current behavior in WPS.
Shipping Details Address Override Address displayed on the modal Can Change Address on modal Address in PP Transaction
yes no Shipping adress from WC checkout page. Yes, can choose a different address Same one from the modal
yes yes Shipping adress from WC checkout page. No Same one from the modal
no yes Billing adress from WC checkout page. No Same one from the modal
no no Billing adress from WC checkout page. Yes, can choose a different address Same one from the modal
  1. As a shopper, add a product to cart and go to checkout.
  2. You should see PayPal as a payment option.
  3. Click "Proceed to PayPal".
  4. Use your Personal sandbox account credentials to log in and check the modal.
  5. Confirm that the shipping address matches the above table.
  6. Click to pay. You should get redirected to the "Order Confirmation" page.
  7. Wait a few seconds, and go to the wp-admin order page.
  8. In the order details section, the transaction ID should be linked.
  9. Click the transaction ID. It should take you to the PayPal transaction page.
  10. Check the shipping address. It should match what you finally selected on the modal.

Note If you change and select a different shipping address on the PP modal, it does not reflect on the store order. The WC order still shows the shipping address from the checkout page. Though this is also the current behavior in legacy, we should fix it at some point.

Testing that has already taken place:

Changelog entry

  • Automatically create a changelog entry from the details below.
  • This Pull Request does not require a changelog entry. (Comment required below)
Changelog Entry Details

Significance

  • Patch
  • Minor
  • Major

Type

  • Fix - Fixes an existing bug
  • Add - Adds functionality
  • Update - Update existing functionality
  • Dev - Development related task
  • Tweak - A minor adjustment to the codebase
  • Performance - Address performance issues
  • Enhancement - Improvement to existing functionality

Message

Changelog Entry Comment

Comment

@github-actions github-actions Bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Jul 25, 2025
@Mayisha
Mayisha requested a review from Copilot July 25, 2025 11:54
@github-actions

github-actions Bot commented Jul 25, 2025 •

Copy link
Copy Markdown
Contributor

Testing Guidelines

Hi @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:

  • 🖼️ Screenshots or screen recordings.
  • 📝 List of functionality tested / steps followed.
  • 🌐 Site details (environment attributes such as hosting type, plugins, theme, store size, store age, and relevant settings).
  • 🔍 Any analysis performed, such as assessing potential impacts on environment attributes and other plugins, conducting performance profiling, or using LLM/AI-based analysis.

⚠️ Within the testing details you provide, please ensure that no sensitive information (such as API keys, passwords, user data, etc.) is included in this public issue.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 address settings parity between the legacy PayPal gateway and the new PayPal Orders v2 API migration, ensuring consistent behavior for shipping details and address override options.

  • Adds Orders v2 API support with address handling that matches legacy behavior
  • Introduces webhook handling for PayPal payment events
  • Conditionally hides API credential settings when using Orders v2

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
class-wc-gateway-paypal.php Modified payment processing to support Orders v2 API and conditionally route between legacy and new flows
class-wc-gateway-paypal-request.php Added Orders v2 API methods for creating orders and capturing payments with proper address handling
class-wc-gateway-paypal-helper.php Added helper class to determine whether to use Orders v2 API
settings-paypal.php Modified settings to conditionally hide API credentials when using Orders v2
class-wc-gateway-paypal-webhook-handler.php Added webhook event handling for PayPal payment events
REST API controllers Added proxy and webhook controllers for testing PayPal integration
Test file Added unit tests for PayPal request functionality

@Mayisha
Mayisha requested a review from annemirasol July 25, 2025 11:57
@coderabbitai

coderabbitai Bot commented Jul 25, 2025

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This update introduces PayPal Orders v2 API support to WooCommerce's PayPal gateway. It adds new REST API controllers and webhook handlers for PayPal event processing, implements a helper class for API selection logic, and extends the gateway's payment processing flow. Corresponding unit tests and settings logic are also updated, with several new files and significant method additions.

Changes

File(s) Change Summary
.../class-wc-gateway-paypal.php Refactored logging initialization; added Orders v2 API support in payment processing; added method to determine Orders v2 use.
.../includes/class-wc-gateway-paypal-helper.php New helper class for determining Orders v2 API usage.
.../includes/class-wc-gateway-paypal-request.php Added strict typing; implemented PayPal Orders v2 API integration methods; improved error handling.
.../includes/class-wc-gateway-paypal-webhook-handler.php New webhook handler class for PayPal events; processes order approval and payment capture events.
.../includes/settings-paypal.php Refactored to conditionally include API credentials settings based on Orders v2 usage.
.../rest-api/Controllers/Version3/class-wc-rest-paypal-proxy-controller.php New REST API controller for proxying PayPal API requests (test-only, marked for removal).
.../rest-api/Controllers/Version3/class-wc-rest-paypal-webhooks-controller.php New REST API controller for handling PayPal webhooks.
.../rest-api/Controllers/Version3/class-wc-rest-paypal-webhooks-proxy-controller.php New REST API controller for proxying PayPal webhooks (test-only, marked for removal).
.../rest-api/Server.php Registered new REST API controllers for PayPal proxy and webhook proxy (test-only).
.../tests/php/includes/gateways/paypal/class-wc-gateway-paypal-request-test.php New unit tests for PayPal Orders v2 API request logic, error handling, and payload validation.

Sequence Diagram(s)

sequenceDiagram
    participant Customer
    participant WooCommerce
    participant PayPal
    participant WebhookHandler

    Customer->>WooCommerce: Initiate payment
    WooCommerce->>PayPal: Create PayPal Order (Orders v2 API)
    PayPal-->>WooCommerce: Order ID & Approval URL
    WooCommerce->>Customer: Redirect to Approval URL
    Customer->>PayPal: Approve payment
    PayPal->>WebhookHandler: Send CHECKOUT.ORDER.APPROVED webhook
    WebhookHandler->>WooCommerce: Capture Payment via PayPal API
    PayPal-->>WebhookHandler: PAYMENT.CAPTURE.COMPLETED webhook
    WebhookHandler->>WooCommerce: Mark order as paid
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch task/paypal-address-parity

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 20

🧹 Nitpick comments (9)
plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-helper.php (1)

25-28: TODO: Implement merchant eligibility checks

The TODO comment indicates that merchant eligibility logic (checking if merchant needs API keys and ToS acceptance) is not yet implemented. This is important for the migration flow.

Would you like me to help implement the merchant eligibility checks or create an issue to track this requirement?

plugins/woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-paypal-proxy-controller.php (1)

116-116: Security: Validate PayPal-Request-Id format

The PayPal-Request-Id uses uniqid() which may not provide sufficient entropy for idempotency keys.

-'PayPal-Request-Id' => uniqid(), // A unique ID for idempotency (recommended by PayPal).
+'PayPal-Request-Id' => wp_generate_uuid4(), // A unique ID for idempotency (recommended by PayPal).
plugins/woocommerce/tests/php/includes/gateways/paypal/class-wc-gateway-paypal-request-test.php (3)

13-15: Fix class documentation mismatch

The class documentation refers to WC_Gateway_Paypal_Test but the actual class name is WC_Gateway_Paypal_Request_Test.

/**
- * Class WC_Gateway_Paypal_Test.
+ * Class WC_Gateway_Paypal_Request_Test.
 */

70-70: Remove or use the unused $result variable

The static analysis correctly identifies that $result is assigned but never used in the test.

-$result  = $request->create_paypal_order( $order );
+$request->create_paypal_order( $order );

1-157: Consider adding more test coverage

The tests cover basic success/error cases and parameter validation, but could benefit from additional scenarios such as:

  • Testing with different payment actions (authorize vs capture)
  • Testing with different shipping scenarios
  • Testing edge cases like very long order descriptions

Would you like me to generate additional test cases to improve coverage?

plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-request.php (4)

109-110: Address TODO comments about wpcom endpoints

Multiple TODO comments indicate these endpoints should be replaced with wpcom endpoints. This needs to be completed before production deployment.

Would you like assistance in implementing the wpcom endpoint integration?

Also applies to: 174-175, 242-243, 252-253


360-360: Remove unused parameters in method call

Static analysis correctly identifies unused parameters in the get_item_subtotal call.

-'value' => $order->get_item_subtotal( $item, $include_tax = false, $rounding_enabled = false ),
+'value' => $order->get_item_subtotal( $item, false, false ),

403-403: Fix missing space in function parameter

Missing space after parameter name in function declaration.

-private function get_paypal_shipping_preference( $order) {
+private function get_paypal_shipping_preference( $order ) {

142-142: Avoid null return in error cases

Returning null on error makes it harder for calling code to distinguish between different error conditions.

Consider throwing specific exceptions or returning a WP_Error object instead:

-return null;
+return new WP_Error( 'paypal_order_creation_failed', $e->getMessage() );
📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f6efbf6 and 504eded.

📒 Files selected for processing (10)
  • plugins/woocommerce/includes/gateways/paypal/class-wc-gateway-paypal.php (4 hunks)
  • plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-helper.php (1 hunks)
  • plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-request.php (3 hunks)
  • plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-webhook-handler.php (1 hunks)
  • plugins/woocommerce/includes/gateways/paypal/includes/settings-paypal.php (3 hunks)
  • plugins/woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-paypal-proxy-controller.php (1 hunks)
  • plugins/woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-paypal-webhooks-controller.php (1 hunks)
  • plugins/woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-paypal-webhooks-proxy-controller.php (1 hunks)
  • plugins/woocommerce/includes/rest-api/Server.php (1 hunks)
  • plugins/woocommerce/tests/php/includes/gateways/paypal/class-wc-gateway-paypal-request-test.php (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{php,js,jsx,ts,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/code-quality.mdc)

**/*.{php,js,jsx,ts,tsx}: Guard against unexpected inputs
Sanitize and validate any potentially dangerous inputs
Ensure code is backwards compatible
Write code that is readable and intuitive
Ensure code has unit or E2E tests where applicable

Files:

  • plugins/woocommerce/includes/rest-api/Server.php
  • plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-helper.php
  • plugins/woocommerce/includes/gateways/paypal/includes/settings-paypal.php
  • plugins/woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-paypal-webhooks-proxy-controller.php
  • plugins/woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-paypal-webhooks-controller.php
  • plugins/woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-paypal-proxy-controller.php
  • plugins/woocommerce/includes/gateways/paypal/class-wc-gateway-paypal.php
  • plugins/woocommerce/tests/php/includes/gateways/paypal/class-wc-gateway-paypal-request-test.php
  • plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-webhook-handler.php
  • plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-request.php
**/*.{php,js,ts,jsx,tsx}

⚙️ CodeRabbit Configuration File

**/*.{php,js,ts,jsx,tsx}: Don't trust that extension developers will follow the best practices, make sure the code:

  • Guards against unexpected inputs.
  • Sanitizes and validates any potentially dangerous inputs.
  • Is backwards compatible.
  • Is readable and intuitive.
  • Has unit or E2E tests where applicable.

Files:

  • plugins/woocommerce/includes/rest-api/Server.php
  • plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-helper.php
  • plugins/woocommerce/includes/gateways/paypal/includes/settings-paypal.php
  • plugins/woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-paypal-webhooks-proxy-controller.php
  • plugins/woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-paypal-webhooks-controller.php
  • plugins/woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-paypal-proxy-controller.php
  • plugins/woocommerce/includes/gateways/paypal/class-wc-gateway-paypal.php
  • plugins/woocommerce/tests/php/includes/gateways/paypal/class-wc-gateway-paypal-request-test.php
  • plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-webhook-handler.php
  • plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-request.php
🪛 PHPMD (2.15.0)
plugins/woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-paypal-webhooks-controller.php

81-81: Avoid unused local variables such as '$data'. (Unused Code Rules)

(UnusedLocalVariable)

plugins/woocommerce/tests/php/includes/gateways/paypal/class-wc-gateway-paypal-request-test.php

70-70: Avoid unused local variables such as '$result'. (Unused Code Rules)

(UnusedLocalVariable)


124-124: Avoid unused parameters such as '$value'. (Unused Code Rules)

(UnusedFormalParameter)


124-124: Avoid unused parameters such as '$parsed_url'. (Unused Code Rules)

(UnusedFormalParameter)


152-152: Avoid unused parameters such as '$value'. (Unused Code Rules)

(UnusedFormalParameter)


152-152: Avoid unused parameters such as '$parsed_url'. (Unused Code Rules)

(UnusedFormalParameter)

plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-request.php

360-360: Avoid unused local variables such as '$include_tax'. (Unused Code Rules)

(UnusedLocalVariable)


360-360: Avoid unused local variables such as '$rounding_enabled'. (Unused Code Rules)

(UnusedLocalVariable)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (24)
  • GitHub Check: Blocks e2e tests 8/10 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Blocks e2e tests 10/10 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Blocks e2e tests 7/10 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Blocks e2e tests 9/10 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Blocks e2e tests 2/10 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Blocks e2e tests 5/10 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Blocks e2e tests 6/10 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Blocks e2e tests 4/10 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Blocks e2e tests 1/10 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Metrics - @woocommerce/plugin-woocommerce [performance]
  • GitHub Check: Blocks e2e tests 3/10 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Core API tests - @woocommerce/plugin-woocommerce [api]
  • GitHub Check: Core e2e tests 6/6 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: PHP: 7.4 WP: latest - 1 [WP 6.7.2] 2/2 - @woocommerce/plugin-woocommerce [unit:php]
  • GitHub Check: Core e2e tests 5/6 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: PHP: 8.4 WP: latest [WP latest] 2/2 - @woocommerce/plugin-woocommerce [unit:php]
  • GitHub Check: Core e2e tests 4/6 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Core e2e tests 2/6 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Core e2e tests 3/6 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: Core e2e tests 1/6 - @woocommerce/plugin-woocommerce [e2e]
  • GitHub Check: PHP: 8.4 WP: latest [WP latest] 1/2 - @woocommerce/plugin-woocommerce [unit:php]
  • GitHub Check: PHP: 7.4 WP: latest - 1 [WP 6.7.2] 1/2 - @woocommerce/plugin-woocommerce [unit:php]
  • GitHub Check: Lint - @woocommerce/plugin-woocommerce
  • GitHub Check: build
🔇 Additional comments (5)
plugins/woocommerce/includes/gateways/paypal/includes/settings-paypal.php (1)

139-197: Good implementation of conditional API settings

The conditional inclusion of API credential settings based on Orders v2 usage is well implemented. This ensures merchants using the new API don't see unnecessary legacy settings.

plugins/woocommerce/includes/gateways/paypal/class-wc-gateway-paypal.php (2)

37-37: Good implementation of lazy logging initialization

The change from false to null for $log_enabled and the lazy initialization in the log() method is a good optimization that avoids loading settings unnecessarily.

Also applies to: 162-165


379-394: Well-implemented Orders v2 API integration

The integration properly:

  • Uses the helper class for consistency
  • Validates the PayPal order response
  • Saves the PayPal order ID as metadata
  • Provides user-friendly error messages
  • Falls back to legacy flow when Orders v2 is disabled
plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-webhook-handler.php (1)

142-142: Validate filter_var return value

filter_var with FILTER_VALIDATE_URL can return false, which should be checked before using the URL.

-if ( 'capture' === $link['rel'] && 'POST' === $link['method'] && filter_var( $link['href'], FILTER_VALIDATE_URL ) ) {
+$validated_url = filter_var( $link['href'], FILTER_VALIDATE_URL );
+if ( 'capture' === $link['rel'] && 'POST' === $link['method'] && $validated_url !== false ) {
-    $capture_url = esc_url_raw( $link['href'] );
+    $capture_url = esc_url_raw( $validated_url );

Likely an incorrect or invalid review comment.

plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-request.php (1)

327-341: Good implementation of custom ID validation

The code properly validates the custom ID length to ensure it doesn't exceed PayPal's 255 character limit.

@github-actions

github-actions Bot commented Jul 25, 2025 •

Copy link
Copy Markdown
Contributor

Test using WordPress Playground

The changes in this pull request can be previewed and tested using a WordPress Playground instance.
WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

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.

@Mayisha
Mayisha changed the base branch from trunk to feature/paypal-wps-migration July 25, 2025 13:05
@Mayisha

Mayisha commented Jul 25, 2025

Copy link
Copy Markdown
Contributor Author

@annemirasol you can ignore all the AI comments. I mistakenly requested for a review before changing the base branch. So all the comments (except one) are irrelevant to this PR.

@annemirasol annemirasol left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as described, LGTM!

Note: address_override was confusing. Maybe later we should consider rephrasing the label, or adding a better explanation.

Note: There's one more linting error.

@Mayisha

Mayisha commented Jul 28, 2025

Copy link
Copy Markdown
Contributor Author

Note: address_override was confusing. Maybe later we should consider rephrasing the label, or adding a better explanation.

That's true. I also had a hard time understanding it. The opposite logic seems more intuitive.

@Mayisha
Mayisha merged commit 5f06455 into feature/paypal-wps-migration Jul 28, 2025
@Mayisha
Mayisha deleted the task/paypal-address-parity branch July 28, 2025 05:52
@coderabbitai coderabbitai Bot mentioned this pull request Jul 31, 2025
12 tasks
Mayisha added a commit that referenced this pull request Sep 19, 2025
* Add proxy layer for testing

* WPS migration: implement Orders v2 approval phase (#59860)

* WPS migration: specify user_action field for order creation (#59942)

Specify user action as PAY_NOW

* Update paypal settings (#59943)

* WPS Migration: Capture payment (#59945)

* WPS Migration: Set invoice id for transaction details (#59996)

* WPS Migration: Add timeout and capture condtion (#60027)

* WPS Migration: address settings parity (#60017)

* WPS migration: include testmode flag in requests (#60041)

* WPS migration: site registration with WPCOM (#59950)

* WPS Migration: Settings refactor (#60082)

* WPS Migration: Authorize payment (#60044)

* WPS Migration: Fix capture failure (#60136)

* WPS Migration: Hide 'Pay' button on order received page (#60114)

* WPS Migration: Check PayPal payment status before sending capture request (#60242)

check status before sending capture request

* WPS Migration: Update PayPal `custom_id` (#60308)

* WPS Migration: validate webhooks (#60322)

* add blog_id in custom data

* update proxy webhook to generate endpoint from site url

* jp check

* remove test changes

* validate webhook

* validate test webhook

* remove backslash

* check if class & method exists

* fix return and log

* WPS migration: Transact onboarding (#60238)

* Add Transact merchant onboarding

* Add Transact provider onboarding

* Handle onboarding responses and set local flag

* Include PayPal account email in onboarding request

* Update is_transact_onboarded to use yes/no values

* Update should_use_orders_v2() check

* Move stuff to manager class, add caching

* Feedback: remove unnecessary store_url and statement_descriptor

* Remove error logs and fix phpcs errors

* Wrap API call in helper method; make class final for security

* Add unit tests

* Remove changes unrelated to branch

* Remove email from merchant onboarding request and response

* Fix onboarding logic, limit trigger

* Check use_orders_v2 filter before onboarding

* Feedback: fix GET request body

* Remove unused libraries

Co-authored-by: Mayisha <33387139+Mayisha@users.noreply.github.com>

* Fix class docblock typo

Co-authored-by: Mayisha <33387139+Mayisha@users.noreply.github.com>

* Add gateway type in constructor param

Co-authored-by: Mayisha <33387139+Mayisha@users.noreply.github.com>

* Revert changes to API loaders

* Use already available response data

Co-authored-by: Mayisha <33387139+Mayisha@users.noreply.github.com>

* Remove unused libraries in test

Co-authored-by: Mayisha <33387139+Mayisha@users.noreply.github.com>

* Move onboarding trigger to plugin update and settings save

* Cache merchant and provider data on onboarding complete

* Fix onboarding status checking, caching

---------

Co-authored-by: Mayisha <33387139+Mayisha@users.noreply.github.com>

* WPS migration: PayPal gateway singleton (#60440)

* Implement singleton for WC_Gateway_Paypal

* Fix unit tests

* Remove unnecessary changes to unit test

* WPS migration: authenticated requests to proxy (#60065)

* Handle 201 in capture/authorize payment

* Use Jetpack for authenticated requests to proxy

* Update proxy endpoints

* Fix unit tests

* WPS MIgration: Use `experiece_context` instead of `application_context` (#60478)

* Delete temp proxy

* Remove is_tos_accepted() checks

* Remove unused methods

* Fix unit test pre_http_request filter arg count

* Use wc_format_decimal() and wc_get_price_decimals()

* Fix WC_Gateway_Paypal_Request_Test unit tests

* Remove webhooks controller test route and method

* Check for json_decode() failure

* Also accept 201 for capture authorized payment

* Use wc_print_r when logging response array

* Fix gateway check

* Remove old TODO re webhook validation

* Add check for invalid webhook payload

* WPS migration: fix onboarding plugin update trigger (#60617)

* Use woocommerce_updated action for onboarding trigger

* Fix is enabled check

* WPS Migration: Note PayPal debug ID (#60558)

* WPS migration: fix loading and hiding of legacy settings (#60682)

* Make merchant and provider cache getters consistent with network getters

* Remove invalid HTML in order note

* Add check for missing approval link

* Perform URL validation on the request method side

* Sanitize payee email first

* Limit order item name, format decimals for item price

* Avoid unnecessary option write for transact_onboarding_complete flag

* Include 201 in possible PAYER_ACTION_REQUIRED status

* Tweak some comments

* Move item name max length to a constant

* Add default off feature flag

* Add changelog

* Fix unit tests

* WPS Migration: Add PayPal constants (#60895)

* add safety checks for keys

* extract get_action_url method

* consolidate get account from cache and update account in cache methods

* create a common get_transact_account_data method

* get cache key if param is empty

* Unify cache key logic and update unit tests

---------

Co-authored-by: Mayisha <mayisha.alam@automattic.com>
@coderabbitai coderabbitai Bot mentioned this pull request Sep 19, 2025
3 of 12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

plugin: woocommerce Issues related to the WooCommerce Core plugin.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants