@tonder.io/rn-sdk 0.1.0-beta.DEV1355.7 → 0.1.0-beta.DEV1355.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/core/3DSHandler.js +7 -2
- package/lib/commonjs/core/3DSHandler.js.map +1 -1
- package/lib/commonjs/core/BaseCheckout/index.js +1 -1
- package/lib/commonjs/core/BaseCheckout/index.js.map +1 -1
- package/lib/commonjs/core/EnrollmentContainer/index.js +2 -2
- package/lib/commonjs/core/EnrollmentContainer/index.js.map +1 -1
- package/lib/commonjs/core/Tonder/index.js +11 -5
- package/lib/commonjs/core/Tonder/index.js.map +1 -1
- package/lib/commonjs/shared/constants/environments.js +1 -1
- package/lib/commonjs/ui/components/PaymentMethodsList/index.js +3 -3
- package/lib/commonjs/ui/components/PaymentMethodsList/index.js.map +1 -1
- package/lib/commonjs/ui/components/WebView/ThreeDSWebView.js +17 -3
- package/lib/commonjs/ui/components/WebView/ThreeDSWebView.js.map +1 -1
- package/lib/commonjs/ui/features/TonderPayment/index.js +10 -10
- package/lib/commonjs/ui/features/TonderPayment/index.js.map +1 -1
- package/lib/commonjs/ui/providers/TonderProvider/index.js +6 -4
- package/lib/commonjs/ui/providers/TonderProvider/index.js.map +1 -1
- package/lib/module/core/3DSHandler.js +7 -2
- package/lib/module/core/3DSHandler.js.map +1 -1
- package/lib/module/core/BaseCheckout/index.js +1 -1
- package/lib/module/core/BaseCheckout/index.js.map +1 -1
- package/lib/module/core/EnrollmentContainer/index.js +2 -2
- package/lib/module/core/EnrollmentContainer/index.js.map +1 -1
- package/lib/module/core/Tonder/index.js +11 -5
- package/lib/module/core/Tonder/index.js.map +1 -1
- package/lib/module/shared/constants/environments.js +1 -1
- package/lib/module/ui/components/PaymentMethodsList/index.js +3 -3
- package/lib/module/ui/components/PaymentMethodsList/index.js.map +1 -1
- package/lib/module/ui/components/WebView/ThreeDSWebView.js +18 -4
- package/lib/module/ui/components/WebView/ThreeDSWebView.js.map +1 -1
- package/lib/module/ui/features/TonderPayment/index.js +10 -10
- package/lib/module/ui/features/TonderPayment/index.js.map +1 -1
- package/lib/module/ui/providers/TonderProvider/index.js +6 -4
- package/lib/module/ui/providers/TonderProvider/index.js.map +1 -1
- package/lib/typescript/commonjs/src/core/3DSHandler.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/core/EnrollmentContainer/index.d.ts +1 -1
- package/lib/typescript/commonjs/src/core/EnrollmentContainer/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/core/Tonder/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/shared/constants/environments.d.ts +1 -1
- package/lib/typescript/commonjs/src/ui/components/WebView/ThreeDSWebView.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/ui/features/TonderPayment/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/ui/providers/TonderProvider/index.d.ts.map +1 -1
- package/lib/typescript/module/src/core/3DSHandler.d.ts.map +1 -1
- package/lib/typescript/module/src/core/EnrollmentContainer/index.d.ts +1 -1
- package/lib/typescript/module/src/core/EnrollmentContainer/index.d.ts.map +1 -1
- package/lib/typescript/module/src/core/Tonder/index.d.ts.map +1 -1
- package/lib/typescript/module/src/shared/constants/environments.d.ts +1 -1
- package/lib/typescript/module/src/ui/components/WebView/ThreeDSWebView.d.ts.map +1 -1
- package/lib/typescript/module/src/ui/features/TonderPayment/index.d.ts.map +1 -1
- package/lib/typescript/module/src/ui/providers/TonderProvider/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/core/3DSHandler.ts +24 -8
- package/src/core/BaseCheckout/index.ts +1 -1
- package/src/core/EnrollmentContainer/index.ts +2 -1
- package/src/core/Tonder/index.ts +9 -5
- package/src/shared/constants/environments.ts +1 -1
- package/src/types/srn-temp.d.ts +2 -0
- package/src/ui/components/PaymentMethodsList/index.tsx +3 -3
- package/src/ui/components/WebView/ThreeDSWebView.tsx +20 -5
- package/src/ui/features/TonderPayment/index.tsx +13 -18
- package/src/ui/providers/TonderProvider/index.tsx +14 -10
package/package.json
CHANGED
package/src/core/3DSHandler.ts
CHANGED
|
@@ -64,12 +64,25 @@ export class ThreeDSHandler implements IThreeDSHandler {
|
|
|
64
64
|
// return await this.handleRedirect();
|
|
65
65
|
// }
|
|
66
66
|
const url = this.getRedirectUrl();
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
|
|
68
|
+
if (!url) {
|
|
69
|
+
const url_verify = this.payload.actions.find(
|
|
70
|
+
(it) => it.name === 'verify_transaction_status'
|
|
71
|
+
);
|
|
69
72
|
await this.saveVerifyTransactionUrl(get(url_verify, 'url'));
|
|
70
|
-
}else{
|
|
71
|
-
this.saveVerifyTransactionUrl()
|
|
73
|
+
} else {
|
|
74
|
+
this.saveVerifyTransactionUrl();
|
|
72
75
|
}
|
|
76
|
+
|
|
77
|
+
if (
|
|
78
|
+
this.payload?.provider === 'nuvei' &&
|
|
79
|
+
['Success', 'Authorized'].includes(this.payload?.transaction_status)
|
|
80
|
+
) {
|
|
81
|
+
this.emit3DS('hide3DS', {});
|
|
82
|
+
await this.removeVerifyTransactionUrl();
|
|
83
|
+
await this.onFinish(this.payload);
|
|
84
|
+
}
|
|
85
|
+
|
|
73
86
|
const trx_response = await this.verifyTransaction();
|
|
74
87
|
if (!url) {
|
|
75
88
|
this.emit3DS('hide3DS', {});
|
|
@@ -86,8 +99,10 @@ export class ThreeDSHandler implements IThreeDSHandler {
|
|
|
86
99
|
const transaction_status = response?.transaction_status || '';
|
|
87
100
|
if (
|
|
88
101
|
response?.decline?.error_type === 'Hard' ||
|
|
89
|
-
response?.checkout
|
|
90
|
-
['Success', 'Authorized'].includes(transaction_status)
|
|
102
|
+
response?.checkout?.is_route_finished ||
|
|
103
|
+
['Success', 'Authorized'].includes(transaction_status) ||
|
|
104
|
+
(['Pending'].includes(transaction_status) &&
|
|
105
|
+
!!response?.payment_method?.is_apm)
|
|
91
106
|
) {
|
|
92
107
|
this.emit3DS('hide3DS', {});
|
|
93
108
|
await this.removeVerifyTransactionUrl();
|
|
@@ -95,7 +110,7 @@ export class ThreeDSHandler implements IThreeDSHandler {
|
|
|
95
110
|
} else {
|
|
96
111
|
try {
|
|
97
112
|
const retry_checkout = await this.resumeCheckout(
|
|
98
|
-
response?.checkout
|
|
113
|
+
response?.checkout?.id!
|
|
99
114
|
);
|
|
100
115
|
this.setPayload(retry_checkout);
|
|
101
116
|
|
|
@@ -133,7 +148,8 @@ export class ThreeDSHandler implements IThreeDSHandler {
|
|
|
133
148
|
}
|
|
134
149
|
private async saveVerifyTransactionUrl(urlData?: string): Promise<void> {
|
|
135
150
|
const url =
|
|
136
|
-
|
|
151
|
+
urlData ||
|
|
152
|
+
this.payload?.next_action?.redirect_to_url
|
|
137
153
|
?.verify_transaction_status_url ||
|
|
138
154
|
this.payload?.next_action?.iframe_resources
|
|
139
155
|
?.verify_transaction_status_url;
|
|
@@ -34,7 +34,8 @@ export class EnrollmentContainer implements IEnrollment {
|
|
|
34
34
|
): Promise<{ error?: TonderError }> => {
|
|
35
35
|
return await this.#baseSDK.create(data);
|
|
36
36
|
};
|
|
37
|
-
|
|
37
|
+
|
|
38
|
+
public saveCustomerCard = async(): Promise<IBaseResponse<ISaveCardResponse>> => {
|
|
38
39
|
const currentCallbacks = this.#baseSDK.getState().callbacks;
|
|
39
40
|
try {
|
|
40
41
|
await this.#baseSDK.setState({
|
package/src/core/Tonder/index.ts
CHANGED
|
@@ -81,9 +81,9 @@ class Tonder {
|
|
|
81
81
|
...(selectedMethod && selectedMethod !== ''
|
|
82
82
|
? {
|
|
83
83
|
...(card && card !== ''
|
|
84
|
-
? { card }
|
|
84
|
+
? { card, payment_method: '' }
|
|
85
85
|
: paymentMethod && paymentMethod !== ''
|
|
86
|
-
? { payment_method: paymentMethod }
|
|
86
|
+
? { payment_method: paymentMethod, card: '' }
|
|
87
87
|
: { card: '', payment_method: '' }),
|
|
88
88
|
}
|
|
89
89
|
: {}),
|
|
@@ -110,9 +110,13 @@ class Tonder {
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
public emit = (eventName: string, data: any): void => {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
listeners
|
|
113
|
+
try {
|
|
114
|
+
const listeners = this.eventListeners.get(eventName);
|
|
115
|
+
if (listeners) {
|
|
116
|
+
listeners.forEach((listener) => listener(data));
|
|
117
|
+
}
|
|
118
|
+
} catch (e) {
|
|
119
|
+
console.error('[Tonder | emit | ERROR]', e);
|
|
116
120
|
}
|
|
117
121
|
};
|
|
118
122
|
|
|
@@ -2,7 +2,7 @@ const TONDER_URL_BY_MODE = Object.freeze({
|
|
|
2
2
|
production: 'https://app.tonder.io',
|
|
3
3
|
sandbox: 'https://sandbox.tonder.io',
|
|
4
4
|
stage: 'https://stage.tonder.io',
|
|
5
|
-
development: 'http://192.168.
|
|
5
|
+
development: 'http://192.168.68.102:8000',
|
|
6
6
|
});
|
|
7
7
|
|
|
8
8
|
export { TONDER_URL_BY_MODE };
|
package/src/types/srn-temp.d.ts
CHANGED
|
@@ -67,6 +67,7 @@ declare module 'skyflow-react-native' {
|
|
|
67
67
|
export interface CollectInputStylesVariant
|
|
68
68
|
extends StylesBaseVariant,
|
|
69
69
|
StylesFocusVariant {
|
|
70
|
+
base?: Record<string, any>;
|
|
70
71
|
complete?: Record<string, any>;
|
|
71
72
|
invalid?: Record<string, any>;
|
|
72
73
|
empty?: Record<string, any>;
|
|
@@ -76,6 +77,7 @@ declare module 'skyflow-react-native' {
|
|
|
76
77
|
export interface CollectLabelStylesVariant
|
|
77
78
|
extends StylesBaseVariant,
|
|
78
79
|
StylesFocusVariant {
|
|
80
|
+
base?: Record<string, any>;
|
|
79
81
|
requiredAsterisk?: Record<string, any>;
|
|
80
82
|
}
|
|
81
83
|
}
|
|
@@ -32,9 +32,9 @@ const PaymentMethodsList: React.FC<PaymentMethodsListProps> = ({
|
|
|
32
32
|
selected: style?.radioSelected,
|
|
33
33
|
inner: style?.radioInner,
|
|
34
34
|
}}
|
|
35
|
-
value={method.
|
|
36
|
-
selected={selectedMethod === method.
|
|
37
|
-
onSelect={() => onMethodSelect(method.
|
|
35
|
+
value={method.payment_method}
|
|
36
|
+
selected={selectedMethod === method.payment_method}
|
|
37
|
+
onSelect={() => onMethodSelect(method.payment_method)}
|
|
38
38
|
/>
|
|
39
39
|
<View style={styles.methodIconContainer}>
|
|
40
40
|
<View style={styles.methodIconBorder} />
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
|
+
import { X } from 'lucide-react-native';
|
|
2
3
|
import React, { useEffect, useRef, useState } from 'react';
|
|
3
4
|
import {
|
|
4
5
|
ActivityIndicator,
|
|
5
6
|
Modal,
|
|
6
7
|
SafeAreaView,
|
|
7
8
|
StyleSheet,
|
|
9
|
+
TouchableOpacity,
|
|
8
10
|
View,
|
|
9
11
|
} from 'react-native';
|
|
10
12
|
import WebView from 'react-native-webview';
|
|
@@ -33,12 +35,25 @@ export const ThreeDSWebView: React.FC<ThreeDSWebViewProps> = ({
|
|
|
33
35
|
</View>
|
|
34
36
|
);
|
|
35
37
|
return (
|
|
36
|
-
<Modal
|
|
38
|
+
<Modal
|
|
39
|
+
visible={!!url}
|
|
40
|
+
animationType="slide"
|
|
41
|
+
onRequestClose={() => {
|
|
42
|
+
setIsLoading(true);
|
|
43
|
+
onComplete();
|
|
44
|
+
}}
|
|
45
|
+
>
|
|
37
46
|
<SafeAreaView style={styles.safeArea}>
|
|
38
47
|
<View style={styles.container}>
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
48
|
+
<TouchableOpacity
|
|
49
|
+
style={styles.closeButton}
|
|
50
|
+
onPress={() => {
|
|
51
|
+
setIsLoading(true);
|
|
52
|
+
onComplete();
|
|
53
|
+
}}
|
|
54
|
+
>
|
|
55
|
+
<X size={22} color="#000" />
|
|
56
|
+
</TouchableOpacity>
|
|
42
57
|
<WebView
|
|
43
58
|
source={{ uri: url }}
|
|
44
59
|
style={styles.webview}
|
|
@@ -99,7 +114,7 @@ const styles = StyleSheet.create({
|
|
|
99
114
|
bottom: 0,
|
|
100
115
|
justifyContent: 'center',
|
|
101
116
|
alignItems: 'center',
|
|
102
|
-
backgroundColor: 'rgba(255, 255, 255,1)',
|
|
117
|
+
backgroundColor: 'rgba(255, 255, 255, 1)',
|
|
103
118
|
},
|
|
104
119
|
closeButton: {
|
|
105
120
|
position: 'absolute',
|
|
@@ -19,14 +19,7 @@ const TonderPayment: React.FC<ITonderPaymentProps> = () => {
|
|
|
19
19
|
const [deletingCards, setDelitingCards] = useState<string[]>([]);
|
|
20
20
|
|
|
21
21
|
const handleMethodSelect = (methodId: string, type: string) => {
|
|
22
|
-
|
|
23
|
-
type === 'card'
|
|
24
|
-
? methodId
|
|
25
|
-
: type === 'payment_method'
|
|
26
|
-
? state.uiData?.paymentMethods.find((it) => it.id === methodId)
|
|
27
|
-
?.payment_method || ''
|
|
28
|
-
: '';
|
|
29
|
-
uiWrapper.updateMethod(type, value);
|
|
22
|
+
uiWrapper.updateMethod(type, methodId);
|
|
30
23
|
};
|
|
31
24
|
|
|
32
25
|
const handleSaveCardChange = (value: boolean) => {
|
|
@@ -136,6 +129,17 @@ const TonderPayment: React.FC<ITonderPaymentProps> = () => {
|
|
|
136
129
|
placeholders={state?.customization?.placeholders}
|
|
137
130
|
/>
|
|
138
131
|
)}
|
|
132
|
+
{state?.customization?.paymentMethods?.show && (
|
|
133
|
+
<PaymentMethodsList
|
|
134
|
+
methods={state?.uiData.paymentMethods}
|
|
135
|
+
selectedMethod={state?.uiData?.payment_method || ''}
|
|
136
|
+
onMethodSelect={(methodId) => {
|
|
137
|
+
handleMethodSelect(methodId, 'payment_method');
|
|
138
|
+
}}
|
|
139
|
+
style={state?.customization?.styles?.paymentMethods}
|
|
140
|
+
/>
|
|
141
|
+
)}
|
|
142
|
+
|
|
139
143
|
{state?.customization?.showMessages &&
|
|
140
144
|
state?.message &&
|
|
141
145
|
state?.message !== '' &&
|
|
@@ -181,16 +185,6 @@ const TonderPayment: React.FC<ITonderPaymentProps> = () => {
|
|
|
181
185
|
</Text>
|
|
182
186
|
</View>
|
|
183
187
|
)}
|
|
184
|
-
{state?.customization?.paymentMethods?.show && (
|
|
185
|
-
<PaymentMethodsList
|
|
186
|
-
methods={state?.uiData.paymentMethods}
|
|
187
|
-
selectedMethod={state?.uiData?.payment_method || ''}
|
|
188
|
-
onMethodSelect={(methodId) => {
|
|
189
|
-
handleMethodSelect(methodId, 'payment_method');
|
|
190
|
-
}}
|
|
191
|
-
style={state?.customization?.styles?.paymentMethods}
|
|
192
|
-
/>
|
|
193
|
-
)}
|
|
194
188
|
|
|
195
189
|
{state?.customization?.paymentButton?.show && (
|
|
196
190
|
<ProcessButton
|
|
@@ -229,6 +223,7 @@ const styles = StyleSheet.create({
|
|
|
229
223
|
},
|
|
230
224
|
messageContainer: {
|
|
231
225
|
paddingHorizontal: 20,
|
|
226
|
+
marginVertical: 5,
|
|
232
227
|
},
|
|
233
228
|
errorText: {
|
|
234
229
|
color: 'red',
|
|
@@ -62,7 +62,7 @@ const TonderProvider: React.FC<React.PropsWithChildren<ITonderProvider>> = <
|
|
|
62
62
|
}, [tonder]);
|
|
63
63
|
|
|
64
64
|
useEffect(() => {
|
|
65
|
-
if (!tonder) return;
|
|
65
|
+
if (!tonder || !state?.isCreated) return;
|
|
66
66
|
|
|
67
67
|
const unsubscribeShow = tonder.on(
|
|
68
68
|
'show3DS',
|
|
@@ -71,14 +71,15 @@ const TonderProvider: React.FC<React.PropsWithChildren<ITonderProvider>> = <
|
|
|
71
71
|
}
|
|
72
72
|
);
|
|
73
73
|
const unsubscribeHide = tonder.on('hide3DS', ({}) => {
|
|
74
|
-
setThreeDSConfig({ url:
|
|
74
|
+
setThreeDSConfig({ url: undefined });
|
|
75
75
|
});
|
|
76
76
|
|
|
77
77
|
return () => {
|
|
78
|
+
console.log('unsubs');
|
|
78
79
|
unsubscribeShow();
|
|
79
80
|
unsubscribeHide();
|
|
80
81
|
};
|
|
81
|
-
}, [tonder]);
|
|
82
|
+
}, [tonder, state?.isCreated]);
|
|
82
83
|
|
|
83
84
|
const contextValue = useMemo(
|
|
84
85
|
() => ({
|
|
@@ -89,17 +90,20 @@ const TonderProvider: React.FC<React.PropsWithChildren<ITonderProvider>> = <
|
|
|
89
90
|
[sdk, state, uiSDKWrapper]
|
|
90
91
|
);
|
|
91
92
|
|
|
93
|
+
console.log('threeDSConfig.url: ', threeDSConfig.url);
|
|
92
94
|
return (
|
|
93
95
|
<tonderContext.Provider value={contextValue}>
|
|
94
96
|
<SkyflowProvider config={skyflowConfig}>
|
|
95
97
|
<SkyflowContainerWrapper contextValue={contextValue}>
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
98
|
+
{!!threeDSConfig.url && (
|
|
99
|
+
<ThreeDSWebView
|
|
100
|
+
url={threeDSConfig.url}
|
|
101
|
+
onComplete={() => {
|
|
102
|
+
threeDSConfig.onComplete?.();
|
|
103
|
+
}}
|
|
104
|
+
returnURL={threeDSConfig.returnURL!}
|
|
105
|
+
/>
|
|
106
|
+
)}
|
|
103
107
|
{children}
|
|
104
108
|
</SkyflowContainerWrapper>
|
|
105
109
|
</SkyflowProvider>
|