Skip to content

[Payments NOX] Use backend-provided URLs for resetting onboarding and disabling test accounts #60192

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

Merged
merged 18 commits into from
Aug 5, 2025

Conversation

vladolaru
Copy link
Contributor

@vladolaru vladolaru commented Aug 4, 2025

Submission Review Guidelines:

Changes proposed in this Pull Request:

We replace the JS hard-coded relative REST API endpoint paths with backend-provided account reset and test account disable full REST API endpoint URLs that are build dynamically thus taking into consideration the permalink structure of the site (plain or pretty permalinks).

For the WooPayments NOX in-context steps I decided to wrap the general endpoints into step-specific ones to keep the concerns separate and not wrangle data outside each step.

Closes WOOPLUG-5250

How to test the changes in this Pull Request:

Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:

  1. Spin up a new JurassicNinja store with WC using this PR's branch and WC Beta Tester (here's a direct create link)
  2. Go to the dashboard, click on WooCommerce to open the WC profiler, skip it, and set your store location to France.
  3. Go to Settings > Permalinks and set them to "Plain".
  4. Go to the Payments Settings page, click Install for WooPayments, go through the onboarding wizard until you have a test account set up.
  5. Go to WooCommerce > Settings > Payments and click on "Reset account" from the contextual menu for WooPayments. It should work.
  6. Onboard WooPayments with a new test account.
  7. Go to WooCommerce > Settings > Payments and click on "Activate payments" for WooPayments. It should work and you should be presented with the business verification form:
Screenshot 2025-08-04 at 19 17 34
  1. Complete the form until you are presented with the Stripe KYC embedded form. Close the modal.
  2. Reset the WooPayments account.
  3. Reonboard a test account.
  4. Open the NOX in-context onboarding by navigation directly to it (/wp-admin/admin.php?page=wc-settings&tab=checkout&path=%2Fwoopayments%2Fonboarding).
  5. Click on "Activate payments" and you should be presented with the business verification form.
  6. Complete the form until you are presented with the Stripe KYC embedded form. Close the modal.

Repeat steps 5 to 13, but first go to Settings > Permalinks and set the permalink structure to "Post name" ( and thus use pretty permalinks).

Testing that has already taken place:

I tested the same steps as the testing instructions.

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

@vladolaru vladolaru self-assigned this Aug 4, 2025
@github-actions github-actions bot added package: @woocommerce/data issues related to @woocommerce/data plugin: woocommerce Issues related to the WooCommerce Core plugin. labels Aug 4, 2025
Copy link
Contributor

coderabbitai bot commented Aug 4, 2025

📝 Walkthrough

Walkthrough

This change introduces new REST API endpoints, type definitions, and frontend logic to support dynamic, runtime-generated URLs for resetting WooPayments accounts and disabling test accounts during onboarding. It updates backend schemas, onboarding steps, and React component props to use these new links, removing previous hard-coded URLs and utility functions.

Changes

