Skip to content

WPS migration: Transact onboarding #60238

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

Open
wants to merge 14 commits into
base: feature/paypal-wps-migration
Choose a base branch
from

Conversation

annemirasol
Copy link

@annemirasol annemirasol commented Aug 6, 2025

Submission Review Guidelines:

Changes proposed in this Pull Request:

Towards PAYPAL-62

Merges into feature/paypal-wps-migration.
Client-side changes for Transact merchant and provider onboarding.

How to test the changes in this Pull Request:

  1. Checkout the Transact PR for the server part: https://github.com/Automattic/transact-platform-server/pull/7588, and get the Transact server running, including routing requests to your local server instance.
  2. wp option patch insert woocommerce_paypal_settings _should_load 'yes' (or patch update) to enable PayPal Standard.
  3. Go to WooCommerce > Settings > Payments, enable PayPal Standard, and enter an email address in the PayPal email field, and check Enable PayPal sandbox
  4. wp option patch insert woocommerce_paypal_settings is_tos_accepted 'yes' (or patch update) to simulate ToS accepted flag.
  5. Reload wp-admin.
  6. Verify in the Transact server database that the merchant and provider accounts have been created.

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

This will be merged into a feature branch.

@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Aug 6, 2025
@annemirasol annemirasol force-pushed the add/paypal-transact-merchant-onboarding branch from 232d338 to 22c0739 Compare August 6, 2025 20:42
}

// If the merchant is already onboarded, nothing to do.
if ( $this->get_option( 'is_transact_onboarded', 'no' ) === 'yes' ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

A simple bool option might fail. I think the best way would be to have a cache of the account data.

So we could have a method checks:

  • Is Jetpack connected?
    • If not, connect
    • If yes, proceed
  • Is there a merchant account in the cache and is it not expired?
    • If not, fetch from the server, store it using update_option (not transients) and some expiry time. Similar to what we do for Stripe (I hope) and WooPayments in the DatabaseCache class.
    • If fetch returns empty data, create a merchant account and then cache it
    • If the account is there, proceed to the next step
  • Is PayPal Standard provider account onboarded?
    • Same as above: fetch, cache, if it's there, we're onboarded

Normally it will be a method checking the local DB, but also with a fallback to the server in case any data gets outdated or goes missing.

$jetpack_connection_manager = new Jetpack_Connection_Manager( 'woocommerce' );
$is_connected = $jetpack_connection_manager->is_connected();
return $is_connected;

if ( ! $is_connected ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Parts of the method I described above, especially around caching/fetching, could be DRY-ed and reused here.

Here's an example method like that from WooPayments, and the underlying cache/fetch method (we probably don't need anything as complicated here, though)

@annemirasol annemirasol force-pushed the add/paypal-transact-merchant-onboarding branch 2 times, most recently from 119fd7b to 38f3db0 Compare August 7, 2025 21:55
@annemirasol annemirasol force-pushed the add/paypal-transact-merchant-onboarding branch from 38f3db0 to e7b12e5 Compare August 7, 2025 21:57
@annemirasol annemirasol self-assigned this Aug 7, 2025
@annemirasol annemirasol marked this pull request as ready for review August 8, 2025 01:51
Copy link
Contributor

github-actions bot commented Aug 8, 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.

Comment on lines 258 to 259
// TODO: Do we need to pass this? If yes, do we need to handle scenario where the store changes domain?
'store_url' => get_site_url(),
Copy link
Contributor

Choose a reason for hiding this comment

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

This is for the KYC reasons, which we don't really need here. I'd say let's make this field nullable in the server.

Copy link
Author

Choose a reason for hiding this comment

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

Removed, thanks. It's already nullable in the server, too.

Comment on lines 260 to 262
'settings' => array(
// TODO: Merchant account creation requires a statement descriptor, but we are not using it anywhere.
'statement_descriptor' => get_bloginfo( 'name' ),
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above, let's make the field nullable and regenerate the server routes to make it not required.

Copy link
Author

Choose a reason for hiding this comment

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

Removed. It was nullable after all. (I was getting some errors before, and misread this part that checks for statement descriptors).

// TODO: We expect this flag to be true if the merchant can be migrated,
// i.e. does not need PayPal API keys, and they have accepted the ToS.

public function should_use_orders_v2() {
Copy link
Author

Choose a reason for hiding this comment

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

@Mayisha FYI that I'm moving this check from the helper to the gateway class, as it needs the gateway instance to perform the Transact checks.

I added a filter to handle the legacy settings logic.

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.

2 participants