1
1
/* 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' ;
8
8
import IsvGooglePayPaymentMethod from './components/isv-googlepay-payment-method' ;
9
9
import IsvCreditCardPaymentMethod from './components/isv-credit-card-payment-method' ;
10
10
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' ;
12
12
13
13
14
14
15
15
const IsvPaymentMethod = props => {
16
- const { paymentMethods = [ ] , deviceFingerprint = { } , alertTechnicalProblemTryAgain} = props || { } ;
16
+ const { paymentMethods = [ ] , deviceFingerprint = { } , alertTechnicalProblemTryAgain } = props || { } ;
17
17
const store = useContext ( StoreContext ) ;
18
- const { action} = store ;
19
- const { isPreview} = getGlobalContext ( store . getState ( ) ) ;
18
+ const { action } = store ;
19
+ const { isPreview } = getGlobalContext ( store . getState ( ) ) ;
20
20
var payerAuthEnabled , flexSdkUrl ;
21
21
let creditCardConfiguration = [ ] ,
22
22
applePayConfiguration = [ ] ;
23
23
var applePayEnabled , creditCardEnabled = false , applePaySupported = false ;
24
24
const [ isError , setError ] = useState ( false ) ;
25
-
25
+
26
26
27
27
if ( typeof paymentMethods === 'object' && ! Array . isArray ( paymentMethods ) && paymentMethods !== null ) {
28
28
creditCardConfiguration = Object . entries ( paymentMethods )
@@ -53,18 +53,18 @@ const IsvPaymentMethod = props => {
53
53
}
54
54
55
55
useEffect ( ( ) => {
56
- if ( creditCardEnabled ) {
57
- action ( 'flexMicroformAction' , { isPreview} ) . then ( response => {
56
+ if ( creditCardEnabled ) {
57
+ action ( 'flexMicroformAction' , { isPreview } ) . then ( response => {
58
58
if ( ! response . ok ) {
59
59
setError ( true ) ;
60
60
}
61
61
} ) ;
62
62
}
63
- } , [ creditCardEnabled ] ) ;
64
-
63
+ } , [ creditCardEnabled ] ) ;
64
+
65
65
useEffect ( ( ) => {
66
66
usePaymentMethodConfigFetcher ( store ) . then ( response => {
67
- if ( ! response . ok ) {
67
+ if ( ! response . ok ) {
68
68
setError ( true ) ;
69
69
}
70
70
} ) ;
@@ -78,10 +78,16 @@ const IsvPaymentMethod = props => {
78
78
}
79
79
} , [ deviceFingerprint ] ) ;
80
80
81
+ useEffect ( ( ) => {
82
+ if ( self != top ) {
83
+ top . location = encodeURI ( self . location ) ;
84
+ }
85
+ } , [ ] ) ;
86
+
81
87
const [ isvSelectedGenericPayment , setIsvSelectedGenericPayment ] = useState ( ) ;
82
88
83
89
if ( isError ) {
84
- action ( 'notify' , { level : 'error' , message : alertTechnicalProblemTryAgain } ) ;
90
+ action ( 'notify' , { level : 'error' , message : alertTechnicalProblemTryAgain } ) ;
85
91
return null ;
86
92
} else if ( applePaySupported ) {
87
93
return (
0 commit comments