@dintero/checkout-web-sdk 0.6.4 → 0.6.5
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/dependabot.yml +14 -1
- package/dist/dintero-checkout-web-sdk.cjs.d.ts +1 -1
- package/dist/dintero-checkout-web-sdk.cjs.dev.js +82 -28
- package/dist/dintero-checkout-web-sdk.cjs.prod.js +82 -28
- package/dist/dintero-checkout-web-sdk.esm.js +82 -28
- 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 +11 -12
- package/dist/declarations/src/checkout.d.ts +0 -104
- package/dist/declarations/src/index.d.ts +0 -60
- package/dist/declarations/src/session.d.ts +0 -937
- package/dist/declarations/src/subscribe.d.ts +0 -62
- package/dist/dintero-checkout-web-sdk.cjs.d.ts.map +0 -1
- package/patches/vitest+0.34.6.patch +0 -33
package/.github/dependabot.yml
CHANGED
|
@@ -3,8 +3,21 @@ updates:
|
|
|
3
3
|
- package-ecosystem: npm
|
|
4
4
|
directory: "/"
|
|
5
5
|
schedule:
|
|
6
|
-
interval:
|
|
6
|
+
interval: weekly
|
|
7
7
|
commit-message:
|
|
8
8
|
prefix: fix
|
|
9
9
|
prefix-development: chore
|
|
10
10
|
include: scope
|
|
11
|
+
groups:
|
|
12
|
+
babel:
|
|
13
|
+
patterns:
|
|
14
|
+
- "@babel/*"
|
|
15
|
+
semantic-release:
|
|
16
|
+
patterns:
|
|
17
|
+
- "@semantic-release/*"
|
|
18
|
+
- "semantic-release"
|
|
19
|
+
vitest-webdriverio:
|
|
20
|
+
patterns:
|
|
21
|
+
- "@vitest/*"
|
|
22
|
+
- "vitest"
|
|
23
|
+
- "webdriverio"
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from "./declarations/src/index";
|
|
2
|
-
//# sourceMappingURL=
|
|
2
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGludGVyby1jaGVja291dC13ZWItc2RrLmNqcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi9kZWNsYXJhdGlvbnMvc3JjL2luZGV4LmQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEifQ==
|
|
@@ -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.5",
|
|
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,10 +17,9 @@ var pkg = {
|
|
|
17
17
|
umdName: "dintero"
|
|
18
18
|
},
|
|
19
19
|
scripts: {
|
|
20
|
-
|
|
21
|
-
build: "preconstruct build",
|
|
20
|
+
build: "yarn tsc --noEmit && preconstruct build",
|
|
22
21
|
lint: "prettier --cache --log-level warn -c --config .prettierrc.yml .",
|
|
23
|
-
test: "
|
|
22
|
+
test: "vitest --browser.name=chrome --browser.headless",
|
|
24
23
|
"semantic-release": "semantic-release",
|
|
25
24
|
prepublishOnly: "yarn run build"
|
|
26
25
|
},
|
|
@@ -36,16 +35,16 @@ var pkg = {
|
|
|
36
35
|
url: "https://github.com/Dintero/Dintero.Checkout.Web.SDK/issues"
|
|
37
36
|
},
|
|
38
37
|
devDependencies: {
|
|
39
|
-
"@babel/core": "7.23.
|
|
38
|
+
"@babel/core": "7.23.7",
|
|
40
39
|
"@babel/preset-typescript": "7.23.3",
|
|
41
|
-
"@preconstruct/cli": "2.8.
|
|
40
|
+
"@preconstruct/cli": "2.8.3",
|
|
42
41
|
"@semantic-release/git": "10.0.1",
|
|
43
|
-
"@vitest/browser": "
|
|
44
|
-
prettier: "3.1.
|
|
45
|
-
"semantic-release": "22.0.
|
|
46
|
-
typescript: "5.3.
|
|
47
|
-
vitest: "
|
|
48
|
-
webdriverio: "8.
|
|
42
|
+
"@vitest/browser": "1.2.0",
|
|
43
|
+
prettier: "3.1.1",
|
|
44
|
+
"semantic-release": "22.0.12",
|
|
45
|
+
typescript: "5.3.3",
|
|
46
|
+
vitest: "1.2.0",
|
|
47
|
+
webdriverio: "8.27.2"
|
|
49
48
|
},
|
|
50
49
|
dependencies: {
|
|
51
50
|
"native-promise-only": "0.8.1"
|
|
@@ -83,8 +82,7 @@ const windowLocationAssign = url => {
|
|
|
83
82
|
};
|
|
84
83
|
|
|
85
84
|
/**
|
|
86
|
-
* Get the url for the session
|
|
87
|
-
.DS_Store
|
|
85
|
+
* Get the url for the session
|
|
88
86
|
*/
|
|
89
87
|
|
|
90
88
|
const getSessionUrl = options => {
|
|
@@ -144,6 +142,11 @@ const getPopOutUrl = ({
|
|
|
144
142
|
}
|
|
145
143
|
return `${padTralingSlash(endpoint)}?${params.toString()}`;
|
|
146
144
|
};
|
|
145
|
+
const url = {
|
|
146
|
+
getPopOutUrl,
|
|
147
|
+
getSessionUrl,
|
|
148
|
+
windowLocationAssign
|
|
149
|
+
};
|
|
147
150
|
|
|
148
151
|
/**
|
|
149
152
|
* Creates an iframe and adds it to the container.
|
|
@@ -677,7 +680,9 @@ const configureButton = (button, {
|
|
|
677
680
|
left,
|
|
678
681
|
right,
|
|
679
682
|
styles,
|
|
680
|
-
onClick
|
|
683
|
+
onClick,
|
|
684
|
+
stylesHover,
|
|
685
|
+
stylesFocusVisible
|
|
681
686
|
}) => {
|
|
682
687
|
button.setAttribute("id", OPEN_POP_OUT_BUTTON_ID);
|
|
683
688
|
button.setAttribute("type", "button");
|
|
@@ -717,9 +722,49 @@ const configureButton = (button, {
|
|
|
717
722
|
button.style.right = right + "px";
|
|
718
723
|
|
|
719
724
|
// Appearance from checkout
|
|
720
|
-
|
|
725
|
+
const {
|
|
726
|
+
...directStyles
|
|
727
|
+
} = styles;
|
|
728
|
+
for (const [key, value] of Object.entries(directStyles)) {
|
|
721
729
|
button.style[key] = value;
|
|
722
730
|
}
|
|
731
|
+
|
|
732
|
+
// Add hover and focus-visible styles
|
|
733
|
+
try {
|
|
734
|
+
addHoverAndFocusVisibleStyles(stylesHover, stylesFocusVisible);
|
|
735
|
+
} catch (e) {
|
|
736
|
+
console.error(e);
|
|
737
|
+
}
|
|
738
|
+
};
|
|
739
|
+
const addHoverAndFocusVisibleStyles = (stylesHover, stylesFocusVisible) => {
|
|
740
|
+
if (!stylesHover && !stylesFocusVisible) {
|
|
741
|
+
return;
|
|
742
|
+
}
|
|
743
|
+
const styleId = `${OPEN_POP_OUT_BUTTON_ID}-styles`;
|
|
744
|
+
const hasStyles = document.getElementById(styleId);
|
|
745
|
+
if (hasStyles) {
|
|
746
|
+
return;
|
|
747
|
+
}
|
|
748
|
+
const style = document.createElement("style");
|
|
749
|
+
style.setAttribute("id", styleId);
|
|
750
|
+
let content = [];
|
|
751
|
+
if (stylesHover) {
|
|
752
|
+
content.push(toCssEntity(`#${OPEN_POP_OUT_BUTTON_ID}:hover:not(:disabled)`, stylesHover));
|
|
753
|
+
}
|
|
754
|
+
if (stylesFocusVisible) {
|
|
755
|
+
content.push(toCssEntity(`#${OPEN_POP_OUT_BUTTON_ID}:focus-visible`, stylesFocusVisible));
|
|
756
|
+
}
|
|
757
|
+
style.textContent = content.join("\n");
|
|
758
|
+
document.head.appendChild(style);
|
|
759
|
+
};
|
|
760
|
+
const toCssEntity = (selector, keyValues) => {
|
|
761
|
+
return [`${selector} {`, toCssParameters(keyValues), `}`].join("\n");
|
|
762
|
+
};
|
|
763
|
+
const toCssParameters = keyValues => {
|
|
764
|
+
return Object.entries(keyValues).map(([key, value]) => ` ${slugify(key)}: ${value} !important;`).join("\n");
|
|
765
|
+
};
|
|
766
|
+
const slugify = str => {
|
|
767
|
+
return str.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
723
768
|
};
|
|
724
769
|
const addPopOutButton = options => {
|
|
725
770
|
// Will add or update existing button
|
|
@@ -813,8 +858,8 @@ const openPopOut = async options => {
|
|
|
813
858
|
}
|
|
814
859
|
|
|
815
860
|
// Open popup window
|
|
816
|
-
const
|
|
817
|
-
popOutWindow = await createPopOutWindow(options.sid,
|
|
861
|
+
const popOutUrl = url.getPopOutUrl(options);
|
|
862
|
+
popOutWindow = await createPopOutWindow(options.sid, popOutUrl, WIDTH, HEIGHT);
|
|
818
863
|
const focusPopOut = () => {
|
|
819
864
|
if (popOutWindow) {
|
|
820
865
|
popOutWindow.focus();
|
|
@@ -856,6 +901,9 @@ const openPopOut = async options => {
|
|
|
856
901
|
popOutWindow
|
|
857
902
|
};
|
|
858
903
|
};
|
|
904
|
+
const popOut = {
|
|
905
|
+
openPopOut
|
|
906
|
+
};
|
|
859
907
|
|
|
860
908
|
/**
|
|
861
909
|
* An event handler that navigates to the href in the event.
|
|
@@ -863,7 +911,7 @@ const openPopOut = async options => {
|
|
|
863
911
|
const followHref = (event, checkout) => {
|
|
864
912
|
cleanUpPopOut(checkout);
|
|
865
913
|
if (event.href) {
|
|
866
|
-
windowLocationAssign(event.href);
|
|
914
|
+
url.windowLocationAssign(event.href);
|
|
867
915
|
}
|
|
868
916
|
};
|
|
869
917
|
|
|
@@ -984,7 +1032,7 @@ const showPopOut = async (event, checkout) => {
|
|
|
984
1032
|
close,
|
|
985
1033
|
focus,
|
|
986
1034
|
popOutWindow
|
|
987
|
-
} = await openPopOut({
|
|
1035
|
+
} = await popOut.openPopOut({
|
|
988
1036
|
sid: checkout.options.sid,
|
|
989
1037
|
endpoint: checkout.options.endpoint,
|
|
990
1038
|
shouldCallValidateSession: Boolean(checkout.options.onValidateSession),
|
|
@@ -1025,7 +1073,7 @@ const createPopOutValidationCallback = (event, checkout) => {
|
|
|
1025
1073
|
postValidationResult(checkout.iframe, checkout.options.sid, result);
|
|
1026
1074
|
if (result.success && checkout.popOutWindow) {
|
|
1027
1075
|
// Redirect user to session in pop out window
|
|
1028
|
-
checkout.popOutWindow.location.href = getPopOutUrl({
|
|
1076
|
+
checkout.popOutWindow.location.href = url.getPopOutUrl({
|
|
1029
1077
|
sid: checkout.options.sid,
|
|
1030
1078
|
endpoint: checkout.options.endpoint,
|
|
1031
1079
|
shouldCallValidateSession: false,
|
|
@@ -1093,6 +1141,8 @@ const handleShowButton = (event, checkout) => {
|
|
|
1093
1141
|
left: event.left,
|
|
1094
1142
|
right: event.right,
|
|
1095
1143
|
styles: event.styles,
|
|
1144
|
+
stylesHover: event.stylesHover,
|
|
1145
|
+
stylesFocusVisible: event.stylesFocusVisible,
|
|
1096
1146
|
disabled: event.disabled,
|
|
1097
1147
|
onClick: () => handlePopOutButtonClick(event, checkout)
|
|
1098
1148
|
});
|
|
@@ -1122,6 +1172,10 @@ const cleanUpPopOut = checkout => {
|
|
|
1122
1172
|
}
|
|
1123
1173
|
}
|
|
1124
1174
|
};
|
|
1175
|
+
const composeUrl = (base, path, query) => {
|
|
1176
|
+
const slash = base.endsWith("/") ? "" : "/";
|
|
1177
|
+
return `${base}${slash}${path}?${query}`;
|
|
1178
|
+
};
|
|
1125
1179
|
|
|
1126
1180
|
/**
|
|
1127
1181
|
* Show a dintero payment session in an embedded iframe.
|
|
@@ -1162,7 +1216,7 @@ const embed = async options => {
|
|
|
1162
1216
|
const {
|
|
1163
1217
|
iframe,
|
|
1164
1218
|
initiate
|
|
1165
|
-
} = createIframeAsync(innerContainer, endpoint, getSessionUrl({
|
|
1219
|
+
} = createIframeAsync(innerContainer, endpoint, url.getSessionUrl({
|
|
1166
1220
|
sid,
|
|
1167
1221
|
endpoint,
|
|
1168
1222
|
language,
|
|
@@ -1261,7 +1315,7 @@ const embed = async options => {
|
|
|
1261
1315
|
pairs.push(["language", checkout.language]);
|
|
1262
1316
|
pairs.push(["sdk", pkg.version]);
|
|
1263
1317
|
const urlQuery = pairs.filter(([key, value]) => value).map(([key, value]) => `${key}=${value}`).join("&");
|
|
1264
|
-
checkout.iframe.setAttribute("src",
|
|
1318
|
+
checkout.iframe.setAttribute("src", composeUrl(endpoint, "embedResult/", urlQuery));
|
|
1265
1319
|
handler(event, checkout);
|
|
1266
1320
|
}
|
|
1267
1321
|
};
|
|
@@ -1310,15 +1364,15 @@ const embed = async options => {
|
|
|
1310
1364
|
eventTypes: [CheckoutEvents.SessionLoaded, CheckoutEvents.SessionUpdated]
|
|
1311
1365
|
}, {
|
|
1312
1366
|
eventTypes: [CheckoutEvents.SessionPaymentOnHold],
|
|
1313
|
-
handler:
|
|
1367
|
+
handler: handleWithResult(sid, endpoint, onPayment || followHref)
|
|
1314
1368
|
}, {
|
|
1315
1369
|
eventTypes: [CheckoutEvents.SessionPaymentAuthorized],
|
|
1316
|
-
handler:
|
|
1370
|
+
handler: handleWithResult(sid, endpoint, onPaymentAuthorized || onPayment || followHref)
|
|
1317
1371
|
}, {
|
|
1318
|
-
handler:
|
|
1372
|
+
handler: handleWithResult(sid, endpoint, onSessionCancel || followHref),
|
|
1319
1373
|
eventTypes: [CheckoutEvents.SessionCancel]
|
|
1320
1374
|
}, {
|
|
1321
|
-
handler:
|
|
1375
|
+
handler: handleWithResult(sid, endpoint, onPaymentError || followHref),
|
|
1322
1376
|
eventTypes: [CheckoutEvents.SessionPaymentError]
|
|
1323
1377
|
}, {
|
|
1324
1378
|
handler: onSessionNotFound,
|
|
@@ -1388,7 +1442,7 @@ const redirect = options => {
|
|
|
1388
1442
|
endpoint = "https://checkout.dintero.com"
|
|
1389
1443
|
} = options;
|
|
1390
1444
|
// Redirect the current browser window to the checkout session url.
|
|
1391
|
-
windowLocationAssign(getSessionUrl({
|
|
1445
|
+
url.windowLocationAssign(url.getSessionUrl({
|
|
1392
1446
|
sid,
|
|
1393
1447
|
endpoint,
|
|
1394
1448
|
language,
|
|
@@ -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.5",
|
|
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,10 +17,9 @@ var pkg = {
|
|
|
17
17
|
umdName: "dintero"
|
|
18
18
|
},
|
|
19
19
|
scripts: {
|
|
20
|
-
|
|
21
|
-
build: "preconstruct build",
|
|
20
|
+
build: "yarn tsc --noEmit && preconstruct build",
|
|
22
21
|
lint: "prettier --cache --log-level warn -c --config .prettierrc.yml .",
|
|
23
|
-
test: "
|
|
22
|
+
test: "vitest --browser.name=chrome --browser.headless",
|
|
24
23
|
"semantic-release": "semantic-release",
|
|
25
24
|
prepublishOnly: "yarn run build"
|
|
26
25
|
},
|
|
@@ -36,16 +35,16 @@ var pkg = {
|
|
|
36
35
|
url: "https://github.com/Dintero/Dintero.Checkout.Web.SDK/issues"
|
|
37
36
|
},
|
|
38
37
|
devDependencies: {
|
|
39
|
-
"@babel/core": "7.23.
|
|
38
|
+
"@babel/core": "7.23.7",
|
|
40
39
|
"@babel/preset-typescript": "7.23.3",
|
|
41
|
-
"@preconstruct/cli": "2.8.
|
|
40
|
+
"@preconstruct/cli": "2.8.3",
|
|
42
41
|
"@semantic-release/git": "10.0.1",
|
|
43
|
-
"@vitest/browser": "
|
|
44
|
-
prettier: "3.1.
|
|
45
|
-
"semantic-release": "22.0.
|
|
46
|
-
typescript: "5.3.
|
|
47
|
-
vitest: "
|
|
48
|
-
webdriverio: "8.
|
|
42
|
+
"@vitest/browser": "1.2.0",
|
|
43
|
+
prettier: "3.1.1",
|
|
44
|
+
"semantic-release": "22.0.12",
|
|
45
|
+
typescript: "5.3.3",
|
|
46
|
+
vitest: "1.2.0",
|
|
47
|
+
webdriverio: "8.27.2"
|
|
49
48
|
},
|
|
50
49
|
dependencies: {
|
|
51
50
|
"native-promise-only": "0.8.1"
|
|
@@ -83,8 +82,7 @@ const windowLocationAssign = url => {
|
|
|
83
82
|
};
|
|
84
83
|
|
|
85
84
|
/**
|
|
86
|
-
* Get the url for the session
|
|
87
|
-
.DS_Store
|
|
85
|
+
* Get the url for the session
|
|
88
86
|
*/
|
|
89
87
|
|
|
90
88
|
const getSessionUrl = options => {
|
|
@@ -144,6 +142,11 @@ const getPopOutUrl = ({
|
|
|
144
142
|
}
|
|
145
143
|
return `${padTralingSlash(endpoint)}?${params.toString()}`;
|
|
146
144
|
};
|
|
145
|
+
const url = {
|
|
146
|
+
getPopOutUrl,
|
|
147
|
+
getSessionUrl,
|
|
148
|
+
windowLocationAssign
|
|
149
|
+
};
|
|
147
150
|
|
|
148
151
|
/**
|
|
149
152
|
* Creates an iframe and adds it to the container.
|
|
@@ -677,7 +680,9 @@ const configureButton = (button, {
|
|
|
677
680
|
left,
|
|
678
681
|
right,
|
|
679
682
|
styles,
|
|
680
|
-
onClick
|
|
683
|
+
onClick,
|
|
684
|
+
stylesHover,
|
|
685
|
+
stylesFocusVisible
|
|
681
686
|
}) => {
|
|
682
687
|
button.setAttribute("id", OPEN_POP_OUT_BUTTON_ID);
|
|
683
688
|
button.setAttribute("type", "button");
|
|
@@ -717,9 +722,49 @@ const configureButton = (button, {
|
|
|
717
722
|
button.style.right = right + "px";
|
|
718
723
|
|
|
719
724
|
// Appearance from checkout
|
|
720
|
-
|
|
725
|
+
const {
|
|
726
|
+
...directStyles
|
|
727
|
+
} = styles;
|
|
728
|
+
for (const [key, value] of Object.entries(directStyles)) {
|
|
721
729
|
button.style[key] = value;
|
|
722
730
|
}
|
|
731
|
+
|
|
732
|
+
// Add hover and focus-visible styles
|
|
733
|
+
try {
|
|
734
|
+
addHoverAndFocusVisibleStyles(stylesHover, stylesFocusVisible);
|
|
735
|
+
} catch (e) {
|
|
736
|
+
console.error(e);
|
|
737
|
+
}
|
|
738
|
+
};
|
|
739
|
+
const addHoverAndFocusVisibleStyles = (stylesHover, stylesFocusVisible) => {
|
|
740
|
+
if (!stylesHover && !stylesFocusVisible) {
|
|
741
|
+
return;
|
|
742
|
+
}
|
|
743
|
+
const styleId = `${OPEN_POP_OUT_BUTTON_ID}-styles`;
|
|
744
|
+
const hasStyles = document.getElementById(styleId);
|
|
745
|
+
if (hasStyles) {
|
|
746
|
+
return;
|
|
747
|
+
}
|
|
748
|
+
const style = document.createElement("style");
|
|
749
|
+
style.setAttribute("id", styleId);
|
|
750
|
+
let content = [];
|
|
751
|
+
if (stylesHover) {
|
|
752
|
+
content.push(toCssEntity(`#${OPEN_POP_OUT_BUTTON_ID}:hover:not(:disabled)`, stylesHover));
|
|
753
|
+
}
|
|
754
|
+
if (stylesFocusVisible) {
|
|
755
|
+
content.push(toCssEntity(`#${OPEN_POP_OUT_BUTTON_ID}:focus-visible`, stylesFocusVisible));
|
|
756
|
+
}
|
|
757
|
+
style.textContent = content.join("\n");
|
|
758
|
+
document.head.appendChild(style);
|
|
759
|
+
};
|
|
760
|
+
const toCssEntity = (selector, keyValues) => {
|
|
761
|
+
return [`${selector} {`, toCssParameters(keyValues), `}`].join("\n");
|
|
762
|
+
};
|
|
763
|
+
const toCssParameters = keyValues => {
|
|
764
|
+
return Object.entries(keyValues).map(([key, value]) => ` ${slugify(key)}: ${value} !important;`).join("\n");
|
|
765
|
+
};
|
|
766
|
+
const slugify = str => {
|
|
767
|
+
return str.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
723
768
|
};
|
|
724
769
|
const addPopOutButton = options => {
|
|
725
770
|
// Will add or update existing button
|
|
@@ -813,8 +858,8 @@ const openPopOut = async options => {
|
|
|
813
858
|
}
|
|
814
859
|
|
|
815
860
|
// Open popup window
|
|
816
|
-
const
|
|
817
|
-
popOutWindow = await createPopOutWindow(options.sid,
|
|
861
|
+
const popOutUrl = url.getPopOutUrl(options);
|
|
862
|
+
popOutWindow = await createPopOutWindow(options.sid, popOutUrl, WIDTH, HEIGHT);
|
|
818
863
|
const focusPopOut = () => {
|
|
819
864
|
if (popOutWindow) {
|
|
820
865
|
popOutWindow.focus();
|
|
@@ -856,6 +901,9 @@ const openPopOut = async options => {
|
|
|
856
901
|
popOutWindow
|
|
857
902
|
};
|
|
858
903
|
};
|
|
904
|
+
const popOut = {
|
|
905
|
+
openPopOut
|
|
906
|
+
};
|
|
859
907
|
|
|
860
908
|
/**
|
|
861
909
|
* An event handler that navigates to the href in the event.
|
|
@@ -863,7 +911,7 @@ const openPopOut = async options => {
|
|
|
863
911
|
const followHref = (event, checkout) => {
|
|
864
912
|
cleanUpPopOut(checkout);
|
|
865
913
|
if (event.href) {
|
|
866
|
-
windowLocationAssign(event.href);
|
|
914
|
+
url.windowLocationAssign(event.href);
|
|
867
915
|
}
|
|
868
916
|
};
|
|
869
917
|
|
|
@@ -984,7 +1032,7 @@ const showPopOut = async (event, checkout) => {
|
|
|
984
1032
|
close,
|
|
985
1033
|
focus,
|
|
986
1034
|
popOutWindow
|
|
987
|
-
} = await openPopOut({
|
|
1035
|
+
} = await popOut.openPopOut({
|
|
988
1036
|
sid: checkout.options.sid,
|
|
989
1037
|
endpoint: checkout.options.endpoint,
|
|
990
1038
|
shouldCallValidateSession: Boolean(checkout.options.onValidateSession),
|
|
@@ -1025,7 +1073,7 @@ const createPopOutValidationCallback = (event, checkout) => {
|
|
|
1025
1073
|
postValidationResult(checkout.iframe, checkout.options.sid, result);
|
|
1026
1074
|
if (result.success && checkout.popOutWindow) {
|
|
1027
1075
|
// Redirect user to session in pop out window
|
|
1028
|
-
checkout.popOutWindow.location.href = getPopOutUrl({
|
|
1076
|
+
checkout.popOutWindow.location.href = url.getPopOutUrl({
|
|
1029
1077
|
sid: checkout.options.sid,
|
|
1030
1078
|
endpoint: checkout.options.endpoint,
|
|
1031
1079
|
shouldCallValidateSession: false,
|
|
@@ -1093,6 +1141,8 @@ const handleShowButton = (event, checkout) => {
|
|
|
1093
1141
|
left: event.left,
|
|
1094
1142
|
right: event.right,
|
|
1095
1143
|
styles: event.styles,
|
|
1144
|
+
stylesHover: event.stylesHover,
|
|
1145
|
+
stylesFocusVisible: event.stylesFocusVisible,
|
|
1096
1146
|
disabled: event.disabled,
|
|
1097
1147
|
onClick: () => handlePopOutButtonClick(event, checkout)
|
|
1098
1148
|
});
|
|
@@ -1122,6 +1172,10 @@ const cleanUpPopOut = checkout => {
|
|
|
1122
1172
|
}
|
|
1123
1173
|
}
|
|
1124
1174
|
};
|
|
1175
|
+
const composeUrl = (base, path, query) => {
|
|
1176
|
+
const slash = base.endsWith("/") ? "" : "/";
|
|
1177
|
+
return `${base}${slash}${path}?${query}`;
|
|
1178
|
+
};
|
|
1125
1179
|
|
|
1126
1180
|
/**
|
|
1127
1181
|
* Show a dintero payment session in an embedded iframe.
|
|
@@ -1162,7 +1216,7 @@ const embed = async options => {
|
|
|
1162
1216
|
const {
|
|
1163
1217
|
iframe,
|
|
1164
1218
|
initiate
|
|
1165
|
-
} = createIframeAsync(innerContainer, endpoint, getSessionUrl({
|
|
1219
|
+
} = createIframeAsync(innerContainer, endpoint, url.getSessionUrl({
|
|
1166
1220
|
sid,
|
|
1167
1221
|
endpoint,
|
|
1168
1222
|
language,
|
|
@@ -1261,7 +1315,7 @@ const embed = async options => {
|
|
|
1261
1315
|
pairs.push(["language", checkout.language]);
|
|
1262
1316
|
pairs.push(["sdk", pkg.version]);
|
|
1263
1317
|
const urlQuery = pairs.filter(([key, value]) => value).map(([key, value]) => `${key}=${value}`).join("&");
|
|
1264
|
-
checkout.iframe.setAttribute("src",
|
|
1318
|
+
checkout.iframe.setAttribute("src", composeUrl(endpoint, "embedResult/", urlQuery));
|
|
1265
1319
|
handler(event, checkout);
|
|
1266
1320
|
}
|
|
1267
1321
|
};
|
|
@@ -1310,15 +1364,15 @@ const embed = async options => {
|
|
|
1310
1364
|
eventTypes: [CheckoutEvents.SessionLoaded, CheckoutEvents.SessionUpdated]
|
|
1311
1365
|
}, {
|
|
1312
1366
|
eventTypes: [CheckoutEvents.SessionPaymentOnHold],
|
|
1313
|
-
handler:
|
|
1367
|
+
handler: handleWithResult(sid, endpoint, onPayment || followHref)
|
|
1314
1368
|
}, {
|
|
1315
1369
|
eventTypes: [CheckoutEvents.SessionPaymentAuthorized],
|
|
1316
|
-
handler:
|
|
1370
|
+
handler: handleWithResult(sid, endpoint, onPaymentAuthorized || onPayment || followHref)
|
|
1317
1371
|
}, {
|
|
1318
|
-
handler:
|
|
1372
|
+
handler: handleWithResult(sid, endpoint, onSessionCancel || followHref),
|
|
1319
1373
|
eventTypes: [CheckoutEvents.SessionCancel]
|
|
1320
1374
|
}, {
|
|
1321
|
-
handler:
|
|
1375
|
+
handler: handleWithResult(sid, endpoint, onPaymentError || followHref),
|
|
1322
1376
|
eventTypes: [CheckoutEvents.SessionPaymentError]
|
|
1323
1377
|
}, {
|
|
1324
1378
|
handler: onSessionNotFound,
|
|
@@ -1388,7 +1442,7 @@ const redirect = options => {
|
|
|
1388
1442
|
endpoint = "https://checkout.dintero.com"
|
|
1389
1443
|
} = options;
|
|
1390
1444
|
// Redirect the current browser window to the checkout session url.
|
|
1391
|
-
windowLocationAssign(getSessionUrl({
|
|
1445
|
+
url.windowLocationAssign(url.getSessionUrl({
|
|
1392
1446
|
sid,
|
|
1393
1447
|
endpoint,
|
|
1394
1448
|
language,
|