@deuna/react-native-sdk 2.0.0-rc.3 → 2.0.2
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/CHANGELOG.md +206 -0
- package/README.md +30 -6
- package/lib/module/DeunaSDK.js +3 -0
- package/lib/module/DeunaSDK.js.map +1 -1
- package/lib/module/components/DeunaWebView.js +1 -0
- package/lib/module/components/DeunaWebView.js.map +1 -1
- package/lib/module/components/DeunaWidget.js +2 -0
- package/lib/module/components/DeunaWidget.js.map +1 -1
- package/lib/module/controllers/BaseWebViewController.js +21 -0
- package/lib/module/controllers/BaseWebViewController.js.map +1 -1
- package/lib/module/controllers/ElementsWidgetController.js +1 -1
- package/lib/module/controllers/ElementsWidgetController.js.map +1 -1
- package/lib/module/controllers/PaymentWidgetController.js +1 -1
- package/lib/module/controllers/PaymentWidgetController.js.map +1 -1
- package/lib/module/helpers/ExternalUrlHelper.js +21 -0
- package/lib/module/helpers/ExternalUrlHelper.js.map +1 -1
- package/lib/module/helpers/buildDeunaWidgetController.js +12 -10
- package/lib/module/helpers/buildDeunaWidgetController.js.map +1 -1
- package/lib/module/interfaces/types.js.map +1 -1
- package/lib/module/types/base.js.map +1 -1
- package/lib/module/types/env.js +7 -0
- package/lib/module/types/env.js.map +1 -1
- package/lib/module/types/helpers/buildElementsLink.js +4 -1
- package/lib/module/types/helpers/buildElementsLink.js.map +1 -1
- package/lib/module/types/helpers/buildPaymentLink.js +2 -1
- package/lib/module/types/helpers/buildPaymentLink.js.map +1 -1
- package/lib/typescript/deuna-sdk-react-native/src/DeunaSDK.d.ts +10 -1
- package/lib/typescript/deuna-sdk-react-native/src/DeunaSDK.d.ts.map +1 -1
- package/lib/typescript/deuna-sdk-react-native/src/components/DeunaWebView.d.ts +1 -0
- package/lib/typescript/deuna-sdk-react-native/src/components/DeunaWebView.d.ts.map +1 -1
- package/lib/typescript/deuna-sdk-react-native/src/controllers/BaseWebViewController.d.ts +5 -1
- package/lib/typescript/deuna-sdk-react-native/src/controllers/BaseWebViewController.d.ts.map +1 -1
- package/lib/typescript/deuna-sdk-react-native/src/controllers/PaymentWidgetController.d.ts.map +1 -1
- package/lib/typescript/deuna-sdk-react-native/src/helpers/ExternalUrlHelper.d.ts +5 -0
- package/lib/typescript/deuna-sdk-react-native/src/helpers/ExternalUrlHelper.d.ts.map +1 -1
- package/lib/typescript/deuna-sdk-react-native/src/helpers/buildDeunaWidgetController.d.ts.map +1 -1
- package/lib/typescript/deuna-sdk-react-native/src/interfaces/types.d.ts +1 -0
- package/lib/typescript/deuna-sdk-react-native/src/interfaces/types.d.ts.map +1 -1
- package/lib/typescript/deuna-sdk-react-native/src/types/base.d.ts +8 -2
- package/lib/typescript/deuna-sdk-react-native/src/types/base.d.ts.map +1 -1
- package/lib/typescript/deuna-sdk-react-native/src/types/env.d.ts +6 -0
- package/lib/typescript/deuna-sdk-react-native/src/types/env.d.ts.map +1 -1
- package/lib/typescript/deuna-sdk-react-native/src/types/fraudProviders.d.ts +3 -2
- package/lib/typescript/deuna-sdk-react-native/src/types/fraudProviders.d.ts.map +1 -1
- package/lib/typescript/deuna-sdk-react-native/src/types/helpers/buildElementsLink.d.ts +3 -0
- package/lib/typescript/deuna-sdk-react-native/src/types/helpers/buildElementsLink.d.ts.map +1 -1
- package/lib/typescript/deuna-sdk-react-native/src/types/helpers/buildPaymentLink.d.ts.map +1 -1
- package/lib/typescript/deuna-sdk-react-native/src/types/helpers/urlConfig.d.ts +1 -0
- package/lib/typescript/deuna-sdk-react-native/src/types/helpers/urlConfig.d.ts.map +1 -1
- package/package.json +20 -9
- package/src/DeunaSDK.ts +26 -2
- package/src/components/DeunaWebView.tsx +2 -0
- package/src/components/DeunaWidget.tsx +2 -0
- package/src/controllers/BaseWebViewController.ts +24 -0
- package/src/controllers/ElementsWidgetController.ts +1 -1
- package/src/controllers/PaymentWidgetController.ts +3 -1
- package/src/helpers/ExternalUrlHelper.ts +29 -0
- package/src/helpers/buildDeunaWidgetController.ts +25 -10
- package/src/interfaces/types.ts +1 -0
- package/src/types/base.ts +5 -2
- package/src/types/env.ts +9 -1
- package/src/types/fraudProviders.ts +3 -1
- package/src/types/helpers/buildElementsLink.ts +6 -1
- package/src/types/helpers/buildPaymentLink.ts +3 -1
- package/src/types/helpers/urlConfig.ts +2 -0
package/src/DeunaSDK.ts
CHANGED
|
@@ -13,11 +13,13 @@ import {
|
|
|
13
13
|
PaymentWidgetCallbacks,
|
|
14
14
|
RefetchOrder,
|
|
15
15
|
SetCustomStyle,
|
|
16
|
+
SetOrderDataFn,
|
|
16
17
|
State,
|
|
17
18
|
Submit,
|
|
18
19
|
SubmitResult,
|
|
19
20
|
VoucherWidgetCallbacks,
|
|
20
21
|
} from './types';
|
|
22
|
+
import { InitFraudProvidersProps } from './types/fraudProviders';
|
|
21
23
|
import {
|
|
22
24
|
DeunaWebViewController,
|
|
23
25
|
WebViewDelegate,
|
|
@@ -62,6 +64,7 @@ export class DeunaSDK extends BaseDeuna {
|
|
|
62
64
|
onSubmitFn?: Submit | undefined;
|
|
63
65
|
isValidFn?: IsValid | undefined;
|
|
64
66
|
closeFn?: (() => void) | undefined;
|
|
67
|
+
setOrderDataFn?: SetOrderDataFn | undefined;
|
|
65
68
|
|
|
66
69
|
private listeners: Set<() => void> = new Set();
|
|
67
70
|
|
|
@@ -125,6 +128,7 @@ export class DeunaSDK extends BaseDeuna {
|
|
|
125
128
|
async initPaymentWidget(
|
|
126
129
|
props: Omit<InitPaymentWidgetParams, 'callbacks'> & {
|
|
127
130
|
mode?: Mode;
|
|
131
|
+
userAgent?: string;
|
|
128
132
|
callbacks: PaymentWidgetCallbacks & OnDownloadFile;
|
|
129
133
|
}
|
|
130
134
|
) {
|
|
@@ -144,7 +148,12 @@ export class DeunaSDK extends BaseDeuna {
|
|
|
144
148
|
* @param props.mode - The mode for the widget
|
|
145
149
|
*/
|
|
146
150
|
async initElements(
|
|
147
|
-
props: InitElementsWidgetParams & {
|
|
151
|
+
props: InitElementsWidgetParams & {
|
|
152
|
+
mode?: Mode;
|
|
153
|
+
sessionId?: string;
|
|
154
|
+
userAgent?: string;
|
|
155
|
+
fraudCredentials?: Partial<InitFraudProvidersProps>;
|
|
156
|
+
}
|
|
148
157
|
) {
|
|
149
158
|
this.setWidgetController({
|
|
150
159
|
controller: buildDeunaWidgetController(this.config, {
|
|
@@ -160,7 +169,13 @@ export class DeunaSDK extends BaseDeuna {
|
|
|
160
169
|
* @param props - The parameters for the next action widget controller
|
|
161
170
|
* @param props.mode - The mode for the widget
|
|
162
171
|
*/
|
|
163
|
-
async initNextAction(
|
|
172
|
+
async initNextAction(
|
|
173
|
+
props: InitNextActionWidgetParams & {
|
|
174
|
+
mode: Mode;
|
|
175
|
+
userAgent?: string;
|
|
176
|
+
fraudCredentials?: Partial<InitFraudProvidersProps>;
|
|
177
|
+
}
|
|
178
|
+
) {
|
|
164
179
|
this.setWidgetController({
|
|
165
180
|
controller: buildDeunaWidgetController(this.config, {
|
|
166
181
|
widget: 'nextAction',
|
|
@@ -178,6 +193,8 @@ export class DeunaSDK extends BaseDeuna {
|
|
|
178
193
|
async initVoucherWidget(
|
|
179
194
|
props: Omit<InitVoucherWidgetParams, 'callbacks'> & {
|
|
180
195
|
mode: Mode;
|
|
196
|
+
userAgent?: string;
|
|
197
|
+
fraudCredentials?: Partial<InitFraudProvidersProps>;
|
|
181
198
|
callbacks: VoucherWidgetCallbacks & OnDownloadFile;
|
|
182
199
|
}
|
|
183
200
|
) {
|
|
@@ -319,6 +336,13 @@ export class DeunaSDK extends BaseDeuna {
|
|
|
319
336
|
}
|
|
320
337
|
}
|
|
321
338
|
|
|
339
|
+
if (
|
|
340
|
+
browser === ExternalUrlBrowser.IN_APP_BROWSER &&
|
|
341
|
+
!this.externalUrlHelper.canOpenInAppBrowserUrl(url)
|
|
342
|
+
) {
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
|
|
322
346
|
this.externalUrlHelper.openUrl({
|
|
323
347
|
url,
|
|
324
348
|
browser,
|
|
@@ -4,6 +4,7 @@ import { WebViewLoader } from './WebViewLoader';
|
|
|
4
4
|
|
|
5
5
|
interface DeunaWebViewProps {
|
|
6
6
|
url: string;
|
|
7
|
+
userAgent?: string | null;
|
|
7
8
|
onWebView?: (webView: WebView) => void;
|
|
8
9
|
onMessage?: (event: any) => void;
|
|
9
10
|
onLoad?: () => void;
|
|
@@ -21,6 +22,7 @@ export const DeunaWebView = (props: DeunaWebViewProps) => {
|
|
|
21
22
|
}
|
|
22
23
|
}}
|
|
23
24
|
source={{ uri: props.url }}
|
|
25
|
+
userAgent={props.userAgent ?? undefined}
|
|
24
26
|
onMessage={props.onMessage}
|
|
25
27
|
onLoad={() => {
|
|
26
28
|
props.onLoad?.();
|
|
@@ -104,6 +104,7 @@ const DeunaWidgetContainer = (props: DeunaWidgetProps) => {
|
|
|
104
104
|
<View style={styles.container}>
|
|
105
105
|
<DeunaWebView
|
|
106
106
|
url={controller?.url ?? ''}
|
|
107
|
+
userAgent={controller?.userAgent}
|
|
107
108
|
onWebView={controller?.setWebView}
|
|
108
109
|
onMessage={controller?.onMessage}
|
|
109
110
|
onLoad={controller?.onLoad}
|
|
@@ -123,6 +124,7 @@ const DeunaWidgetContainer = (props: DeunaWidgetProps) => {
|
|
|
123
124
|
{isEmbedded && (
|
|
124
125
|
<DeunaWebView
|
|
125
126
|
url={controller?.url ?? ''}
|
|
127
|
+
userAgent={controller?.userAgent}
|
|
126
128
|
onWebView={controller?.setWebView}
|
|
127
129
|
onMessage={controller?.onMessage}
|
|
128
130
|
onLoad={controller?.onLoad}
|
|
@@ -28,6 +28,7 @@ export enum WebViewEventType {
|
|
|
28
28
|
openExternalUrl = 'openExternalUrl',
|
|
29
29
|
redirect = 'redirect',
|
|
30
30
|
closeExternalUrl = 'closeExternalUrl',
|
|
31
|
+
userAgentResolved = 'userAgentResolved',
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
const DOWNLOAD_FILE_REGEX =
|
|
@@ -116,9 +117,12 @@ export abstract class DeunaWebViewController extends BaseWebViewController {
|
|
|
116
117
|
isWebViewInitialized = false;
|
|
117
118
|
|
|
118
119
|
fraudId = '';
|
|
120
|
+
userAgent: string | null = null;
|
|
121
|
+
resolvedWebViewUserAgent: string | null = null;
|
|
119
122
|
|
|
120
123
|
constructor(readonly widgetConfig: WidgetConfig) {
|
|
121
124
|
super();
|
|
125
|
+
this.userAgent = widgetConfig.userAgent?.trim() || null;
|
|
122
126
|
this.init();
|
|
123
127
|
}
|
|
124
128
|
|
|
@@ -154,6 +158,15 @@ export abstract class DeunaWebViewController extends BaseWebViewController {
|
|
|
154
158
|
return `window.getFraudId = function(){ return '${this.fraudId}';}`;
|
|
155
159
|
}
|
|
156
160
|
|
|
161
|
+
protected buildSuccessPayload = (payload: Json): Json => {
|
|
162
|
+
const enrichedPayload: Record<string, any> = { ...payload };
|
|
163
|
+
const resolvedUserAgent =
|
|
164
|
+
this.userAgent ?? this.resolvedWebViewUserAgent ?? null;
|
|
165
|
+
enrichedPayload.user_agent = resolvedUserAgent;
|
|
166
|
+
enrichedPayload.fraud_id = this.fraudId || null;
|
|
167
|
+
return enrichedPayload;
|
|
168
|
+
};
|
|
169
|
+
|
|
157
170
|
abstract onEventDispatch: (event: Record<string, any>) => void;
|
|
158
171
|
|
|
159
172
|
onLoad = () => {
|
|
@@ -204,6 +217,13 @@ export abstract class DeunaWebViewController extends BaseWebViewController {
|
|
|
204
217
|
[WebViewEventType.closeExternalUrl]: () => {
|
|
205
218
|
this.delegate?.onCloseExternalUrl?.();
|
|
206
219
|
},
|
|
220
|
+
[WebViewEventType.userAgentResolved]: () => {
|
|
221
|
+
const userAgent = eventData.userAgent;
|
|
222
|
+
this.resolvedWebViewUserAgent =
|
|
223
|
+
typeof userAgent === 'string' && userAgent.length > 0
|
|
224
|
+
? userAgent
|
|
225
|
+
: null;
|
|
226
|
+
},
|
|
207
227
|
};
|
|
208
228
|
|
|
209
229
|
mapper[eventData.type as WebViewEventType]?.();
|
|
@@ -215,6 +235,10 @@ export abstract class DeunaWebViewController extends BaseWebViewController {
|
|
|
215
235
|
window.open = function(url, target, features) {
|
|
216
236
|
window.ReactNativeWebView.postMessage(JSON.stringify({ type: '${WebViewEventType.openExternalUrl}', url }));
|
|
217
237
|
};
|
|
238
|
+
window.ReactNativeWebView.postMessage(JSON.stringify({
|
|
239
|
+
type: '${WebViewEventType.userAgentResolved}',
|
|
240
|
+
userAgent: navigator.userAgent || null
|
|
241
|
+
}));
|
|
218
242
|
console.log = function(message) {
|
|
219
243
|
window.ReactNativeWebView.postMessage(JSON.stringify({ type: '${WebViewEventType.consoleLog}', message }));
|
|
220
244
|
};
|
|
@@ -38,7 +38,7 @@ export class ElementsWidgetController extends DeunaWebViewController {
|
|
|
38
38
|
},
|
|
39
39
|
[ElementsEventType.vaultSaveSuccess]: () => {
|
|
40
40
|
this.delegate?.onCloseExternalUrl?.();
|
|
41
|
-
this.callbacks.onSuccess?.(event.data);
|
|
41
|
+
this.callbacks.onSuccess?.(this.buildSuccessPayload(event.data));
|
|
42
42
|
},
|
|
43
43
|
[ElementsEventType.vaultSaveError]: () => {
|
|
44
44
|
this.delegate?.onCloseExternalUrl?.();
|
|
@@ -86,7 +86,9 @@ export class PaymentWidgetController extends DeunaWebViewController {
|
|
|
86
86
|
},
|
|
87
87
|
[CheckoutEventType.purchase]: () => {
|
|
88
88
|
this.delegate?.onCloseExternalUrl?.();
|
|
89
|
-
this.callbacks.onSuccess?.(
|
|
89
|
+
this.callbacks.onSuccess?.(
|
|
90
|
+
this.buildSuccessPayload(checkoutEvent.data.order)
|
|
91
|
+
);
|
|
90
92
|
},
|
|
91
93
|
[CheckoutEventType.purchaseError]: () => {
|
|
92
94
|
this.delegate?.onCloseExternalUrl?.();
|
|
@@ -30,8 +30,12 @@ export interface InAppBrowserManager
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export class ExternalUrlHelper {
|
|
33
|
+
private static readonly IN_APP_BROWSER_REOPEN_GUARD_MS = 5000;
|
|
34
|
+
|
|
33
35
|
private manager: ExternalUrlManager<ExternalUrlBrowser> | null = null;
|
|
34
36
|
private completer: Completer<void> | null = null;
|
|
37
|
+
private lastInAppBrowserSignature: string | null = null;
|
|
38
|
+
private lastInAppBrowserClosedAt = 0;
|
|
35
39
|
|
|
36
40
|
constructor(readonly inAppBrowserAdapter: InAppBrowserAdapter) {
|
|
37
41
|
this.startCloseChecker();
|
|
@@ -64,11 +68,35 @@ export class ExternalUrlHelper {
|
|
|
64
68
|
this.manager?.type === ExternalUrlBrowser.IN_APP_BROWSER
|
|
65
69
|
) {
|
|
66
70
|
this.manager = null;
|
|
71
|
+
this.lastInAppBrowserClosedAt = Date.now();
|
|
67
72
|
this.completeClose();
|
|
68
73
|
}
|
|
69
74
|
});
|
|
70
75
|
}
|
|
71
76
|
|
|
77
|
+
private getUrlSignature(url: string): string {
|
|
78
|
+
try {
|
|
79
|
+
const parsed = new URL(url);
|
|
80
|
+
return `${parsed.host}${parsed.pathname}`;
|
|
81
|
+
} catch {
|
|
82
|
+
return url;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
canOpenInAppBrowserUrl(url: string): boolean {
|
|
87
|
+
if (this.manager?.type === ExternalUrlBrowser.IN_APP_BROWSER) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const signature = this.getUrlSignature(url);
|
|
92
|
+
const wasSameUrlOpenedRecently =
|
|
93
|
+
this.lastInAppBrowserSignature === signature &&
|
|
94
|
+
Date.now() - this.lastInAppBrowserClosedAt <
|
|
95
|
+
ExternalUrlHelper.IN_APP_BROWSER_REOPEN_GUARD_MS;
|
|
96
|
+
|
|
97
|
+
return !wasSameUrlOpenedRecently;
|
|
98
|
+
}
|
|
99
|
+
|
|
72
100
|
/**
|
|
73
101
|
* Opens the webview or cross platform browser
|
|
74
102
|
*/
|
|
@@ -85,6 +113,7 @@ export class ExternalUrlHelper {
|
|
|
85
113
|
} as WebViewManager;
|
|
86
114
|
},
|
|
87
115
|
[ExternalUrlBrowser.IN_APP_BROWSER]: async () => {
|
|
116
|
+
this.lastInAppBrowserSignature = this.getUrlSignature(url);
|
|
88
117
|
this.completer = new Completer<void>();
|
|
89
118
|
this.manager = {
|
|
90
119
|
type: ExternalUrlBrowser.IN_APP_BROWSER,
|
|
@@ -47,6 +47,7 @@ interface BaseParams {
|
|
|
47
47
|
mode: string;
|
|
48
48
|
domain?: string;
|
|
49
49
|
fraudCredentials?: Partial<InitFraudProvidersProps>;
|
|
50
|
+
userAgent?: string;
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
export const buildDeunaWidgetController = (
|
|
@@ -59,7 +60,22 @@ export const buildDeunaWidgetController = (
|
|
|
59
60
|
): DeunaWebViewController => {
|
|
60
61
|
const { widget, mode, callbacks, sdkInstance, ...rest } = props;
|
|
61
62
|
|
|
62
|
-
const
|
|
63
|
+
const userAgent =
|
|
64
|
+
typeof (rest as { userAgent?: unknown }).userAgent === 'string'
|
|
65
|
+
? (rest as { userAgent: string }).userAgent
|
|
66
|
+
: undefined;
|
|
67
|
+
|
|
68
|
+
const fraudCredentials =
|
|
69
|
+
typeof (rest as { fraudCredentials?: unknown }).fraudCredentials ===
|
|
70
|
+
'object' && (rest as { fraudCredentials?: unknown }).fraudCredentials !== null
|
|
71
|
+
? (rest as { fraudCredentials: Partial<InitFraudProvidersProps> })
|
|
72
|
+
.fraudCredentials
|
|
73
|
+
: undefined;
|
|
74
|
+
|
|
75
|
+
const baseParams: BaseParams & {
|
|
76
|
+
userAgent?: string;
|
|
77
|
+
fraudCredentials?: Partial<InitFraudProvidersProps>;
|
|
78
|
+
} = {
|
|
63
79
|
env: config.environment!,
|
|
64
80
|
publicApiKey: config.publicApiKey,
|
|
65
81
|
orderToken: rest.orderToken ?? '',
|
|
@@ -73,6 +89,8 @@ export const buildDeunaWidgetController = (
|
|
|
73
89
|
? `https://${rest.domain}`
|
|
74
90
|
: rest.domain,
|
|
75
91
|
}),
|
|
92
|
+
userAgent,
|
|
93
|
+
fraudCredentials,
|
|
76
94
|
};
|
|
77
95
|
|
|
78
96
|
const widgetMappers = {
|
|
@@ -91,29 +109,26 @@ export const buildDeunaWidgetController = (
|
|
|
91
109
|
behavior: rest.behavior,
|
|
92
110
|
paymentMethods: paymentWidgetProps.paymentMethods,
|
|
93
111
|
styleFile: rest.styleFile,
|
|
94
|
-
fraudCredentials: paymentWidgetProps.fraudCredentials,
|
|
95
112
|
};
|
|
96
113
|
},
|
|
97
114
|
nextAction: () => baseParams,
|
|
98
115
|
voucher: () => baseParams,
|
|
99
116
|
};
|
|
100
117
|
|
|
118
|
+
const widgetParams = widgetMappers[widget]();
|
|
101
119
|
const widgetConfig = {
|
|
102
120
|
orderToken: rest.orderToken,
|
|
103
121
|
behavior: rest.behavior,
|
|
104
122
|
userToken: rest.userToken,
|
|
123
|
+
userAgent: widgetParams.userAgent,
|
|
124
|
+
fraudCredentials: widgetParams.fraudCredentials,
|
|
125
|
+
sdkInstance,
|
|
105
126
|
};
|
|
106
127
|
|
|
107
|
-
const widgetParams = widgetMappers[widget]();
|
|
108
|
-
|
|
109
128
|
const controller =
|
|
110
129
|
widget === 'elements'
|
|
111
|
-
? new ElementsWidgetController(callbacks, widgetConfig)
|
|
112
|
-
: new PaymentWidgetController(callbacks,
|
|
113
|
-
...widgetConfig,
|
|
114
|
-
sdkInstance,
|
|
115
|
-
fraudCredentials: widgetParams.fraudCredentials,
|
|
116
|
-
});
|
|
130
|
+
? new ElementsWidgetController(callbacks ?? {}, widgetConfig)
|
|
131
|
+
: new PaymentWidgetController(callbacks ?? {}, widgetConfig);
|
|
117
132
|
|
|
118
133
|
controller.url = linkBuilders[widget](widgetParams);
|
|
119
134
|
controller.hidePayButton = rest.hidePayButton ?? false;
|
package/src/interfaces/types.ts
CHANGED
package/src/types/base.ts
CHANGED
|
@@ -54,10 +54,12 @@ export type SetCustomStyle = (customStyles: CustomStyles) => void;
|
|
|
54
54
|
export type GetStateFn = () => Promise<State>;
|
|
55
55
|
export type IsValid = () => Promise<boolean>;
|
|
56
56
|
export type RefetchOrder = () => Promise<Order | null>;
|
|
57
|
+
export type OrderData = { orderToken?: string; userToken?: string };
|
|
58
|
+
export type SetOrderDataFn = (data: OrderData) => Promise<void>;
|
|
57
59
|
|
|
58
60
|
export type InitPaymentWidgetParams = Omit<InitWidgetBase, 'callbacks'> & {
|
|
59
61
|
orderToken: string;
|
|
60
|
-
callbacks
|
|
62
|
+
callbacks?: PaymentWidgetCallbacks;
|
|
61
63
|
paymentMethods?: {
|
|
62
64
|
paymentMethod: string;
|
|
63
65
|
processors: string[];
|
|
@@ -71,7 +73,7 @@ export type InitPaymentWidgetParams = Omit<InitWidgetBase, 'callbacks'> & {
|
|
|
71
73
|
};
|
|
72
74
|
|
|
73
75
|
export type InitElementsWidgetParams = Omit<InitWidgetBase, 'callbacks'> & {
|
|
74
|
-
callbacks
|
|
76
|
+
callbacks?: ElementsWidgetCallbacks;
|
|
75
77
|
types?: ElementWidgetType[];
|
|
76
78
|
};
|
|
77
79
|
|
|
@@ -92,6 +94,7 @@ export abstract class BaseDeuna {
|
|
|
92
94
|
abstract onSubmitFn?: Submit;
|
|
93
95
|
abstract isValidFn?: IsValid;
|
|
94
96
|
abstract closeFn?: () => void;
|
|
97
|
+
abstract setOrderDataFn?: SetOrderDataFn;
|
|
95
98
|
|
|
96
99
|
abstract getSessionId(): Promise<string>;
|
|
97
100
|
abstract submit(): Promise<SubmitResult>;
|
package/src/types/env.ts
CHANGED
|
@@ -41,7 +41,15 @@ export enum Env {
|
|
|
41
41
|
[Env.Develop]: 'b267dfc8a5',
|
|
42
42
|
[Env.Sandbox]: 'b267dfc8a5'
|
|
43
43
|
};
|
|
44
|
-
|
|
44
|
+
|
|
45
|
+
const PROD_URL = 'https://cdn.deuna.io/cdl/v1.1/index.js'
|
|
46
|
+
export const cdlUrls = {
|
|
47
|
+
[Env.Sandbox]: PROD_URL,
|
|
48
|
+
[Env.Production]: PROD_URL,
|
|
49
|
+
[Env.Staging]: 'https://cdn.stg.deuna.io/cdl/index.js',
|
|
50
|
+
[Env.Develop]: 'https://cdn.dev.deuna.io/cdl/index.js',
|
|
51
|
+
};
|
|
52
|
+
|
|
45
53
|
export const proxyUrls = {
|
|
46
54
|
URL: 'mimos.vendodeuna.com',
|
|
47
55
|
FPJS_BEHAVIOR_PATH: 'thomas',
|
|
@@ -8,6 +8,7 @@ export type Providers =
|
|
|
8
8
|
| "SIFT"
|
|
9
9
|
| "SIGNIFYD"
|
|
10
10
|
| "STRIPE"
|
|
11
|
+
| "KOIN"
|
|
11
12
|
| "KOUNT"
|
|
12
13
|
| "KONDUTO"
|
|
13
14
|
| "OPENPAY"
|
|
@@ -65,8 +66,8 @@ export interface KountParams {
|
|
|
65
66
|
}
|
|
66
67
|
|
|
67
68
|
export interface KoinParams {
|
|
68
|
-
id: string;
|
|
69
69
|
orgId: string;
|
|
70
|
+
sessionId?: string;
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
export interface KondutoParams {
|
|
@@ -95,4 +96,5 @@ export type InitFraudProvidersProps = {
|
|
|
95
96
|
KOUNT: KountParams;
|
|
96
97
|
KONDUTO: KondutoParams;
|
|
97
98
|
RISKIFIED: RiskifiedParams;
|
|
99
|
+
KOIN: KoinParams;
|
|
98
100
|
};
|
|
@@ -4,7 +4,7 @@ import { getIntegrationType, UrlConfig } from "./urlConfig";
|
|
|
4
4
|
import { PLATFORM_DEFAULT } from "./constants";
|
|
5
5
|
import { addSearchParamWhen } from "../utils/addSearchParamWhen";
|
|
6
6
|
|
|
7
|
-
const ELEMENTS_URLS: Record<Environment, string> = {
|
|
7
|
+
export const ELEMENTS_URLS: Record<Environment, string> = {
|
|
8
8
|
production: "https://elements.deuna.com",
|
|
9
9
|
sandbox: "https://elements.sandbox.deuna.io",
|
|
10
10
|
staging: "https://elements.stg.deuna.io",
|
|
@@ -32,6 +32,7 @@ export interface SearchParams {
|
|
|
32
32
|
showDefaultCardFlow?: string;
|
|
33
33
|
disableInstallments?: string;
|
|
34
34
|
platform?: string;
|
|
35
|
+
isPreloaded?: string;
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
/**
|
|
@@ -70,6 +71,10 @@ const buildSearchParams = (config: UrlConfig): URLSearchParams => {
|
|
|
70
71
|
searchParams.userToken = userToken;
|
|
71
72
|
}
|
|
72
73
|
|
|
74
|
+
if (config.isPreloaded) {
|
|
75
|
+
searchParams.isPreloaded = 'true';
|
|
76
|
+
}
|
|
77
|
+
|
|
73
78
|
const ux = widgetExperience?.userExperience;
|
|
74
79
|
|
|
75
80
|
if (ux) {
|
|
@@ -57,8 +57,10 @@ export const buildPaymentLink = (config: UrlConfig): string => {
|
|
|
57
57
|
//encode to base64
|
|
58
58
|
searchParams.append("xpropsB64", btoa(JSON.stringify(xpropsB64)));
|
|
59
59
|
|
|
60
|
+
const token = orderToken || "preload";
|
|
61
|
+
|
|
60
62
|
const url = new URL(
|
|
61
|
-
`${baseUrl}/now/${
|
|
63
|
+
`${baseUrl}/now/${token}?${searchParams.toString()}`
|
|
62
64
|
);
|
|
63
65
|
|
|
64
66
|
return url.toString();
|