@dintero/checkout-web-sdk 0.6.0 → 0.6.2
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/.github/workflows/build.yml +14 -15
- package/.github/workflows/release.yml +4 -5
- package/.prettierrc.yml +8 -0
- package/.releaserc.json +7 -9
- package/CHANGELOG.md +11 -9
- package/README.md +39 -25
- package/dist/declarations/src/checkout.d.ts +2 -2
- package/dist/dintero-checkout-web-sdk.cjs.dev.js +105 -97
- package/dist/dintero-checkout-web-sdk.cjs.prod.js +105 -97
- package/dist/dintero-checkout-web-sdk.esm.js +105 -97
- package/dist/dintero-checkout-web-sdk.umd.min.js +1 -1
- package/dist/dintero-checkout-web-sdk.umd.min.js.map +1 -1
- package/package.json +45 -49
- package/patches/vitest+0.34.6.patch +33 -0
- package/coverage/Chrome Headless 117.0.5938.92 (Linux x86_64)/html/base.css +0 -224
- package/coverage/Chrome Headless 117.0.5938.92 (Linux x86_64)/html/block-navigation.js +0 -79
- package/coverage/Chrome Headless 117.0.5938.92 (Linux x86_64)/html/checkout.ts.html +0 -473
- package/coverage/Chrome Headless 117.0.5938.92 (Linux x86_64)/html/createIframeAsync.ts.html +0 -263
- package/coverage/Chrome Headless 117.0.5938.92 (Linux x86_64)/html/favicon.png +0 -0
- package/coverage/Chrome Headless 117.0.5938.92 (Linux x86_64)/html/index.html +0 -216
- package/coverage/Chrome Headless 117.0.5938.92 (Linux x86_64)/html/index.ts.html +0 -2366
- package/coverage/Chrome Headless 117.0.5938.92 (Linux x86_64)/html/popOut.ts.html +0 -377
- package/coverage/Chrome Headless 117.0.5938.92 (Linux x86_64)/html/popOutBackdrop.ts.html +0 -1046
- package/coverage/Chrome Headless 117.0.5938.92 (Linux x86_64)/html/popOutButton.ts.html +0 -374
- package/coverage/Chrome Headless 117.0.5938.92 (Linux x86_64)/html/prettify.css +0 -1
- package/coverage/Chrome Headless 117.0.5938.92 (Linux x86_64)/html/prettify.js +0 -2
- package/coverage/Chrome Headless 117.0.5938.92 (Linux x86_64)/html/sort-arrow-sprite.png +0 -0
- package/coverage/Chrome Headless 117.0.5938.92 (Linux x86_64)/html/sorter.js +0 -170
- package/coverage/Chrome Headless 117.0.5938.92 (Linux x86_64)/html/subscribe.ts.html +0 -632
- package/coverage/Chrome Headless 117.0.5938.92 (Linux x86_64)/html/url.ts.html +0 -284
- package/karma.conf.js +0 -33
|
@@ -6,7 +6,7 @@ require('native-promise-only');
|
|
|
6
6
|
|
|
7
7
|
var pkg = {
|
|
8
8
|
name: "@dintero/checkout-web-sdk",
|
|
9
|
-
version: "0.6.
|
|
9
|
+
version: "0.6.2",
|
|
10
10
|
description: "Dintero Checkout SDK for web frontends",
|
|
11
11
|
main: "dist/dintero-checkout-web-sdk.cjs.js",
|
|
12
12
|
module: "dist/dintero-checkout-web-sdk.esm.js",
|
|
@@ -17,8 +17,10 @@ var pkg = {
|
|
|
17
17
|
umdName: "dintero"
|
|
18
18
|
},
|
|
19
19
|
scripts: {
|
|
20
|
+
postinstall: "patch -u node_modules/vitest/dist/vendor-node.a7c48fe1.js -i patches/vitest+0.34.6.patch --forward || true",
|
|
20
21
|
build: "preconstruct build",
|
|
21
|
-
|
|
22
|
+
lint: "prettier --cache --log-level warn -c --config .prettierrc.yml .",
|
|
23
|
+
test: "$(yarn bin)/vitest --browser.name=chrome --browser.headless",
|
|
22
24
|
"semantic-release": "semantic-release",
|
|
23
25
|
prepublishOnly: "yarn run build"
|
|
24
26
|
},
|
|
@@ -34,25 +36,19 @@ var pkg = {
|
|
|
34
36
|
url: "https://github.com/Dintero/Dintero.Checkout.Web.SDK/issues"
|
|
35
37
|
},
|
|
36
38
|
devDependencies: {
|
|
37
|
-
"@babel/
|
|
38
|
-
"@babel/preset-typescript": "
|
|
39
|
-
"@preconstruct/cli": "
|
|
40
|
-
"@semantic-release/git": "
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
mocha: "^8.1.1",
|
|
48
|
-
prettier: "^3.0.3",
|
|
49
|
-
puppeteer: "^21.1.0",
|
|
50
|
-
"semantic-release": "^22.0.1",
|
|
51
|
-
sinon: "^15.0.0",
|
|
52
|
-
typescript: "^5.2.2"
|
|
39
|
+
"@babel/core": "7.13.0",
|
|
40
|
+
"@babel/preset-typescript": "7.13.0",
|
|
41
|
+
"@preconstruct/cli": "2.8.1",
|
|
42
|
+
"@semantic-release/git": "10.0.1",
|
|
43
|
+
"@vitest/browser": "0.34.6",
|
|
44
|
+
prettier: "3.0.3",
|
|
45
|
+
"semantic-release": "22.0.5",
|
|
46
|
+
typescript: "5.2.2",
|
|
47
|
+
vitest: "0.34.6",
|
|
48
|
+
webdriverio: "8.16.22"
|
|
53
49
|
},
|
|
54
50
|
dependencies: {
|
|
55
|
-
"native-promise-only": "
|
|
51
|
+
"native-promise-only": "0.8.1"
|
|
56
52
|
}
|
|
57
53
|
};
|
|
58
54
|
|
|
@@ -104,18 +100,18 @@ const getSessionUrl = options => {
|
|
|
104
100
|
throw new Error("Invalid endpoint");
|
|
105
101
|
}
|
|
106
102
|
const params = new URLSearchParams();
|
|
107
|
-
params.append(
|
|
103
|
+
params.append("sdk", pkg.version);
|
|
108
104
|
if (ui) {
|
|
109
|
-
params.append(
|
|
105
|
+
params.append("ui", ui);
|
|
110
106
|
}
|
|
111
107
|
if (language) {
|
|
112
|
-
params.append(
|
|
108
|
+
params.append("language", language);
|
|
113
109
|
}
|
|
114
110
|
if (shouldCallValidateSession) {
|
|
115
|
-
params.append(
|
|
111
|
+
params.append("client_side_validation", "true");
|
|
116
112
|
}
|
|
117
113
|
if (popOut) {
|
|
118
|
-
params.append(
|
|
114
|
+
params.append("role", "pop_out_launcher");
|
|
119
115
|
}
|
|
120
116
|
if (endpoint === "https://checkout.dintero.com") {
|
|
121
117
|
// Default endpoint will redirect via the view endpoint
|
|
@@ -124,28 +120,29 @@ const getSessionUrl = options => {
|
|
|
124
120
|
// When a custom endpoint is set skip the view redirect endpoint since
|
|
125
121
|
// custom endpoints like localhost and PR builds does not support the
|
|
126
122
|
// serverside view flow.
|
|
127
|
-
params.append(
|
|
128
|
-
return `${endpoint}
|
|
123
|
+
params.append("sid", sid);
|
|
124
|
+
return `${padTralingSlash(endpoint)}?${params.toString()}`;
|
|
129
125
|
};
|
|
130
|
-
const padTralingSlash = endpoint => endpoint.endsWith(
|
|
126
|
+
const padTralingSlash = endpoint => endpoint.endsWith("/") ? endpoint : `${endpoint}/`;
|
|
131
127
|
const getPopOutUrl = ({
|
|
132
128
|
sid,
|
|
133
129
|
endpoint,
|
|
134
130
|
language,
|
|
135
131
|
shouldCallValidateSession
|
|
136
132
|
}) => {
|
|
137
|
-
if (shouldCallValidateSession) {
|
|
138
|
-
return `${padTralingSlash(endpoint)}?loader=true`;
|
|
139
|
-
}
|
|
140
133
|
const params = new URLSearchParams();
|
|
141
|
-
params.append(
|
|
142
|
-
params.append(
|
|
143
|
-
params.append(
|
|
144
|
-
params.append(
|
|
134
|
+
params.append("ui", "fullscreen");
|
|
135
|
+
params.append("role", "pop_out_payment");
|
|
136
|
+
params.append("sid", sid);
|
|
137
|
+
params.append("sdk", pkg.version);
|
|
145
138
|
if (language) {
|
|
146
|
-
params.append(
|
|
139
|
+
params.append("language", language);
|
|
140
|
+
}
|
|
141
|
+
if (shouldCallValidateSession) {
|
|
142
|
+
params.append("loader", "true");
|
|
143
|
+
return `${padTralingSlash(endpoint)}?${params.toString()}`;
|
|
147
144
|
}
|
|
148
|
-
return `${endpoint}
|
|
145
|
+
return `${padTralingSlash(endpoint)}?${params.toString()}`;
|
|
149
146
|
};
|
|
150
147
|
|
|
151
148
|
/**
|
|
@@ -372,11 +369,11 @@ const subscribe = options => {
|
|
|
372
369
|
|
|
373
370
|
const getBackdropZIndex = () => {
|
|
374
371
|
// Iterate all DOM items to get current highest element.
|
|
375
|
-
const elements = document.getElementsByTagName(
|
|
372
|
+
const elements = document.getElementsByTagName("*");
|
|
376
373
|
const highest = Array.from(elements).reduce((acc, element) => {
|
|
377
374
|
try {
|
|
378
375
|
const zIndexStr = document.defaultView.getComputedStyle(element, null).getPropertyValue("z-index");
|
|
379
|
-
const zIndex = parseInt(zIndexStr ||
|
|
376
|
+
const zIndex = parseInt(zIndexStr || "0");
|
|
380
377
|
if (!isNaN(zIndex) && zIndex > acc) {
|
|
381
378
|
return zIndex;
|
|
382
379
|
}
|
|
@@ -387,15 +384,15 @@ const getBackdropZIndex = () => {
|
|
|
387
384
|
return acc;
|
|
388
385
|
}, 0);
|
|
389
386
|
if (highest < 9999) {
|
|
390
|
-
return
|
|
387
|
+
return "9999";
|
|
391
388
|
}
|
|
392
389
|
return (highest + 1).toString();
|
|
393
390
|
};
|
|
394
|
-
const STYLE_ID =
|
|
395
|
-
const BACKDROP_ID =
|
|
396
|
-
const BACKDROP_DESCRIPTION =
|
|
397
|
-
const FOCUS_CHECKOUT_BUTTON_ID =
|
|
398
|
-
const CLOSE_BACKDROP_BUTTON_ID =
|
|
391
|
+
const STYLE_ID = "dintero-checkout-sdk-style";
|
|
392
|
+
const BACKDROP_ID = "dintero-checkout-sdk-backdrop";
|
|
393
|
+
const BACKDROP_DESCRIPTION = "dintero-checkout-sdk-backdrop-description";
|
|
394
|
+
const FOCUS_CHECKOUT_BUTTON_ID = "dintero-checkout-sdk-backdrop-focus";
|
|
395
|
+
const CLOSE_BACKDROP_BUTTON_ID = "dintero-checkout-sdk-backdrop-close";
|
|
399
396
|
const wrapPreventDefault = fn => {
|
|
400
397
|
// Creates a wrapped function that will invoke preventDefault() to stop
|
|
401
398
|
// the event from bubbling up the DOM tree.
|
|
@@ -412,8 +409,8 @@ const appendBackdropStyles = () => {
|
|
|
412
409
|
return;
|
|
413
410
|
}
|
|
414
411
|
// Add style to DOM
|
|
415
|
-
const style = document.createElement(
|
|
416
|
-
style.setAttribute(
|
|
412
|
+
const style = document.createElement("style");
|
|
413
|
+
style.setAttribute("id", STYLE_ID);
|
|
417
414
|
style.innerHTML = `
|
|
418
415
|
@keyframes ${BACKDROP_ID}-fade-in {
|
|
419
416
|
from {opacity: 0;}
|
|
@@ -528,7 +525,7 @@ const appendBackdropStyles = () => {
|
|
|
528
525
|
};
|
|
529
526
|
const createBackdropDOM = () => {
|
|
530
527
|
// Dark translucent backdrop element
|
|
531
|
-
const backdrop = document.createElement(
|
|
528
|
+
const backdrop = document.createElement("div");
|
|
532
529
|
backdrop.setAttribute("id", BACKDROP_ID);
|
|
533
530
|
backdrop.setAttribute("role", "dialog");
|
|
534
531
|
backdrop.style.zIndex = getBackdropZIndex();
|
|
@@ -536,7 +533,7 @@ const createBackdropDOM = () => {
|
|
|
536
533
|
};
|
|
537
534
|
const createCloseButtonDOM = label => {
|
|
538
535
|
// Close button for the top right corner
|
|
539
|
-
const button = document.createElement(
|
|
536
|
+
const button = document.createElement("button");
|
|
540
537
|
button.setAttribute("id", CLOSE_BACKDROP_BUTTON_ID);
|
|
541
538
|
button.setAttribute("type", "button");
|
|
542
539
|
button.setAttribute("aria-label", label);
|
|
@@ -560,7 +557,7 @@ const createCloseButtonDOM = label => {
|
|
|
560
557
|
};
|
|
561
558
|
const createDinteroLogoDOM = () => {
|
|
562
559
|
// Close button for the top right corner
|
|
563
|
-
const div = document.createElement(
|
|
560
|
+
const div = document.createElement("div");
|
|
564
561
|
div.innerHTML = `
|
|
565
562
|
<svg width="120px" height="22px" viewBox="0 0 630 111" version="1.1" >
|
|
566
563
|
<g id="Page-1" stroke="none" strokeWidth="1" fill="none" fillRule="evenodd">
|
|
@@ -573,8 +570,8 @@ const createDinteroLogoDOM = () => {
|
|
|
573
570
|
};
|
|
574
571
|
const createLabelDOM = text => {
|
|
575
572
|
// Text about the pop out
|
|
576
|
-
const p = document.createElement(
|
|
577
|
-
p.setAttribute(
|
|
573
|
+
const p = document.createElement("p");
|
|
574
|
+
p.setAttribute("id", BACKDROP_DESCRIPTION);
|
|
578
575
|
p.innerText = text;
|
|
579
576
|
return p;
|
|
580
577
|
};
|
|
@@ -582,7 +579,7 @@ const createFocusButtonDOM = text => {
|
|
|
582
579
|
// Mock button to give the user a call to action element to click, even
|
|
583
580
|
// though the entire backdrop (except the close button) returns focus to the
|
|
584
581
|
// checkout.
|
|
585
|
-
const button = document.createElement(
|
|
582
|
+
const button = document.createElement("button");
|
|
586
583
|
button.setAttribute("id", FOCUS_CHECKOUT_BUTTON_ID);
|
|
587
584
|
button.setAttribute("type", "button");
|
|
588
585
|
button.innerText = text;
|
|
@@ -592,7 +589,7 @@ const focusTrap = e => {
|
|
|
592
589
|
// Prevent the user focusing outside of the backdrop while it is visible
|
|
593
590
|
const focusButton = document.getElementById(FOCUS_CHECKOUT_BUTTON_ID);
|
|
594
591
|
const closeButton = document.getElementById(CLOSE_BACKDROP_BUTTON_ID);
|
|
595
|
-
if (e.key ===
|
|
592
|
+
if (e.key === "Tab" || e.code === "Tab") {
|
|
596
593
|
if (document.activeElement === focusButton) {
|
|
597
594
|
closeButton.focus();
|
|
598
595
|
e.preventDefault();
|
|
@@ -619,7 +616,7 @@ const createBackdropView = options => {
|
|
|
619
616
|
closeButton.onclick = wrapPreventDefault(options.close);
|
|
620
617
|
|
|
621
618
|
// Add focus trap when backdrop is visible
|
|
622
|
-
document.addEventListener(
|
|
619
|
+
document.addEventListener("keydown", focusTrap);
|
|
623
620
|
|
|
624
621
|
// Append to document
|
|
625
622
|
backdrop.appendChild(closeButton);
|
|
@@ -641,7 +638,7 @@ const setBackdropLabels = event => {
|
|
|
641
638
|
}
|
|
642
639
|
const closeButton = document.getElementById(CLOSE_BACKDROP_BUTTON_ID);
|
|
643
640
|
if (closeButton) {
|
|
644
|
-
closeButton.setAttribute(
|
|
641
|
+
closeButton.setAttribute("aria-label", event.descriptionLabel);
|
|
645
642
|
}
|
|
646
643
|
};
|
|
647
644
|
const createBackdrop = options => {
|
|
@@ -664,7 +661,7 @@ const removeBackdrop = () => {
|
|
|
664
661
|
if (backdrop) {
|
|
665
662
|
document.body.removeChild(backdrop);
|
|
666
663
|
}
|
|
667
|
-
document.removeEventListener(
|
|
664
|
+
document.removeEventListener("keydown", focusTrap);
|
|
668
665
|
} catch (e) {
|
|
669
666
|
// Ignore errors when closing backdrop. If it fails we should not stop
|
|
670
667
|
// the rest of the application from working.
|
|
@@ -682,14 +679,14 @@ const configureButton = (button, {
|
|
|
682
679
|
styles,
|
|
683
680
|
onClick
|
|
684
681
|
}) => {
|
|
685
|
-
button.setAttribute(
|
|
686
|
-
button.setAttribute(
|
|
682
|
+
button.setAttribute("id", OPEN_POP_OUT_BUTTON_ID);
|
|
683
|
+
button.setAttribute("type", "button");
|
|
687
684
|
|
|
688
685
|
// Is clickable
|
|
689
|
-
if (disabled ===
|
|
690
|
-
button.setAttribute(
|
|
686
|
+
if (disabled === "true") {
|
|
687
|
+
button.setAttribute("disabled", disabled);
|
|
691
688
|
} else {
|
|
692
|
-
button.removeAttribute(
|
|
689
|
+
button.removeAttribute("disabled");
|
|
693
690
|
}
|
|
694
691
|
|
|
695
692
|
// Click handler
|
|
@@ -699,14 +696,14 @@ const configureButton = (button, {
|
|
|
699
696
|
event.stopPropagation();
|
|
700
697
|
|
|
701
698
|
// Update look
|
|
702
|
-
button.style.boxShadow =
|
|
699
|
+
button.style.boxShadow = "inset 0 0 10px rgba(34, 84, 65, 0.9)";
|
|
703
700
|
|
|
704
701
|
// Invoke handler
|
|
705
702
|
onClick();
|
|
706
703
|
|
|
707
704
|
// Reset look
|
|
708
705
|
window.setTimeout(() => {
|
|
709
|
-
button.style.boxShadow =
|
|
706
|
+
button.style.boxShadow = "none";
|
|
710
707
|
}, 200);
|
|
711
708
|
};
|
|
712
709
|
|
|
@@ -714,10 +711,10 @@ const configureButton = (button, {
|
|
|
714
711
|
button.innerText = label;
|
|
715
712
|
|
|
716
713
|
// Position
|
|
717
|
-
button.style.position =
|
|
718
|
-
button.style.top = top +
|
|
719
|
-
button.style.left = left +
|
|
720
|
-
button.style.right = right +
|
|
714
|
+
button.style.position = "absolute";
|
|
715
|
+
button.style.top = top + "px";
|
|
716
|
+
button.style.left = left + "px";
|
|
717
|
+
button.style.right = right + "px";
|
|
721
718
|
|
|
722
719
|
// Appearance from checkout
|
|
723
720
|
for (const [key, value] of Object.entries(styles)) {
|
|
@@ -730,7 +727,7 @@ const addPopOutButton = options => {
|
|
|
730
727
|
container
|
|
731
728
|
} = options;
|
|
732
729
|
const exists = document.getElementById(OPEN_POP_OUT_BUTTON_ID);
|
|
733
|
-
const button = exists || document.createElement(
|
|
730
|
+
const button = exists || document.createElement("button");
|
|
734
731
|
configureButton(button, options);
|
|
735
732
|
if (!exists) {
|
|
736
733
|
container.appendChild(button);
|
|
@@ -741,9 +738,9 @@ const setPopOutButtonDisabled = disabled => {
|
|
|
741
738
|
const button = document.getElementById(OPEN_POP_OUT_BUTTON_ID);
|
|
742
739
|
if (button) {
|
|
743
740
|
if (disabled) {
|
|
744
|
-
button.setAttribute(
|
|
741
|
+
button.setAttribute("disabled", disabled.toString());
|
|
745
742
|
} else {
|
|
746
|
-
button.removeAttribute(
|
|
743
|
+
button.removeAttribute("disabled");
|
|
747
744
|
}
|
|
748
745
|
}
|
|
749
746
|
} catch (e) {
|
|
@@ -766,31 +763,42 @@ const removePopOutButton = () => {
|
|
|
766
763
|
const WIDTH = Math.min(480, window.screen.width);
|
|
767
764
|
const HEIGHT = Math.min(840, window.screen.height);
|
|
768
765
|
let popOutWindow;
|
|
769
|
-
const createPopOutWindow = (url, width, height) => {
|
|
766
|
+
const createPopOutWindow = (sid, url, width, height) => {
|
|
770
767
|
return new Promise(resolve => {
|
|
771
768
|
try {
|
|
772
|
-
//
|
|
769
|
+
// Creates a centered pop up window
|
|
773
770
|
const left = window.screenX + (window.outerWidth - width) / 2;
|
|
774
771
|
const top = window.screenY + (window.outerHeight - height) / 2;
|
|
775
772
|
const features = `width=${width},height=${height},left=${left},top=${top},location=no,menubar=no,toolbar=no,status=no`;
|
|
776
|
-
|
|
773
|
+
let popOut;
|
|
774
|
+
let timeout = -1;
|
|
775
|
+
// Set up listener for application loaded message from pop out window
|
|
776
|
+
const handleAppLoaded = event => {
|
|
777
|
+
const correctSource = event.source === popOut;
|
|
778
|
+
const correctOrigin = event.origin === new URL(url).origin;
|
|
779
|
+
const correctMessage = event.data && event.data.type === "AppLoaded";
|
|
780
|
+
const correctContext = event.data.context === "popOut";
|
|
781
|
+
const correctSid = event.data.sid === sid;
|
|
782
|
+
if (correctSource && correctOrigin && correctMessage && correctContext && correctSid) {
|
|
783
|
+
clearTimeout(timeout);
|
|
784
|
+
resolve(popOut);
|
|
785
|
+
window.removeEventListener("message", handleAppLoaded);
|
|
786
|
+
}
|
|
787
|
+
};
|
|
788
|
+
window.addEventListener("message", handleAppLoaded);
|
|
789
|
+
// Open pop out
|
|
790
|
+
popOut = window.open(url, "dintero-checkout", features);
|
|
791
|
+
// Check that pop out was opened
|
|
777
792
|
if (!popOut) {
|
|
778
|
-
console.log(
|
|
793
|
+
console.log("createPopOutWindow no popOut");
|
|
779
794
|
resolve(undefined);
|
|
780
795
|
return;
|
|
781
796
|
}
|
|
782
|
-
|
|
783
|
-
|
|
797
|
+
// Trigger timeout if pop out is not loaded
|
|
798
|
+
timeout = window.setTimeout(() => {
|
|
799
|
+
console.log("createPopOutWindow timeout");
|
|
784
800
|
resolve(undefined);
|
|
785
801
|
}, 3000);
|
|
786
|
-
popOut.addEventListener('load', event => {
|
|
787
|
-
console.log('createPopOutWindow loaded', {
|
|
788
|
-
popOut,
|
|
789
|
-
event
|
|
790
|
-
});
|
|
791
|
-
clearTimeout(timeout);
|
|
792
|
-
resolve(popOut);
|
|
793
|
-
});
|
|
794
802
|
} catch (err) {
|
|
795
803
|
resolve(undefined);
|
|
796
804
|
}
|
|
@@ -806,7 +814,7 @@ const openPopOut = async options => {
|
|
|
806
814
|
|
|
807
815
|
// Open popup window
|
|
808
816
|
const url = getPopOutUrl(options);
|
|
809
|
-
popOutWindow = await createPopOutWindow(url, WIDTH, HEIGHT);
|
|
817
|
+
popOutWindow = await createPopOutWindow(options.sid, url, WIDTH, HEIGHT);
|
|
810
818
|
const focusPopOut = () => {
|
|
811
819
|
if (popOutWindow) {
|
|
812
820
|
popOutWindow.focus();
|
|
@@ -815,7 +823,7 @@ const openPopOut = async options => {
|
|
|
815
823
|
const cleanUpClosed = () => {
|
|
816
824
|
window.clearInterval(intervalId);
|
|
817
825
|
intervalId = -1;
|
|
818
|
-
window.removeEventListener(
|
|
826
|
+
window.removeEventListener("beforeunload", closePopOut);
|
|
819
827
|
popOutWindow = undefined;
|
|
820
828
|
options.onClose();
|
|
821
829
|
if (unsubscribe) {
|
|
@@ -835,7 +843,7 @@ const openPopOut = async options => {
|
|
|
835
843
|
};
|
|
836
844
|
|
|
837
845
|
// Close pop out if current window is closed
|
|
838
|
-
window.addEventListener(
|
|
846
|
+
window.addEventListener("beforeunload", closePopOut);
|
|
839
847
|
|
|
840
848
|
// Check if checkout is still open
|
|
841
849
|
intervalId = window.setInterval(checkIfPopupClosed, 200);
|
|
@@ -875,8 +883,8 @@ const setIframeHeight = (event, checkout) => {
|
|
|
875
883
|
const scrollToIframeTop = (event, checkout) => {
|
|
876
884
|
try {
|
|
877
885
|
checkout.iframe.scrollIntoView({
|
|
878
|
-
block:
|
|
879
|
-
behavior:
|
|
886
|
+
block: "start",
|
|
887
|
+
behavior: "smooth"
|
|
880
888
|
});
|
|
881
889
|
} catch (e) {
|
|
882
890
|
// Ignore error silently bug log it to the console.
|
|
@@ -935,7 +943,7 @@ const createPopOutMessageHandler = (source, checkout) => {
|
|
|
935
943
|
console.error(e);
|
|
936
944
|
}
|
|
937
945
|
} else {
|
|
938
|
-
console.error(
|
|
946
|
+
console.error("Payment Complete event missing href property");
|
|
939
947
|
}
|
|
940
948
|
}
|
|
941
949
|
};
|
|
@@ -943,7 +951,7 @@ const createPopOutMessageHandler = (source, checkout) => {
|
|
|
943
951
|
// Listens to messages from pop out window and routes the events to dedicated handlers
|
|
944
952
|
const messageRouter = event => {
|
|
945
953
|
// Check that we should handle the message
|
|
946
|
-
if (event.source === source && event.data.context ===
|
|
954
|
+
if (event.source === source && event.data.context === "popOut" && event.data.sid === checkout.options.sid) {
|
|
947
955
|
// Check if handler matches incoming event and trigger the handler if so.
|
|
948
956
|
[
|
|
949
957
|
// SDK events for managing the pop out flow.
|
|
@@ -960,11 +968,11 @@ const createPopOutMessageHandler = (source, checkout) => {
|
|
|
960
968
|
}
|
|
961
969
|
};
|
|
962
970
|
// Add messageRouter event listener to the Pop Out
|
|
963
|
-
window.addEventListener(
|
|
971
|
+
window.addEventListener("message", messageRouter);
|
|
964
972
|
|
|
965
973
|
// Return unsubscribe function
|
|
966
974
|
return () => {
|
|
967
|
-
window.removeEventListener(
|
|
975
|
+
window.removeEventListener("message", messageRouter);
|
|
968
976
|
};
|
|
969
977
|
};
|
|
970
978
|
|
|
@@ -1060,7 +1068,7 @@ const handlePopOutButtonClick = async (event, checkout) => {
|
|
|
1060
1068
|
console.error(e);
|
|
1061
1069
|
postValidationResult(checkout.iframe, checkout.options.sid, {
|
|
1062
1070
|
success: false,
|
|
1063
|
-
clientValidationError:
|
|
1071
|
+
clientValidationError: "Validation runtime error"
|
|
1064
1072
|
});
|
|
1065
1073
|
}
|
|
1066
1074
|
}
|
|
@@ -1120,9 +1128,9 @@ const cleanUpPopOut = checkout => {
|
|
|
1120
1128
|
*/
|
|
1121
1129
|
const embed = async options => {
|
|
1122
1130
|
// Create inner container to offset any styling on the container.
|
|
1123
|
-
const innerContainer = document.createElement(
|
|
1124
|
-
innerContainer.style.position =
|
|
1125
|
-
innerContainer.style[
|
|
1131
|
+
const innerContainer = document.createElement("div");
|
|
1132
|
+
innerContainer.style.position = "relative";
|
|
1133
|
+
innerContainer.style["box-sizing"] = "border-box";
|
|
1126
1134
|
const internalOptions = {
|
|
1127
1135
|
endpoint: "https://checkout.dintero.com",
|
|
1128
1136
|
innerContainer: innerContainer,
|