Skip to content
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

Simplify and harden our onboarding [connect] links and Connect page state logic #9105

Merged

Conversation

vladolaru
Copy link
Contributor

@vladolaru vladolaru commented Jul 16, 2024

Fixes #9103
Fixes #9101
Fixes #8990
Fixes #7803
Fixes #183
Fixes #6542
Fixes #9024
Yeah... I know these are quite a few, but that is what you get when you work on something long overdue.

Changes proposed in this Pull Request

The bullet points

  1. Ensure the Connect page contents make sense in the given context:
  • If you have an account connected, the builder flow section will not show
  • If you have an account connected, the incentive will not show
  • If you have a missing/broken Jetpack connection but a connected account, we will not show the sandbox notice as you will not be onboarding a new account
  • If you have a broken account in test mode, we will show the switch to live sandbox notice (the same as in Payments Overview), as opposed to the regular one, to allow you to switch to live right from the Connect page
  • The "Reset account" button will appear whenever there is a partially onboarded account or a test mode account that is broken
  • If you had a previously working setup that is now broken, show a persistent error notice instructing you complete the WooPayments setup to process transactions.
  1. Separate between dev mode and test mode onboarding:
  • There is test mode onboarding (like through the builder flow) and then there is dev mode which has the effect of forcing test mode onboarding regardless of flow (besides doing other things like forcing the gateway into test mode)
  • Dev mode should be additional/on-top-of the onboarding mode. It should not overreach if we are to maintain our sanity.
  1. Ensure from and source in the URLs maintain/determine proper value even when coming from WooCommerce places where we have no control of the URLs used
  2. Ensure from and source get sent with Tracks events, when we have them.
  3. Restyle the error notices on the Connect page to make their content more legible (the red background was an eye-sore) - make them similar to warning notices.
  4. Ensure our main menu item has that red badge when a previously good setup is now broken to catch the attention (as attention is definitely needed).
  5. Have far more test coverage.

The story

I would say refactor, but it is more like reengineering our handling of connect links (via the maybe_handle_onboarding method) to make it simpler, predictable, resilient, much better documented, and covered by unit tests (there were none before).

Connect links are a catchall tool where we can throw merchants from anywhere into the onboarding flow, trusting the system to look at the current store state, maybe take some action, and point the merchant to the right place. Naturally, as we wanted to do more and provide more tailored experiences, the complexity has become too much to handle. This PR "cleans the room" and establishes code logic driven by business/product logic (and documents it).

At the same time, I tried to impose a clear separation between determining the from of a connect link and the onboarding source of the current onboarding flow. Conflating the two got it into trouble with the recent onboarding incident (paJDYF-ehK-p2).

  • from means where the merchant was in the onboarding flow immediately before. It might mean a certain step, or a certain page, or a certain button on a page. Its goal is to guide us on what to do next. from is not meant to be sticky and it should change throughout the onboarding flow, generally representing the previous step.
  • source means the very top place the merchant started the onboarding flow (our TOFU, if you will). source is meant to be sticky and not change throughout the onboarding flow as it gets attached to our Tracks events.

Another important concept that I tried to apply consistently is: when do we have a GOOD Stripe account to work with? Up until now, we've been dangling between is_stripe_connected and is_details_submitted (or a combination of the two). I believe the is_stripe_account_valid logic is the way to go! We are much more strict about the account state and will redirect to the connect page whenever the account is not in working condition (this doesn't mean pending verifications). A GOOD account:

  • is connected (obviously)
  • has submitted details
  • has the minimum capabilities in a working state (right now, card_payments NOT unrequested)

If either of these is not met, WooPayments can't work, and we should not show the Payments Overview page or any other page. This is building/expanding this PR by Oleks.

For our sanity, I went to our surfaces (in JS) and made sure that whenever some place (like a button) redirects folks to onboarding, it also declares where they are sending from and maintains the source. It is best to avoid automagically determining the from as much as possible (we have logic to fallback on referer and stuff, but it is best to be declarative about it because it has important implications).

