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

Add connect.js library and embedded onboarding integration #9251

Merged
merged 59 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
6fb21bd
WIP: Adding connect.js library for Stripe.
dmallory42 Aug 13, 2024
b3f2856
WIP: Adding JS resolvers for component.
dmallory42 Aug 13, 2024
e64e239
Merge remote-tracking branch 'origin/develop' into dev/include-connec…
dmallory42 Aug 13, 2024
e7c4719
Updates to the onboarding logic for embedded onboarding.
dmallory42 Aug 13, 2024
04f1cad
updates to the onboarding.
dmallory42 Aug 14, 2024
cce3a56
Removing the test publishable key which was originally from Stripe do…
dmallory42 Aug 14, 2024
a772281
WIP
Aug 16, 2024
c1e2a03
Change hooks call to useApiFetch call
Aug 16, 2024
5f92d50
Changes to make the functionality working
Aug 20, 2024
48aced0
label TODOs better
Aug 20, 2024
0395760
Remove not needed hooks
Aug 20, 2024
b76d623
Support publishableKey in `GET /onboarding/session`
Aug 21, 2024
9e409db
Merge branch 'develop' into dev/include-connect-js
dmallory42 Aug 21, 2024
313f187
Implemented PO and passing onboarding params to the server
Aug 21, 2024
a121e35
Merge with Dan
Aug 21, 2024
ef3b067
REmove not needed test
Aug 21, 2024
a4ee48d
Small refactoring
Aug 21, 2024
5870661
Fix unit tests
Aug 21, 2024
64c2d84
Merge branch 'develop' into dev/include-connect-js
oaratovskyi Aug 21, 2024
bf2b3eb
Add changelog
Aug 21, 2024
3c263ae
Remove not needed function
Aug 21, 2024
17807d0
Add loader
Aug 21, 2024
762b889
Add on load error handler
Aug 21, 2024
986c459
Add styling
Aug 21, 2024
186ad8a
Merge branch 'develop' into dev/include-connect-js
dmallory42 Aug 21, 2024
16ec5a3
Adding finalization logic and updating terminology to use american en…
dmallory42 Aug 22, 2024
3aab1da
Extract styles to separate component
Aug 22, 2024
0b488f9
Add localization
Aug 22, 2024
61dc892
Fix psalm errors
Aug 22, 2024
30a1fcc
Merge branch 'develop' into dev/include-connect-js
oaratovskyi Aug 23, 2024
af90385
Logic updates.
dmallory42 Aug 23, 2024
cdd8f48
Remove heading/subheading on embedded form.
dmallory42 Aug 24, 2024
1c02d75
Some fixes.
dmallory42 Aug 24, 2024
b3eefba
Updates to the logic.
dmallory42 Aug 25, 2024
1f695eb
Merge branch 'develop' into dev/include-connect-js
dmallory42 Aug 25, 2024
8c123d8
Updating to hide the back button once the embedded onboarding is reac…
dmallory42 Aug 29, 2024
7949a2a
Merge branch 'develop' into dev/include-connect-js
dmallory42 Aug 29, 2024
dcd0c21
Update to use american english
dmallory42 Aug 30, 2024
69f9d08
Update to use american english
dmallory42 Aug 30, 2024
1511ae9
Small fixes (order the dependencies and add locale only if account se…
Aug 30, 2024
290c6cf
Update to use american eng
Aug 30, 2024
6ea2e0d
Updates relating to passing promos to/from server.
dmallory42 Aug 30, 2024
11cec94
Add source/from args.
dmallory42 Aug 30, 2024
d4b750d
Update variable names.
dmallory42 Aug 30, 2024
fc76970
Add handling for error responses.
dmallory42 Aug 30, 2024
4dc7b46
Add handling for error responses.
dmallory42 Aug 30, 2024
eb2420a
Merge branch 'develop' into dev/include-connect-js
dmallory42 Aug 30, 2024
62c2dbb
Simple embedded onboarding test
Sep 4, 2024
6120c1c
Add success case of embedded onboarding
Sep 4, 2024
712bd82
Small tweak
Sep 4, 2024
8616837
Merge branch 'develop' into dev/include-connect-js
dmallory42 Sep 4, 2024
2336b30
Update continue onboarding to use embedded component (#9380)
oaratovskyi Sep 6, 2024
a6156b9
Merge branch 'develop' into dev/include-connect-js
dmallory42 Sep 6, 2024
ab934b6
Update to the styling file to use the Woo Purple.
dmallory42 Sep 6, 2024
e417b2e
Fixed display of font stack.
dmallory42 Sep 6, 2024
dd5630c
Remove version number change.
dmallory42 Sep 6, 2024
be632df
Add Feature Flag for Embedded KYC (#9394)
oaratovskyi Sep 6, 2024
6705109
Merge branch 'develop' into dev/include-connect-js
dmallory42 Sep 6, 2024
495f4ae
Update changelog.
dmallory42 Sep 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog/dev-include-connect-js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: add

Added Embdedded KYC, currently behind feature flag.
1 change: 1 addition & 0 deletions client/globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ declare global {
paymentTimeline: boolean;
isDisputeIssuerEvidenceEnabled: boolean;
isPaymentOverviewWidgetEnabled?: boolean;
isEmbeddedKycEnabled?: boolean;
};
fraudServices: unknown[];
testMode: boolean;
Expand Down
21 changes: 21 additions & 0 deletions client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import CapitalPage from 'capital';
import OverviewPage from 'overview';
import DocumentsPage from 'documents';
import OnboardingPage from 'onboarding';
import OnboardingKycPage from 'onboarding/kyc';
import FraudProtectionAdvancedSettingsPage from './settings/fraud-protection/advanced-settings';
import { getTasks } from 'overview/task-list/tasks';

Expand Down Expand Up @@ -69,6 +70,26 @@ addFilter(
capability: 'manage_woocommerce',
} );

// Currently under feature flag.
if (
wcpaySettings &&
wcpaySettings.featureFlags.isEmbeddedKycEnabled
) {
pages.push( {
container: OnboardingKycPage,
path: '/payments/onboarding/kyc',
wpOpenMenu: menuID,
breadcrumbs: [
rootLink,
__( 'Continue onboarding', 'woocommerce-payments' ),
],
navArgs: {
id: 'wc-payments-continue-onboarding',
},
capability: 'manage_woocommerce',
} );
}

pages.push( {
container: OverviewPage,
path: '/payments/overview',
Expand Down
11 changes: 9 additions & 2 deletions client/onboarding/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ import { getMccFromIndustry } from 'onboarding/utils';
import { OnboardingForm } from './form';
import Step from './step';
import BusinessDetails from './steps/business-details';
import EmbeddedKyc from './steps/embedded-kyc';
import StoreDetails from './steps/store-details';
import LoadingStep from './steps/loading';
import { trackStarted } from './tracking';
import { getAdminUrl } from 'wcpay/utils';
import './style.scss';
import LoadingStep from 'wcpay/onboarding/steps/loading';

const OnboardingStepper = () => {
const handleExit = () => {
Expand Down Expand Up @@ -47,7 +48,13 @@ const OnboardingStepper = () => {
<StoreDetails />
</OnboardingForm>
</Step>
<LoadingStep name="loading" />
{ wcpaySettings?.featureFlags?.isEmbeddedKycEnabled ? (
<Step name="embedded" showHeading={ false }>
<EmbeddedKyc />
</Step>
) : (
<LoadingStep name={ 'loading' } />
) }
</Stepper>
);
};
Expand Down
62 changes: 62 additions & 0 deletions client/onboarding/kyc/appearance.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/* eslint-disable max-len */

/**
* Customised appearance variables for the external KYC flow.
*/
export default {
variables: {
colorPrimary: '#3C2861',
colorBackground: '#FFFFFF',
buttonPrimaryColorBackground: '#3858E9',
buttonPrimaryColorBorder: '#3858E9',
buttonPrimaryColorText: '#FFFFFF',
buttonSecondaryColorBackground: '#FFFFFF',
buttonSecondaryColorBorder: '#3858E9',
buttonSecondaryColorText: '#3858E9',
colorText: '#101517',
colorSecondaryText: '#50575E',
actionPrimaryColorText: '#3858E9',
actionSecondaryColorText: '#101517',
colorBorder: '#DDDDDD',
formHighlightColorBorder: '#3858E9',
formAccentColor: '#3858E9',
colorDanger: '#CC1818',
offsetBackgroundColor: '#F0F0F0',
formBackgroundColor: '#FFFFFF',
badgeNeutralColorText: '#2C3338',
badgeNeutralColorBackground: '#F6F7F7',
badgeNeutralColorBorder: '#F6F7F7',
badgeSuccessColorText: '#005C12',
badgeSuccessColorBackground: '#EDFAEF',
badgeSuccessColorBorder: '#EDFAEF',
badgeWarningColorText: '#614200',
badgeWarningColorBackground: '#FCF9E8',
badgeWarningColorBorder: '#FCF9E8',
badgeDangerColorText: '#8A2424',
badgeDangerColorBackground: '#FCF0F1',
badgeDangerColorBorder: '#FCF0F1',
borderRadius: '2px',
buttonBorderRadius: '2px',
formBorderRadius: '2px',
badgeBorderRadius: '2px',
overlayBorderRadius: '8px',
spacingUnit: '10px',
fontFamily:
"-apple-system, BlinkMacSystemFont, 'system-ui', 'Segoe UI', 'Helvetica Neue', 'Helvetica', 'Roboto', 'Arial', sans-serif",
fontSizeBase: '16px',
headingXlFontSize: '32px',
headingXlFontWeight: '400',
headingLgFontSize: '24px',
headingLgFontWeight: '400',
headingMdFontSize: '20px',
headingMdFontWeight: '400',
headingSmFontSize: '16px',
headingSmFontWeight: '600',
headingXsFontSize: '12px',
headingXsFontWeight: '600',
bodyMdFontWeight: '400',
bodyMdFontSize: '16px',
bodySmFontSize: '14px',
bodySmFontWeight: '400',
},
};
77 changes: 77 additions & 0 deletions client/onboarding/kyc/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/**
* External dependencies
*/
import React, { useEffect } from 'react';
import { closeSmall, Icon } from '@wordpress/icons';

/**
* Internal dependencies
*/
import Logo from 'assets/images/woopayments.svg';
import Page from 'components/page';
import { OnboardingContextProvider } from 'onboarding/context';
import EmbeddedKyc from 'onboarding/steps/embedded-kyc';
import strings from 'onboarding/strings';
import { getConnectUrl } from 'utils';

const OnboardingKycPage: React.FC = () => {
const handleExit = () => {
const urlParams = new URLSearchParams( window.location.search );

window.location.href = getConnectUrl(
{
source:
urlParams.get( 'source' )?.replace( /[^\w-]+/g, '' ) ||
'unknown',
},
'WCPAY_ONBOARDING_KYC'
);
};

useEffect( () => {
// Remove loading class and add those required for full screen.
document.body.classList.remove( 'woocommerce-admin-is-loading' );
document.body.classList.add( 'woocommerce-admin-full-screen' );
document.body.classList.add( 'is-wp-toolbar-disabled' );
document.body.classList.add( 'wcpay-onboarding__body' );

// Remove full screen classes on unmount.
return () => {
document.body.classList.remove( 'woocommerce-admin-full-screen' );
document.body.classList.remove( 'is-wp-toolbar-disabled' );
document.body.classList.remove( 'wcpay-onboarding__body' );
};
}, [] );
return (
<Page className="wcpay-onboarding-prototype">
<OnboardingContextProvider>
<div className="stepper__nav">
<button
type="button"
className={ `stepper__nav-button hide` }
>
{ strings.back }
</button>
<img
src={ Logo }
alt="WooPayments"
className="stepper__nav-logo"
/>
<button
type="button"
className="stepper__nav-button"
onClick={ handleExit }
>
<Icon icon={ closeSmall } />
</button>
</div>
<div className="stepper__wrapper">
<div className="stepper__content">
<EmbeddedKyc continueKyc={ true } />
</div>
</div>
</OnboardingContextProvider>
</Page>
);
};
export default OnboardingKycPage;
23 changes: 15 additions & 8 deletions client/onboarding/step.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ import './style.scss';

interface Props {
name: OnboardingSteps;
showHeading?: boolean;
}

const Step: React.FC< Props > = ( { name, children } ) => {
const Step: React.FC< Props > = ( { name, children, showHeading = true } ) => {
const { trackAbandoned } = useTrackAbandoned();
const { prevStep, exit } = useStepperContext();
const handleExit = () => {
Expand All @@ -36,7 +37,9 @@ const Step: React.FC< Props > = ( { name, children } ) => {
<div className="stepper__nav">
<button
type="button"
className="stepper__nav-button"
className={ `stepper__nav-button ${
name === 'embedded' ? 'hide' : ''
}` }
onClick={ prevStep }
>
<ChevronLeft />
Expand All @@ -56,12 +59,16 @@ const Step: React.FC< Props > = ( { name, children } ) => {
</button>
</div>
<div className="stepper__wrapper">
<h1 className="stepper__heading">
{ strings.steps[ name ].heading }
</h1>
<h2 className="stepper__subheading">
{ strings.steps[ name ].subheading }
</h2>
{ showHeading && (
<>
<h1 className="stepper__heading">
{ strings.steps[ name ].heading }
</h1>
<h2 className="stepper__subheading">
{ strings.steps[ name ].subheading }
</h2>
</>
) }
<div className="stepper__content">{ children }</div>
</div>
</>
Expand Down
Loading
Loading