@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.
Files changed (61) hide show
  1. package/lib/commonjs/core/3DSHandler.js +7 -2
  2. package/lib/commonjs/core/3DSHandler.js.map +1 -1
  3. package/lib/commonjs/core/BaseCheckout/index.js +1 -1
  4. package/lib/commonjs/core/BaseCheckout/index.js.map +1 -1
  5. package/lib/commonjs/core/EnrollmentContainer/index.js +2 -2
  6. package/lib/commonjs/core/EnrollmentContainer/index.js.map +1 -1
  7. package/lib/commonjs/core/Tonder/index.js +11 -5
  8. package/lib/commonjs/core/Tonder/index.js.map +1 -1
  9. package/lib/commonjs/shared/constants/environments.js +1 -1
  10. package/lib/commonjs/ui/components/PaymentMethodsList/index.js +3 -3
  11. package/lib/commonjs/ui/components/PaymentMethodsList/index.js.map +1 -1
  12. package/lib/commonjs/ui/components/WebView/ThreeDSWebView.js +17 -3
  13. package/lib/commonjs/ui/components/WebView/ThreeDSWebView.js.map +1 -1
  14. package/lib/commonjs/ui/features/TonderPayment/index.js +10 -10
  15. package/lib/commonjs/ui/features/TonderPayment/index.js.map +1 -1
  16. package/lib/commonjs/ui/providers/TonderProvider/index.js +6 -4
  17. package/lib/commonjs/ui/providers/TonderProvider/index.js.map +1 -1
  18. package/lib/module/core/3DSHandler.js +7 -2
  19. package/lib/module/core/3DSHandler.js.map +1 -1
  20. package/lib/module/core/BaseCheckout/index.js +1 -1
  21. package/lib/module/core/BaseCheckout/index.js.map +1 -1
  22. package/lib/module/core/EnrollmentContainer/index.js +2 -2
  23. package/lib/module/core/EnrollmentContainer/index.js.map +1 -1
  24. package/lib/module/core/Tonder/index.js +11 -5
  25. package/lib/module/core/Tonder/index.js.map +1 -1
  26. package/lib/module/shared/constants/environments.js +1 -1
  27. package/lib/module/ui/components/PaymentMethodsList/index.js +3 -3
  28. package/lib/module/ui/components/PaymentMethodsList/index.js.map +1 -1
  29. package/lib/module/ui/components/WebView/ThreeDSWebView.js +18 -4
  30. package/lib/module/ui/components/WebView/ThreeDSWebView.js.map +1 -1
  31. package/lib/module/ui/features/TonderPayment/index.js +10 -10
  32. package/lib/module/ui/features/TonderPayment/index.js.map +1 -1
  33. package/lib/module/ui/providers/TonderProvider/index.js +6 -4
  34. package/lib/module/ui/providers/TonderProvider/index.js.map +1 -1
  35. package/lib/typescript/commonjs/src/core/3DSHandler.d.ts.map +1 -1
  36. package/lib/typescript/commonjs/src/core/EnrollmentContainer/index.d.ts +1 -1
  37. package/lib/typescript/commonjs/src/core/EnrollmentContainer/index.d.ts.map +1 -1
  38. package/lib/typescript/commonjs/src/core/Tonder/index.d.ts.map +1 -1
  39. package/lib/typescript/commonjs/src/shared/constants/environments.d.ts +1 -1
  40. package/lib/typescript/commonjs/src/ui/components/WebView/ThreeDSWebView.d.ts.map +1 -1
  41. package/lib/typescript/commonjs/src/ui/features/TonderPayment/index.d.ts.map +1 -1
  42. package/lib/typescript/commonjs/src/ui/providers/TonderProvider/index.d.ts.map +1 -1
  43. package/lib/typescript/module/src/core/3DSHandler.d.ts.map +1 -1
  44. package/lib/typescript/module/src/core/EnrollmentContainer/index.d.ts +1 -1
  45. package/lib/typescript/module/src/core/EnrollmentContainer/index.d.ts.map +1 -1
  46. package/lib/typescript/module/src/core/Tonder/index.d.ts.map +1 -1
  47. package/lib/typescript/module/src/shared/constants/environments.d.ts +1 -1
  48. package/lib/typescript/module/src/ui/components/WebView/ThreeDSWebView.d.ts.map +1 -1
  49. package/lib/typescript/module/src/ui/features/TonderPayment/index.d.ts.map +1 -1
  50. package/lib/typescript/module/src/ui/providers/TonderProvider/index.d.ts.map +1 -1
  51. package/package.json +1 -1
  52. package/src/core/3DSHandler.ts +24 -8
  53. package/src/core/BaseCheckout/index.ts +1 -1
  54. package/src/core/EnrollmentContainer/index.ts +2 -1
  55. package/src/core/Tonder/index.ts +9 -5
  56. package/src/shared/constants/environments.ts +1 -1
  57. package/src/types/srn-temp.d.ts +2 -0
  58. package/src/ui/components/PaymentMethodsList/index.tsx +3 -3
  59. package/src/ui/components/WebView/ThreeDSWebView.tsx +20 -5
  60. package/src/ui/features/TonderPayment/index.tsx +13 -18
  61. package/src/ui/providers/TonderProvider/index.tsx +14 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tonder.io/rn-sdk",
3
- "version": "0.1.0-beta.DEV1355.7",
3
+ "version": "0.1.0-beta.DEV1355.9",
4
4
  "description": "Tonder react native sdk",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "./lib/commonjs/index.js",
@@ -64,12 +64,25 @@ export class ThreeDSHandler implements IThreeDSHandler {
64
64
  // return await this.handleRedirect();
65
65
  // }
66
66
  const url = this.getRedirectUrl();
67
- if(!url){
68
- const url_verify = this.payload.actions.find((it) => it.name === 'verify_transaction_status')
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.is_route_finished ||
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.id!
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
- urlData || this.payload?.next_action?.redirect_to_url
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;
@@ -301,7 +301,7 @@ class BaseCheckout extends BaseSDK {
301
301
  return;
302
302
  }
303
303
 
304
- await executeCallback({
304
+ executeCallback({
305
305
  callbacks: this.getState().callbacks,
306
306
  callback: 'onFinishPayment',
307
307
  data: { response: finalResponse },
@@ -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
- public async saveCustomerCard(): Promise<IBaseResponse<ISaveCardResponse>> {
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({
@@ -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
- const listeners = this.eventListeners.get(eventName);
114
- if (listeners) {
115
- listeners.forEach((listener) => listener(data));
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.100.117:8000',
5
+ development: 'http://192.168.68.102:8000',
6
6
  });
7
7
 
8
8
  export { TONDER_URL_BY_MODE };
@@ -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.id}
36
- selected={selectedMethod === method.id}
37
- onSelect={() => onMethodSelect(method.id)}
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 visible={!!url} animationType="slide" onRequestClose={onComplete}>
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
- {/*<TouchableOpacity style={styles.closeButton} onPress={onComplete}>*/}
40
- {/* <X size={22} color="#000" />*/}
41
- {/*</TouchableOpacity>*/}
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
- const value =
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
- <ThreeDSWebView
97
- url={threeDSConfig.url}
98
- onComplete={() => {
99
- threeDSConfig.onComplete?.();
100
- }}
101
- returnURL={threeDSConfig.returnURL!}
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>