idpay-b2b-sdk 0.0.26 → 0.0.27

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 CHANGED
@@ -10,7 +10,10 @@
10
10
  let _initialized = false;
11
11
  let _openWhileInitializing = false;
12
12
  let _collectionId;
13
- const TYPE__IFRAME = 'IFRAME';
13
+ let _script;
14
+
15
+ // const TYPE__IFRAME = 'IFRAME';
16
+ const TYPE__REDIRECT = 'REDIRECT';
14
17
  const TYPE_SILENT = 'SILENT';
15
18
  const ENV_DEV = 'dev';
16
19
  const ENV_UAT = 'uat';
@@ -23,12 +26,15 @@
23
26
  const _createScript = ({
24
27
  host
25
28
  }) => {
26
- const script = document.createElement('script');
27
- script.src = `${host}/sdk-assets/index.js`;
29
+ if (_script) {
30
+ return Promise.resolve();
31
+ }
32
+ _script = document.createElement('script');
33
+ _script.src = `${host}/sdk-assets/index.js`;
28
34
  const prmScript = new Promise(resolve => {
29
- script.onload = resolve;
35
+ _script.onload = resolve;
30
36
  });
31
- document.body.appendChild(script);
37
+ document.body.appendChild(_script);
32
38
  return Promise.all([prmScript]);
33
39
  };
34
40
  const _createStyles = ({
@@ -54,7 +60,8 @@
54
60
  _type = options?.type;
55
61
  if (_type === TYPE_SILENT) {
56
62
  _collectionId = await IDPaySDKAssets.clientBoxControl.initSilent();
57
- } else if (_type === TYPE__IFRAME) {
63
+ } else if (_type !== TYPE__REDIRECT) {
64
+ // iframe
58
65
  await _createStyles({
59
66
  host
60
67
  });
@@ -100,18 +107,23 @@
100
107
  collectionId: _collectionId,
101
108
  onFinish
102
109
  });
103
- } else if (_type === TYPE__IFRAME) {
110
+ } else if (_type === TYPE__REDIRECT) {
111
+ IDPaySDKAssets.clientBoxControl.redirect(transactionId, token);
112
+ } else {
113
+ // iframe
104
114
  IDPaySDKAssets.clientBoxControl.open({
105
115
  transactionId,
106
116
  token,
107
117
  onFinish
108
118
  });
109
- } else {
110
- IDPaySDKAssets.clientBoxControl.redirect(transactionId, token);
111
119
  }
112
120
  };
121
+ const close = () => {
122
+ IDPaySDKAssets.clientBoxControl.close();
123
+ };
113
124
  const IDPaySDK = {
114
125
  init,
126
+ close,
115
127
  open: startPayFlow
116
128
  };
117
129
 
package/index.js CHANGED
@@ -4,7 +4,10 @@ let _type;
4
4
  let _initialized = false;
5
5
  let _openWhileInitializing = false;
6
6
  let _collectionId;
7
- const TYPE__IFRAME = 'IFRAME';
7
+ let _script;
8
+
9
+ // const TYPE__IFRAME = 'IFRAME';
10
+ const TYPE__REDIRECT = 'REDIRECT';
8
11
  const TYPE_SILENT = 'SILENT';
9
12
  const ENV_DEV = 'dev';
10
13
  const ENV_UAT = 'uat';
