Skip to content

t523d: Add payee.merchant_id to purchase_units in create_order()#735

Merged
superdav42 merged 2 commits intomainfrom
bugfix/730-paypal-merchant-id
Apr 1, 2026
Merged

t523d: Add payee.merchant_id to purchase_units in create_order()#735
superdav42 merged 2 commits intomainfrom
bugfix/730-paypal-merchant-id

Conversation

@superdav42
Copy link
Copy Markdown
Collaborator

Summary

  • Adds payee.merchant_id to purchase_units[0] in create_order() when $this->merchant_id is set (OAuth/PPCP mode)
  • PayPal partner model requires this field to route payments to the correct merchant account; previously only the PayPal-Auth-Assertion header was set
  • Field is conditionally added — manual-credentials mode (no merchant_id) is unaffected

Changes

inc/gateways/class-paypal-rest-gateway.php

  • Extracted purchase_unit array into a local variable before building $order_data
  • Added conditional payee.merchant_id injection when $this->merchant_id is non-empty

tests/WP_Ultimo/Gateways/PayPal_REST_Gateway_Test.php

  • Added create_order_test_fixtures() helper to create user/customer/membership/payment
  • Added invoke_create_order_and_capture() helper using wu_paypal_rest_order_data filter to capture order data before the API call
  • Added test_create_order_includes_payee_merchant_id_when_set — asserts payee.merchant_id present in OAuth mode
  • Added test_create_order_omits_payee_when_merchant_id_empty — asserts payee absent in manual-credentials mode

Test Results

OK (94 tests, 162 assertions, 5 skipped)

Closes #730


aidevops.sh v3.5.556 plugin for OpenCode v1.3.0 with claude-sonnet-4-6 spent 15h 14m and 13,232 tokens on this as a headless worker.

PayPal partner model requires payee.merchant_id in each purchase_unit
to ensure payments route to the correct merchant account when using
OAuth (PPCP) mode. Previously only the PayPal-Auth-Assertion header
was set; this adds the explicit payee field as PayPal requires.

The field is only added when $this->merchant_id is non-empty (OAuth
mode). Manual-credentials mode is unaffected.

Closes #730. Part of the t523 PayPal PPCP compliance series.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 1, 2026

Warning

Rate limit exceeded

@superdav42 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 17 minutes and 47 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 17 minutes and 47 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 21eeadf9-c611-4b62-96b5-04aeb9c2c31b

📥 Commits

Reviewing files that changed from the base of the PR and between 03bdae6 and 2dc7a99.

📒 Files selected for processing (1)
  • tests/WP_Ultimo/Gateways/PayPal_REST_Gateway_Test.php
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bugfix/730-paypal-merchant-id

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 1, 2026

🔨 Build Complete - Ready for Testing!

📦 Download Build Artifact (Recommended)

Download the zip build, upload to WordPress and test:

🌐 Test in WordPress Playground (Very Experimental)

Click the link below to instantly test this PR in your browser - no installation needed!
Playground support for multisite is very limitied, hopefully it will get better in the future.

🚀 Launch in Playground

Login credentials: admin / password

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 1, 2026

Performance Test Results

Performance test results for f52793e are in 🛎️!

Note: the numbers in parentheses show the difference to the previous (baseline) test run. Differences below 2% or 0.5 in absolute values are not shown.

URL: /

Run DB Queries Memory Before Template Template WP Total LCP TTFB LCP - TTFB
0 40 37.73 MB 862.00 ms (+55.00 ms / +6% ) 167.50 ms (-4.50 ms / -3% ) 1068.50 ms (+51.50 ms / +5% ) 1996.00 ms 1903.60 ms 91.85 ms (+2.65 ms / +3% )
1 56 49.02 MB 911.50 ms (-33.50 ms / -4% ) 147.00 ms 1059.50 ms (-36.00 ms / -3% ) 2030.00 ms 1949.60 ms 82.25 ms

@superdav42 superdav42 merged commit c93aa89 into main Apr 1, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

t523d: Add payee.merchant_id to purchase_units in create_order()

1 participant