Skip to content

Commit 7d6d56c

Browse files
committed
Updated code for Checkmarx issue
1 parent 8a4bdc4 commit 7d6d56c

File tree

1 file changed

+23
-17
lines changed
  • plugins/components/isv-payment-method

1 file changed

+23
-17
lines changed

plugins/components/isv-payment-method/index.jsx

+23-17
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
/* eslint-disable no-inner-declarations */
2-
import React, {useContext, useEffect,useState} from 'react';
3-
import {StoreContext} from '@oracle-cx-commerce/react-ui/contexts';
4-
import {connect} from '@oracle-cx-commerce/react-components/provider';
5-
import { getGlobalContext} from '@oracle-cx-commerce/commerce-utils/selector';
6-
import {usePaymentMethodConfigFetcher} from '../../fetchers/hooks';
7-
import {getPaymentMethodConfigRepository} from '../../selectors';
2+
import React, { useContext, useEffect, useState } from 'react';
3+
import { StoreContext } from '@oracle-cx-commerce/react-ui/contexts';
4+
import { connect } from '@oracle-cx-commerce/react-components/provider';
5+
import { getGlobalContext } from '@oracle-cx-commerce/commerce-utils/selector';
6+
import { usePaymentMethodConfigFetcher } from '../../fetchers/hooks';
7+
import { getPaymentMethodConfigRepository } from '../../selectors';
88
import IsvGooglePayPaymentMethod from './components/isv-googlepay-payment-method';
99
import IsvCreditCardPaymentMethod from './components/isv-credit-card-payment-method';
1010
import IsvApplePayPaymentMethod from './components/isv-applepay-payment-method';
11-
import {amdJsLoad} from './isv-payment-utility/script-loader';
11+
import { amdJsLoad } from './isv-payment-utility/script-loader';
1212

1313

1414

1515
const IsvPaymentMethod = props => {
16-
const {paymentMethods = [], deviceFingerprint = {}, alertTechnicalProblemTryAgain} = props || {};
16+
const { paymentMethods = [], deviceFingerprint = {}, alertTechnicalProblemTryAgain } = props || {};
1717
const store = useContext(StoreContext);
18-
const {action} = store;
19-
const {isPreview} = getGlobalContext(store.getState());
18+
const { action } = store;
19+
const { isPreview } = getGlobalContext(store.getState());
2020
var payerAuthEnabled, flexSdkUrl;
2121
let creditCardConfiguration = [],
2222
applePayConfiguration = [];
2323
var applePayEnabled, creditCardEnabled = false, applePaySupported = false;
2424
const [isError, setError] = useState(false);
25-
25+
2626

2727
if (typeof paymentMethods === 'object' && !Array.isArray(paymentMethods) && paymentMethods !== null) {
2828
creditCardConfiguration = Object.entries(paymentMethods)
@@ -53,18 +53,18 @@ const IsvPaymentMethod = props => {
5353
}
5454

5555
useEffect(() => {
56-
if(creditCardEnabled){
57-
action('flexMicroformAction', {isPreview}).then(response => {
56+
if (creditCardEnabled) {
57+
action('flexMicroformAction', { isPreview }).then(response => {
5858
if (!response.ok) {
5959
setError(true);
6060
}
6161
});
6262
}
63-
},[creditCardEnabled]);
64-
63+
}, [creditCardEnabled]);
64+
6565
useEffect(() => {
6666
usePaymentMethodConfigFetcher(store).then(response => {
67-
if(!response.ok) {
67+
if (!response.ok) {
6868
setError(true);
6969
}
7070
});
@@ -78,10 +78,16 @@ const IsvPaymentMethod = props => {
7878
}
7979
}, [deviceFingerprint]);
8080

81+
useEffect(() => {
82+
if (self != top) {
83+
top.location = encodeURI(self.location);
84+
}
85+
}, []);
86+
8187
const [isvSelectedGenericPayment, setIsvSelectedGenericPayment] = useState();
8288

8389
if (isError) {
84-
action('notify', {level: 'error', message: alertTechnicalProblemTryAgain});
90+
action('notify', { level: 'error', message: alertTechnicalProblemTryAgain });
8591
return null;
8692
} else if (applePaySupported) {
8793
return (

0 commit comments

Comments
 (0)