@@ -17,12 +20,15 @@ const _HOSTS = {
17
20
  const _createScript = ({
18
21
  host
19
22
  }) => {
20
- const script = document.createElement('script');
21
- script.src = `${host}/sdk-assets/index.js`;
23
+ if (_script) {
24
+ return Promise.resolve();
25
+ }
26
+ _script = document.createElement('script');
27
+ _script.src = `${host}/sdk-assets/index.js`;
22
28
  const prmScript = new Promise(resolve => {
23
- script.onload = resolve;
29
+ _script.onload = resolve;
24
30
  });
25
- document.body.appendChild(script);
31
+ document.body.appendChild(_script);
26
32
  return Promise.all([prmScript]);
27
33
  };
28
34
  const _createStyles = ({
@@ -48,7 +54,8 @@ const init = async options => {
48
54
  _type = options?.type;
49
55
  if (_type === TYPE_SILENT) {
50
56
  _collectionId = await IDPaySDKAssets.clientBoxControl.initSilent();
51
- } else if (_type === TYPE__IFRAME) {
57
+ } else if (_type !== TYPE__REDIRECT) {
58
+ // iframe
52
59
  await _createStyles({
53
60
  host
54
61
  });
@@ -94,18 +101,23 @@ const startPayFlow = ({
94
101
  collectionId: _collectionId,
95
102
  onFinish
96
103
  });
97
- } else if (_type === TYPE__IFRAME) {
104
+ } else if (_type === TYPE__REDIRECT) {
105
+ IDPaySDKAssets.clientBoxControl.redirect(transactionId, token);
106
+ } else {
107
+ // iframe
98
108
  IDPaySDKAssets.clientBoxControl.open({
99
109
  transactionId,
100
110
  token,
101
111
  onFinish
102
112
  });
103
- } else {
104
- IDPaySDKAssets.clientBoxControl.redirect(transactionId, token);
105
113
  }
106
114
  };
115
+ const close = () => {
116
+ IDPaySDKAssets.clientBoxControl.close();
117
+ };
107
118
  const IDPaySDK = {
108
119
  init,
120
+ close,
109
121
  open: startPayFlow
110
122
  };
111
123
 
package/index.umd.js CHANGED
@@ -10,7 +10,10 @@
10
10
  let _initialized = false;
11
11
  let _openWhileInitializing = false;
12
12
  let _collectionId;
13
- const TYPE__IFRAME = 'IFRAME';
13
+ let _script;
14
+
15
+ // const TYPE__IFRAME = 'IFRAME';
16
+ const TYPE__REDIRECT = 'REDIRECT';
14
17
  const TYPE_SILENT = 'SILENT';
15
18
  const ENV_DEV = 'dev';
16
19
  const ENV_UAT = 'uat';
@@ -23,12 +26,15 @@
23
26
  const _createScript = ({
24
27
  host
25
28
  }) => {
26
- const script = document.createElement('script');
27
- script.src = `${host}/sdk-assets/index.js`;
29
+ if (_script) {
30
+ return Promise.resolve();
31
+ }
32
+ _script = document.createElement('script');
33
+ _script.src = `${host}/sdk-assets/index.js`;
28
34
  const prmScript = new Promise(resolve => {
29
- script.onload = resolve;
35
+ _script.onload = resolve;
30
36
  });
31
- document.body.appendChild(script);
37
+ document.body.appendChild(_script);
32
38
  return Promise.all([prmScript]);
33
39
  };
34
40
  const _createStyles = ({
@@ -54,7 +60,8 @@
54
60
  _type = options?.type;
55
61
  if (_type === TYPE_SILENT) {
56
62
  _collectionId = await IDPaySDKAssets.clientBoxControl.initSilent();
57
- } else if (_type === TYPE__IFRAME) {
63
+ } else if (_type !== TYPE__REDIRECT) {
64
+ // iframe
58
65
  await _createStyles({
59
66
  host
60
67
  });
@@ -100,18 +107,23 @@
100
107
  collectionId: _collectionId,
101
108
  onFinish
102
109
  });
103
- } else if (_type === TYPE__IFRAME) {
110
+ } else if (_type === TYPE__REDIRECT) {
111
+ IDPaySDKAssets.clientBoxControl.redirect(transactionId, token);
112
+ } else {
113
+ // iframe
104
114
  IDPaySDKAssets.clientBoxControl.open({
105
115
  transactionId,
106
116
  token,
107
117
  onFinish
108
118
  });
109
- } else {
110
- IDPaySDKAssets.clientBoxControl.redirect(transactionId, token);
111
119
  }
112
120
  };
121
+ const close = () => {
122
+ IDPaySDKAssets.clientBoxControl.close();
123
+ };
113
124
  const IDPaySDK = {
114
125
  init,
126
+ close,
115
127
  open: startPayFlow
116
128
  };
117
129
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "idpay-b2b-sdk",
3
- "version": "0.0.26",
3
+ "version": "0.0.27",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/acesso-io/frontend.git",
@@ -8,7 +8,7 @@
8
8
  },
9
9
  "publishConfig": {
10
10
  "registry": "https://registry.npmjs.org",
11
- "tag": "internal"
11
+ "tag": "beta"
12
12
  },
13
13
  "module": "./index.esm.js",
14
14
  "type": "module",