@deuna/react-native-sdk 1.0.4 → 1.0.6
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/module/DeunaSDK.js +2 -1
- package/lib/module/DeunaSDK.js.map +1 -1
- package/lib/module/controllers/BaseWebViewController.js +44 -2
- package/lib/module/controllers/BaseWebViewController.js.map +1 -1
- package/lib/module/helpers/buildDeunaWidgetController.js +18 -8
- 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/envs.js +48 -0
- package/lib/module/types/envs.js.map +1 -0
- package/lib/module/types/fraudProviders.js +4 -0
- package/lib/module/types/fraudProviders.js.map +1 -0
- package/lib/module/types/helpers/buildElementsLink.js +12 -5
- package/lib/module/types/helpers/buildElementsLink.js.map +1 -1
- package/lib/module/types/helpers/buildPaymentLink.js +4 -2
- package/lib/module/types/helpers/buildPaymentLink.js.map +1 -1
- package/lib/module/types/utils/addSearchParamWhen.js +8 -0
- package/lib/module/types/utils/addSearchParamWhen.js.map +1 -0
- package/lib/typescript/deuna-sdk-react-native/src/DeunaSDK.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/helpers/buildDeunaWidgetController.d.ts +2 -0
- 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 +4 -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 +2 -0
- package/lib/typescript/deuna-sdk-react-native/src/types/base.d.ts.map +1 -1
- package/lib/typescript/deuna-sdk-react-native/src/types/envs.d.ts +45 -0
- package/lib/typescript/deuna-sdk-react-native/src/types/envs.d.ts.map +1 -0
- package/lib/typescript/deuna-sdk-react-native/src/types/fraudProviders.d.ts +68 -0
- package/lib/typescript/deuna-sdk-react-native/src/types/fraudProviders.d.ts.map +1 -0
- package/lib/typescript/deuna-sdk-react-native/src/types/helpers/buildElementsLink.d.ts +15 -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/interfaces/initWidgetBase.d.ts +1 -0
- package/lib/typescript/deuna-sdk-react-native/src/types/interfaces/initWidgetBase.d.ts.map +1 -1
- package/lib/typescript/deuna-sdk-react-native/src/types/utils/addSearchParamWhen.d.ts +3 -0
- package/lib/typescript/deuna-sdk-react-native/src/types/utils/addSearchParamWhen.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/DeunaSDK.ts +1 -0
- package/src/controllers/BaseWebViewController.ts +49 -2
- package/src/helpers/buildDeunaWidgetController.ts +40 -11
- package/src/interfaces/types.ts +4 -0
- package/src/types/base.ts +2 -0
- package/src/types/envs.ts +50 -0
- package/src/types/fraudProviders.ts +98 -0
- package/src/types/helpers/buildElementsLink.ts +15 -10
- package/src/types/helpers/buildPaymentLink.ts +5 -2
- package/src/types/interfaces/initWidgetBase.ts +1 -0
- package/src/types/utils/addSearchParamWhen.ts +11 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Env } from "./envs";
|
|
2
|
+
export type Providers = "CLEARSALE" | "CLEARSALE-BRASIL" | "CYBERSOURCE" | "MERCADOPAGO" | "SIFT" | "SIGNIFYD" | "STRIPE" | "KOUNT" | "KONDUTO" | "OPENPAY" | "RISKIFIED";
|
|
3
|
+
export interface FraudProviderParams<T> {
|
|
4
|
+
sessionId: string;
|
|
5
|
+
env: Env;
|
|
6
|
+
params: T;
|
|
7
|
+
}
|
|
8
|
+
export type FraudProvider<T, Provider extends Providers> = (params: FraudProviderParams<T>) => Promise<{
|
|
9
|
+
[key in Provider]?: string | string[];
|
|
10
|
+
} | undefined>;
|
|
11
|
+
export interface RiskifiedParams {
|
|
12
|
+
storeDomain: string;
|
|
13
|
+
}
|
|
14
|
+
export interface CyberSourceParams {
|
|
15
|
+
orgId: string;
|
|
16
|
+
merchantId: string;
|
|
17
|
+
}
|
|
18
|
+
export interface SignifydParams {
|
|
19
|
+
account: string;
|
|
20
|
+
email: string;
|
|
21
|
+
}
|
|
22
|
+
export interface SiftParams {
|
|
23
|
+
accountId: string;
|
|
24
|
+
restApiKey: string;
|
|
25
|
+
}
|
|
26
|
+
export interface ClearSaleParams {
|
|
27
|
+
clientId: string;
|
|
28
|
+
}
|
|
29
|
+
export interface StripeParams {
|
|
30
|
+
apiKey: string;
|
|
31
|
+
}
|
|
32
|
+
export interface KountParams {
|
|
33
|
+
dataCollectorUrl: string;
|
|
34
|
+
merchantId: string;
|
|
35
|
+
clientId: string;
|
|
36
|
+
environment: string;
|
|
37
|
+
version: string;
|
|
38
|
+
isSinglePageApp: boolean;
|
|
39
|
+
}
|
|
40
|
+
export interface KoinParams {
|
|
41
|
+
id: string;
|
|
42
|
+
orgId: string;
|
|
43
|
+
}
|
|
44
|
+
export interface KondutoParams {
|
|
45
|
+
publicKey: string;
|
|
46
|
+
}
|
|
47
|
+
export interface OpenPayParams {
|
|
48
|
+
merchantId: string;
|
|
49
|
+
publicApiKey: string;
|
|
50
|
+
sandboxMode?: boolean;
|
|
51
|
+
}
|
|
52
|
+
export type FraudProvidersObject = {
|
|
53
|
+
[key in Providers]: FraudProvider<any, key>;
|
|
54
|
+
};
|
|
55
|
+
export type InitFraudProvidersProps = {
|
|
56
|
+
CLEARSALE: ClearSaleParams;
|
|
57
|
+
"CLEARSALE-BRASIL": ClearSaleParams;
|
|
58
|
+
OPENPAY: OpenPayParams;
|
|
59
|
+
CYBERSOURCE: CyberSourceParams;
|
|
60
|
+
MERCADOPAGO: {};
|
|
61
|
+
SIFT: SiftParams;
|
|
62
|
+
SIGNIFYD: SignifydParams;
|
|
63
|
+
STRIPE: StripeParams;
|
|
64
|
+
KOUNT: KountParams;
|
|
65
|
+
KONDUTO: KondutoParams;
|
|
66
|
+
RISKIFIED: RiskifiedParams;
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=fraudProviders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fraudProviders.d.ts","sourceRoot":"","sources":["../../../../../src/types/fraudProviders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAE7B,MAAM,MAAM,SAAS,GACjB,WAAW,GACX,kBAAkB,GAClB,aAAa,GACb,aAAa,GACb,MAAM,GACN,UAAU,GACV,QAAQ,GACR,OAAO,GACP,SAAS,GACT,SAAS,GACT,WAAW,CAAC;AAEhB,MAAM,WAAW,mBAAmB,CAAC,CAAC;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,GAAG,CAAC;IACT,MAAM,EAAE,CAAC,CAAC;CACX;AAED,MAAM,MAAM,aAAa,CAAC,CAAC,EAAE,QAAQ,SAAS,SAAS,IAAI,CACzD,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAC,KAC3B,OAAO,CACR;KACG,GAAG,IAAI,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE;CACtC,GACD,SAAS,CACZ,CAAC;AAEF,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,E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iKey: string;
|
|
4
|
+
orderToken: string;
|
|
5
|
+
email: string;
|
|
6
|
+
firstName: string;
|
|
7
|
+
lastName: string;
|
|
8
|
+
int: string;
|
|
9
|
+
language: string;
|
|
10
|
+
cssFile?: string;
|
|
11
|
+
userToken?: string;
|
|
12
|
+
showSavedCardsFlow?: string;
|
|
13
|
+
showDefaultCardFlow?: string;
|
|
14
|
+
disableInstallments?: string;
|
|
15
|
+
platform?: string;
|
|
16
|
+
}
|
|
2
17
|
/**
|
|
3
18
|
* Builds a complete Elements widget URL with all necessary parameters
|
|
4
19
|
* @param config - Configuration object for building the Elements URL
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildElementsLink.d.ts","sourceRoot":"","sources":["../../../../../../src/types/helpers/buildElementsLink.ts"],"names":[],"mappings":"AAEA,OAAO,EAAsB,SAAS,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"buildElementsLink.d.ts","sourceRoot":"","sources":["../../../../../../src/types/helpers/buildElementsLink.ts"],"names":[],"mappings":"AAEA,OAAO,EAAsB,SAAS,EAAE,MAAM,aAAa,CAAC;AAkB5D,MAAM,WAAW,YAAY;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAqED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,QAAQ,SAAS,KAAG,MAmBrD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildPaymentLink.d.ts","sourceRoot":"","sources":["../../../../../../src/types/helpers/buildPaymentLink.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAGL,SAAS,EACV,MAAM,aAAa,CAAC;AAUrB,eAAO,MAAM,gBAAgB,GAAI,QAAQ,SAAS,KAAG,
|
|
1
|
+
{"version":3,"file":"buildPaymentLink.d.ts","sourceRoot":"","sources":["../../../../../../src/types/helpers/buildPaymentLink.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAGL,SAAS,EACV,MAAM,aAAa,CAAC;AAUrB,eAAO,MAAM,gBAAgB,GAAI,QAAQ,SAAS,KAAG,MA2CpD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initWidgetBase.d.ts","sourceRoot":"","sources":["../../../../../../src/types/interfaces/initWidgetBase.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,yBAAyB,EACzB,sBAAsB,EACtB,sBAAsB,EACvB,MAAM,aAAa,CAAC;AAErB,KAAK,WAAW,CAAC,CAAC,IAAI;KACnB,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAChE,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE1C,UAAU,QAAQ;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,UAAU,gBAAgB;IACxB,KAAK,EAAE;QACL,SAAS,EAAE,MAAM,CAAC;QAClB,cAAc,EAAE,MAAM,CAAC;QACvB,eAAe,EAAE,MAAM,CAAC;QACxB,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,oBAAoB,EAAE,MAAM,CAAC;KAC9B,CAAC;IACF,cAAc,EAAE;QACd,kBAAkB,EAAE,OAAO,CAAC;QAC5B,eAAe,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"initWidgetBase.d.ts","sourceRoot":"","sources":["../../../../../../src/types/interfaces/initWidgetBase.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,yBAAyB,EACzB,sBAAsB,EACtB,sBAAsB,EACvB,MAAM,aAAa,CAAC;AAErB,KAAK,WAAW,CAAC,CAAC,IAAI;KACnB,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAChE,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE1C,UAAU,QAAQ;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,UAAU,gBAAgB;IACxB,KAAK,EAAE;QACL,SAAS,EAAE,MAAM,CAAC;QAClB,cAAc,EAAE,MAAM,CAAC;QACvB,eAAe,EAAE,MAAM,CAAC;QACxB,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,oBAAoB,EAAE,MAAM,CAAC;KAC9B,CAAC;IACF,cAAc,EAAE;QACd,kBAAkB,EAAE,OAAO,CAAC;QAC5B,eAAe,EAAE,OAAO,CAAC;QACzB,mBAAmB,CAAC,EAAE,OAAO,CAAC;KAC/B,CAAC;IACF,KAAK,EAAE;QACL,iBAAiB,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Q,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,SAAS,CAAC,EAAE,sBAAsB,GAChC,uBAAuB,GACvB,yBAAyB,GACzB,sBAAsB,CAAC;CAC1B;AAGD,KAAK,kCAAkC,GAAG,SAAS,GAAG,YAAY,CAAC;AACnE,MAAM,WAAW,8BAA8B;IAC7C,IAAI,EAAE,kCAAkC,CAAC;CAC1C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addSearchParamWhen.d.ts","sourceRoot":"","sources":["../../../../../../src/types/utils/addSearchParamWhen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE5D,eAAO,MAAM,kBAAkB,GAC7B,WAAW,OAAO,GAAG,SAAS,EAC9B,WAAW,MAAM,YAAY,EAC7B,cAAc,YAAY,SAK3B,CAAC"}
|
package/package.json
CHANGED
package/src/DeunaSDK.ts
CHANGED
|
@@ -11,6 +11,8 @@ import {
|
|
|
11
11
|
import { submitError, WidgetConfig } from '../interfaces';
|
|
12
12
|
import { Platform } from 'react-native';
|
|
13
13
|
import { ShouldStartLoadRequest } from 'react-native-webview/lib/WebViewTypes';
|
|
14
|
+
import { InitFraudProvidersProps } from '../types/fraudProviders';
|
|
15
|
+
import { DeunaSDK } from '../DeunaSDK';
|
|
14
16
|
|
|
15
17
|
export interface WebViewDelegate {
|
|
16
18
|
onOpenExternalUrl?: (url: string) => void;
|
|
@@ -32,7 +34,6 @@ const DOWNLOAD_FILE_REGEX =
|
|
|
32
34
|
/\.(pdf|doc|docx|xls|xlsx|zip|rar|txt|mp3|mp4|jpg|jpeg|png|gif)$/i;
|
|
33
35
|
|
|
34
36
|
export abstract class BaseWebViewController {
|
|
35
|
-
initialized = false;
|
|
36
37
|
webView: WebView | null = null;
|
|
37
38
|
url: string | null = null;
|
|
38
39
|
|
|
@@ -112,13 +113,51 @@ export abstract class DeunaWebViewController extends BaseWebViewController {
|
|
|
112
113
|
redirectUrl: string | null = null;
|
|
113
114
|
closedAction: ClosedAction = 'systemAction';
|
|
114
115
|
|
|
116
|
+
isWebViewInitialized = false;
|
|
117
|
+
|
|
118
|
+
fraudId = '';
|
|
119
|
+
|
|
115
120
|
constructor(readonly widgetConfig: WidgetConfig) {
|
|
116
121
|
super();
|
|
122
|
+
this.init();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
private init() {
|
|
126
|
+
const { fraudCredentials, sdkInstance } = this.widgetConfig;
|
|
127
|
+
if (!sdkInstance || !fraudCredentials) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (fraudCredentials) {
|
|
132
|
+
this.generateFraudId({ sdkInstance, fraudCredentials });
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
private async generateFraudId({
|
|
137
|
+
sdkInstance,
|
|
138
|
+
fraudCredentials,
|
|
139
|
+
}: {
|
|
140
|
+
sdkInstance: DeunaSDK;
|
|
141
|
+
fraudCredentials: Partial<InitFraudProvidersProps>;
|
|
142
|
+
}) {
|
|
143
|
+
try {
|
|
144
|
+
this.fraudId = await sdkInstance.getSessionId(fraudCredentials);
|
|
145
|
+
if (this.isWebViewInitialized) {
|
|
146
|
+
this.jsExecutor.execute(this.getFraudIdFnString());
|
|
147
|
+
}
|
|
148
|
+
} catch (e) {
|
|
149
|
+
console.log('❌ fraudId', e);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
private getFraudIdFnString() {
|
|
154
|
+
return `window.getFraudId = function(){ return '${this.fraudId}';}`;
|
|
117
155
|
}
|
|
118
156
|
|
|
119
157
|
abstract onEventDispatch: (event: Record<string, any>) => void;
|
|
120
158
|
|
|
121
159
|
onLoad = () => {
|
|
160
|
+
this.isWebViewInitialized = true;
|
|
122
161
|
this.setXprops();
|
|
123
162
|
};
|
|
124
163
|
|
|
@@ -199,7 +238,15 @@ export abstract class DeunaWebViewController extends BaseWebViewController {
|
|
|
199
238
|
onSubmit: function (fn) {
|
|
200
239
|
window.submit = fn;
|
|
201
240
|
},
|
|
202
|
-
|
|
241
|
+
getFraudId: function(){
|
|
242
|
+
if(typeof window.getFraudId === 'function'){
|
|
243
|
+
return window.getFraudId();
|
|
244
|
+
}
|
|
245
|
+
return "";
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
${this.fraudId.length > 0 ? this.getFraudIdFnString() : ''}
|
|
203
250
|
`
|
|
204
251
|
);
|
|
205
252
|
};
|
|
@@ -11,6 +11,9 @@ import {
|
|
|
11
11
|
import { linkBuilders } from '../types/helpers';
|
|
12
12
|
import { Mode } from '../interfaces/types';
|
|
13
13
|
import { DeunaLogs } from '../DeunaLogs';
|
|
14
|
+
import { InitFraudProvidersProps } from '../types/fraudProviders';
|
|
15
|
+
import { Environment } from '../types';
|
|
16
|
+
import { DeunaSDK } from '../DeunaSDK';
|
|
14
17
|
|
|
15
18
|
type PaymentWidgetControllerProps = InitPaymentWidgetParams & {
|
|
16
19
|
widget: 'payment';
|
|
@@ -34,13 +37,29 @@ type ControllerProps =
|
|
|
34
37
|
| VoucherWidgetControllerProps
|
|
35
38
|
| ElementsWidgetControllerProps;
|
|
36
39
|
|
|
40
|
+
interface BaseParams {
|
|
41
|
+
env: Environment;
|
|
42
|
+
publicApiKey: string;
|
|
43
|
+
orderToken: string;
|
|
44
|
+
userToken: string;
|
|
45
|
+
language: string;
|
|
46
|
+
sessionId: string;
|
|
47
|
+
mode: string;
|
|
48
|
+
domain?: string;
|
|
49
|
+
fraudCredentials?: Partial<InitFraudProvidersProps>;
|
|
50
|
+
}
|
|
51
|
+
|
|
37
52
|
export const buildDeunaWidgetController = (
|
|
38
53
|
config: InitializeParams,
|
|
39
|
-
props: ControllerProps & {
|
|
54
|
+
props: ControllerProps & {
|
|
55
|
+
mode?: Mode;
|
|
56
|
+
sessionId?: string;
|
|
57
|
+
sdkInstance?: DeunaSDK;
|
|
58
|
+
}
|
|
40
59
|
): DeunaWebViewController => {
|
|
41
|
-
const { widget, mode, callbacks, ...rest } = props;
|
|
60
|
+
const { widget, mode, callbacks, sdkInstance, ...rest } = props;
|
|
42
61
|
|
|
43
|
-
const baseParams = {
|
|
62
|
+
const baseParams: BaseParams = {
|
|
44
63
|
env: config.environment!,
|
|
45
64
|
publicApiKey: config.publicApiKey,
|
|
46
65
|
orderToken: rest.orderToken ?? '',
|
|
@@ -60,12 +79,16 @@ export const buildDeunaWidgetController = (
|
|
|
60
79
|
widgetExperience: rest.widgetExperience,
|
|
61
80
|
types: (props as ElementsWidgetControllerProps).types,
|
|
62
81
|
}),
|
|
63
|
-
payment: () =>
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
82
|
+
payment: () => {
|
|
83
|
+
const paymentWidgetProps = props as PaymentWidgetControllerProps;
|
|
84
|
+
return {
|
|
85
|
+
...baseParams,
|
|
86
|
+
behavior: rest.behavior,
|
|
87
|
+
paymentMethods: paymentWidgetProps.paymentMethods,
|
|
88
|
+
styleFile: rest.styleFile,
|
|
89
|
+
fraudCredentials: paymentWidgetProps.fraudCredentials,
|
|
90
|
+
};
|
|
91
|
+
},
|
|
69
92
|
nextAction: () => baseParams,
|
|
70
93
|
voucher: () => baseParams,
|
|
71
94
|
};
|
|
@@ -76,12 +99,18 @@ export const buildDeunaWidgetController = (
|
|
|
76
99
|
userToken: rest.userToken,
|
|
77
100
|
};
|
|
78
101
|
|
|
102
|
+
const widgetParams = widgetMappers[widget]();
|
|
103
|
+
|
|
79
104
|
const controller =
|
|
80
105
|
widget === 'elements'
|
|
81
106
|
? new ElementsWidgetController(callbacks, widgetConfig)
|
|
82
|
-
: new PaymentWidgetController(callbacks,
|
|
107
|
+
: new PaymentWidgetController(callbacks, {
|
|
108
|
+
...widgetConfig,
|
|
109
|
+
sdkInstance,
|
|
110
|
+
fraudCredentials: widgetParams.fraudCredentials,
|
|
111
|
+
});
|
|
83
112
|
|
|
84
|
-
controller.url = linkBuilders[widget](
|
|
113
|
+
controller.url = linkBuilders[widget](baseParams);
|
|
85
114
|
controller.hidePayButton = rest.hidePayButton ?? false;
|
|
86
115
|
|
|
87
116
|
DeunaLogs.info('👀 loading link', controller.url);
|
package/src/interfaces/types.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import { DeunaSDK } from '../DeunaSDK';
|
|
1
2
|
import { BehaviorWidget } from '../types';
|
|
3
|
+
import { InitFraudProvidersProps } from '../types/fraudProviders';
|
|
2
4
|
|
|
3
5
|
export interface WidgetConfig {
|
|
4
6
|
behavior?: BehaviorWidget;
|
|
5
7
|
orderToken?: string;
|
|
6
8
|
userToken?: string;
|
|
9
|
+
sdkInstance?: DeunaSDK;
|
|
10
|
+
fraudCredentials?: Partial<InitFraudProvidersProps>;
|
|
7
11
|
}
|
|
8
12
|
|
|
9
13
|
export enum Mode {
|
package/src/types/base.ts
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
} from './interfaces/merchant';
|
|
18
18
|
import { Order } from './interfaces/order';
|
|
19
19
|
import { User } from './interfaces/user';
|
|
20
|
+
import { InitFraudProvidersProps } from './fraudProviders';
|
|
20
21
|
|
|
21
22
|
export type Environment = 'production' | 'sandbox' | 'develop' | 'staging';
|
|
22
23
|
|
|
@@ -65,6 +66,7 @@ export type InitPaymentWidgetParams = Omit<InitWidgetBase, 'callbacks'> & {
|
|
|
65
66
|
flowType?: PaymentMethodConfigurationFlow;
|
|
66
67
|
};
|
|
67
68
|
}[];
|
|
69
|
+
fraudCredentials?: Partial<InitFraudProvidersProps>;
|
|
68
70
|
sessionId?: string;
|
|
69
71
|
};
|
|
70
72
|
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export enum Env {
|
|
2
|
+
Production = 'production',
|
|
3
|
+
Staging = 'staging',
|
|
4
|
+
Develop = 'develop',
|
|
5
|
+
Sandbox = 'sandbox',
|
|
6
|
+
local = 'local'
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const env = {
|
|
10
|
+
[Env.Production]: 'https://apigw.getduna.com/',
|
|
11
|
+
[Env.Staging]: 'https://api.stg.deuna.io/',
|
|
12
|
+
[Env.Develop]: 'https://api.dev.deuna.io/',
|
|
13
|
+
[Env.Sandbox]: 'https://api.sandbox.deuna.io/'
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const checkout = {
|
|
17
|
+
[Env.Production]: 'https://checkout-ux.deuna.com/',
|
|
18
|
+
[Env.Staging]: 'https://checkout.stg.deuna.io/',
|
|
19
|
+
[Env.Develop]: 'https://checkout.dev.deuna.io/',
|
|
20
|
+
[Env.Sandbox]: 'https://checkout.sandbox.deuna.io/'
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const fingerprintjsEnv = {
|
|
24
|
+
[Env.Production]: 'PczoxhUz1RUyPv5Ih7nM',
|
|
25
|
+
[Env.Staging]: 'sB9jPdnpvLP3FkjjUPi3',
|
|
26
|
+
[Env.Develop]: 'sB9jPdnpvLP3FkjjUPi3',
|
|
27
|
+
[Env.Sandbox]: 'sB9jPdnpvLP3FkjjUPi3'
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const storageSite = {
|
|
31
|
+
[Env.Production]: 'https://cdn.getduna.com/cdl/storageSite/index.html',
|
|
32
|
+
[Env.Staging]: 'https://cdn.stg.deuna.io/cdl/storageSite/index.html',
|
|
33
|
+
[Env.Develop]: 'https://cdn.dev.deuna.io/cdl/storageSite/index.html',
|
|
34
|
+
[Env.Sandbox]: 'https://cdn.stg.deuna.io/cdl/storageSite/index.html',
|
|
35
|
+
[Env.local]: 'http://localhost:3005/'
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const siftCred = {
|
|
39
|
+
[Env.Production]: 'ab8ca5421b',
|
|
40
|
+
[Env.Staging]: 'b267dfc8a5',
|
|
41
|
+
[Env.Develop]: 'b267dfc8a5',
|
|
42
|
+
[Env.Sandbox]: 'b267dfc8a5'
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const proxyUrls = {
|
|
46
|
+
URL: 'mimos.vendodeuna.com',
|
|
47
|
+
FPJS_BEHAVIOR_PATH: 'thomas',
|
|
48
|
+
FPJS_AGENT_DOWNLOAD_PATH: 'tommy',
|
|
49
|
+
FPJS_GET_RESULT_PATH: 'pabloinvita'
|
|
50
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { Env } from "./envs";
|
|
2
|
+
|
|
3
|
+
export type Providers =
|
|
4
|
+
| "CLEARSALE"
|
|
5
|
+
| "CLEARSALE-BRASIL"
|
|
6
|
+
| "CYBERSOURCE"
|
|
7
|
+
| "MERCADOPAGO"
|
|
8
|
+
| "SIFT"
|
|
9
|
+
| "SIGNIFYD"
|
|
10
|
+
| "STRIPE"
|
|
11
|
+
| "KOUNT"
|
|
12
|
+
| "KONDUTO"
|
|
13
|
+
| "OPENPAY"
|
|
14
|
+
| "RISKIFIED";
|
|
15
|
+
|
|
16
|
+
export interface FraudProviderParams<T> {
|
|
17
|
+
sessionId: string;
|
|
18
|
+
env: Env;
|
|
19
|
+
params: T;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type FraudProvider<T, Provider extends Providers> = (
|
|
23
|
+
params: FraudProviderParams<T>
|
|
24
|
+
) => Promise<
|
|
25
|
+
| {
|
|
26
|
+
[key in Provider]?: string | string[];
|
|
27
|
+
}
|
|
28
|
+
| undefined
|
|
29
|
+
>;
|
|
30
|
+
|
|
31
|
+
export interface RiskifiedParams {
|
|
32
|
+
storeDomain: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface CyberSourceParams {
|
|
36
|
+
orgId: string;
|
|
37
|
+
merchantId: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface SignifydParams {
|
|
41
|
+
account: string;
|
|
42
|
+
email: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface SiftParams {
|
|
46
|
+
accountId: string;
|
|
47
|
+
restApiKey: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface ClearSaleParams {
|
|
51
|
+
clientId: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface StripeParams {
|
|
55
|
+
apiKey: string;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface KountParams {
|
|
59
|
+
dataCollectorUrl: string;
|
|
60
|
+
merchantId: string; // m = six digit Merchant ID number issued by Kount
|
|
61
|
+
clientId: string;
|
|
62
|
+
environment: string;
|
|
63
|
+
version: string;
|
|
64
|
+
isSinglePageApp: boolean;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface KoinParams {
|
|
68
|
+
id: string;
|
|
69
|
+
orgId: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface KondutoParams {
|
|
73
|
+
publicKey: string;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface OpenPayParams {
|
|
77
|
+
merchantId: string;
|
|
78
|
+
publicApiKey: string;
|
|
79
|
+
sandboxMode?: boolean;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export type FraudProvidersObject = {
|
|
83
|
+
[key in Providers]: FraudProvider<any, key>;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export type InitFraudProvidersProps = {
|
|
87
|
+
CLEARSALE: ClearSaleParams;
|
|
88
|
+
"CLEARSALE-BRASIL": ClearSaleParams;
|
|
89
|
+
OPENPAY: OpenPayParams;
|
|
90
|
+
CYBERSOURCE: CyberSourceParams;
|
|
91
|
+
MERCADOPAGO: {};
|
|
92
|
+
SIFT: SiftParams;
|
|
93
|
+
SIGNIFYD: SignifydParams;
|
|
94
|
+
STRIPE: StripeParams;
|
|
95
|
+
KOUNT: KountParams;
|
|
96
|
+
KONDUTO: KondutoParams;
|
|
97
|
+
RISKIFIED: RiskifiedParams;
|
|
98
|
+
};
|
|
@@ -2,6 +2,7 @@ import { Environment } from "../base";
|
|
|
2
2
|
import { hasKey } from "../utils/hasKey";
|
|
3
3
|
import { getIntegrationType, UrlConfig } from "./urlConfig";
|
|
4
4
|
import { PLATFORM_DEFAULT } from "./constants";
|
|
5
|
+
import { addSearchParamWhen } from "../utils/addSearchParamWhen";
|
|
5
6
|
|
|
6
7
|
const ELEMENTS_URLS: Record<Environment, string> = {
|
|
7
8
|
production: "https://elements.deuna.com",
|
|
@@ -17,7 +18,7 @@ const WIDGET_PATHS = {
|
|
|
17
18
|
|
|
18
19
|
type WidgetPath = keyof typeof WIDGET_PATHS;
|
|
19
20
|
|
|
20
|
-
interface SearchParams {
|
|
21
|
+
export interface SearchParams {
|
|
21
22
|
publicApiKey: string;
|
|
22
23
|
orderToken: string;
|
|
23
24
|
email: string;
|
|
@@ -29,6 +30,7 @@ interface SearchParams {
|
|
|
29
30
|
userToken?: string;
|
|
30
31
|
showSavedCardsFlow?: string;
|
|
31
32
|
showDefaultCardFlow?: string;
|
|
33
|
+
disableInstallments?: string;
|
|
32
34
|
platform?: string;
|
|
33
35
|
}
|
|
34
36
|
|
|
@@ -68,16 +70,19 @@ const buildSearchParams = (config: UrlConfig): URLSearchParams => {
|
|
|
68
70
|
searchParams.userToken = userToken;
|
|
69
71
|
}
|
|
70
72
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
const ux = widgetExperience?.userExperience;
|
|
74
|
+
|
|
75
|
+
if (ux) {
|
|
76
|
+
const userExpParams: Record<keyof typeof ux, keyof SearchParams> = {
|
|
77
|
+
showSavedCardsFlow: "showSavedCardsFlow",
|
|
78
|
+
defaultCardFlow: "showDefaultCardFlow",
|
|
79
|
+
disableInstallments: "disableInstallments",
|
|
80
|
+
};
|
|
76
81
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
);
|
|
82
|
+
Object.entries(userExpParams).forEach(([sourceKey, targetKey]) => {
|
|
83
|
+
const value = ux[sourceKey as keyof typeof ux];
|
|
84
|
+
addSearchParamWhen(value, targetKey, searchParams);
|
|
85
|
+
});
|
|
81
86
|
}
|
|
82
87
|
|
|
83
88
|
return new URLSearchParams(searchParams as unknown as Record<string, string>);
|
|
@@ -20,7 +20,7 @@ const urls: Record<Environment, string> = {
|
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
export const buildPaymentLink = (config: UrlConfig): string => {
|
|
23
|
-
const { env, orderToken } = config;
|
|
23
|
+
const { env, orderToken, widgetExperience } = config;
|
|
24
24
|
|
|
25
25
|
let baseUrl = urls.production;
|
|
26
26
|
|
|
@@ -45,6 +45,7 @@ export const buildPaymentLink = (config: UrlConfig): string => {
|
|
|
45
45
|
cdl: {
|
|
46
46
|
sessionId: config.sessionId,
|
|
47
47
|
},
|
|
48
|
+
widgetExperience,
|
|
48
49
|
};
|
|
49
50
|
|
|
50
51
|
configToQueryParams(config, searchParams);
|
|
@@ -56,7 +57,9 @@ export const buildPaymentLink = (config: UrlConfig): string => {
|
|
|
56
57
|
//encode to base64
|
|
57
58
|
searchParams.append("xpropsB64", btoa(JSON.stringify(xpropsB64)));
|
|
58
59
|
|
|
59
|
-
const url = new URL(
|
|
60
|
+
const url = new URL(
|
|
61
|
+
`${baseUrl}/now/${orderToken}?${searchParams.toString()}`
|
|
62
|
+
);
|
|
60
63
|
|
|
61
64
|
return url.toString();
|
|
62
65
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SearchParams } from "../helpers/buildElementsLink";
|
|
2
|
+
|
|
3
|
+
export const addSearchParamWhen = (
|
|
4
|
+
condition: boolean | undefined,
|
|
5
|
+
paramName: keyof SearchParams,
|
|
6
|
+
searchParams: SearchParams
|
|
7
|
+
) => {
|
|
8
|
+
if (condition) {
|
|
9
|
+
searchParams[paramName] = String(condition);
|
|
10
|
+
}
|
|
11
|
+
};
|