Our JS Tracks events got a "splash" of conformity: they will send the source and from whenever they can. There were some missing Tracks events around our tasks, modals, etc. Now we have them.

Notes to PR reviewers:

  1. Don't panic at the large diff numbers :) About 1300 of the added lines are unit tests. And a couple more hundred are inline docs.
  2. The maybe_handle_onboarding code flow and documentation need to make sense to you. If something doesn't, point it out.

Onboarding flows testing instructions

  • The code changes need to make sense
  • The PHPUnit tests need to pass
  • Smoke test our onboarding like crazy :)

I think it is best to use short-lived JN stores (quick link to create with just WooCommerce) without WooPayments on the live-branch and instead upload the branch's built zip (you can find it via the Prepare live branch for Jetpack Beta Builder / Build and inform the zip file (pull_request) CI job details > Upload the zip file as an artifact step, but you will need to change the directory name in the zip to just woocommerce-payments). This way all the logic that automatically attempts to install/activate the plugin (like Payments task, Incentive, or Payments Settings) will work and not error out.

Also, try it mostly without the WCPay Dev Tools and dev mode enabled.

At each step in the onboarding flow, please make sure that the source and from GET params make sense. The source param should be very sticky, while the from param should point to the immediately previous step (not sticky) - from is not necessarily pointing to a page, but also to a certain tool.
As long as you stay in an onboarding flow, the source should remain the same. If you navigate away, reset the account, or move from test to live, the source will reset.

Please stay on the lookout and report back any "You are not allowed to access this page" scenarios. There shouldn't be any.

Here are a couple of ideas:

  • Start onboarding from all the Woo places: Payments task, Incentive, Payments Settings (try it with the plugin not installed, installed but not active, and active)
  • Start onboarding from the Connect Page, the Overview page via the reset account tool and the test-to-live notice.
  • Start onboarding with and without having a Jetpack connection. Decline the Jetpack connection. Try again and decline it still. Try again and approve it.
  • When in our Onboarding wizard, exit it and see where you are returned. Enter it again.
  • Finish the Onboarding wizard and go to the Stripe KYC. Return straight away and see where you end up. Try to finish the setup, and you should end up in the Stripe KYC again.
  • Try onboarding a progressive account

Working to not working testing instructions

Start each testing scenario with a fully working setup: Jetpack connection working and a fully onboarded account.

  • Go to the Connect page (/wp-admin/admin.php?page=wc-admin&path=%2Fpayments%2Fconnect&from=WCADMIN_PAYMENT_TASK) and you should be redirected to the Payments Overview page
  • Break your Jetpack connection with the Jetpack Debug Helper plugin.
    • All you should see is the Connect page. The builder flow section should not be visible, there should be an error message, and the "Payments" menu item should have a red badge:
      1ztUPv.png
    • If you try to go to a link like Payments Overview (/wp-admin/admin.php?page=wc-admin&path=%2Fpayments%2Foverview) you should be redirected back to the Connect page.
  • Unbreak your Jetpack connection with the Jetpack Debug Helper plugin and if you go to the Connect page (/wp-admin/admin.php?page=wc-admin&path=%2Fpayments%2Fconnect) you should be redirected to the Payments Overview page.
  • Hack your local account cache (wcpay_account_data option) so it has card_payments as unrequested (put s:13:"card_payments";s:11:"unrequested"; in the serialized JSON)
    • All you should see is the Connect page. The builder flow section should not be visible, the CTA label should be different, it should have an error message, the "Payments" menu item should have a red badge:
      WsZXYe
    • If you try to go to a link like Payments Overview (/wp-admin/admin.php?page=wc-admin&path=%2Fpayments%2Foverview) you should be redirected back to the Connect page
  • Hack your local account cache (wcpay_account_data option) back to a valid state so it has card_payments as active (put s:13:"card_payments";s:6:"active"; in the serialized JSON)
    • If you try to go to a link like Payments Connect (/wp-admin/admin.php?page=wc-admin&path=%2Fpayments%2Fconnect), you should be redirected back to the Overview page
  • Hack your local account cache (wcpay_account_data option) so it has card_payments as unrequested (put s:13:"card_payments";s:11:"unrequested"; in the serialized JSON) and go to the Connect page. Reset your account, and it should work and redirect you back to the Connect page with no error and the builder flow section visible:
    muYMaA.png

