idpay-b2b-sdk 0.0.19 → 0.0.21
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/index.cjs +17 -3
- package/index.js +17 -3
- package/package.json +2 -2
package/index.cjs
CHANGED
|
@@ -38,6 +38,14 @@
|
|
|
38
38
|
}
|
|
39
39
|
let _openWhileInitializing = false;
|
|
40
40
|
const TYPE__IFRAME = 'IFRAME';
|
|
41
|
+
const ENV_DEV = 'dev';
|
|
42
|
+
const ENV_UAT = 'uat';
|
|
43
|
+
const ENV_PROD = 'prod';
|
|
44
|
+
const _HOSTS = {
|
|
45
|
+
[ENV_DEV]: 'https://idpay-dev.unico.io',
|
|
46
|
+
[ENV_UAT]: 'https://idpay-uat.unico.io',
|
|
47
|
+
[ENV_PROD]: 'https://idpay.unico.io'
|
|
48
|
+
};
|
|
41
49
|
const _createScript = ({
|
|
42
50
|
host
|
|
43
51
|
}) => {
|
|
@@ -61,9 +69,10 @@
|
|
|
61
69
|
document.head.appendChild(style);
|
|
62
70
|
return Promise.all([prmStyle]);
|
|
63
71
|
};
|
|
72
|
+
const _getEnvHost = (env = ENV_PROD) => _HOSTS[env];
|
|
64
73
|
const init = _async(function (options) {
|
|
65
74
|
console.log('init', options);
|
|
66
|
-
const host = options?.useCurrentOrigin ? window.location.origin :
|
|
75
|
+
const host = options?.useCurrentOrigin ? window.location.origin : _getEnvHost(options?.env);
|
|
67
76
|
return _await(_createScript({
|
|
68
77
|
host
|
|
69
78
|
}), function () {
|
|
@@ -89,29 +98,34 @@
|
|
|
89
98
|
});
|
|
90
99
|
const startPayFlow = ({
|
|
91
100
|
transactionId,
|
|
101
|
+
token,
|
|
92
102
|
onFinish
|
|
93
103
|
}) => {
|
|
94
104
|
console.log('startPayFlow', {
|
|
95
105
|
transactionId,
|
|
106
|
+
token,
|
|
96
107
|
onFinish
|
|
97
108
|
});
|
|
98
109
|
if (!_initialized) {
|
|
99
110
|
_openWhileInitializing = {
|
|
100
111
|
transactionId,
|
|
112
|
+
token,
|
|
101
113
|
onFinish
|
|
102
114
|
};
|
|
103
115
|
return;
|
|
104
116
|
}
|
|
105
117
|
IDPaySDKAssets.trackEvent(IDPaySDKAssets.EVENT_TYPES.START_FLOW, {
|
|
106
|
-
transactionId
|
|
118
|
+
transactionId,
|
|
119
|
+
token
|
|
107
120
|
});
|
|
108
121
|
if (_type === TYPE__IFRAME) {
|
|
109
122
|
IDPaySDKAssets.clientBoxControl.open({
|
|
110
123
|
transactionId,
|
|
124
|
+
token,
|
|
111
125
|
onFinish
|
|
112
126
|
});
|
|
113
127
|
} else {
|
|
114
|
-
IDPaySDKAssets.clientBoxControl.redirect(transactionId);
|
|
128
|
+
IDPaySDKAssets.clientBoxControl.redirect(transactionId, token);
|
|
115
129
|
}
|
|
116
130
|
};
|
|
117
131
|
const IDPaySDK = {
|
package/index.js
CHANGED
|
@@ -4,6 +4,14 @@ let _type;
|
|
|
4
4
|
let _initialized = false;
|
|
5
5
|
let _openWhileInitializing = false;
|
|
6
6
|
const TYPE__IFRAME = 'IFRAME';
|
|
7
|
+
const ENV_DEV = 'dev';
|
|
8
|
+
const ENV_UAT = 'uat';
|
|
9
|
+
const ENV_PROD = 'prod';
|
|
10
|
+
const _HOSTS = {
|
|
11
|
+
[ENV_DEV]: 'https://idpay-dev.unico.io',
|
|
12
|
+
[ENV_UAT]: 'https://idpay-uat.unico.io',
|
|
13
|
+
[ENV_PROD]: 'https://idpay.unico.io'
|
|
14
|
+
};
|
|
7
15
|
const _createScript = ({
|
|
8
16
|
host
|
|
9
17
|
}) => {
|
|
@@ -27,9 +35,10 @@ const _createStyles = ({
|
|
|
27
35
|
document.head.appendChild(style);
|
|
28
36
|
return Promise.all([prmStyle]);
|
|
29
37
|
};
|
|
38
|
+
const _getEnvHost = (env = ENV_PROD) => _HOSTS[env];
|
|
30
39
|
const init = async options => {
|
|
31
40
|
console.log('init', options);
|
|
32
|
-
const host = options?.useCurrentOrigin ? window.location.origin :
|
|
41
|
+
const host = options?.useCurrentOrigin ? window.location.origin : _getEnvHost(options?.env);
|
|
33
42
|
await _createScript({
|
|
34
43
|
host
|
|
35
44
|
});
|
|
@@ -50,29 +59,34 @@ const init = async options => {
|
|
|
50
59
|
};
|
|
51
60
|
const startPayFlow = ({
|
|
52
61
|
transactionId,
|
|
62
|
+
token,
|
|
53
63
|
onFinish
|
|
54
64
|
}) => {
|
|
55
65
|
console.log('startPayFlow', {
|
|
56
66
|
transactionId,
|
|
67
|
+
token,
|
|
57
68
|
onFinish
|
|
58
69
|
});
|
|
59
70
|
if (!_initialized) {
|
|
60
71
|
_openWhileInitializing = {
|
|
61
72
|
transactionId,
|
|
73
|
+
token,
|
|
62
74
|
onFinish
|
|
63
75
|
};
|
|
64
76
|
return;
|
|
65
77
|
}
|
|
66
78
|
IDPaySDKAssets.trackEvent(IDPaySDKAssets.EVENT_TYPES.START_FLOW, {
|
|
67
|
-
transactionId
|
|
79
|
+
transactionId,
|
|
80
|
+
token
|
|
68
81
|
});
|
|
69
82
|
if (_type === TYPE__IFRAME) {
|
|
70
83
|
IDPaySDKAssets.clientBoxControl.open({
|
|
71
84
|
transactionId,
|
|
85
|
+
token,
|
|
72
86
|
onFinish
|
|
73
87
|
});
|
|
74
88
|
} else {
|
|
75
|
-
IDPaySDKAssets.clientBoxControl.redirect(transactionId);
|
|
89
|
+
IDPaySDKAssets.clientBoxControl.redirect(transactionId, token);
|
|
76
90
|
}
|
|
77
91
|
};
|
|
78
92
|
const IDPaySDK = {
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "idpay-b2b-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.21",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "https://github.com/acesso-io/
|
|
7
|
+
"url": "https://github.com/acesso-io/frontend.git",
|
|
8
8
|
"directory": "libs/pay/sdk/idpay-b2b-sdk"
|
|
9
9
|
},
|
|
10
10
|
"publishConfig": {
|