@@ -34,7 +34,9 @@ const updateElementFromAction = (
34
34
) => {
35
35
if ( message . type === ResponseMessageTypes . ERROR || message . type === ResponseMessageTypes . FAILED ) {
36
36
iframe . initialized = false ;
37
- iframe . resetToken ( ) ;
37
+ iframe . resetToken ( ) . catch ( e => {
38
+ console . error ( e ) ;
39
+ } ) ;
38
40
} else if ( message . type !== ResponseMessageTypes . CONFIRMATION ) {
39
41
iframe . complete = true ;
40
42
}
@@ -43,7 +45,7 @@ const updateElementFromAction = (
43
45
const reconnectIfDisconnected = async (
44
46
iframe : PayTheoryHostedFieldTransactional ,
45
47
) : Promise < ErrorResponse | null > => {
46
- if ( iframe . connected == false ) {
48
+ if ( ! iframe . connected ) {
47
49
const result = await iframe . resetToken ( ) ;
48
50
if ( result . type === ResponseMessageTypes . ERROR ) {
49
51
return common . handleTypedError ( ErrorType . SOCKET_ERROR , result . error ) ;
@@ -76,9 +78,9 @@ export const transact = async (
76
78
ErrorType . ACTION_IN_PROGRESS ,
77
79
'this function has already been called' ,
78
80
) ;
79
- } else if ( transactingElement . valid == false ) {
81
+ } else if ( ! transactingElement . valid ) {
80
82
return common . handleTypedError ( ErrorType . NOT_VALID , 'The transaction element is invalid' ) ;
81
- } else if ( transactingElement . ready == false ) {
83
+ } else if ( ! transactingElement . ready ) {
82
84
return common . handleTypedError ( ErrorType . NOT_READY , 'The transaction element is not ready' ) ;
83
85
} else {
84
86
const reconnectError = await reconnectIfDisconnected ( transactingElement ) ;
@@ -87,14 +89,14 @@ export const transact = async (
87
89
transactingElement . initialized = true ;
88
90
const newProps = common . parseInputParams ( props ) as ModifiedTransactProps ;
89
91
const { payorInfo, customerInfo, shippingDetails } = newProps ;
90
- newProps . payorInfo = payorInfo || customerInfo || shippingDetails || { } ;
92
+ newProps . payorInfo = payorInfo ?? customerInfo ?? shippingDetails ?? { } ;
91
93
// Adding line for backwards compatability. Default to what was passed into the transact function, then the one passed into create, then the default
92
94
newProps . feeMode = newProps . feeMode
93
95
? newProps . feeMode
94
96
: transactingElement . feeMode
95
97
? transactingElement . feeMode
96
98
: MERCHANT_FEE ;
97
- // @ts -ignore Adding line for backwards compatibility
99
+ // @ts -expect-error Adding line for backwards compatibility
98
100
newProps . feeMode = newProps . feeMode === 'interchange' ? MERCHANT_FEE : newProps . feeMode ;
99
101
// Check for validity of the transaction parameters
100
102
const validity = valid . validTransactionParams ( newProps ) ;
@@ -125,7 +127,8 @@ export const transact = async (
125
127
sendObserverMessage ( parsedResponse ) ;
126
128
return parsedResponse ;
127
129
} catch ( e ) {
128
- return common . handleError ( e ?. error || e ?. message || e ) ;
130
+ const errorString : string = e ?. error || e ?. message || e ;
131
+ return common . handleError ( errorString ) ;
129
132
}
130
133
}
131
134
} else {
@@ -163,7 +166,6 @@ export const confirm = async (): Promise<
163
166
}
164
167
} ;
165
168
166
- // @ts -ignore
167
169
export const cancel = async ( ) : Promise < true | ErrorResponse > => {
168
170
const transactingElement = findTransactingElement ( ) ;
169
171
if ( transactingElement ) {
@@ -237,7 +239,7 @@ export const tokenizePaymentMethod = async (
237
239
}
238
240
} ;
239
241
240
- export const activateCardPresentDevice = async ( ) : Promise < ErrorResponse | true > => {
242
+ export const activateCardPresentDevice = ( ) : ErrorResponse | true => {
241
243
return true ;
242
244
} ;
243
245
@@ -253,7 +255,7 @@ export const updateAmount = async (amount: number): Promise<ErrorResponse | true
253
255
const elements = document . getElementsByName ( id ) ;
254
256
if ( elements . length ) {
255
257
const transactingElement = elements [ 0 ] as PayTheoryHostedFieldTransactional ;
256
- if ( transactingElement . ready == false ) {
258
+ if ( ! transactingElement . ready ) {
257
259
return common . handleTypedError (
258
260
ErrorType . NOT_READY ,
259
261
'Not all fields are ready to update the amount' ,
0 commit comments