Multiple onboarding sessions testing instructions

  1. Start a new onboarding flow and proceed to the Stripe KYC - stay there
  2. In a new browser tab, go to the Connect page and click on "Verify business details"
  3. You should be redirected back to the Connect page with a notice like this:
    UZTeIm

  • Run npm run changelog to add a changelog file, choose patch to leave it empty if the change is not significant. You can add multiple changelog files in one PR by running this command a few times.
  • Covered with tests (or have a good reason not to test in description ☝️)
  • Tested on mobile (or does not apply)

Post merge

@vladolaru vladolaru self-assigned this Jul 16, 2024
@botwoo
Copy link
Collaborator

botwoo commented Jul 16, 2024

Test the build

Option 1. Jetpack Beta

  • Install and activate Jetpack Beta.
  • Use this build by searching for PR number 9105 or branch name fix/9103-payments-settings-originated-onboarding-flow in your-test.site/wp-admin/admin.php?page=jetpack-beta&plugin=woocommerce-payments

Option 2. Jurassic Ninja - available for logged-in A12s

🚀 Launch a JN site with this branch 🚀

ℹ️ Install this Tampermonkey script to get more options.


Build info:

  • Latest commit: 66c3ec7
  • Build time: 2024-08-08 10:51:41 UTC

Note: the build is updated when a new commit is pushed to this PR.

Copy link
Contributor

github-actions bot commented Jul 16, 2024

Size Change: +526 B (0%)

Total Size: 1.33 MB