Cohort / File(s) Change Summary
Type Definitions & Onboarding Actions
packages/js/data/src/payment-settings/types.ts, plugins/woocommerce/client/admin/client/settings-payments/onboarding/types.ts
Extended type definitions to include new optional reset and test_account_disable actions and REST API link properties for payment providers and onboarding steps.
Backend: REST API & Onboarding Steps
plugins/woocommerce/src/Internal/Admin/Settings/PaymentsProviders/WooPayments/WooPaymentsRestController.php, plugins/woocommerce/src/Internal/Admin/Settings/PaymentsProviders/WooPaymentsService.php, plugins/woocommerce/src/Internal/Admin/Settings/PaymentsProviders/WooPayments.php, plugins/woocommerce/src/Internal/Admin/Settings/PaymentsRestController.php
Added new REST API endpoints and schema fields for resetting accounts and disabling test accounts. Updated onboarding steps to include these actions and links. Improved error handling and code reuse.
Frontend: React Components & Logic
plugins/woocommerce/client/admin/client/settings-payments/components/buttons/activate-payments-button.tsx, plugins/woocommerce/client/admin/client/settings-payments/components/ellipsis-menu-content/ellipsis-menu.tsx, plugins/woocommerce/client/admin/client/settings-payments/components/modals/woo-payments-reset-account-modal.tsx, plugins/woocommerce/client/admin/client/settings-payments/components/payment-gateway-list-item/payment-gateway-list-item.tsx, plugins/woocommerce/client/admin/client/settings-payments/onboarding/providers/woopayments/steps/business-verification/sections/activate-payments.tsx, plugins/woocommerce/client/admin/client/settings-payments/onboarding/providers/woopayments/steps/test-account/index.tsx
Updated components to accept and use new dynamic URLs for reset and disable actions. Removed old utility calls in favor of direct API calls using the provided URLs.
Frontend: Utility Cleanup
plugins/woocommerce/client/admin/client/settings-payments/utils.ts
Removed obsolete utility functions for resetting and disabling test accounts, as these are now handled via direct API calls with dynamic URLs.
Changelog & Patch Documentation
packages/js/data/changelog/fix-WOOPLUG-5250-hard-coded-woopayments-rest-links, plugins/woocommerce/changelog/fix-WOOPLUG-5250-hard-coded-woopayments-rest-links
Added documentation and changelog entries describing the patch and its scope.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ReactComponent
    participant API
    participant WooPaymentsRestController

    User->>ReactComponent: Click "Reset Account" or "Disable Test Account"
    ReactComponent->>API: POST to dynamic reset/disable URL
    API->>WooPaymentsRestController: Handle request (reset/disable)
    WooPaymentsRestController->>API: Return result
    API->>ReactComponent: Response (success/failure)
    ReactComponent->>User: Update UI (proceed/notify)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • woocommerce/woocommerce#59290: Adds UI and flow for resetting a test account from the NOX onboarding step, directly building on the backend and type changes introduced here.

Note

⚡️ Unit Test Generation is now available in beta!

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


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f280447 and fb85a0f.

📒 Files selected for processing (1)
  • plugins/woocommerce/tests/php/src/Internal/Admin/Settings/PaymentsProviders/WooPaymentsTest.php (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • plugins/woocommerce/tests/php/src/Internal/Admin/Settings/PaymentsProviders/WooPaymentsTest.php
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/WOOPLUG-5250-hard-coded-woopayments-rest-links

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.
  • 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.

Support

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

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.

Copy link
Contributor

github-actions bot commented Aug 4, 2025

Size Change: +15 B (0%)

Total Size: 5.91 MB

Filename Size Change
./plugins/woocommerce/client/admin/build/chunks/settings-payments-main.js 14.7 kB +106 B (+0.73%)
./plugins/woocommerce/client/admin/build/wp-admin-scripts/settings-embed.js 375 kB -134 B (-0.04%)

compressed-size-action

Copy link
Contributor

github-actions bot commented Aug 4, 2025

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.

@vladolaru vladolaru requested a review from elazzabi August 4, 2025 16:19
Copy link
Contributor

github-actions bot commented Aug 4, 2025

Testing Guidelines

Hi @elazzabi ,

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.

Copy link
Contributor

@elazzabi elazzabi left a comment

Choose a reason for hiding this comment

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

Testing instructions check out! I tested with different permalinks options, onboarding a test account, resetting, and initiating an embedded onboarding... everything works as expected.

@vladolaru vladolaru merged commit 2fc4ff7 into trunk Aug 5, 2025
46 checks passed
@vladolaru vladolaru deleted the fix/WOOPLUG-5250-hard-coded-woopayments-rest-links branch August 5, 2025 11:23
Copy link
Contributor

github-actions bot commented Aug 5, 2025

⚠️ API Documentation Reminder

Hi @vladolaru! Your PR contains REST API changes. Please consider updating the REST API documentation if your changes affect the public API.

Changed API files:

plugins/woocommerce/src/Internal/Admin/Settings/PaymentsProviders/WooPayments/WooPaymentsRestController.php
plugins/woocommerce/src/Internal/Admin/Settings/PaymentsRestController.php

@github-actions github-actions bot added this to the 10.2.0 milestone Aug 5, 2025
@vladolaru
Copy link
Contributor Author

No need to worry about documenting REST API changes since the affected APIs are for internal use only (at least for now).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: @woocommerce/data issues related to @woocommerce/data plugin: woocommerce Issues related to the WooCommerce Core plugin.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants