Skip to content

Commit

Permalink
Removing legacy action types relating to 3DS2. Preparing for MDFlow u…
Browse files Browse the repository at this point in the history
…sing createFromAction
  • Loading branch information
sponglord committed Oct 2, 2023
1 parent 3251083 commit 97fcd5c
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 52 deletions.
9 changes: 4 additions & 5 deletions packages/lib/src/components/ThreeDS2/ThreeDS2Challenge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface ThreeDS2ChallengeProps {
challengeWindowSize?: '01' | '02' | '03' | '04' | '05';
type?: string;
loadingContext?: string;
useOriginalFlow?: boolean;
isMDFlow?: boolean;
i18n?: Language;
onActionHandled: (rtnObj: ActionHandledReturnObject) => void;
}
Expand All @@ -44,11 +44,10 @@ class ThreeDS2Challenge extends UIElement<ThreeDS2ChallengeProps> {
// existy used because threeds2InMDFlow will send empty string for paymentData and we should be allowed to proceed with this
if (!existy(this.props.paymentData)) {
/**
* One component is used for both old and new 3DS2 challenge flows
* - The presence of useOriginalFlow indicates the old flow which used paymentData from the 3DS2 action
* - The new flow uses authorisationToken from the 3DS2 action, passed internally in a prop called paymentData
* The presence of props.isMDFlow indicates the action to create this component came from the threeds2InMDFlow process which passes (an empty) paymentsData.
* The regular, "native" flow uses the authorisationToken from the 3DS2 action, which actionTypes.ts assigns to a property called paymentData
*/
const dataTypeForError = hasOwnProperty(this.props, 'useOriginalFlow') ? 'paymentData' : 'authorisationToken';
const dataTypeForError = hasOwnProperty(this.props, 'isMDFlow') ? 'paymentData' : 'authorisationToken';

this.props.onError({ errorCode: 'threeds2.challenge', message: `No ${dataTypeForError} received. Challenge cannot proceed` });
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface ThreeDS2DeviceFingerprintProps {
paymentData: string;
showSpinner: boolean;
type: string;
useOriginalFlow?: boolean;
isMDFlow?: boolean;
loadingContext?: string;
clientKey?: string;
elementRef?: UIElement;
Expand Down Expand Up @@ -53,11 +53,10 @@ class ThreeDS2DeviceFingerprint extends UIElement<ThreeDS2DeviceFingerprintProps
}

/**
* this.props.useOriginalFlow indicates the old 3DS2 flow.
* It means the call to create this component came from the old 'threeDS2Fingerprint' action and upon completion should call the /details endpoint
* instead of the new /submitThreeDS2Fingerprint endpoint
* this.props.isMDFlow indicates a threeds2InMDFlow process. It means the action to create this component came from the threeds2InMDFlow process
* and upon completion should call the passed onComplete callback (instead of the /submitThreeDS2Fingerprint endpoint for the regular, "native" flow)
*/
return <PrepareFingerprint {...this.props} onComplete={this.props.useOriginalFlow ? this.onComplete : this.callSubmit3DS2Fingerprint} />;
return <PrepareFingerprint {...this.props} onComplete={this.props.isMDFlow ? this.onComplete : this.callSubmit3DS2Fingerprint} />;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,9 @@ class PrepareChallenge3DS2 extends Component<PrepareChallenge3DS2Props, PrepareC
this.setState({ status: 'complete' }, () => {
/**
* Create the data in the way that the /details endpoint expects.
* This is different for the 'old',v66, flow triggered by a 'threeDS2Challenge' action (which includes the threeds2InMDFlow)
* than for the new, v67, 'threeDS2' action
* This is different for the flow triggered by the threeds2InMDFlow process than for the new, v67, 'threeDS2' action
*/
const resolveDataFunction = this.props.useOriginalFlow ? createOldChallengeResolveData : createChallengeResolveData;
const resolveDataFunction = this.props.isMDFlow ? createOldChallengeResolveData : createChallengeResolveData;
const data = resolveDataFunction(this.props.dataKey, resultObj.transStatus, this.props.paymentData);

this.props.onComplete(data); // (equals onAdditionalDetails - except for 3DS2InMDFlow)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,10 @@ class PrepareFingerprint3DS2 extends Component<PrepareFingerprint3DS2Props, Prep
setStatusComplete(resultObj: ResultObject) {
this.setState({ status: 'complete' }, () => {
/**
* Create the data in the way that the endpoint expects:
* - this will be the /details endpoint for the 'old', v66, flow triggered by a 'threeDS2Fingerprint' action
* - and will be the /submitThreeDS2Fingerprint endpoint for the new, v67, 'threeDS2' action
* Create the data in the way that the /details endpoint expects.
* This is different for the flow triggered by the threeds2InMDFlow process than for the new, v67, 'threeDS2' action
*/
const resolveDataFunction = this.props.useOriginalFlow ? createOldFingerprintResolveData : createFingerprintResolveData;
const resolveDataFunction = this.props.isMDFlow ? createOldFingerprintResolveData : createFingerprintResolveData;
const data = resolveDataFunction(this.props.dataKey, resultObj, this.props.paymentData);

/**
Expand Down
39 changes: 4 additions & 35 deletions packages/lib/src/core/ProcessResponse/PaymentAction/actionTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,56 +40,25 @@ const actionTypes = {
return createComponent(core, registry, 'redirect', config);
},

threeDS2Fingerprint: (core: ICore, registry, action: PaymentAction, props) => {
const config = {
createFromAction: props.createFromAction,
token: action.token,
paymentData: action.paymentData,
onError: props.onError,
showSpinner: !props.isDropin,
isDropin: !!props.isDropin,
...props,
type: 'IdentifyShopper',
onComplete: props.onAdditionalDetails,
statusType: 'loading',
useOriginalFlow: true
};
return createComponent(core, registry, 'threeDS2DeviceFingerprint', config);
},

threeDS2Challenge: (core: ICore, registry, action: PaymentAction, props) => {
const config = {
...props,
token: action.token,
paymentData: action.paymentData,
onComplete: props.onAdditionalDetails,
onError: props.onError,
size: props.size ?? '02',
isDropin: !!props.isDropin,
type: 'ChallengeShopper',
statusType: 'custom',
useOriginalFlow: true
};
return createComponent(core, registry, 'threeDS2Challenge', config);
},

threeDS2: (core: ICore, registry, action: PaymentAction, props) => {
const componentType = action.subtype === 'fingerprint' ? 'threeDS2DeviceFingerprint' : 'threeDS2Challenge';
const paymentData = action.subtype === 'fingerprint' ? action.paymentData : action.authorisationToken;

const paymentData = action.subtype === 'fingerprint' || props.isMDFlow ? action.paymentData : action.authorisationToken;

const config = {
// Props common to both flows
core: core,
token: action.token,
paymentData,
onActionHandled: props.onActionHandled,
onComplete: props.onAdditionalDetails,
onComplete: props.isMDFlow ? props.onComplete : props.onAdditionalDetails,
onError: props.onError,
isDropin: !!props.isDropin,
loadingContext: props.loadingContext,
clientKey: props.clientKey,
paymentMethodType: props.paymentMethodType,
challengeWindowSize: props.challengeWindowSize, // always pass challengeWindowSize in case it's been set directly in the handleAction config object
isMDFlow: props.isMDFlow,

// Props unique to a particular flow
...get3DS2FlowProps(action.subtype, props)
Expand Down

0 comments on commit 97fcd5c

Please sign in to comment.