Filename Size Change
release/woocommerce-payments/dist/blocks-checkout.js 65.1 kB +110 B (0%)
release/woocommerce-payments/dist/index-rtl.css 39.1 kB +45 B (0%)
release/woocommerce-payments/dist/index.css 39.1 kB +38 B (0%)
release/woocommerce-payments/dist/index.js 296 kB +231 B (0%)
release/woocommerce-payments/dist/settings.js 223 kB +159 B (0%)
release/woocommerce-payments/dist/woopay-express-button.js 23.9 kB -57 B (0%)
ℹ️ View Unchanged
Filename Size
release/woocommerce-payments/assets/css/admin.css 1.08 kB
release/woocommerce-payments/assets/css/admin.rtl.css 1.08 kB
release/woocommerce-payments/assets/css/success.css 173 B
release/woocommerce-payments/assets/css/success.rtl.css 173 B
release/woocommerce-payments/dist/blocks-checkout-rtl.css 2.21 kB
release/woocommerce-payments/dist/blocks-checkout.css 2.21 kB
release/woocommerce-payments/dist/bnpl-announcement-rtl.css 528 B
release/woocommerce-payments/dist/bnpl-announcement.css 529 B
release/woocommerce-payments/dist/bnpl-announcement.js 20.8 kB
release/woocommerce-payments/dist/cart-block.js 16.2 kB
release/woocommerce-payments/dist/cart.js 5.72 kB
release/woocommerce-payments/dist/checkout-rtl.css 600 B
release/woocommerce-payments/dist/checkout.css 600 B
release/woocommerce-payments/dist/checkout.js 31.7 kB
release/woocommerce-payments/dist/express-checkout-rtl.css 235 B
release/woocommerce-payments/dist/express-checkout.css 235 B
release/woocommerce-payments/dist/express-checkout.js 14 kB
release/woocommerce-payments/dist/multi-currency-analytics.js 1.08 kB
release/woocommerce-payments/dist/multi-currency-rtl.css 3.41 kB
release/woocommerce-payments/dist/multi-currency-switcher-block.js 60.5 kB
release/woocommerce-payments/dist/multi-currency.css 3.41 kB
release/woocommerce-payments/dist/multi-currency.js 55.5 kB
release/woocommerce-payments/dist/order-rtl.css 730 B
release/woocommerce-payments/dist/order.css 730 B
release/woocommerce-payments/dist/order.js 42.7 kB
release/woocommerce-payments/dist/payment-gateways-rtl.css 1.35 kB
release/woocommerce-payments/dist/payment-gateways.css 1.35 kB
release/woocommerce-payments/dist/payment-gateways.js 39.2 kB
release/woocommerce-payments/dist/payment-request-rtl.css 235 B
release/woocommerce-payments/dist/payment-request.css 235 B
release/woocommerce-payments/dist/payment-request.js 13.5 kB
release/woocommerce-payments/dist/plugins-page-rtl.css 386 B
release/woocommerce-payments/dist/plugins-page.css 386 B
release/woocommerce-payments/dist/plugins-page.js 20.1 kB
release/woocommerce-payments/dist/product-details-rtl.css 433 B
release/woocommerce-payments/dist/product-details.css 436 B
release/woocommerce-payments/dist/product-details.js 11.3 kB
release/woocommerce-payments/dist/settings-rtl.css 11.2 kB
release/woocommerce-payments/dist/settings.css 11.1 kB
release/woocommerce-payments/dist/subscription-edit-page.js 703 B
release/woocommerce-payments/dist/subscription-product-onboarding-modal-rtl.css 524 B
release/woocommerce-payments/dist/subscription-product-onboarding-modal.css 524 B
release/woocommerce-payments/dist/subscription-product-onboarding-modal.js 20.2 kB
release/woocommerce-payments/dist/subscription-product-onboarding-toast.js 730 B
release/woocommerce-payments/dist/subscriptions-empty-state-rtl.css 120 B
release/woocommerce-payments/dist/subscriptions-empty-state.css 120 B
release/woocommerce-payments/dist/subscriptions-empty-state.js 19.3 kB
release/woocommerce-payments/dist/tokenized-payment-request-rtl.css 235 B
release/woocommerce-payments/dist/tokenized-payment-request.css 235 B
release/woocommerce-payments/dist/tokenized-payment-request.js 14.3 kB
release/woocommerce-payments/dist/tos-rtl.css 235 B
release/woocommerce-payments/dist/tos.css 235 B
release/woocommerce-payments/dist/tos.js 21.8 kB
release/woocommerce-payments/dist/woopay-direct-checkout.js 6.14 kB
release/woocommerce-payments/dist/woopay-express-button-rtl.css 235 B
release/woocommerce-payments/dist/woopay-express-button.css 235 B
release/woocommerce-payments/dist/woopay-rtl.css 4.5 kB
release/woocommerce-payments/dist/woopay.css 4.48 kB
release/woocommerce-payments/dist/woopay.js 71.1 kB
release/woocommerce-payments/includes/subscriptions/assets/css/plugin-page.css 625 B
release/woocommerce-payments/includes/subscriptions/assets/js/plugin-page.js 814 B
release/woocommerce-payments/vendor/automattic/jetpack-assets/build/i18n-loader.js 2.46 kB
release/woocommerce-payments/vendor/automattic/jetpack-assets/src/js/i18n-loader.js 1.02 kB
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-admin-create-user.css 198 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-admin-create-user.js 20 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-admin-create-user.rtl.css 198 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-login.css 625 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-login.js 20 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-login.rtl.css 626 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-users.js 392 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/tracks-ajax.js 521 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/tracks-callables.js 584 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/src/sso/jetpack-sso-admin-create-user.css 215 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/src/sso/jetpack-sso-admin-create-user.js 521 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/src/sso/jetpack-sso-login.css 721 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/src/sso/jetpack-sso-login.js 412 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/src/sso/jetpack-sso-users.js 520 B
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/babel.config.js 159 B
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/build/index.css 2.36 kB
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/build/index.js 13.6 kB
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/build/index.rtl.css 2.36 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/about.css 1.04 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/admin-empty-state.css 294 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/admin-order-statuses.css 408 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/admin.css 3.59 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/checkout.css 301 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/modal.css 746 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/view-subscription.css 574 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/wcs-upgrade.css 414 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/admin-pointers.js 543 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/admin.js 9.4 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/jstz.js 6.78 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/jstz.min.js 3.84 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/meta-boxes-coupon.js 545 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/meta-boxes-subscription.js 2.52 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/moment.js 22.2 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/moment.min.js 11.7 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/payment-method-restrictions.js 1.29 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/wcs-meta-boxes-order.js 507 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/payment-methods.js 358 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/single-product.js 428 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/view-subscription.js 1.38 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/wcs-cart.js 782 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/modal.js 1.09 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/wcs-upgrade.js 1.26 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/build/index.css 391 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/build/index.js 3.04 kB

