-
Notifications
You must be signed in to change notification settings - Fork 68
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
Extract the Account Session logic from Embedded components onboarding into a reusable utility hook #10273
base: develop
Are you sure you want to change the base?
Conversation
Test the buildOption 1. Jetpack Beta
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:
Note: the build is updated when a new commit is pushed to this PR. |
Size Change: -8.25 kB (-1%) Total Size: 1.36 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mordeth for some readon those requests are in the endless loop. I used the same code as you for the KYC and it does not work as expected - see the video
const stripeConnectInstance = useAccountSession( {
isOnboarding: false,
data: [],
continueKyc: false,
setLoadErrorMessage: () => {},
appearance,
} );
gNFzB9.mp4
in the embedded KYC it works better - only two duplicated requests. Could you please take a look?
@oaratovskyi I was able to reproduce the loop using the provided code. However, replacing |
Yes, works for me, thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @mordeth ! Pre-approving
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! I tested everything expect the Progressive flow (I wasn't able to get a slot) - if possible it would be good to test that locally. But since we have a few globalstep cycles prior to the 9.0 release, I think it is okay to go ahead with this, we just need to ensure the critical flows are tested ahead of that release.
A small note that I didn't see the Congratulations
component on onboarding completion, but I think it was because I onboarded a test account, so instead I saw the test account notification component, I think it is expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick - can we use Kyc
instead of KYC
to stay consistent with other usages on the client (example)?
e.g. KycAccountSession
instead of KYCAccountSession
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great spot! I’ve renamed all occurrences accordingly.
* | ||
* @return WP_Error|WP_REST_Response | ||
*/ | ||
public function get_embedded_session( WP_REST_Request $request ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public function get_embedded_session( WP_REST_Request $request ) { | |
public function create_embedded_account_session( WP_REST_Request $request ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That change makes sense as we are sending a POST request. Updated.
fetchClientSecret, | ||
locale, | ||
] ); | ||
const stripeConnectInstance = useKYCAccountSession( { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const stripeConnectInstance = useKYCAccountSession( { | |
const stripeConnectInstance = useKycAccountSession( { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated!
Fixes #10256
Changes proposed in this Pull Request
To reduce code duplication and improve maintainability, this PR extracts the shared JavaScript logic for retrieving the account session from the embedded components onboarding flow into a reusable utility hook. This refactoring ensures consistency across components, making the logic easier to manage, reuse, and update in the future.
Testing instructions
Before testing
npm install
to install the Stripe libraries.npm run watch
Before each test (prerequisites)
Non-progressive onboarding
Progressive onboarding
United States
as the countryOnboarding isresumed
Localisation
Tracking
wcadmin_wcpay_onboarding_flow_started
- upon redirect to the MOXwcadmin_wcpay_onboarding_flow_step_completed
- after completion of a step in the MOXwcadmin_wcpay_onboarding_flow_redirected
- after loading the embedded component (note that the name of this event is slightly inaccurate to maintain backwards compatibility)wcadmin_wcpay_stripe_connected
- after completion of the embedded onboarding.npm run changelog
to add a changelog file, choosepatch
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.Post merge