@medipass/checkout-sdk 3.0.0-alpha.2 → 3.0.0-alpha.4
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/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +3 -3
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +3 -3
- package/dist/umd/index.d.ts +1 -1
- package/dist/umd/index.min.js +14 -14
- package/package.json +3 -2
- package/rollup.config.mjs +4 -2
- package/src/index.ts +8 -8
- package/src/initialiseWindow.ts +2 -4
- package/src/overlay.ts +1 -2
- package/src/requestUpdatePaymentDetails.ts +9 -10
- package/src/updatePaymentOverlay.ts +1 -2
- /package/dist/cjs/{assets/index-e17dd0fd.css → index.css} +0 -0
- /package/dist/esm/{assets/index-e17dd0fd.css → index.css} +0 -0
- /package/dist/umd/{assets/index.min-e17dd0fd.css → index.min.css} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medipass/checkout-sdk",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.4",
|
|
4
4
|
"description": "Describe medipass-checkout-sdk here",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
"@rollup/plugin-terser": "0.4.3",
|
|
29
29
|
"@rollup/plugin-typescript": "11.1.2",
|
|
30
30
|
"@types/file-saver": "2.0.5",
|
|
31
|
-
"@types/lodash": "4.14.196",
|
|
32
31
|
"@typescript-eslint/eslint-plugin": "5.57.1",
|
|
33
32
|
"@typescript-eslint/parser": "5.57.1",
|
|
34
33
|
"eslint": "8.39.0",
|
|
@@ -36,10 +35,12 @@
|
|
|
36
35
|
"eslint-plugin-prettier": "4.2.1",
|
|
37
36
|
"eslint-plugin-react": "7.11.1",
|
|
38
37
|
"nodemon": "2.0.12",
|
|
38
|
+
"postcss": "8.4.27",
|
|
39
39
|
"prettier": "2.8.1",
|
|
40
40
|
"rollup": "3.27.0",
|
|
41
41
|
"rollup-plugin-import-css": "3.3.1",
|
|
42
42
|
"rollup-plugin-polyfill-node": "0.12.0",
|
|
43
|
+
"rollup-plugin-postcss": "4.0.2",
|
|
43
44
|
"typescript": "5.1.6"
|
|
44
45
|
},
|
|
45
46
|
"exports": {
|
package/rollup.config.mjs
CHANGED
|
@@ -4,7 +4,8 @@ import typescript from '@rollup/plugin-typescript';
|
|
|
4
4
|
import commonjs from '@rollup/plugin-commonjs';
|
|
5
5
|
import { nodeResolve } from '@rollup/plugin-node-resolve';
|
|
6
6
|
import nodePolyfills from 'rollup-plugin-polyfill-node';
|
|
7
|
-
import css from 'rollup-plugin-import-css';
|
|
7
|
+
// import css from 'rollup-plugin-import-css';
|
|
8
|
+
import postcss from 'rollup-plugin-postcss';
|
|
8
9
|
|
|
9
10
|
export default {
|
|
10
11
|
input: './src/index.ts',
|
|
@@ -28,8 +29,9 @@ export default {
|
|
|
28
29
|
terser(),
|
|
29
30
|
typescript(),
|
|
30
31
|
commonjs({ include: /node_modules/ }),
|
|
32
|
+
postcss({ extract: true }),
|
|
31
33
|
nodeResolve(),
|
|
32
34
|
nodePolyfills(),
|
|
33
|
-
css(),
|
|
35
|
+
// css(),
|
|
34
36
|
],
|
|
35
37
|
};
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import _get from 'lodash/get';
|
|
2
1
|
import overlay from './overlay';
|
|
3
2
|
import { ORIGINS, ENVS, EVENTS } from './constants';
|
|
4
|
-
import './style.css';
|
|
5
3
|
import initialiseWindow from './initialiseWindow';
|
|
6
4
|
import updatePaymentDetails, { UpdatePaymentDetails } from './requestUpdatePaymentDetails';
|
|
7
5
|
|
|
6
|
+
import './style.css';
|
|
7
|
+
|
|
8
8
|
////////////////////////////////////////////////////////////
|
|
9
9
|
|
|
10
10
|
let _windowReferenceObject: Window | null | undefined = null;
|
|
@@ -73,7 +73,7 @@ const checkoutSDK: CheckoutSdk = {
|
|
|
73
73
|
clearInterval(timer);
|
|
74
74
|
return;
|
|
75
75
|
}
|
|
76
|
-
if (
|
|
76
|
+
if (_windowReferenceObject?.closed) {
|
|
77
77
|
clearInterval(timer);
|
|
78
78
|
handleClose();
|
|
79
79
|
}
|
|
@@ -107,7 +107,7 @@ const checkoutSDK: CheckoutSdk = {
|
|
|
107
107
|
////////////////////////////////////////////////////////////
|
|
108
108
|
|
|
109
109
|
const checkWindowClosed = () => {
|
|
110
|
-
if (
|
|
110
|
+
if (_windowReferenceObject?.closed) {
|
|
111
111
|
clearInterval(timer);
|
|
112
112
|
handleClose();
|
|
113
113
|
}
|
|
@@ -150,11 +150,11 @@ const checkoutSDK: CheckoutSdk = {
|
|
|
150
150
|
if (!e || !origin) return;
|
|
151
151
|
|
|
152
152
|
// Ensure the message is coming from the correct origin.
|
|
153
|
-
if (
|
|
153
|
+
if (e?.origin !== origin) return;
|
|
154
154
|
|
|
155
|
-
const event =
|
|
156
|
-
const transactionId =
|
|
157
|
-
const receiptAutoSent =
|
|
155
|
+
const event = e?.data?.event;
|
|
156
|
+
const transactionId = e?.data?.transactionId;
|
|
157
|
+
const receiptAutoSent = e?.data?.receiptAutoSent;
|
|
158
158
|
|
|
159
159
|
if (!event || !transactionId) return;
|
|
160
160
|
|
package/src/initialiseWindow.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import _get from 'lodash/get';
|
|
2
|
-
|
|
3
1
|
const POPUP_WIDTH = 450;
|
|
4
2
|
|
|
5
3
|
const getWindowFeatures = ({
|
|
@@ -20,8 +18,8 @@ function initialiseWindow({ url }: { url: string }) {
|
|
|
20
18
|
|
|
21
19
|
// The target window could either be in an iframe, or just a normal standalone window.
|
|
22
20
|
// We need to grab the correct window height and width for calculating dimensions.
|
|
23
|
-
const windowHeight =
|
|
24
|
-
const windowWidth =
|
|
21
|
+
const windowHeight = window?.outerHeight || window?.innerHeight;
|
|
22
|
+
const windowWidth = window?.outerWidth || window?.innerWidth;
|
|
25
23
|
|
|
26
24
|
const popupHeight = windowHeight * 0.8;
|
|
27
25
|
const popupWidth = windowWidth > POPUP_WIDTH ? POPUP_WIDTH : windowWidth * 0.25;
|
package/src/overlay.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ROOT_ELEMENT_ID } from './constants';
|
|
2
2
|
import toCss from './utils/object-to-css';
|
|
3
|
-
import _get from 'lodash/get';
|
|
4
3
|
|
|
5
4
|
const SUBHEADING_ELEMENT_ID = 'medipass-checkout-sdk-subheading';
|
|
6
5
|
|
|
@@ -32,7 +31,7 @@ function createElement({
|
|
|
32
31
|
if (styles) {
|
|
33
32
|
newElement.style.cssText = toCss(styles);
|
|
34
33
|
}
|
|
35
|
-
if (
|
|
34
|
+
if (newElement?.addEventListener && onClick) {
|
|
36
35
|
newElement.addEventListener('click', () => {
|
|
37
36
|
onClick();
|
|
38
37
|
});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import _get from 'lodash/get';
|
|
2
1
|
import updatePaymentOverlay from './updatePaymentOverlay';
|
|
3
2
|
import { ENVS, EVENTS, ERROR_MESSAGES, ORIGINS } from './constants';
|
|
4
|
-
import coreSDK from '@medipass/web-sdk';
|
|
3
|
+
import coreSDK, { Business, PaginatedResponse } from '@medipass/web-sdk';
|
|
5
4
|
import initialiseWindow from './initialiseWindow';
|
|
6
5
|
|
|
7
6
|
if (!coreSDK.hasInit) {
|
|
@@ -84,7 +83,7 @@ const updatePaymentDetails = async ({
|
|
|
84
83
|
};
|
|
85
84
|
|
|
86
85
|
const checkWindowClosed = () => {
|
|
87
|
-
if (
|
|
86
|
+
if (windowReferenceObject?.closed) {
|
|
88
87
|
clearInterval(timer);
|
|
89
88
|
handleClose();
|
|
90
89
|
}
|
|
@@ -105,12 +104,12 @@ const updatePaymentDetails = async ({
|
|
|
105
104
|
// Check the window every 0.5 seconds to see if it has been closed.
|
|
106
105
|
const timer = setInterval(checkWindowClosed, 500);
|
|
107
106
|
|
|
108
|
-
const myBusinesses = await coreSDK.businesses.getMyBusinesses()
|
|
109
|
-
const myBusiness = myBusinesses
|
|
110
|
-
const myBusinessId =
|
|
107
|
+
const myBusinesses = (await coreSDK.businesses.getMyBusinesses()) as unknown as PaginatedResponse<Business>;
|
|
108
|
+
const myBusiness = myBusinesses?.items?.[0];
|
|
109
|
+
const myBusinessId = myBusiness?._id;
|
|
111
110
|
|
|
112
111
|
const patient = await coreSDK.patients.getBusinessPatientByRefId(myBusinessId, patientRefId);
|
|
113
|
-
const patientId =
|
|
112
|
+
const patientId = patient?._id;
|
|
114
113
|
|
|
115
114
|
const requestPaymentMethodResponse = await coreSDK.patients.requestUpdatePatientPaymentMethod(
|
|
116
115
|
myBusinessId,
|
|
@@ -121,7 +120,7 @@ const updatePaymentDetails = async ({
|
|
|
121
120
|
},
|
|
122
121
|
);
|
|
123
122
|
|
|
124
|
-
const paymentMethodUpdateLink =
|
|
123
|
+
const paymentMethodUpdateLink = requestPaymentMethodResponse?.paymentMethodUpdateLink;
|
|
125
124
|
|
|
126
125
|
const openWindow = () => {
|
|
127
126
|
// windowReferenceObject may not be defined if browser blocks the pop-up.
|
|
@@ -149,9 +148,9 @@ const updatePaymentDetails = async ({
|
|
|
149
148
|
if (!e || !origin) return;
|
|
150
149
|
|
|
151
150
|
// Ensure the message is coming from the correct origin.
|
|
152
|
-
if (
|
|
151
|
+
if (e?.origin !== origin) return;
|
|
153
152
|
|
|
154
|
-
const event =
|
|
153
|
+
const event = e?.data?.event;
|
|
155
154
|
|
|
156
155
|
if (!event) return;
|
|
157
156
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ROOT_ELEMENT_ID } from './constants';
|
|
2
2
|
import toCss from './utils/object-to-css';
|
|
3
|
-
import _get from 'lodash/get';
|
|
4
3
|
|
|
5
4
|
const SUBHEADING_ELEMENT_ID = 'medipass-checkout-sdk-subheading';
|
|
6
5
|
|
|
@@ -32,7 +31,7 @@ function createElement({
|
|
|
32
31
|
if (styles) {
|
|
33
32
|
newElement.style.cssText = toCss(styles);
|
|
34
33
|
}
|
|
35
|
-
if (
|
|
34
|
+
if (newElement?.addEventListener && onClick) {
|
|
36
35
|
newElement.addEventListener('click', () => {
|
|
37
36
|
onClick();
|
|
38
37
|
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|