@dintero/checkout-web-sdk 0.12.11 → 0.12.13
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/declarations/src/index.d.ts +1 -1
- package/dist/declarations/src/subscribe.d.ts +1 -1
- package/dist/dintero-checkout-web-sdk.cjs.dev.js +60 -37
- package/dist/dintero-checkout-web-sdk.cjs.prod.js +60 -37
- package/dist/dintero-checkout-web-sdk.esm.js +60 -37
- 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 +5 -5
|
@@ -2,7 +2,7 @@ import 'native-promise-only';
|
|
|
2
2
|
|
|
3
3
|
var pkg = {
|
|
4
4
|
name: "@dintero/checkout-web-sdk",
|
|
5
|
-
version: "0.12.
|
|
5
|
+
version: "0.12.13",
|
|
6
6
|
description: "Dintero Checkout SDK for web frontends",
|
|
7
7
|
main: "dist/dintero-checkout-web-sdk.cjs.js",
|
|
8
8
|
module: "dist/dintero-checkout-web-sdk.esm.js",
|
|
@@ -36,15 +36,15 @@ var pkg = {
|
|
|
36
36
|
devDependencies: {
|
|
37
37
|
"@babel/core": "7.29.0",
|
|
38
38
|
"@babel/preset-typescript": "7.28.5",
|
|
39
|
-
"@biomejs/biome": "2.4.
|
|
39
|
+
"@biomejs/biome": "2.4.13",
|
|
40
40
|
"@preconstruct/cli": "2.8.12",
|
|
41
41
|
"@semantic-release/exec": "7.1.0",
|
|
42
42
|
"@semantic-release/git": "10.0.1",
|
|
43
|
-
"@vitest/browser": "4.1.
|
|
43
|
+
"@vitest/browser": "4.1.5",
|
|
44
44
|
"@vitest/browser-webdriverio": "^4.0.4",
|
|
45
45
|
"semantic-release": "25.0.3",
|
|
46
|
-
typescript: "
|
|
47
|
-
vitest: "4.1.
|
|
46
|
+
typescript: "6.0.3",
|
|
47
|
+
vitest: "4.1.5",
|
|
48
48
|
webdriverio: "9.27.0"
|
|
49
49
|
},
|
|
50
50
|
dependencies: {
|
|
@@ -84,7 +84,7 @@ let InternalCheckoutEvents = /*#__PURE__*/function (InternalCheckoutEvents) {
|
|
|
84
84
|
* Rejects the promise if there is a problem loading the iframe.
|
|
85
85
|
*/
|
|
86
86
|
const createIframeAsync = (container, url) => {
|
|
87
|
-
if (!container
|
|
87
|
+
if (!container?.appendChild) {
|
|
88
88
|
throw new Error("Invalid container");
|
|
89
89
|
}
|
|
90
90
|
const iframe = document.createElement("iframe");
|
|
@@ -236,8 +236,8 @@ const hostnameIsTop = () => {
|
|
|
236
236
|
return true;
|
|
237
237
|
}
|
|
238
238
|
const hostname = getHostname();
|
|
239
|
-
const topHostname = window.top
|
|
240
|
-
return topHostname && hostname && hostname === topHostname;
|
|
239
|
+
const topHostname = window.top?.location.hostname;
|
|
240
|
+
return Boolean(topHostname && hostname && hostname === topHostname);
|
|
241
241
|
} catch (_) {
|
|
242
242
|
return false;
|
|
243
243
|
}
|
|
@@ -272,7 +272,7 @@ const createPopOutWindow = (sid, url, width, height) => {
|
|
|
272
272
|
};
|
|
273
273
|
window.addEventListener("message", handleAppLoaded);
|
|
274
274
|
// Open pop out
|
|
275
|
-
popOut = window.open(url, "dintero-checkout", features);
|
|
275
|
+
popOut = window.open(url, "dintero-checkout", features) ?? undefined;
|
|
276
276
|
// Check that pop out was opened
|
|
277
277
|
if (!popOut) {
|
|
278
278
|
console.log("createPopOutWindow no popOut");
|
|
@@ -295,7 +295,11 @@ const openPopOut = async options => {
|
|
|
295
295
|
let popOutWindow;
|
|
296
296
|
if (popOutWindow && !popOutWindow.closed) {
|
|
297
297
|
// Skip if already open.
|
|
298
|
-
return
|
|
298
|
+
return {
|
|
299
|
+
close: () => {},
|
|
300
|
+
focus: () => {},
|
|
301
|
+
popOutWindow: undefined
|
|
302
|
+
};
|
|
299
303
|
}
|
|
300
304
|
|
|
301
305
|
// Open popup window
|
|
@@ -335,7 +339,9 @@ const openPopOut = async options => {
|
|
|
335
339
|
intervalId = window.setInterval(checkIfPopupClosed, 200);
|
|
336
340
|
|
|
337
341
|
// Set up pub/sub of messages from pop out to SDK
|
|
338
|
-
|
|
342
|
+
if (popOutWindow) {
|
|
343
|
+
unsubscribe = options.onOpen(popOutWindow);
|
|
344
|
+
}
|
|
339
345
|
return {
|
|
340
346
|
close: closePopOut,
|
|
341
347
|
focus: focusPopOut,
|
|
@@ -391,7 +397,7 @@ const getBackdropZIndex = () => {
|
|
|
391
397
|
const elements = document.getElementsByTagName("*");
|
|
392
398
|
const highest = Array.from(elements).reduce((acc, element) => {
|
|
393
399
|
try {
|
|
394
|
-
const zIndexStr = document.defaultView
|
|
400
|
+
const zIndexStr = document.defaultView?.getComputedStyle(element, null).getPropertyValue("z-index");
|
|
395
401
|
const zIndex = Number.parseInt(zIndexStr || "0", 10);
|
|
396
402
|
if (!Number.isNaN(zIndex) && zIndex > acc) {
|
|
397
403
|
return zIndex;
|
|
@@ -610,11 +616,11 @@ const focusTrap = e => {
|
|
|
610
616
|
const closeButton = document.getElementById(CLOSE_BACKDROP_BUTTON_ID);
|
|
611
617
|
if (e.key === "Tab" || e.code === "Tab") {
|
|
612
618
|
if (document.activeElement === focusButton) {
|
|
613
|
-
closeButton
|
|
619
|
+
closeButton?.focus();
|
|
614
620
|
e.preventDefault();
|
|
615
621
|
} else {
|
|
616
622
|
// Tab
|
|
617
|
-
focusButton
|
|
623
|
+
focusButton?.focus();
|
|
618
624
|
e.preventDefault();
|
|
619
625
|
}
|
|
620
626
|
}
|
|
@@ -742,6 +748,8 @@ const configureButton = (button, {
|
|
|
742
748
|
...directStyles
|
|
743
749
|
} = styles;
|
|
744
750
|
for (const [key, value] of Object.entries(directStyles)) {
|
|
751
|
+
// TODO: CSSStyleDeclaration lost its string index signature in TS6;
|
|
752
|
+
// styles from checkout are camelCase property names sent at runtime.
|
|
745
753
|
button.style[key] = value;
|
|
746
754
|
}
|
|
747
755
|
|
|
@@ -1064,6 +1072,7 @@ const createPopOutMessageHandler = (source, checkout) => {
|
|
|
1064
1072
|
const popOutChangedLanguageHandler = {
|
|
1065
1073
|
internalPopOutHandler: true,
|
|
1066
1074
|
eventTypes: [InternalCheckoutEvents.LanguageChanged],
|
|
1075
|
+
// biome-ignore lint/suspicious/noExplicitAny: internal LanguageChanged event, not part of SessionEvent
|
|
1067
1076
|
handler: (eventData, checkout) => {
|
|
1068
1077
|
// Tell the embedded checkout to change language.
|
|
1069
1078
|
postSetLanguage(checkout.iframe, checkout.options.sid, eventData.language);
|
|
@@ -1075,6 +1084,7 @@ const createPopOutMessageHandler = (source, checkout) => {
|
|
|
1075
1084
|
const popOutCompletedHandler = {
|
|
1076
1085
|
internalPopOutHandler: true,
|
|
1077
1086
|
eventTypes: paymentCompletedEvents,
|
|
1087
|
+
// biome-ignore lint/suspicious/noExplicitAny: href is not present on all SessionEvent subtypes
|
|
1078
1088
|
handler: (eventData, _checkout) => {
|
|
1079
1089
|
if (eventData.href) {
|
|
1080
1090
|
// Remove open pop out button rendered by SDK
|
|
@@ -1104,8 +1114,11 @@ const createPopOutMessageHandler = (source, checkout) => {
|
|
|
1104
1114
|
...checkout.handlers]) {
|
|
1105
1115
|
if (handlerObject.eventTypes.includes(event.data.type) && handlerObject.handler) {
|
|
1106
1116
|
// Invoking the handler function if the event type matches the handler.
|
|
1117
|
+
const {
|
|
1118
|
+
handler
|
|
1119
|
+
} = handlerObject;
|
|
1107
1120
|
safelyInvoke(() => {
|
|
1108
|
-
|
|
1121
|
+
handler(event.data, checkout);
|
|
1109
1122
|
});
|
|
1110
1123
|
}
|
|
1111
1124
|
}
|
|
@@ -1124,13 +1137,9 @@ const createPopOutMessageHandler = (source, checkout) => {
|
|
|
1124
1137
|
* Configures and shows the pop out with the payment options.
|
|
1125
1138
|
*/
|
|
1126
1139
|
const showPopOut = async (event, checkout) => {
|
|
1127
|
-
const {
|
|
1128
|
-
close,
|
|
1129
|
-
focus,
|
|
1130
|
-
popOutWindow
|
|
1131
|
-
} = await popOutModule.openPopOut({
|
|
1140
|
+
const openPopOutResult = await popOutModule.openPopOut({
|
|
1132
1141
|
sid: checkout.options.sid,
|
|
1133
|
-
endpoint: checkout.options.endpoint,
|
|
1142
|
+
endpoint: checkout.options.endpoint ?? "https://checkout.dintero.com",
|
|
1134
1143
|
shouldCallValidateSession: Boolean(checkout.options.onValidateSession),
|
|
1135
1144
|
shouldCallAddressCallback: false,
|
|
1136
1145
|
// handled by embedded checkout not the pop out window
|
|
@@ -1143,6 +1152,11 @@ const showPopOut = async (event, checkout) => {
|
|
|
1143
1152
|
checkout.popOutWindow = undefined;
|
|
1144
1153
|
}
|
|
1145
1154
|
});
|
|
1155
|
+
const {
|
|
1156
|
+
close,
|
|
1157
|
+
focus,
|
|
1158
|
+
popOutWindow
|
|
1159
|
+
} = openPopOutResult;
|
|
1146
1160
|
if (popOutWindow) {
|
|
1147
1161
|
postOpenPopOutEvent(checkout.iframe, checkout.options.sid);
|
|
1148
1162
|
// Add pop out window to checkout instance
|
|
@@ -1173,7 +1187,7 @@ const createPopOutValidationCallback = (event, checkout) => {
|
|
|
1173
1187
|
// Redirect user to session in pop out window
|
|
1174
1188
|
checkout.popOutWindow.location.href = url.getPopOutUrl({
|
|
1175
1189
|
sid: checkout.options.sid,
|
|
1176
|
-
endpoint: checkout.options.endpoint,
|
|
1190
|
+
endpoint: checkout.options.endpoint ?? "https://checkout.dintero.com",
|
|
1177
1191
|
shouldCallValidateSession: false,
|
|
1178
1192
|
shouldCallAddressCallback: false,
|
|
1179
1193
|
language: event.language
|
|
@@ -1208,6 +1222,8 @@ const handlePopOutButtonClick = async (event, checkout) => {
|
|
|
1208
1222
|
try {
|
|
1209
1223
|
checkout.options.onValidateSession({
|
|
1210
1224
|
type: CheckoutEvents.ValidateSession,
|
|
1225
|
+
// TODO: session may be undefined before SessionLoaded fires;
|
|
1226
|
+
// ValidateSession.session is typed as Session (non-optional).
|
|
1211
1227
|
session: checkout.session,
|
|
1212
1228
|
callback
|
|
1213
1229
|
}, checkout, callback);
|
|
@@ -1225,7 +1241,7 @@ const handlePopOutButtonClick = async (event, checkout) => {
|
|
|
1225
1241
|
* Type guard for ShowPopOutButton
|
|
1226
1242
|
*/
|
|
1227
1243
|
const isShowPopOutButton = event => {
|
|
1228
|
-
return event && event.type === InternalCheckoutEvents.ShowPopOutButton;
|
|
1244
|
+
return typeof event === "object" && event !== null && event.type === InternalCheckoutEvents.ShowPopOutButton;
|
|
1229
1245
|
};
|
|
1230
1246
|
|
|
1231
1247
|
/**
|
|
@@ -1287,7 +1303,7 @@ const embed = async options => {
|
|
|
1287
1303
|
// Create inner container to offset any styling on the container.
|
|
1288
1304
|
const innerContainer = document.createElement("div");
|
|
1289
1305
|
innerContainer.style.position = "relative";
|
|
1290
|
-
innerContainer.style
|
|
1306
|
+
innerContainer.style.boxSizing = "border-box";
|
|
1291
1307
|
const internalOptions = {
|
|
1292
1308
|
endpoint: "https://checkout.dintero.com",
|
|
1293
1309
|
innerContainer: innerContainer,
|
|
@@ -1338,7 +1354,9 @@ const embed = async options => {
|
|
|
1338
1354
|
* Function that removes the iframe, pop out and all event listeners.
|
|
1339
1355
|
*/
|
|
1340
1356
|
const destroy = () => {
|
|
1341
|
-
|
|
1357
|
+
if (checkout) {
|
|
1358
|
+
cleanUpPopOut(checkout);
|
|
1359
|
+
}
|
|
1342
1360
|
if (iframe) {
|
|
1343
1361
|
if (internalOptions.popOut) {
|
|
1344
1362
|
// Try to remove backdrop if it exists
|
|
@@ -1364,6 +1382,7 @@ const embed = async options => {
|
|
|
1364
1382
|
if (!checkout) {
|
|
1365
1383
|
throw new Error("Unable to create action promise: checkout is undefined");
|
|
1366
1384
|
}
|
|
1385
|
+
const checkoutInstance = checkout;
|
|
1367
1386
|
return new Promise((resolve, reject) => {
|
|
1368
1387
|
const eventSubscriptions = [];
|
|
1369
1388
|
eventSubscriptions.push(subscribe({
|
|
@@ -1376,8 +1395,8 @@ const embed = async options => {
|
|
|
1376
1395
|
resolve(sessionEvent);
|
|
1377
1396
|
},
|
|
1378
1397
|
eventTypes: [resolveEvent],
|
|
1379
|
-
checkout,
|
|
1380
|
-
source:
|
|
1398
|
+
checkout: checkoutInstance,
|
|
1399
|
+
source: checkoutInstance.iframe.contentWindow
|
|
1381
1400
|
}));
|
|
1382
1401
|
eventSubscriptions.push(subscribe({
|
|
1383
1402
|
sid,
|
|
@@ -1389,8 +1408,8 @@ const embed = async options => {
|
|
|
1389
1408
|
reject(`Received unexpected event: ${rejectEvent}`);
|
|
1390
1409
|
},
|
|
1391
1410
|
eventTypes: [rejectEvent],
|
|
1392
|
-
checkout,
|
|
1393
|
-
source:
|
|
1411
|
+
checkout: checkoutInstance,
|
|
1412
|
+
source: checkoutInstance.iframe.contentWindow
|
|
1394
1413
|
}));
|
|
1395
1414
|
action();
|
|
1396
1415
|
});
|
|
@@ -1430,6 +1449,7 @@ const embed = async options => {
|
|
|
1430
1449
|
* If no custom handler is set the followHref handler is used instead.
|
|
1431
1450
|
*/
|
|
1432
1451
|
const handleWithResult = (_sid, endpoint, handler) => {
|
|
1452
|
+
// biome-ignore lint/suspicious/noExplicitAny: requires dynamic key access on event payload
|
|
1433
1453
|
return (event, checkout) => {
|
|
1434
1454
|
if (!has_delivered_final_event) {
|
|
1435
1455
|
has_delivered_final_event = true;
|
|
@@ -1510,15 +1530,17 @@ const embed = async options => {
|
|
|
1510
1530
|
eventTypes: [CheckoutEvents.SessionLoaded, CheckoutEvents.SessionUpdated]
|
|
1511
1531
|
}, {
|
|
1512
1532
|
eventTypes: [CheckoutEvents.SessionPaymentOnHold],
|
|
1513
|
-
|
|
1533
|
+
// TODO: user callbacks have narrower event param types than SubscriptionHandler;
|
|
1534
|
+
// casts are safe because handleWithResult only invokes them with the matching event type.
|
|
1535
|
+
handler: handleWithResult(sid, endpoint, onPayment ?? followHref)
|
|
1514
1536
|
}, {
|
|
1515
1537
|
eventTypes: [CheckoutEvents.SessionPaymentAuthorized],
|
|
1516
|
-
handler: handleWithResult(sid, endpoint, onPaymentAuthorized
|
|
1538
|
+
handler: handleWithResult(sid, endpoint, onPaymentAuthorized ?? onPayment ?? followHref)
|
|
1517
1539
|
}, {
|
|
1518
|
-
handler: handleWithResult(sid, endpoint, onSessionCancel
|
|
1540
|
+
handler: handleWithResult(sid, endpoint, onSessionCancel ?? followHref),
|
|
1519
1541
|
eventTypes: [CheckoutEvents.SessionCancel]
|
|
1520
1542
|
}, {
|
|
1521
|
-
handler: handleWithResult(sid, endpoint, onPaymentError
|
|
1543
|
+
handler: handleWithResult(sid, endpoint, onPaymentError ?? followHref),
|
|
1522
1544
|
eventTypes: [CheckoutEvents.SessionPaymentError]
|
|
1523
1545
|
}, {
|
|
1524
1546
|
handler: onSessionNotFound,
|
|
@@ -1549,7 +1571,7 @@ const embed = async options => {
|
|
|
1549
1571
|
checkout = {
|
|
1550
1572
|
destroy,
|
|
1551
1573
|
iframe,
|
|
1552
|
-
language,
|
|
1574
|
+
language: language ?? "",
|
|
1553
1575
|
lockSession,
|
|
1554
1576
|
refreshSession,
|
|
1555
1577
|
setActivePaymentProductType,
|
|
@@ -1560,6 +1582,7 @@ const embed = async options => {
|
|
|
1560
1582
|
session: undefined,
|
|
1561
1583
|
popOutWindow: undefined
|
|
1562
1584
|
};
|
|
1585
|
+
const checkoutInstance = checkout;
|
|
1563
1586
|
for (const {
|
|
1564
1587
|
handler,
|
|
1565
1588
|
eventTypes
|
|
@@ -1570,8 +1593,8 @@ const embed = async options => {
|
|
|
1570
1593
|
endpoint,
|
|
1571
1594
|
handler,
|
|
1572
1595
|
eventTypes,
|
|
1573
|
-
checkout,
|
|
1574
|
-
source:
|
|
1596
|
+
checkout: checkoutInstance,
|
|
1597
|
+
source: checkoutInstance.iframe.contentWindow
|
|
1575
1598
|
}));
|
|
1576
1599
|
}
|
|
1577
1600
|
}
|
|
@@ -1579,7 +1602,7 @@ const embed = async options => {
|
|
|
1579
1602
|
// Add iframe to DOM
|
|
1580
1603
|
await initiate();
|
|
1581
1604
|
// Return object with function to destroy the checkout.
|
|
1582
|
-
return
|
|
1605
|
+
return checkoutInstance;
|
|
1583
1606
|
};
|
|
1584
1607
|
|
|
1585
1608
|
/**
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
v0.8.1 (c) Kyle Simpson
|
|
4
4
|
MIT License: http://getify.mit-license.org
|
|
5
5
|
*/
|
|
6
|
-
var n,o,i;i=function(){var e,t,n,o=Object.prototype.toString,i="undefined"!=typeof setImmediate?function(e){return setImmediate(e)}:setTimeout;try{Object.defineProperty({},"x",{}),e=function(e,t,n,o){return Object.defineProperty(e,t,{value:n,writable:!0,configurable:!1!==o})}}catch(t){e=function(e,t,n){return e[t]=n,e}}function r(e,o){n.add(e,o),t||(t=i(n.drain))}function s(e){var t,n=typeof e;return null==e||"object"!=n&&"function"!=n||(t=e.then),"function"==typeof t&&t}function a(){for(var e=0;e<this.chain.length;e++)d(this,1===this.state?this.chain[e].success:this.chain[e].failure,this.chain[e]);this.chain.length=0}function d(e,t,n){var o,i;try{!1===t?n.reject(e.msg):(o=!0===t?e.msg:t.call(void 0,e.msg))===n.promise?n.reject(TypeError("Promise-chain cycle")):(i=s(o))?i.call(o,n.resolve,n.reject):n.resolve(o)}catch(e){n.reject(e)}}function c(e){var t,n=this;if(!n.triggered){n.triggered=!0,n.def&&(n=n.def);try{(t=s(e))?r(function(){var o=new u(n);try{t.call(e,function(){c.apply(o,arguments)},function(){l.apply(o,arguments)})}catch(e){l.call(o,e)}}):(n.msg=e,n.state=1,n.chain.length>0&&r(a,n))}catch(e){l.call(new u(n),e)}}}function l(e){var t=this;t.triggered||(t.triggered=!0,t.def&&(t=t.def),t.msg=e,t.state=2,t.chain.length>0&&r(a,t))}function p(e,t,n,o){for(var i=0;i<t.length;i++)(function(i){e.resolve(t[i]).then(function(e){n(i,e)},o)})(i)}function u(e){this.def=e,this.triggered=!1}function f(e){this.promise=e,this.state=0,this.triggered=!1,this.chain=[],this.msg=void 0}function h(e){if("function"!=typeof e)throw TypeError("Not a function");if(0!==this.__NPO__)throw TypeError("Not a promise");this.__NPO__=1;var t=new f(this);this.then=function(e,n){var o={success:"function"!=typeof e||e,failure:"function"==typeof n&&n};return o.promise=new this.constructor(function(e,t){if("function"!=typeof e||"function"!=typeof t)throw TypeError("Not a function");o.resolve=e,o.reject=t}),t.chain.push(o),0!==t.state&&r(a,t),o.promise},this.catch=function(e){return this.then(void 0,e)};try{e.call(void 0,function(e){c.call(t,e)},function(e){l.call(t,e)})}catch(e){l.call(t,e)}}n=function(){var e,n,o;function i(e,t){this.fn=e,this.self=t,this.next=void 0}return{add:function(t,r){o=new i(t,r),n?n.next=o:e=o,n=o,o=void 0},drain:function(){var o=e;for(e=n=t=void 0;o;)o.fn.call(o.self),o=o.next}}}();var m=e({},"constructor",h,!1);return h.prototype=m,e(m,"__NPO__",0,!1),e(h,"resolve",function(e){return e&&"object"==typeof e&&1===e.__NPO__?e:new this(function(t,n){if("function"!=typeof t||"function"!=typeof n)throw TypeError("Not a function");t(e)})}),e(h,"reject",function(e){return new this(function(t,n){if("function"!=typeof t||"function"!=typeof n)throw TypeError("Not a function");n(e)})}),e(h,"all",function(e){var t=this;return"[object Array]"!=o.call(e)?t.reject(TypeError("Not an array")):0===e.length?t.resolve([]):new t(function(n,o){if("function"!=typeof n||"function"!=typeof o)throw TypeError("Not a function");var i=e.length,r=Array(i),s=0;p(t,e,function(e,t){r[e]=t,++s===i&&n(r)},o)})}),e(h,"race",function(e){var t=this;return"[object Array]"!=o.call(e)?t.reject(TypeError("Not an array")):new t(function(n,o){if("function"!=typeof n||"function"!=typeof o)throw TypeError("Not a function");p(t,e,function(e,t){n(t)},o)})}),h},(o=t)[n="Promise"]=o[n]||i(),e.exports&&(e.exports=o[n])});var n="0.12.11";let o=function(e){return e.SessionNotFound="SessionNotFound",e.SessionLoaded="SessionLoaded",e.SessionUpdated="SessionUpdated",e.SessionCancel="SessionCancel",e.SessionPaymentOnHold="SessionPaymentOnHold",e.SessionPaymentAuthorized="SessionPaymentAuthorized",e.SessionPaymentError="SessionPaymentError",e.SessionLocked="SessionLocked",e.SessionLockFailed="SessionLockFailed",e.ActivePaymentProductType="ActivePaymentProductType",e.ValidateSession="ValidateSession",e.AddressCallback="AddressCallback",e}({}),i=function(e){return e.HeightChanged="HeightChanged",e.LanguageChanged="LanguageChanged",e.ScrollToTop="ScrollToTop",e.ShowPopOutButton="ShowPopOutButton",e.HidePopOutButton="HidePopOutButton",e.TopLevelNavigation="TopLevelNavigation",e}({});const r=e=>e.endsWith("/")?e:`${e}/`,s=()=>{try{const{hostname:e}=window.location;return e}catch(e){return}},a=()=>{try{if(window.self===window.top)return!0;const e=s(),t=window.top.location.hostname;return t&&e&&e===t}catch(e){return!1}},d=({sid:e,endpoint:t,language:o,shouldCallValidateSession:i})=>{const a=new URLSearchParams;a.append("ui","fullscreen"),a.append("role","pop_out_payment"),a.append("sid",e),a.append("sdk",n),o&&a.append("language",o),i&&a.append("loader","true");const d=s();return d&&a.append("sdk_hostname",d),`${r(t)}?${a.toString()}`},c=e=>{const{sid:t,endpoint:o,language:i,ui:d,shouldCallValidateSession:c,shouldCallAddressCallback:l,popOut:p,redirect:u}=e;if(!o)throw new Error("Invalid endpoint");const f=new URLSearchParams;f.append("sdk",n),d&&f.append("ui",d),i&&f.append("language",i),c&&f.append("client_side_validation","true"),l&&f.append("client_side_address_callback","true"),p&&f.append("role","pop_out_launcher"),e.hasOwnProperty("hideTestMessage")&&void 0!==e.hideTestMessage&&!0===e.hideTestMessage&&f.append("hide_test_message","true");const h=s();return h&&f.append("sdk_hostname",h),u||a()||f.append("sdk_not_top_level","true"),"https://checkout.dintero.com"===o?`${o}/v1/view/${t}?${f.toString()}`:(f.append("sid",t),`${r(o)}?${f.toString()}`)},l=e=>{window.location.assign(e)},p=async e=>{let t,n,o=-1;if(n&&!n.closed)return;const i=d(e);n=await((e,t,n,o)=>new Promise(i=>{try{const r=window.screenX+(window.outerWidth-n)/2,s=window.screenY+(window.outerHeight-o)/2,a=`width=${n},height=${o},left=${r},top=${s},location=no,menubar=no,toolbar=no,status=no`;let d,c=-1;const l=n=>{const o=n.source===d,r=n.origin===new URL(t).origin,s=n.data&&"AppLoaded"===n.data.type,a="popOut"===n.data.context,p=n.data.sid===e;o&&r&&s&&a&&p&&(clearTimeout(c),i(d),window.removeEventListener("message",l))};if(window.addEventListener("message",l),d=window.open(t,"dintero-checkout",a),!d)return console.log("createPopOutWindow no popOut"),void i(void 0);c=window.setTimeout(()=>{console.log("createPopOutWindow timeout"),i(void 0)},1e4)}catch(e){i(void 0)}}))(e.sid,i,Math.min(480,window.screen.width),Math.min(840,window.screen.height));const r=()=>{window.clearInterval(o),o=-1,window.removeEventListener("beforeunload",s),n=void 0,e.onClose(),t&&t()},s=()=>{n&&n.close(),r()};return window.addEventListener("beforeunload",s),o=window.setInterval(()=>{n?.closed&&r()},200),t=e.onOpen(n),{close:s,focus:()=>{n&&n.focus()},popOutWindow:n}},u=(e,t)=>{try{e&&e.postMessage({type:"LockSession",sid:t},"*")}catch(e){console.error(e)}},f=(e,t)=>{try{e&&e.postMessage({type:"RefreshSession",sid:t},"*")}catch(e){console.error(e)}},h=(e,t,n)=>{try{e&&e.postMessage({type:"SetActivePaymentProductType",sid:t,payment_product_type:n},"*")}catch(e){console.error(e)}},m="dintero-checkout-sdk-style",g="dintero-checkout-sdk-backdrop",y="dintero-checkout-sdk-backdrop-description",w="dintero-checkout-sdk-backdrop-focus",b="dintero-checkout-sdk-backdrop-close",v=e=>t=>(t.preventDefault(),t.stopPropagation(),e(),!1),L=()=>{const e=document.createElement("div");return e.setAttribute("id",g),e.setAttribute("role","dialog"),e.style.zIndex=(()=>{const e=document.getElementsByTagName("*"),t=Array.from(e).reduce((e,t)=>{try{const n=document.defaultView.getComputedStyle(t,null).getPropertyValue("z-index"),o=Number.parseInt(n||"0",10);if(!Number.isNaN(o)&&o>e)return o}catch(e){console.error(e)}return e},0);return t<9999?"9999":(t+1).toString()})(),e},C=e=>{const t=document.getElementById(w),n=document.getElementById(b);"Tab"!==e.key&&"Tab"!==e.code||(document.activeElement===t?(n.focus(),e.preventDefault()):(t.focus(),e.preventDefault()))},S=e=>{(()=>{if(document.getElementById(m))return;const e=document.createElement("style");e.setAttribute("id",m),e.innerHTML=`\n @keyframes ${g}-fade-in {\n from {opacity: 0;}\n to {opacity: 1;}\n }\n\n #${g} {\n position: fixed;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n height: 100vh;\n width: 100vw;\n background-color: rgba(0,0,0,0.9);\n background: radial-gradient(rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.8) 100%);\n cursor: pointer;\n animation: 20ms ease-out ${g}-fade-in;\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n gap: 20px;\n color: #ffffff;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';\n font-size: 18px;\n font-weight: 400;\n line-height: normal;\n text-rendering: geometricPrecision;\n margin: 0;\n padding: 0;\n border: 0;\n vertical-align: baseline;\n line-height: normal;\n }\n\n #${g} p {\n padding: 0;\n margin: 0;\n border: 0;\n user-select: none;\n }\n\n #${w} {\n background-color: #efefef !important;\n color: #000000 !important;\n font-size: 16px !important;\n font-weight: 600 !important;\n border-radius: 200px !important;\n margin: 0 !important;\n line-height: normal !important;\n border: none !important;\n padding: 10px 20px !important;\n user-select: none !important;\n cursor: pointer !important;\n }\n #${w}:hover,\n #${w}:focus {\n outline: none !important;\n background-color: #ffffff !important;\n border: none !important;\n color: #000000 !important;\n padding: 10px 20px !important;\n margin: 0 !important;\n }\n #${w}:focus{\n outline-offset: 2px;\n outline: 1px #ffffff solid !important;\n }\n\n #${b} {\n background: transparent !important;\n padding: 0 !important;\n margin: 0 !important;\n border: none !important;\n border-radius: 4px !important;\n height: 24px !important;\n width: 24px !important;\n color: #efefef !important;\n position: absolute !important;\n top: 16px !important;\n right: 24px !important;\n transition: all 200ms ease-out !important;\n cursor: pointer !important;\n }\n\n #${b}:hover,\n #${b}:focus {\n outline: none !important;\n color: #ffffff !important;\n border: none !important;\n background: transparent !important;\n padding: 0 !important;\n margin: 0 !important;\n position: absolute;\n top: 16px;\n right: 24px;\n }\n #${b}:focus{\n outline: 1px #ffffff solid !important;\n }\n\n #${g}:before,\n #${g}:after,\n #${g} > *:before,\n #${g} > *:after {\n content: '';\n content: none;\n }\n `,document.head.appendChild(e)})();const t=L(),n=(e=>{const t=document.createElement("button");return t.setAttribute("id",b),t.setAttribute("type","button"),t.setAttribute("aria-label",e),t.innerHTML='\n <svg\n xmlns="http://www.w3.org/2000/svg"\n width="24"\n height="24"\n viewBox="0 0 24 24"\n fill="none"\n stroke="currentColor"\n stroke-width="2"\n stroke-linecap="round"\n stroke-linejoin="round"\n alt="close icon"\n >\n <line x1="18" y1="6" x2="6" y2="18"></line>\n <line x1="6" y1="6" x2="18" y2="18"></line>\n </svg>',t})(e.event.closeLabel),o=(()=>{const e=document.createElement("div");return e.innerHTML='\n <svg width="120px" height="22px" viewBox="0 0 630 111" version="1.1" >\n <g id="Page-1" stroke="none" strokeWidth="1" fill="none" fillRule="evenodd">\n <g id="Dintero" fill="#ffffff" fillRule="nonzero">\n <path d="M376.23,60.48 L376.23,73.54 L454.13,73.54 C456.31,41.55 435.85,23.71 410.61,23.71 C385.37,23.71 367.09,41.77 367.09,66.79 C367.09,92.03 386.02,110.31 411.91,110.31 C433.02,110.31 448.9,97.25 453.25,82.24 L436.5,82.24 C432.37,89.42 423.88,95.51 411.91,95.51 C395.16,95.51 382.75,83.11 382.75,66.79 C382.75,50.69 394.72,38.5 410.6,38.5 C426.48,38.5 438.45,50.68 438.45,66.79 L444.54,60.48 L376.23,60.48 Z M154.29,17.83 L171.7,17.83 L171.7,0.42 L154.29,0.42 L154.29,17.83 Z M120.34,108.13 L191.27,108.13 L191.27,93.77 L120.34,93.77 L120.34,108.13 Z M156.46,40.24 L156.46,108.13 L171.69,108.13 L171.69,45.47 C171.69,32.85 165.82,25.89 151.89,25.89 L120.34,25.89 L120.34,40.25 L156.46,40.25 L156.46,40.24 Z M499.17,25.88 L464.36,25.88 L464.36,40.24 L483.94,40.24 L484.16,108.13 L499.39,108.13 L499.17,62.44 C499.17,48.51 508.53,40.25 521.58,40.25 L535.29,40.25 L535.29,25.89 L524.41,25.89 C509.18,25.89 501.78,31.33 497.65,41.56 L495.47,47 L499.17,47.65 L499.17,25.88 Z M288.76,25.88 L310.52,25.88 L310.52,6.3 L325.75,6.3 L325.75,25.88 L359.69,25.88 L359.69,40.24 L325.75,40.24 L325.75,93.77 L359.69,93.77 L359.69,108.13 L332.49,108.13 C318.56,108.13 310.51,98.99 310.51,86.37 L310.51,40.24 L288.75,40.24 L288.75,25.88 L288.76,25.88 Z M464.35,108.13 L535.28,108.13 L535.28,93.77 L464.35,93.77 L464.35,108.13 Z M108.6,54.17 C108.6,23.06 85.54,0.43 53.77,0.43 L0.9,0.43 L0.9,108.14 L53.77,108.14 C85.53,108.13 108.6,85.5 108.6,54.17 M248.07,23.71 C234.58,23.71 223.92,31.98 220,41.55 L220,25.88 L204.77,25.88 L204.77,108.13 L220,108.13 L220,66.35 C220,53.08 224.79,38.93 243.72,38.93 C259.39,38.93 267.44,48.07 267.44,67.43 L267.44,108.12 L282.67,108.12 L282.67,64.6 C282.67,35.02 265.91,23.71 248.07,23.71 M586.2,110.31 C611.22,110.31 629.72,92.03 629.72,67.01 C629.72,41.99 611.23,23.71 586.2,23.71 C560.96,23.71 542.68,41.99 542.68,67.01 C542.68,92.03 560.96,110.31 586.2,110.31 M586.2,95.51 C570.32,95.51 558.35,83.33 558.35,67.01 C558.35,50.69 570.32,38.51 586.2,38.51 C602.08,38.51 614.05,50.69 614.05,67.01 C614.05,83.33 602.08,95.51 586.2,95.51 M16.99,92.9 L16.99,15.66 L51.8,15.66 C75.3,15.66 92.05,31.98 92.05,54.61 C92.05,76.8 75.3,92.91 51.8,92.91 L16.99,92.91 L16.99,92.9 Z" id="Shape"></path>\n </g>\n </g>\n </svg>',e})(),i=(e=>{const t=document.createElement("p");return t.setAttribute("id",y),t.innerText=e,t})(e.event.descriptionLabel),r=(e=>{const t=document.createElement("button");return t.setAttribute("id",w),t.setAttribute("type","button"),t.innerText=e,t})(e.event.focusLabel);return t.onclick=v(e.focus),r.onclick=v(e.focus),n.onclick=v(e.close),document.addEventListener("keydown",C),t.appendChild(n),t.appendChild(o),t.appendChild(i),t.appendChild(r),document.body.appendChild(t),t.focus(),t},k=()=>{try{const e=document.getElementById(g);e&&document.body.removeChild(e),document.removeEventListener("keydown",C)}catch(e){console.error(e)}},T="dintero-checkout-sdk-launch-pop-out",x=(e,t)=>{if(!e&&!t)return;const n=`${T}-styles`;if(document.getElementById(n))return;const o=document.createElement("style");o.setAttribute("id",n);const i=[];e&&i.push(P(`#${T}:hover:not(:disabled)`,e)),t&&i.push(P(`#${T}:focus-visible`,t)),o.textContent=i.join("\n"),document.head.appendChild(o)},P=(e,t)=>[`${e} {`,E(t),"}"].join("\n"),E=e=>Object.entries(e).map(([e,t])=>` ${O(e)}: ${t} !important;`).join("\n"),O=e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),A=e=>{const{container:t}=e,n=document.getElementById(T),o=n||document.createElement("button");((e,{label:t,disabled:n,top:o,left:i,right:r,styles:s,onClick:a,stylesHover:d,stylesFocusVisible:c})=>{e.setAttribute("id",T),e.setAttribute("type","button"),"true"===n?e.setAttribute("disabled",n):e.removeAttribute("disabled"),e.onclick=t=>{t.preventDefault(),t.stopPropagation(),e.style.boxShadow="inset 0 0 10px rgba(34, 84, 65, 0.9)",a(),window.setTimeout(()=>{e.style.boxShadow="none"},200)},e.innerText=t,e.style.position="absolute",e.style.top=`${o}px`,e.style.left=`${i}px`,e.style.right=`${r}px`;const{...l}=s;for(const[t,n]of Object.entries(l))e.style[t]=n;try{x(d,c)}catch(e){console.error(e)}})(o,e),n||t.appendChild(o)},$=()=>{try{const e=document.getElementById(T);e&&e.remove()}catch(e){console.error(e)}},W=(e,t,n)=>{e.contentWindow&&e.contentWindow.postMessage({type:"ValidationResult",sid:t,...n},"*")},_=e=>{const{sid:t,endpoint:n,handler:o,eventTypes:i,checkout:r}=e,s=new URL(n),a=e=>{const n=e.origin===s.origin,a=e.source===r.iframe.contentWindow,d=e.data&&e.data.sid===t,c=-1!==i.indexOf(e.data?.type);n&&a&&d&&c&&(((e,t)=>{t.data.mid&&e&&e.postMessage({ack:t.data.mid},t.origin||"*")})(r.iframe.contentWindow,e),o(e.data,r))};window.addEventListener("message",a,!1);return{unsubscribe:()=>{window.removeEventListener("message",a,!1)}}},M=(e,t)=>{z(t),e.href&&l(e.href)},j=(e,t)=>{(e.height||0===e.height)&&t.iframe.setAttribute("style",`width:100%; height:${e.height}px;`)},V=(e,t)=>{try{t.iframe.scrollIntoView({block:"start",behavior:"smooth"})}catch(e){console.error(e)}},N=(e,t)=>{e.language&&(t.language=e.language)},B=e=>{try{e()}catch(e){console.error(e)}},I=async(e,t)=>{const{close:n,focus:r,popOutWindow:s}=await p({sid:t.options.sid,endpoint:t.options.endpoint,shouldCallValidateSession:Boolean(t.options.onValidateSession),shouldCallAddressCallback:!1,language:e.language,onOpen:e=>((e,t)=>{const n={internalPopOutHandler:!0,eventTypes:[i.LanguageChanged],handler:(e,t)=>{var n,o,i;n=t.iframe,o=t.options.sid,i=e.language,n.contentWindow&&n.contentWindow.postMessage({type:"SetLanguage",sid:o,language:i},"*")}},r={internalPopOutHandler:!0,eventTypes:[o.SessionCancel,o.SessionPaymentOnHold,o.SessionPaymentAuthorized,o.SessionPaymentError],handler:(t,n)=>{if(t.href){$();try{e.close()}catch(e){console.error(e)}}else console.error("Payment Complete event missing href property")}},s=o=>{if(o.source===e&&"popOut"===o.data.context&&o.data.sid===t.options.sid)for(const e of[n,r,...t.handlers])e.eventTypes.includes(o.data.type)&&e.handler&&B(()=>{e.handler(o.data,t)})};return window.addEventListener("message",s),()=>{window.removeEventListener("message",s)}})(e,t),onClose:()=>{var e,n;k(),e=t.iframe,n=t.options.sid,e.contentWindow&&e.contentWindow.postMessage({type:"ClosedPopOut",sid:n},"*"),(e=>{try{const t=document.getElementById(T);t&&(e?t.setAttribute("disabled",e.toString()):t.removeAttribute("disabled"))}catch(e){console.error(e)}})(!1),t.popOutWindow=void 0}});return s?(a=t.iframe,d=t.options.sid,a.contentWindow&&a.contentWindow.postMessage({type:"OpenedPopOut",sid:d},"*"),t.popOutWindow=s,(e=>{try{if(document.getElementById(g))return;return S(e)}catch(e){console.error(e)}})({focus:r,close:n,event:e}),!0):(((e,t)=>{e.contentWindow&&e.contentWindow.postMessage({type:"OpenPopOutFailed",sid:t},"*")})(t.iframe,t.options.sid),!1);var a,d},H=async(e,t)=>{if(await I(e,t)&&t.options.onValidateSession){n=t.iframe,i=t.options.sid,n.contentWindow&&n.contentWindow.postMessage({type:"ValidatingPopOut",sid:i},"*");const r=((e,t)=>n=>{W(t.iframe,t.options.sid,n),n.success&&t.popOutWindow?t.popOutWindow.location.href=d({sid:t.options.sid,endpoint:t.options.endpoint,shouldCallValidateSession:!1,shouldCallAddressCallback:!1,language:e.language}):(t.popOutWindow&&t.popOutWindow.close(),console.error(n.clientValidationError))})(e,t);try{t.options.onValidateSession({type:o.ValidateSession,session:t.session,callback:r},t,r)}catch(e){console.error(e),W(t.iframe,t.options.sid,{success:!1,clientValidationError:"Validation runtime error"})}}var n,i},F=(e,t)=>{(e=>e&&e.type===i.ShowPopOutButton)(e)&&(e.session&&(t.session=e.session),A({container:t.options.innerContainer,label:e.openLabel,top:e.top,left:e.left,right:e.right,styles:e.styles,stylesHover:e.stylesHover,stylesFocusVisible:e.stylesFocusVisible,disabled:e.disabled,onClick:()=>H(e,t)}),(e=>{const t=document.getElementById(w);t&&(t.innerText=e.focusLabel);const n=document.getElementById(y);n&&(n.innerText=e.descriptionLabel);const o=document.getElementById(b);o&&o.setAttribute("aria-label",e.descriptionLabel)})(e))},R=(e,t)=>{e.type===i.HidePopOutButton&&$()},z=e=>{if($(),k(),e.popOutWindow)try{e.popOutWindow.close()}catch(e){console.error(e)}};e.embed=async e=>{const t=document.createElement("div");t.style.position="relative",t.style["box-sizing"]="border-box";const r={endpoint:"https://checkout.dintero.com",innerContainer:t,...e},{container:s,sid:a,language:d,endpoint:l,onSession:p,onSessionCancel:m,onPayment:g,onPaymentAuthorized:y,onPaymentError:w,onSessionNotFound:b,onSessionLocked:v,onSessionLockFailed:L,onActivePaymentType:C,onValidateSession:S,onAddressCallback:T,popOut:x}=r;let P;const E=[];let O=!1;s.appendChild(t);const{iframe:A,initiate:$}=((e,t)=>{if(!e||!e.appendChild)throw new Error("Invalid container");const n=document.createElement("iframe");return n.setAttribute("frameborder","0"),n.setAttribute("allowTransparency","true"),n.setAttribute("style","width:100%; height:0;"),n.setAttribute("sandbox","allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox allow-top-navigation"),n.setAttribute("allow","payment; clipboard-write *"),n.setAttribute("importance","high"),n.setAttribute("src",t),{iframe:n,initiate:async()=>new Promise((t,o)=>{n.onload=()=>t(),n.onerror=()=>o(),e.appendChild(n)})}})(t,c({sid:a,endpoint:l,language:d,ui:e.ui||"inline",shouldCallValidateSession:void 0!==S,shouldCallAddressCallback:void 0!==T,popOut:x,...e.hasOwnProperty("hideTestMessage")&&{hideTestMessage:e.hideTestMessage}})),B=(e,t,n)=>{if(!P)throw new Error("Unable to create action promise: checkout is undefined");return new Promise((o,i)=>{const r=[];r.push(_({sid:a,endpoint:l,handler:e=>{for(const e of r)e.unsubscribe();o(e)},eventTypes:[t],checkout:P,source:P.iframe.contentWindow})),r.push(_({sid:a,endpoint:l,handler:()=>{for(const e of r)e.unsubscribe();i(`Received unexpected event: ${n}`)},eventTypes:[n],checkout:P,source:P.iframe.contentWindow})),e()})},I=()=>B(()=>{((e,t)=>{e.contentWindow&&e.contentWindow.postMessage({type:"RefreshSession",sid:t},"*")})(A,a),f(P?.popOutWindow,a)},o.SessionUpdated,o.SessionNotFound),H=e=>{W(A,a,e)},U=e=>{((e,t,n)=>{e.contentWindow&&e.contentWindow.postMessage({type:"AddressCallbackResult",sid:t,...n},"*")})(A,a,e)},Z=(e,t,i)=>(e,r)=>{if(!O){O=!0,z(r);const s=["sid","merchant_reference","transaction_id","error"].map(t=>[t,e[t]]);e.type!==o.SessionCancel||e.error||s.push(["error","cancelled"]),s.push(["language",r.language]),s.push(["sdk",n]);const a=s.filter(([e,t])=>t).map(([e,t])=>`${e}=${t}`).join("&");r.iframe.setAttribute("src",((e,t,n)=>{const o=e.endsWith("/")?"":"/";return`${e}${o}${t}?${n}`})(t,"embedResult/",a)),i(e,r)}},D=[{handler:N,eventTypes:[i.LanguageChanged]},{handler:j,eventTypes:[i.HeightChanged]},{handler:V,eventTypes:[i.ScrollToTop]},{handler:M,eventTypes:[i.TopLevelNavigation]},{handler:(e,t)=>{t.session=e.session,p&&p(e,t)},eventTypes:[o.SessionLoaded,o.SessionUpdated]},{eventTypes:[o.SessionPaymentOnHold],handler:Z(0,l,g||M)},{eventTypes:[o.SessionPaymentAuthorized],handler:Z(0,l,y||g||M)},{handler:Z(0,l,m||M),eventTypes:[o.SessionCancel]},{handler:Z(0,l,w||M),eventTypes:[o.SessionPaymentError]},{handler:b,eventTypes:[o.SessionNotFound]},{handler:(e,t)=>{v&&v(e,t,I)},eventTypes:[o.SessionLocked]},{handler:L,eventTypes:[o.SessionLockFailed]},{handler:C,eventTypes:[o.ActivePaymentProductType]},{handler:(e,t)=>{if(S)try{S({...e,callback:H},t,H)}catch(e){console.error(e),H({success:!1,clientValidationError:"Validation runtime error"})}},eventTypes:[o.ValidateSession]},{handler:(e,t)=>{if(T)try{T({...e,callback:U},t,U)}catch(e){console.error(e),U({success:!1,error:"Address callback runtime error"})}},eventTypes:[o.AddressCallback]},{handler:F,eventTypes:[i.ShowPopOutButton]},{handler:R,eventTypes:[i.HidePopOutButton]}];P={destroy:()=>{if(z(P),A){r.popOut&&k();for(const e of E)e.unsubscribe();A.parentElement&&t.removeChild(A)}t.parentElement&&s.removeChild(t)},iframe:A,language:d,lockSession:()=>B(()=>{((e,t)=>{e.contentWindow&&e.contentWindow.postMessage({type:"LockSession",sid:t},"*")})(A,a),u(P?.popOutWindow,a)},o.SessionLocked,o.SessionLockFailed),refreshSession:I,setActivePaymentProductType:t=>{e.popOut?h(P?.popOutWindow,a,t):((e,t,n)=>{e.contentWindow&&e.contentWindow.postMessage({type:"SetActivePaymentProductType",sid:t,payment_product_type:n},"*")})(A,a,t)},submitValidationResult:H,submitAddressCallbackResult:U,options:r,handlers:D,session:void 0,popOutWindow:void 0};for(const{handler:e,eventTypes:t}of D)e&&E.push(_({sid:a,endpoint:l,handler:e,eventTypes:t,checkout:P,source:P.iframe.contentWindow}));return await $(),P},e.redirect=e=>{const{sid:t,language:n,endpoint:o="https://checkout.dintero.com"}=e;l(c({sid:t,endpoint:o,language:n,shouldCallValidateSession:!1,shouldCallAddressCallback:!1,redirect:!0}))},Object.defineProperty(e,"__esModule",{value:!0})});
|
|
6
|
+
var n,o,i;i=function(){var e,t,n,o=Object.prototype.toString,i="undefined"!=typeof setImmediate?function(e){return setImmediate(e)}:setTimeout;try{Object.defineProperty({},"x",{}),e=function(e,t,n,o){return Object.defineProperty(e,t,{value:n,writable:!0,configurable:!1!==o})}}catch(t){e=function(e,t,n){return e[t]=n,e}}function r(e,o){n.add(e,o),t||(t=i(n.drain))}function s(e){var t,n=typeof e;return null==e||"object"!=n&&"function"!=n||(t=e.then),"function"==typeof t&&t}function a(){for(var e=0;e<this.chain.length;e++)d(this,1===this.state?this.chain[e].success:this.chain[e].failure,this.chain[e]);this.chain.length=0}function d(e,t,n){var o,i;try{!1===t?n.reject(e.msg):(o=!0===t?e.msg:t.call(void 0,e.msg))===n.promise?n.reject(TypeError("Promise-chain cycle")):(i=s(o))?i.call(o,n.resolve,n.reject):n.resolve(o)}catch(e){n.reject(e)}}function c(e){var t,n=this;if(!n.triggered){n.triggered=!0,n.def&&(n=n.def);try{(t=s(e))?r(function(){var o=new u(n);try{t.call(e,function(){c.apply(o,arguments)},function(){l.apply(o,arguments)})}catch(e){l.call(o,e)}}):(n.msg=e,n.state=1,n.chain.length>0&&r(a,n))}catch(e){l.call(new u(n),e)}}}function l(e){var t=this;t.triggered||(t.triggered=!0,t.def&&(t=t.def),t.msg=e,t.state=2,t.chain.length>0&&r(a,t))}function p(e,t,n,o){for(var i=0;i<t.length;i++)(function(i){e.resolve(t[i]).then(function(e){n(i,e)},o)})(i)}function u(e){this.def=e,this.triggered=!1}function f(e){this.promise=e,this.state=0,this.triggered=!1,this.chain=[],this.msg=void 0}function h(e){if("function"!=typeof e)throw TypeError("Not a function");if(0!==this.__NPO__)throw TypeError("Not a promise");this.__NPO__=1;var t=new f(this);this.then=function(e,n){var o={success:"function"!=typeof e||e,failure:"function"==typeof n&&n};return o.promise=new this.constructor(function(e,t){if("function"!=typeof e||"function"!=typeof t)throw TypeError("Not a function");o.resolve=e,o.reject=t}),t.chain.push(o),0!==t.state&&r(a,t),o.promise},this.catch=function(e){return this.then(void 0,e)};try{e.call(void 0,function(e){c.call(t,e)},function(e){l.call(t,e)})}catch(e){l.call(t,e)}}n=function(){var e,n,o;function i(e,t){this.fn=e,this.self=t,this.next=void 0}return{add:function(t,r){o=new i(t,r),n?n.next=o:e=o,n=o,o=void 0},drain:function(){var o=e;for(e=n=t=void 0;o;)o.fn.call(o.self),o=o.next}}}();var m=e({},"constructor",h,!1);return h.prototype=m,e(m,"__NPO__",0,!1),e(h,"resolve",function(e){return e&&"object"==typeof e&&1===e.__NPO__?e:new this(function(t,n){if("function"!=typeof t||"function"!=typeof n)throw TypeError("Not a function");t(e)})}),e(h,"reject",function(e){return new this(function(t,n){if("function"!=typeof t||"function"!=typeof n)throw TypeError("Not a function");n(e)})}),e(h,"all",function(e){var t=this;return"[object Array]"!=o.call(e)?t.reject(TypeError("Not an array")):0===e.length?t.resolve([]):new t(function(n,o){if("function"!=typeof n||"function"!=typeof o)throw TypeError("Not a function");var i=e.length,r=Array(i),s=0;p(t,e,function(e,t){r[e]=t,++s===i&&n(r)},o)})}),e(h,"race",function(e){var t=this;return"[object Array]"!=o.call(e)?t.reject(TypeError("Not an array")):new t(function(n,o){if("function"!=typeof n||"function"!=typeof o)throw TypeError("Not a function");p(t,e,function(e,t){n(t)},o)})}),h},(o=t)[n="Promise"]=o[n]||i(),e.exports&&(e.exports=o[n])});var n="0.12.13";let o=function(e){return e.SessionNotFound="SessionNotFound",e.SessionLoaded="SessionLoaded",e.SessionUpdated="SessionUpdated",e.SessionCancel="SessionCancel",e.SessionPaymentOnHold="SessionPaymentOnHold",e.SessionPaymentAuthorized="SessionPaymentAuthorized",e.SessionPaymentError="SessionPaymentError",e.SessionLocked="SessionLocked",e.SessionLockFailed="SessionLockFailed",e.ActivePaymentProductType="ActivePaymentProductType",e.ValidateSession="ValidateSession",e.AddressCallback="AddressCallback",e}({}),i=function(e){return e.HeightChanged="HeightChanged",e.LanguageChanged="LanguageChanged",e.ScrollToTop="ScrollToTop",e.ShowPopOutButton="ShowPopOutButton",e.HidePopOutButton="HidePopOutButton",e.TopLevelNavigation="TopLevelNavigation",e}({});const r=e=>e.endsWith("/")?e:`${e}/`,s=()=>{try{const{hostname:e}=window.location;return e}catch(e){return}},a=()=>{try{if(window.self===window.top)return!0;const e=s(),t=window.top?.location.hostname;return Boolean(t&&e&&e===t)}catch(e){return!1}},d=({sid:e,endpoint:t,language:o,shouldCallValidateSession:i})=>{const a=new URLSearchParams;a.append("ui","fullscreen"),a.append("role","pop_out_payment"),a.append("sid",e),a.append("sdk",n),o&&a.append("language",o),i&&a.append("loader","true");const d=s();return d&&a.append("sdk_hostname",d),`${r(t)}?${a.toString()}`},c=e=>{const{sid:t,endpoint:o,language:i,ui:d,shouldCallValidateSession:c,shouldCallAddressCallback:l,popOut:p,redirect:u}=e;if(!o)throw new Error("Invalid endpoint");const f=new URLSearchParams;f.append("sdk",n),d&&f.append("ui",d),i&&f.append("language",i),c&&f.append("client_side_validation","true"),l&&f.append("client_side_address_callback","true"),p&&f.append("role","pop_out_launcher"),e.hasOwnProperty("hideTestMessage")&&void 0!==e.hideTestMessage&&!0===e.hideTestMessage&&f.append("hide_test_message","true");const h=s();return h&&f.append("sdk_hostname",h),u||a()||f.append("sdk_not_top_level","true"),"https://checkout.dintero.com"===o?`${o}/v1/view/${t}?${f.toString()}`:(f.append("sid",t),`${r(o)}?${f.toString()}`)},l=e=>{window.location.assign(e)},p=async e=>{let t,n,o=-1;if(n&&!n.closed)return{close:()=>{},focus:()=>{},popOutWindow:void 0};const i=d(e);n=await((e,t,n,o)=>new Promise(i=>{try{const r=window.screenX+(window.outerWidth-n)/2,s=window.screenY+(window.outerHeight-o)/2,a=`width=${n},height=${o},left=${r},top=${s},location=no,menubar=no,toolbar=no,status=no`;let d,c=-1;const l=n=>{const o=n.source===d,r=n.origin===new URL(t).origin,s=n.data&&"AppLoaded"===n.data.type,a="popOut"===n.data.context,p=n.data.sid===e;o&&r&&s&&a&&p&&(clearTimeout(c),i(d),window.removeEventListener("message",l))};if(window.addEventListener("message",l),d=window.open(t,"dintero-checkout",a)??void 0,!d)return console.log("createPopOutWindow no popOut"),void i(void 0);c=window.setTimeout(()=>{console.log("createPopOutWindow timeout"),i(void 0)},1e4)}catch(e){i(void 0)}}))(e.sid,i,Math.min(480,window.screen.width),Math.min(840,window.screen.height));const r=()=>{window.clearInterval(o),o=-1,window.removeEventListener("beforeunload",s),n=void 0,e.onClose(),t&&t()},s=()=>{n&&n.close(),r()};return window.addEventListener("beforeunload",s),o=window.setInterval(()=>{n?.closed&&r()},200),n&&(t=e.onOpen(n)),{close:s,focus:()=>{n&&n.focus()},popOutWindow:n}},u=(e,t)=>{try{e&&e.postMessage({type:"LockSession",sid:t},"*")}catch(e){console.error(e)}},f=(e,t)=>{try{e&&e.postMessage({type:"RefreshSession",sid:t},"*")}catch(e){console.error(e)}},h=(e,t,n)=>{try{e&&e.postMessage({type:"SetActivePaymentProductType",sid:t,payment_product_type:n},"*")}catch(e){console.error(e)}},m="dintero-checkout-sdk-style",g="dintero-checkout-sdk-backdrop",y="dintero-checkout-sdk-backdrop-description",w="dintero-checkout-sdk-backdrop-focus",b="dintero-checkout-sdk-backdrop-close",v=e=>t=>(t.preventDefault(),t.stopPropagation(),e(),!1),L=()=>{const e=document.createElement("div");return e.setAttribute("id",g),e.setAttribute("role","dialog"),e.style.zIndex=(()=>{const e=document.getElementsByTagName("*"),t=Array.from(e).reduce((e,t)=>{try{const n=document.defaultView?.getComputedStyle(t,null).getPropertyValue("z-index"),o=Number.parseInt(n||"0",10);if(!Number.isNaN(o)&&o>e)return o}catch(e){console.error(e)}return e},0);return t<9999?"9999":(t+1).toString()})(),e},C=e=>{const t=document.getElementById(w),n=document.getElementById(b);"Tab"!==e.key&&"Tab"!==e.code||(document.activeElement===t?(n?.focus(),e.preventDefault()):(t?.focus(),e.preventDefault()))},S=e=>{(()=>{if(document.getElementById(m))return;const e=document.createElement("style");e.setAttribute("id",m),e.innerHTML=`\n @keyframes ${g}-fade-in {\n from {opacity: 0;}\n to {opacity: 1;}\n }\n\n #${g} {\n position: fixed;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n height: 100vh;\n width: 100vw;\n background-color: rgba(0,0,0,0.9);\n background: radial-gradient(rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.8) 100%);\n cursor: pointer;\n animation: 20ms ease-out ${g}-fade-in;\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n gap: 20px;\n color: #ffffff;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';\n font-size: 18px;\n font-weight: 400;\n line-height: normal;\n text-rendering: geometricPrecision;\n margin: 0;\n padding: 0;\n border: 0;\n vertical-align: baseline;\n line-height: normal;\n }\n\n #${g} p {\n padding: 0;\n margin: 0;\n border: 0;\n user-select: none;\n }\n\n #${w} {\n background-color: #efefef !important;\n color: #000000 !important;\n font-size: 16px !important;\n font-weight: 600 !important;\n border-radius: 200px !important;\n margin: 0 !important;\n line-height: normal !important;\n border: none !important;\n padding: 10px 20px !important;\n user-select: none !important;\n cursor: pointer !important;\n }\n #${w}:hover,\n #${w}:focus {\n outline: none !important;\n background-color: #ffffff !important;\n border: none !important;\n color: #000000 !important;\n padding: 10px 20px !important;\n margin: 0 !important;\n }\n #${w}:focus{\n outline-offset: 2px;\n outline: 1px #ffffff solid !important;\n }\n\n #${b} {\n background: transparent !important;\n padding: 0 !important;\n margin: 0 !important;\n border: none !important;\n border-radius: 4px !important;\n height: 24px !important;\n width: 24px !important;\n color: #efefef !important;\n position: absolute !important;\n top: 16px !important;\n right: 24px !important;\n transition: all 200ms ease-out !important;\n cursor: pointer !important;\n }\n\n #${b}:hover,\n #${b}:focus {\n outline: none !important;\n color: #ffffff !important;\n border: none !important;\n background: transparent !important;\n padding: 0 !important;\n margin: 0 !important;\n position: absolute;\n top: 16px;\n right: 24px;\n }\n #${b}:focus{\n outline: 1px #ffffff solid !important;\n }\n\n #${g}:before,\n #${g}:after,\n #${g} > *:before,\n #${g} > *:after {\n content: '';\n content: none;\n }\n `,document.head.appendChild(e)})();const t=L(),n=(e=>{const t=document.createElement("button");return t.setAttribute("id",b),t.setAttribute("type","button"),t.setAttribute("aria-label",e),t.innerHTML='\n <svg\n xmlns="http://www.w3.org/2000/svg"\n width="24"\n height="24"\n viewBox="0 0 24 24"\n fill="none"\n stroke="currentColor"\n stroke-width="2"\n stroke-linecap="round"\n stroke-linejoin="round"\n alt="close icon"\n >\n <line x1="18" y1="6" x2="6" y2="18"></line>\n <line x1="6" y1="6" x2="18" y2="18"></line>\n </svg>',t})(e.event.closeLabel),o=(()=>{const e=document.createElement("div");return e.innerHTML='\n <svg width="120px" height="22px" viewBox="0 0 630 111" version="1.1" >\n <g id="Page-1" stroke="none" strokeWidth="1" fill="none" fillRule="evenodd">\n <g id="Dintero" fill="#ffffff" fillRule="nonzero">\n <path d="M376.23,60.48 L376.23,73.54 L454.13,73.54 C456.31,41.55 435.85,23.71 410.61,23.71 C385.37,23.71 367.09,41.77 367.09,66.79 C367.09,92.03 386.02,110.31 411.91,110.31 C433.02,110.31 448.9,97.25 453.25,82.24 L436.5,82.24 C432.37,89.42 423.88,95.51 411.91,95.51 C395.16,95.51 382.75,83.11 382.75,66.79 C382.75,50.69 394.72,38.5 410.6,38.5 C426.48,38.5 438.45,50.68 438.45,66.79 L444.54,60.48 L376.23,60.48 Z M154.29,17.83 L171.7,17.83 L171.7,0.42 L154.29,0.42 L154.29,17.83 Z M120.34,108.13 L191.27,108.13 L191.27,93.77 L120.34,93.77 L120.34,108.13 Z M156.46,40.24 L156.46,108.13 L171.69,108.13 L171.69,45.47 C171.69,32.85 165.82,25.89 151.89,25.89 L120.34,25.89 L120.34,40.25 L156.46,40.25 L156.46,40.24 Z M499.17,25.88 L464.36,25.88 L464.36,40.24 L483.94,40.24 L484.16,108.13 L499.39,108.13 L499.17,62.44 C499.17,48.51 508.53,40.25 521.58,40.25 L535.29,40.25 L535.29,25.89 L524.41,25.89 C509.18,25.89 501.78,31.33 497.65,41.56 L495.47,47 L499.17,47.65 L499.17,25.88 Z M288.76,25.88 L310.52,25.88 L310.52,6.3 L325.75,6.3 L325.75,25.88 L359.69,25.88 L359.69,40.24 L325.75,40.24 L325.75,93.77 L359.69,93.77 L359.69,108.13 L332.49,108.13 C318.56,108.13 310.51,98.99 310.51,86.37 L310.51,40.24 L288.75,40.24 L288.75,25.88 L288.76,25.88 Z M464.35,108.13 L535.28,108.13 L535.28,93.77 L464.35,93.77 L464.35,108.13 Z M108.6,54.17 C108.6,23.06 85.54,0.43 53.77,0.43 L0.9,0.43 L0.9,108.14 L53.77,108.14 C85.53,108.13 108.6,85.5 108.6,54.17 M248.07,23.71 C234.58,23.71 223.92,31.98 220,41.55 L220,25.88 L204.77,25.88 L204.77,108.13 L220,108.13 L220,66.35 C220,53.08 224.79,38.93 243.72,38.93 C259.39,38.93 267.44,48.07 267.44,67.43 L267.44,108.12 L282.67,108.12 L282.67,64.6 C282.67,35.02 265.91,23.71 248.07,23.71 M586.2,110.31 C611.22,110.31 629.72,92.03 629.72,67.01 C629.72,41.99 611.23,23.71 586.2,23.71 C560.96,23.71 542.68,41.99 542.68,67.01 C542.68,92.03 560.96,110.31 586.2,110.31 M586.2,95.51 C570.32,95.51 558.35,83.33 558.35,67.01 C558.35,50.69 570.32,38.51 586.2,38.51 C602.08,38.51 614.05,50.69 614.05,67.01 C614.05,83.33 602.08,95.51 586.2,95.51 M16.99,92.9 L16.99,15.66 L51.8,15.66 C75.3,15.66 92.05,31.98 92.05,54.61 C92.05,76.8 75.3,92.91 51.8,92.91 L16.99,92.91 L16.99,92.9 Z" id="Shape"></path>\n </g>\n </g>\n </svg>',e})(),i=(e=>{const t=document.createElement("p");return t.setAttribute("id",y),t.innerText=e,t})(e.event.descriptionLabel),r=(e=>{const t=document.createElement("button");return t.setAttribute("id",w),t.setAttribute("type","button"),t.innerText=e,t})(e.event.focusLabel);return t.onclick=v(e.focus),r.onclick=v(e.focus),n.onclick=v(e.close),document.addEventListener("keydown",C),t.appendChild(n),t.appendChild(o),t.appendChild(i),t.appendChild(r),document.body.appendChild(t),t.focus(),t},k=()=>{try{const e=document.getElementById(g);e&&document.body.removeChild(e),document.removeEventListener("keydown",C)}catch(e){console.error(e)}},T="dintero-checkout-sdk-launch-pop-out",x=(e,t)=>{if(!e&&!t)return;const n=`${T}-styles`;if(document.getElementById(n))return;const o=document.createElement("style");o.setAttribute("id",n);const i=[];e&&i.push(P(`#${T}:hover:not(:disabled)`,e)),t&&i.push(P(`#${T}:focus-visible`,t)),o.textContent=i.join("\n"),document.head.appendChild(o)},P=(e,t)=>[`${e} {`,E(t),"}"].join("\n"),E=e=>Object.entries(e).map(([e,t])=>` ${O(e)}: ${t} !important;`).join("\n"),O=e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),A=e=>{const{container:t}=e,n=document.getElementById(T),o=n||document.createElement("button");((e,{label:t,disabled:n,top:o,left:i,right:r,styles:s,onClick:a,stylesHover:d,stylesFocusVisible:c})=>{e.setAttribute("id",T),e.setAttribute("type","button"),"true"===n?e.setAttribute("disabled",n):e.removeAttribute("disabled"),e.onclick=t=>{t.preventDefault(),t.stopPropagation(),e.style.boxShadow="inset 0 0 10px rgba(34, 84, 65, 0.9)",a(),window.setTimeout(()=>{e.style.boxShadow="none"},200)},e.innerText=t,e.style.position="absolute",e.style.top=`${o}px`,e.style.left=`${i}px`,e.style.right=`${r}px`;const{...l}=s;for(const[t,n]of Object.entries(l))e.style[t]=n;try{x(d,c)}catch(e){console.error(e)}})(o,e),n||t.appendChild(o)},$=()=>{try{const e=document.getElementById(T);e&&e.remove()}catch(e){console.error(e)}},W=(e,t,n)=>{e.contentWindow&&e.contentWindow.postMessage({type:"ValidationResult",sid:t,...n},"*")},_=e=>{const{sid:t,endpoint:n,handler:o,eventTypes:i,checkout:r}=e,s=new URL(n),a=e=>{const n=e.origin===s.origin,a=e.source===r.iframe.contentWindow,d=e.data&&e.data.sid===t,c=-1!==i.indexOf(e.data?.type);n&&a&&d&&c&&(((e,t)=>{t.data.mid&&e&&e.postMessage({ack:t.data.mid},t.origin||"*")})(r.iframe.contentWindow,e),o(e.data,r))};window.addEventListener("message",a,!1);return{unsubscribe:()=>{window.removeEventListener("message",a,!1)}}},M=(e,t)=>{z(t),e.href&&l(e.href)},j=(e,t)=>{(e.height||0===e.height)&&t.iframe.setAttribute("style",`width:100%; height:${e.height}px;`)},V=(e,t)=>{try{t.iframe.scrollIntoView({block:"start",behavior:"smooth"})}catch(e){console.error(e)}},B=(e,t)=>{e.language&&(t.language=e.language)},N=e=>{try{e()}catch(e){console.error(e)}},I=async(e,t)=>{const n=await p({sid:t.options.sid,endpoint:t.options.endpoint??"https://checkout.dintero.com",shouldCallValidateSession:Boolean(t.options.onValidateSession),shouldCallAddressCallback:!1,language:e.language,onOpen:e=>((e,t)=>{const n={internalPopOutHandler:!0,eventTypes:[i.LanguageChanged],handler:(e,t)=>{var n,o,i;n=t.iframe,o=t.options.sid,i=e.language,n.contentWindow&&n.contentWindow.postMessage({type:"SetLanguage",sid:o,language:i},"*")}},r={internalPopOutHandler:!0,eventTypes:[o.SessionCancel,o.SessionPaymentOnHold,o.SessionPaymentAuthorized,o.SessionPaymentError],handler:(t,n)=>{if(t.href){$();try{e.close()}catch(e){console.error(e)}}else console.error("Payment Complete event missing href property")}},s=o=>{if(o.source===e&&"popOut"===o.data.context&&o.data.sid===t.options.sid)for(const e of[n,r,...t.handlers])if(e.eventTypes.includes(o.data.type)&&e.handler){const{handler:n}=e;N(()=>{n(o.data,t)})}};return window.addEventListener("message",s),()=>{window.removeEventListener("message",s)}})(e,t),onClose:()=>{var e,n;k(),e=t.iframe,n=t.options.sid,e.contentWindow&&e.contentWindow.postMessage({type:"ClosedPopOut",sid:n},"*"),(e=>{try{const t=document.getElementById(T);t&&(e?t.setAttribute("disabled",e.toString()):t.removeAttribute("disabled"))}catch(e){console.error(e)}})(!1),t.popOutWindow=void 0}}),{close:r,focus:s,popOutWindow:a}=n;return a?(d=t.iframe,c=t.options.sid,d.contentWindow&&d.contentWindow.postMessage({type:"OpenedPopOut",sid:c},"*"),t.popOutWindow=a,(e=>{try{if(document.getElementById(g))return;return S(e)}catch(e){console.error(e)}})({focus:s,close:r,event:e}),!0):(((e,t)=>{e.contentWindow&&e.contentWindow.postMessage({type:"OpenPopOutFailed",sid:t},"*")})(t.iframe,t.options.sid),!1);var d,c},H=async(e,t)=>{if(await I(e,t)&&t.options.onValidateSession){n=t.iframe,i=t.options.sid,n.contentWindow&&n.contentWindow.postMessage({type:"ValidatingPopOut",sid:i},"*");const r=((e,t)=>n=>{W(t.iframe,t.options.sid,n),n.success&&t.popOutWindow?t.popOutWindow.location.href=d({sid:t.options.sid,endpoint:t.options.endpoint??"https://checkout.dintero.com",shouldCallValidateSession:!1,shouldCallAddressCallback:!1,language:e.language}):(t.popOutWindow&&t.popOutWindow.close(),console.error(n.clientValidationError))})(e,t);try{t.options.onValidateSession({type:o.ValidateSession,session:t.session,callback:r},t,r)}catch(e){console.error(e),W(t.iframe,t.options.sid,{success:!1,clientValidationError:"Validation runtime error"})}}var n,i},F=(e,t)=>{(e=>"object"==typeof e&&null!==e&&e.type===i.ShowPopOutButton)(e)&&(e.session&&(t.session=e.session),A({container:t.options.innerContainer,label:e.openLabel,top:e.top,left:e.left,right:e.right,styles:e.styles,stylesHover:e.stylesHover,stylesFocusVisible:e.stylesFocusVisible,disabled:e.disabled,onClick:()=>H(e,t)}),(e=>{const t=document.getElementById(w);t&&(t.innerText=e.focusLabel);const n=document.getElementById(y);n&&(n.innerText=e.descriptionLabel);const o=document.getElementById(b);o&&o.setAttribute("aria-label",e.descriptionLabel)})(e))},R=(e,t)=>{e.type===i.HidePopOutButton&&$()},z=e=>{if($(),k(),e.popOutWindow)try{e.popOutWindow.close()}catch(e){console.error(e)}};e.embed=async e=>{const t=document.createElement("div");t.style.position="relative",t.style.boxSizing="border-box";const r={endpoint:"https://checkout.dintero.com",innerContainer:t,...e},{container:s,sid:a,language:d,endpoint:l,onSession:p,onSessionCancel:m,onPayment:g,onPaymentAuthorized:y,onPaymentError:w,onSessionNotFound:b,onSessionLocked:v,onSessionLockFailed:L,onActivePaymentType:C,onValidateSession:S,onAddressCallback:T,popOut:x}=r;let P;const E=[];let O=!1;s.appendChild(t);const{iframe:A,initiate:$}=((e,t)=>{if(!e?.appendChild)throw new Error("Invalid container");const n=document.createElement("iframe");return n.setAttribute("frameborder","0"),n.setAttribute("allowTransparency","true"),n.setAttribute("style","width:100%; height:0;"),n.setAttribute("sandbox","allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox allow-top-navigation"),n.setAttribute("allow","payment; clipboard-write *"),n.setAttribute("importance","high"),n.setAttribute("src",t),{iframe:n,initiate:async()=>new Promise((t,o)=>{n.onload=()=>t(),n.onerror=()=>o(),e.appendChild(n)})}})(t,c({sid:a,endpoint:l,language:d,ui:e.ui||"inline",shouldCallValidateSession:void 0!==S,shouldCallAddressCallback:void 0!==T,popOut:x,...e.hasOwnProperty("hideTestMessage")&&{hideTestMessage:e.hideTestMessage}})),N=(e,t,n)=>{if(!P)throw new Error("Unable to create action promise: checkout is undefined");const o=P;return new Promise((i,r)=>{const s=[];s.push(_({sid:a,endpoint:l,handler:e=>{for(const e of s)e.unsubscribe();i(e)},eventTypes:[t],checkout:o,source:o.iframe.contentWindow})),s.push(_({sid:a,endpoint:l,handler:()=>{for(const e of s)e.unsubscribe();r(`Received unexpected event: ${n}`)},eventTypes:[n],checkout:o,source:o.iframe.contentWindow})),e()})},I=()=>N(()=>{((e,t)=>{e.contentWindow&&e.contentWindow.postMessage({type:"RefreshSession",sid:t},"*")})(A,a),f(P?.popOutWindow,a)},o.SessionUpdated,o.SessionNotFound),H=e=>{W(A,a,e)},U=e=>{((e,t,n)=>{e.contentWindow&&e.contentWindow.postMessage({type:"AddressCallbackResult",sid:t,...n},"*")})(A,a,e)},Z=(e,t,i)=>(e,r)=>{if(!O){O=!0,z(r);const s=["sid","merchant_reference","transaction_id","error"].map(t=>[t,e[t]]);e.type!==o.SessionCancel||e.error||s.push(["error","cancelled"]),s.push(["language",r.language]),s.push(["sdk",n]);const a=s.filter(([e,t])=>t).map(([e,t])=>`${e}=${t}`).join("&");r.iframe.setAttribute("src",((e,t,n)=>{const o=e.endsWith("/")?"":"/";return`${e}${o}${t}?${n}`})(t,"embedResult/",a)),i(e,r)}},D=[{handler:B,eventTypes:[i.LanguageChanged]},{handler:j,eventTypes:[i.HeightChanged]},{handler:V,eventTypes:[i.ScrollToTop]},{handler:M,eventTypes:[i.TopLevelNavigation]},{handler:(e,t)=>{t.session=e.session,p&&p(e,t)},eventTypes:[o.SessionLoaded,o.SessionUpdated]},{eventTypes:[o.SessionPaymentOnHold],handler:Z(0,l,g??M)},{eventTypes:[o.SessionPaymentAuthorized],handler:Z(0,l,y??g??M)},{handler:Z(0,l,m??M),eventTypes:[o.SessionCancel]},{handler:Z(0,l,w??M),eventTypes:[o.SessionPaymentError]},{handler:b,eventTypes:[o.SessionNotFound]},{handler:(e,t)=>{v&&v(e,t,I)},eventTypes:[o.SessionLocked]},{handler:L,eventTypes:[o.SessionLockFailed]},{handler:C,eventTypes:[o.ActivePaymentProductType]},{handler:(e,t)=>{if(S)try{S({...e,callback:H},t,H)}catch(e){console.error(e),H({success:!1,clientValidationError:"Validation runtime error"})}},eventTypes:[o.ValidateSession]},{handler:(e,t)=>{if(T)try{T({...e,callback:U},t,U)}catch(e){console.error(e),U({success:!1,error:"Address callback runtime error"})}},eventTypes:[o.AddressCallback]},{handler:F,eventTypes:[i.ShowPopOutButton]},{handler:R,eventTypes:[i.HidePopOutButton]}];P={destroy:()=>{if(P&&z(P),A){r.popOut&&k();for(const e of E)e.unsubscribe();A.parentElement&&t.removeChild(A)}t.parentElement&&s.removeChild(t)},iframe:A,language:d??"",lockSession:()=>N(()=>{((e,t)=>{e.contentWindow&&e.contentWindow.postMessage({type:"LockSession",sid:t},"*")})(A,a),u(P?.popOutWindow,a)},o.SessionLocked,o.SessionLockFailed),refreshSession:I,setActivePaymentProductType:t=>{e.popOut?h(P?.popOutWindow,a,t):((e,t,n)=>{e.contentWindow&&e.contentWindow.postMessage({type:"SetActivePaymentProductType",sid:t,payment_product_type:n},"*")})(A,a,t)},submitValidationResult:H,submitAddressCallbackResult:U,options:r,handlers:D,session:void 0,popOutWindow:void 0};const q=P;for(const{handler:e,eventTypes:t}of D)e&&E.push(_({sid:a,endpoint:l,handler:e,eventTypes:t,checkout:q,source:q.iframe.contentWindow}));return await $(),q},e.redirect=e=>{const{sid:t,language:n,endpoint:o="https://checkout.dintero.com"}=e;l(c({sid:t,endpoint:o,language:n,shouldCallValidateSession:!1,shouldCallAddressCallback:!1,redirect:!0}))},Object.defineProperty(e,"__esModule",{value:!0})});
|
|
7
7
|
//# sourceMappingURL=dintero-checkout-web-sdk.umd.min.js.map
|