@medipass/checkout-sdk 2.0.1 → 3.0.0-alpha.0
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/README.md +64 -3
- package/dist/cjs/index.js +9 -0
- package/package.json +35 -9
- package/es/constants.js +0 -16
- package/es/index.js +0 -272
- package/es/overlay.js +0 -184
- package/es/style.css +0 -1
- package/es/utils/object-to-css.js +0 -3
- package/lib/constants.js +0 -25
- package/lib/index.js +0 -284
- package/lib/overlay.js +0 -196
- package/lib/style.css +0 -1
- package/lib/utils/object-to-css.js +0 -11
- package/umd/checkout-sdk.js +0 -2193
- package/umd/checkout-sdk.min.js +0 -3
- package/umd/checkout-sdk.min.js.map +0 -1
- package/umd/main.3a4213e0.css +0 -2
- package/umd/main.3a4213e0.css.map +0 -1
package/package.json
CHANGED
|
@@ -1,29 +1,55 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medipass/checkout-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-alpha.0",
|
|
4
4
|
"description": "Describe medipass-checkout-sdk here",
|
|
5
|
-
"main": "
|
|
6
|
-
"module": "
|
|
5
|
+
"main": "dist/cjs/index.js",
|
|
6
|
+
"module": "dist/esm/index.js",
|
|
7
7
|
"files": [
|
|
8
8
|
"es",
|
|
9
9
|
"lib",
|
|
10
10
|
"umd"
|
|
11
11
|
],
|
|
12
12
|
"scripts": {
|
|
13
|
-
"build": "
|
|
13
|
+
"build": "yarn rollup -c",
|
|
14
|
+
"build:types": "tsc --project tsconfig.build.json --module esnext --declarationDir ./dist/types --emitDeclarationOnly --declaration --declarationMap",
|
|
15
|
+
"check-types": "tsc --noEmit",
|
|
16
|
+
"clean": "rm -rf dist",
|
|
14
17
|
"develop": "nodemon -w src -x 'yarn build'",
|
|
15
|
-
"
|
|
16
|
-
"lint": "eslint
|
|
18
|
+
"lint": "eslint \"**/*.{ts,tsx}\"",
|
|
19
|
+
"lint:fix": "eslint \"**/*.{ts,tsx}\" --fix",
|
|
17
20
|
"prepublishOnly": "npm run build",
|
|
18
21
|
"test": "nwb test",
|
|
19
22
|
"test:coverage": "nwb test --coverage",
|
|
20
23
|
"test:watch": "nwb test --server"
|
|
21
24
|
},
|
|
22
|
-
"dependencies": {
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@medipass/utils": "11.80.7",
|
|
27
|
+
"@medipass/web-sdk": "11.64.8"
|
|
28
|
+
},
|
|
23
29
|
"devDependencies": {
|
|
24
|
-
"
|
|
30
|
+
"@rollup/plugin-commonjs": "25.0.3",
|
|
31
|
+
"@rollup/plugin-json": "6.0.0",
|
|
32
|
+
"@rollup/plugin-node-resolve": "15.0.2",
|
|
33
|
+
"@rollup/plugin-terser": "0.4.3",
|
|
34
|
+
"@rollup/plugin-typescript": "11.1.2",
|
|
35
|
+
"@types/file-saver": "2.0.5",
|
|
36
|
+
"@types/lodash": "4.14.196",
|
|
37
|
+
"@typescript-eslint/eslint-plugin": "5.57.1",
|
|
38
|
+
"@typescript-eslint/parser": "5.57.1",
|
|
39
|
+
"eslint": "8.39.0",
|
|
40
|
+
"eslint-config-prettier": "8.8.0",
|
|
41
|
+
"eslint-plugin-prettier": "4.2.1",
|
|
25
42
|
"eslint-plugin-react": "7.11.1",
|
|
26
43
|
"nodemon": "2.0.12",
|
|
27
|
-
"
|
|
44
|
+
"prettier": "2.8.1",
|
|
45
|
+
"rollup": "3.27.0",
|
|
46
|
+
"rollup-plugin-import-css": "3.3.1",
|
|
47
|
+
"rollup-plugin-polyfill-node": "0.12.0",
|
|
48
|
+
"typescript": "5.1.6"
|
|
49
|
+
},
|
|
50
|
+
"exports": {
|
|
51
|
+
".": {
|
|
52
|
+
"import": "./dist/esm/index.js"
|
|
53
|
+
}
|
|
28
54
|
}
|
|
29
55
|
}
|
package/es/constants.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
var _ORIGINS;
|
|
2
|
-
|
|
3
|
-
export var ENVS = {
|
|
4
|
-
LOCAL: 'local',
|
|
5
|
-
DEV: 'dev',
|
|
6
|
-
STG: 'stg',
|
|
7
|
-
PROD_BLUE: 'prod-blue',
|
|
8
|
-
PROD: 'prod'
|
|
9
|
-
};
|
|
10
|
-
export var ORIGINS = (_ORIGINS = {}, _ORIGINS[ENVS.LOCAL] = 'http://localhost:3001', _ORIGINS[ENVS.DEV] = 'https://dev-my.medipass.io', _ORIGINS[ENVS.STG] = 'https://stg-my.medipass.io', _ORIGINS[ENVS.PROD_BLUE] = 'https://my-blue.medipass.io', _ORIGINS[ENVS.PROD] = 'https://my.medipass.io', _ORIGINS);
|
|
11
|
-
export var EVENTS = {
|
|
12
|
-
SUCCESS: 'success',
|
|
13
|
-
fAILURE: 'failure',
|
|
14
|
-
CANCEL: 'cancel'
|
|
15
|
-
};
|
|
16
|
-
export var ROOT_ELEMENT_ID = 'medipass-checkout-sdk-root';
|
package/es/index.js
DELETED
|
@@ -1,272 +0,0 @@
|
|
|
1
|
-
import _get from 'lodash/get';
|
|
2
|
-
import overlay from './overlay';
|
|
3
|
-
import { ORIGINS, ENVS, EVENTS } from './constants';
|
|
4
|
-
import './style.css';
|
|
5
|
-
var POPUP_WIDTH = 450;
|
|
6
|
-
|
|
7
|
-
var getWindowFeatures = function getWindowFeatures(_ref) {
|
|
8
|
-
var height = _ref.height,
|
|
9
|
-
width = _ref.width,
|
|
10
|
-
left = _ref.left,
|
|
11
|
-
top = _ref.top;
|
|
12
|
-
return "menubar=no, location=no, resizable=no, scrollbars=yes, status=no, height=" + height + ", width=" + width + ", left=" + left + ", top=" + top;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
function initialiseWindow(_ref2) {
|
|
16
|
-
var url = _ref2.url;
|
|
17
|
-
if (!window) return; // The target window could either be in an iframe, or just a normal standalone window.
|
|
18
|
-
// We need to grab the correct window height and width for calculating dimensions.
|
|
19
|
-
|
|
20
|
-
var windowHeight = _get(window, 'outerHeight') || _get(window, 'innerHeight');
|
|
21
|
-
|
|
22
|
-
var windowWidth = _get(window, 'outerWidth') || _get(window, 'innerWidth');
|
|
23
|
-
|
|
24
|
-
var popupHeight = windowHeight * 0.80;
|
|
25
|
-
var popupWidth = windowWidth > POPUP_WIDTH ? POPUP_WIDTH : windowWidth * 0.25;
|
|
26
|
-
var xPosition = windowWidth / 2 - popupWidth / 2;
|
|
27
|
-
var yPosition = windowHeight / 2 - popupHeight / 2;
|
|
28
|
-
var windowRef = window.open(url, 'Medipass Checkout', getWindowFeatures({
|
|
29
|
-
height: popupHeight,
|
|
30
|
-
width: popupWidth,
|
|
31
|
-
left: xPosition,
|
|
32
|
-
top: yPosition
|
|
33
|
-
}));
|
|
34
|
-
return windowRef;
|
|
35
|
-
} ////////////////////////////////////////////////////////////
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
var _windowReferenceObject = null; ////////////////////////////////////////////////////////////
|
|
39
|
-
|
|
40
|
-
var checkoutSDK = {
|
|
41
|
-
ENVS: ENVS,
|
|
42
|
-
isCheckoutInitiated: false,
|
|
43
|
-
isCheckoutComplete: null,
|
|
44
|
-
env: null,
|
|
45
|
-
onSuccess: null,
|
|
46
|
-
onFailure: null,
|
|
47
|
-
onCancel: null,
|
|
48
|
-
onCose: null,
|
|
49
|
-
init: function init(_ref3) {
|
|
50
|
-
var _this = this;
|
|
51
|
-
|
|
52
|
-
var env = _ref3.env,
|
|
53
|
-
onSuccess = _ref3.onSuccess,
|
|
54
|
-
onFailure = _ref3.onFailure,
|
|
55
|
-
onCancel = _ref3.onCancel,
|
|
56
|
-
onClose = _ref3.onClose;
|
|
57
|
-
if (!env) return;
|
|
58
|
-
this.env = env;
|
|
59
|
-
this.onSuccess = onSuccess;
|
|
60
|
-
this.onFailure = onFailure;
|
|
61
|
-
this.onCancel = onCancel;
|
|
62
|
-
this.onClose = onClose; // Open a blank window
|
|
63
|
-
|
|
64
|
-
_windowReferenceObject = initialiseWindow({
|
|
65
|
-
url: ''
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
var handleClose = function handleClose() {
|
|
69
|
-
overlay.removeOverlay();
|
|
70
|
-
onClose && onClose();
|
|
71
|
-
if (!_windowReferenceObject) return;
|
|
72
|
-
|
|
73
|
-
_windowReferenceObject.close();
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
var onClickRelaunch = function onClickRelaunch() {
|
|
77
|
-
if (!_windowReferenceObject) {
|
|
78
|
-
_windowReferenceObject = initialiseWindow({
|
|
79
|
-
url: ''
|
|
80
|
-
});
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
_windowReferenceObject.focus();
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
var checkWindowClosed = function checkWindowClosed() {
|
|
88
|
-
if (_this.isCheckoutInitiated) {
|
|
89
|
-
clearInterval(timer);
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (_get(_windowReferenceObject, 'closed')) {
|
|
94
|
-
clearInterval(timer);
|
|
95
|
-
handleClose();
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
var onClickCancel = function onClickCancel() {
|
|
100
|
-
overlay.removeOverlay();
|
|
101
|
-
|
|
102
|
-
if (_windowReferenceObject) {
|
|
103
|
-
_windowReferenceObject.close();
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
clearInterval(timer);
|
|
107
|
-
onClose && onClose();
|
|
108
|
-
}; // This creates the gray overlay covering the client's screen while payment is in progress.
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
overlay.createOverlay({
|
|
112
|
-
window: window,
|
|
113
|
-
onClickRelaunch: onClickRelaunch,
|
|
114
|
-
onClickCancel: onClickCancel
|
|
115
|
-
}); // Check the window every 0.5 seconds to see if it has been closed.
|
|
116
|
-
|
|
117
|
-
var timer = setInterval(checkWindowClosed, 500);
|
|
118
|
-
},
|
|
119
|
-
createCheckout: function createCheckout(_ref4) {
|
|
120
|
-
var _this2 = this;
|
|
121
|
-
|
|
122
|
-
var paymentRequestUrl = _ref4.paymentRequestUrl;
|
|
123
|
-
if (!paymentRequestUrl || !window) return;
|
|
124
|
-
var env = this.env;
|
|
125
|
-
var onSuccess = this.onSuccess;
|
|
126
|
-
var onFailure = this.onFailure;
|
|
127
|
-
var onCancel = this.onCancel;
|
|
128
|
-
var onClose = this.onClose; ////////////////////////////////////////////////////////////
|
|
129
|
-
|
|
130
|
-
var checkWindowClosed = function checkWindowClosed() {
|
|
131
|
-
if (_get(_windowReferenceObject, 'closed')) {
|
|
132
|
-
clearInterval(timer);
|
|
133
|
-
handleClose();
|
|
134
|
-
}
|
|
135
|
-
}; // Check the window every 0.5 seconds to see if it has been closed.
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
var timer = setInterval(checkWindowClosed, 500);
|
|
139
|
-
this.isCheckoutInitiated = true; ////////////////////////////////////////////////////////////
|
|
140
|
-
|
|
141
|
-
var openWindow = function openWindow() {
|
|
142
|
-
// windowReferenceObject may not be defined if browser blocks the pop-up.
|
|
143
|
-
if (!_windowReferenceObject) {
|
|
144
|
-
_windowReferenceObject = initialiseWindow({
|
|
145
|
-
url: paymentRequestUrl
|
|
146
|
-
});
|
|
147
|
-
} else {
|
|
148
|
-
_windowReferenceObject.location.replace(paymentRequestUrl);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
if (!_windowReferenceObject) {
|
|
152
|
-
return;
|
|
153
|
-
} // Start listening for incoming messages
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
window.addEventListener('message', function (e) {
|
|
157
|
-
return onReceiveMessage(e);
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
var onReceiveMessage = function onReceiveMessage(e) {
|
|
161
|
-
if (!e) return;
|
|
162
|
-
var transactionId = getMessage(e);
|
|
163
|
-
|
|
164
|
-
if (transactionId) {
|
|
165
|
-
_this2.isCheckoutComplete = true;
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
var getMessage = function getMessage(e) {
|
|
170
|
-
var origin = ORIGINS[env];
|
|
171
|
-
if (!e || !origin) return; // Ensure the message is coming from the correct origin.
|
|
172
|
-
|
|
173
|
-
if (_get(e, 'origin') !== origin) return;
|
|
174
|
-
|
|
175
|
-
var event = _get(e, 'data.event');
|
|
176
|
-
|
|
177
|
-
var transactionId = _get(e, 'data.transactionId');
|
|
178
|
-
|
|
179
|
-
var receiptAutoSent = _get(e, 'data.receiptAutoSent');
|
|
180
|
-
|
|
181
|
-
if (!event || !transactionId) return;
|
|
182
|
-
|
|
183
|
-
if (event === EVENTS.SUCCESS) {
|
|
184
|
-
if (receiptAutoSent) {
|
|
185
|
-
// Give 1.5 seconds for the user to see the success page before auto-closing the pop-up.
|
|
186
|
-
setTimeout(function () {
|
|
187
|
-
onSuccess && onSuccess({
|
|
188
|
-
transactionId: transactionId
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
_windowReferenceObject.close();
|
|
192
|
-
}, 1500);
|
|
193
|
-
} else {
|
|
194
|
-
onSuccess && onSuccess({
|
|
195
|
-
transactionId: transactionId
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
return transactionId;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
if (event === EVENTS.fAILURE) {
|
|
203
|
-
onFailure && onFailure({
|
|
204
|
-
transactionId: transactionId
|
|
205
|
-
});
|
|
206
|
-
return transactionId;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
if (event === EVENTS.CANCEL) {
|
|
210
|
-
// Give 1.5 seconds for the user to see the reject page before auto-closing the pop-up.
|
|
211
|
-
setTimeout(function () {
|
|
212
|
-
onCancel && onCancel({
|
|
213
|
-
transactionId: transactionId
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
_windowReferenceObject.close();
|
|
217
|
-
}, 1500);
|
|
218
|
-
return transactionId;
|
|
219
|
-
}
|
|
220
|
-
};
|
|
221
|
-
|
|
222
|
-
return _windowReferenceObject;
|
|
223
|
-
}; ////////////////////////////////////////////////////////////
|
|
224
|
-
// open the pop-up
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
openWindow(); ////////////////////////////////////////////////////////////
|
|
228
|
-
|
|
229
|
-
var handleClose = function handleClose() {
|
|
230
|
-
// We need to remove the gray overlay covering the client's screen.
|
|
231
|
-
overlay.removeOverlay(); // If the pop-up has been closed before a payment action has been taken out, then we
|
|
232
|
-
// need to invoke the onClose callback.
|
|
233
|
-
|
|
234
|
-
if (!_this2.isCheckoutComplete) {
|
|
235
|
-
onClose && onClose();
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
if (!_windowReferenceObject) return;
|
|
239
|
-
|
|
240
|
-
_windowReferenceObject.close();
|
|
241
|
-
}; ////////////////////////////////////////////////////////////
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
var onClickRelaunch = function onClickRelaunch() {
|
|
245
|
-
if (!_windowReferenceObject) {
|
|
246
|
-
_windowReferenceObject = openWindow();
|
|
247
|
-
return;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
_windowReferenceObject.focus();
|
|
251
|
-
};
|
|
252
|
-
|
|
253
|
-
var onClickCancel = function onClickCancel() {
|
|
254
|
-
if (_windowReferenceObject) {
|
|
255
|
-
_windowReferenceObject.close();
|
|
256
|
-
} else {
|
|
257
|
-
clearInterval(timer);
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
overlay.removeOverlay();
|
|
261
|
-
onClose && onClose();
|
|
262
|
-
}; // Reset the relaunch and cancel functions on the subheading
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
overlay.updateSubheading({
|
|
266
|
-
window: window,
|
|
267
|
-
onClickRelaunch: onClickRelaunch,
|
|
268
|
-
onClickCancel: onClickCancel
|
|
269
|
-
}); ////////////////////////////////////////////////////////////
|
|
270
|
-
}
|
|
271
|
-
};
|
|
272
|
-
export default checkoutSDK;
|
package/es/overlay.js
DELETED
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import { ROOT_ELEMENT_ID } from './constants';
|
|
2
|
-
import toCss from './utils/object-to-css';
|
|
3
|
-
import _get from 'lodash/get';
|
|
4
|
-
var SUBHEADING_ELEMENT_ID = 'medipass-checkout-sdk-subheading';
|
|
5
|
-
|
|
6
|
-
function createElement(_ref) {
|
|
7
|
-
var window = _ref.window,
|
|
8
|
-
element = _ref.element,
|
|
9
|
-
text = _ref.text,
|
|
10
|
-
id = _ref.id,
|
|
11
|
-
styles = _ref.styles,
|
|
12
|
-
onClick = _ref.onClick;
|
|
13
|
-
if (!window) return;
|
|
14
|
-
var newElement = window.document.createElement(element);
|
|
15
|
-
|
|
16
|
-
if (text) {
|
|
17
|
-
newElement.innerHTML = text;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (id) {
|
|
21
|
-
newElement.id = id;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (styles) {
|
|
25
|
-
newElement.style.cssText = toCss(styles);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (_get(newElement, 'addEventListener') && onClick) {
|
|
29
|
-
newElement.addEventListener('click', function () {
|
|
30
|
-
onClick();
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return newElement;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
var overlay = {
|
|
38
|
-
contentElement: null,
|
|
39
|
-
removeOverlay: function removeOverlay() {
|
|
40
|
-
var containerDiv = document.getElementById(ROOT_ELEMENT_ID);
|
|
41
|
-
if (!containerDiv) return;
|
|
42
|
-
containerDiv.remove();
|
|
43
|
-
},
|
|
44
|
-
createOverlay: function createOverlay(_ref2) {
|
|
45
|
-
var window = _ref2.window,
|
|
46
|
-
onClickRelaunch = _ref2.onClickRelaunch,
|
|
47
|
-
onClickCancel = _ref2.onClickCancel;
|
|
48
|
-
if (!window) return;
|
|
49
|
-
var containerDiv = createElement({
|
|
50
|
-
window: window,
|
|
51
|
-
element: 'div',
|
|
52
|
-
id: ROOT_ELEMENT_ID,
|
|
53
|
-
styles: {
|
|
54
|
-
'z-index': '2147483100',
|
|
55
|
-
position: 'fixed',
|
|
56
|
-
top: '0',
|
|
57
|
-
left: '0',
|
|
58
|
-
width: '100%',
|
|
59
|
-
height: '100%',
|
|
60
|
-
'background-color': 'rgba(0, 0, 0, 0.8)',
|
|
61
|
-
'font-family': 'Lato',
|
|
62
|
-
color: 'white',
|
|
63
|
-
display: 'flex'
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
var content = createElement({
|
|
67
|
-
window: window,
|
|
68
|
-
element: 'div',
|
|
69
|
-
styles: {
|
|
70
|
-
'max-width': '360px',
|
|
71
|
-
'margin-left': 'auto',
|
|
72
|
-
'margin-right': 'auto',
|
|
73
|
-
'margin-top': 'auto',
|
|
74
|
-
'margin-bottom': 'auto',
|
|
75
|
-
'text-align': 'center'
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
this.contentElement = content; ////////////////////////////////////////////////////////////
|
|
79
|
-
|
|
80
|
-
var heading = createElement({
|
|
81
|
-
window: window,
|
|
82
|
-
element: 'div',
|
|
83
|
-
text: 'Secure Medipass payment in progress',
|
|
84
|
-
styles: {
|
|
85
|
-
color: 'white',
|
|
86
|
-
'font-size': '35px',
|
|
87
|
-
'font-weight': '600',
|
|
88
|
-
'margin-bottom': '30px'
|
|
89
|
-
}
|
|
90
|
-
}); ////////////////////////////////////////////////////////////
|
|
91
|
-
|
|
92
|
-
var subHeading = this.createSubHeading({
|
|
93
|
-
window: window,
|
|
94
|
-
onClickRelaunch: onClickRelaunch,
|
|
95
|
-
onClickCancel: onClickCancel
|
|
96
|
-
}); ////////////////////////////////////////////////////////////
|
|
97
|
-
|
|
98
|
-
content.appendChild(heading);
|
|
99
|
-
content.appendChild(subHeading);
|
|
100
|
-
containerDiv.appendChild(content); ////////////////////////////////////////////////////////////
|
|
101
|
-
|
|
102
|
-
window.document.body.appendChild(containerDiv);
|
|
103
|
-
},
|
|
104
|
-
createSubHeading: function createSubHeading(_ref3) {
|
|
105
|
-
var window = _ref3.window,
|
|
106
|
-
onClickRelaunch = _ref3.onClickRelaunch,
|
|
107
|
-
onClickCancel = _ref3.onClickCancel;
|
|
108
|
-
if (!window) return;
|
|
109
|
-
var subHeadingContainer = createElement({
|
|
110
|
-
window: window,
|
|
111
|
-
id: SUBHEADING_ELEMENT_ID,
|
|
112
|
-
element: 'div'
|
|
113
|
-
});
|
|
114
|
-
var subHeading1 = createElement({
|
|
115
|
-
window: window,
|
|
116
|
-
element: 'div',
|
|
117
|
-
text: 'Don\'t see the payment window?'
|
|
118
|
-
});
|
|
119
|
-
var link1 = createElement({
|
|
120
|
-
window: window,
|
|
121
|
-
element: 'a',
|
|
122
|
-
text: 'Click here',
|
|
123
|
-
onClick: onClickRelaunch,
|
|
124
|
-
styles: {
|
|
125
|
-
'text-decoration': 'underline',
|
|
126
|
-
cursor: 'pointer',
|
|
127
|
-
'font-weight': '600'
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
var subHeading2 = createElement({
|
|
131
|
-
window: window,
|
|
132
|
-
element: 'span',
|
|
133
|
-
text: ' to relaunch and complete your payment.'
|
|
134
|
-
});
|
|
135
|
-
var subHeading3 = createElement({
|
|
136
|
-
window: window,
|
|
137
|
-
element: 'div',
|
|
138
|
-
text: 'OR',
|
|
139
|
-
styles: {
|
|
140
|
-
'margin-top': '20px',
|
|
141
|
-
'margin-bottom': '20px'
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
var link2 = createElement({
|
|
145
|
-
window: window,
|
|
146
|
-
element: 'a',
|
|
147
|
-
text: 'Click here to cancel the payment.',
|
|
148
|
-
onClick: onClickCancel,
|
|
149
|
-
styles: {
|
|
150
|
-
'text-decoration': 'underline',
|
|
151
|
-
cursor: 'pointer',
|
|
152
|
-
'font-weight': '600'
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
subHeadingContainer.appendChild(subHeading1);
|
|
156
|
-
subHeadingContainer.appendChild(link1);
|
|
157
|
-
subHeadingContainer.appendChild(subHeading2);
|
|
158
|
-
subHeadingContainer.appendChild(subHeading3);
|
|
159
|
-
subHeadingContainer.appendChild(link2);
|
|
160
|
-
return subHeadingContainer;
|
|
161
|
-
},
|
|
162
|
-
updateSubheading: function updateSubheading(_ref4) {
|
|
163
|
-
var window = _ref4.window,
|
|
164
|
-
onClickRelaunch = _ref4.onClickRelaunch,
|
|
165
|
-
onClickCancel = _ref4.onClickCancel;
|
|
166
|
-
if (!window) return;
|
|
167
|
-
var subheaderElement = document.getElementById(SUBHEADING_ELEMENT_ID);
|
|
168
|
-
|
|
169
|
-
if (subheaderElement) {
|
|
170
|
-
subheaderElement.remove();
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
var newSubheading = this.createSubHeading({
|
|
174
|
-
window: window,
|
|
175
|
-
onClickRelaunch: onClickRelaunch,
|
|
176
|
-
onClickCancel: onClickCancel
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
if (this.contentElement && _get(this.contentElement, 'appendChild')) {
|
|
180
|
-
this.contentElement.appendChild(newSubheading);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
export default overlay;
|
package/es/style.css
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
@import url("https://fonts.googleapis.com/css?family=Lato:400,700");
|
package/lib/constants.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.__esModule = true;
|
|
4
|
-
exports.ROOT_ELEMENT_ID = exports.EVENTS = exports.ORIGINS = exports.ENVS = void 0;
|
|
5
|
-
|
|
6
|
-
var _ORIGINS;
|
|
7
|
-
|
|
8
|
-
var ENVS = {
|
|
9
|
-
LOCAL: 'local',
|
|
10
|
-
DEV: 'dev',
|
|
11
|
-
STG: 'stg',
|
|
12
|
-
PROD_BLUE: 'prod-blue',
|
|
13
|
-
PROD: 'prod'
|
|
14
|
-
};
|
|
15
|
-
exports.ENVS = ENVS;
|
|
16
|
-
var ORIGINS = (_ORIGINS = {}, _ORIGINS[ENVS.LOCAL] = 'http://localhost:3001', _ORIGINS[ENVS.DEV] = 'https://dev-my.medipass.io', _ORIGINS[ENVS.STG] = 'https://stg-my.medipass.io', _ORIGINS[ENVS.PROD_BLUE] = 'https://my-blue.medipass.io', _ORIGINS[ENVS.PROD] = 'https://my.medipass.io', _ORIGINS);
|
|
17
|
-
exports.ORIGINS = ORIGINS;
|
|
18
|
-
var EVENTS = {
|
|
19
|
-
SUCCESS: 'success',
|
|
20
|
-
fAILURE: 'failure',
|
|
21
|
-
CANCEL: 'cancel'
|
|
22
|
-
};
|
|
23
|
-
exports.EVENTS = EVENTS;
|
|
24
|
-
var ROOT_ELEMENT_ID = 'medipass-checkout-sdk-root';
|
|
25
|
-
exports.ROOT_ELEMENT_ID = ROOT_ELEMENT_ID;
|