compressed-size-action

@vladolaru vladolaru requested a review from a team July 17, 2024 07:47
@vladolaru vladolaru marked this pull request as ready for review July 17, 2024 07:52
@vladolaru
Copy link
Contributor Author

@timmy5685 That is just the disabled primary button component. There is no custom styling that I can see.

@orcunomattic
Copy link

@vladolaru - that doesn't look like our normal pattern for our disabled buttons.
@orcunomattic - can you confirm?

@timmy5685, that does match our button styling for disabled buttons, yes:
Primary-button

more info on the button component here: https://github.com/WordPress/gutenberg/tree/trunk/packages/components/src/button

@timmy5685
Copy link

timmy5685 commented Jul 30, 2024

thanks @vladolaru @orcunomattic - for some reason I thought we have a different style (greyed out or something) when a primary button is disabled. Realizing I was probably confusing that with the disabled secondary button style. Appreciate y'all confirming!

@vladolaru vladolaru requested a review from dmallory42 August 5, 2024 15:12
@vladolaru
Copy link
Contributor Author

@dmallory42 if you have the time for another round of smoke testing... very much appreciated.

@dmallory42 dmallory42 dismissed oaratovskyi’s stale review August 7, 2024 09:54

Oleks is currently AFK and changes he requested have been addressed

Copy link
Contributor

@dmallory42 dmallory42 left a comment

Choose a reason for hiding this comment

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

Thanks a lot for the awesome work on this PR! I've smoke tested some more with different scenarios and everything is looking as expected. I think this is ready to go! :shipit:

A small suggestion, we should consider checking the critical flows to see if there's any other onboarding scenarios we want to add, just to be extra safe - or, if we have especially specific edge cases to test, we can add them to the release-specific testing instructions.

@vladolaru
Copy link
Contributor Author

Thank you, @dmallory42 !

A small suggestion, we should consider checking the critical flows to see if there's any other onboarding scenarios we want to add, just to be extra safe - or, if we have especially specific edge cases to test, we can add them to the release-specific testing instructions.

Good point! I will add a critical flow for onboarding from the WooCommerce Payments Settings. Will also look to update the testing instructions for the rest of the flows, where there are changes.

@vladolaru
Copy link
Contributor Author

@dmallory42 I've updated the critical flows.

@vladolaru vladolaru added this pull request to the merge queue Aug 8, 2024
Merged via the queue into develop with commit 28a3248 Aug 8, 2024
23 checks passed
@vladolaru vladolaru deleted the fix/9103-payments-settings-originated-onboarding-flow branch August 8, 2024 11:06
@vladolaru vladolaru changed the title Simplify and improve our onboarding links and flows handling Simplify and harden our onboarding [connect] links and Connect page state logic Aug 17, 2024
rafaelzaleski pushed a commit that referenced this pull request Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment