Socket
Socket
Sign inDemoInstall

@dintero/checkout-web-sdk

Package Overview
Dependencies
Maintainers
4
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dintero/checkout-web-sdk - npm Package Compare versions

Comparing version 0.6.1 to 0.6.2

.prettierrc.yml

16

.releaserc.json
{
"branches": [
"master"
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/github",
"@semantic-release/npm"
]
"branches": ["master"],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/github",
"@semantic-release/npm"
]
}
## [0.6.0]
### Changed
- Changes iframe to also have `allow="payment"` property to support Apple Pay when embedded
- Changes iframe to also have `allow="payment"` property to support Apple Pay when embedded

@@ -10,4 +11,4 @@ ## [0.4.0]

- Changes `lockSession` to return a promise that resolves when the following `SessionLocked` event is returned from the checkout.
- Changes `refreshSession` to return a promise that resolves when the following `SessionUpdated` event is returned from the checkout.
- Changes `lockSession` to return a promise that resolves when the following `SessionLocked` event is returned from the checkout.
- Changes `refreshSession` to return a promise that resolves when the following `SessionUpdated` event is returned from the checkout.

@@ -17,4 +18,5 @@ ## [0.3.1]

### Bug Fixes
* Add correct package version to url
- Add correct package version to url
## [0.3.0]

@@ -24,3 +26,3 @@

* **lock:** Add callback function to `onSessionLocked`
- **lock:** Add callback function to `onSessionLocked`

@@ -31,3 +33,3 @@ ## [0.2.0]

* Handling of session validation when embedded
- Handling of session validation when embedded

@@ -38,4 +40,4 @@ ## [0.0.17]

- Adds `onActivePaymentProductType` callback.
- Adds `setActivePaymentProductType` function.
- Adds `onActivePaymentProductType` callback.
- Adds `setActivePaymentProductType` function.

@@ -52,3 +54,3 @@ ## [0.0.16]

- Added `lockSession` and `refreshSession` functions
- Added `lockSession` and `refreshSession` functions

@@ -55,0 +57,0 @@ ## [0.0.14]

@@ -55,3 +55,3 @@ import type { Session } from "./session.js";

export type ShowPopOutButton = {
type: 'ShowPopOutButton';
type: "ShowPopOutButton";
styles: {

@@ -79,3 +79,3 @@ font: string;

language: string;
disabled: 'true' | 'false';
disabled: "true" | "false";
};

@@ -82,0 +82,0 @@ export type SessionLockFailed = {

@@ -9,3 +9,3 @@ 'use strict';

name: "@dintero/checkout-web-sdk",
version: "0.6.1",
version: "0.6.2",
description: "Dintero Checkout SDK for web frontends",

@@ -21,4 +21,6 @@ main: "dist/dintero-checkout-web-sdk.cjs.js",

scripts: {
postinstall: "patch -u node_modules/vitest/dist/vendor-node.a7c48fe1.js -i patches/vitest+0.34.6.patch --forward || true",
build: "preconstruct build",
test: "$(yarn bin)/karma start",
lint: "prettier --cache --log-level warn -c --config .prettierrc.yml .",
test: "$(yarn bin)/vitest --browser.name=chrome --browser.headless",
"semantic-release": "semantic-release",

@@ -39,21 +41,15 @@ prepublishOnly: "yarn run build"

devDependencies: {
"@babel/preset-env": "^7.14.1",
"@babel/preset-typescript": "^7.13.0",
"@preconstruct/cli": "^2.1.5",
"@semantic-release/git": "^10.0.1",
chai: "^4.2.0",
karma: "^6.4.2",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^3.1.0",
"karma-mocha": "^2.0.1",
"karma-typescript": "^5.0.3",
mocha: "^8.1.1",
prettier: "^3.0.3",
puppeteer: "^21.1.0",
"semantic-release": "^22.0.1",
sinon: "^15.0.0",
typescript: "^5.2.2"
"@babel/core": "7.13.0",
"@babel/preset-typescript": "7.13.0",
"@preconstruct/cli": "2.8.1",
"@semantic-release/git": "10.0.1",
"@vitest/browser": "0.34.6",
prettier: "3.0.3",
"semantic-release": "22.0.5",
typescript: "5.2.2",
vitest: "0.34.6",
webdriverio: "8.16.22"
},
dependencies: {
"native-promise-only": "^0.8.1"
"native-promise-only": "0.8.1"
}

@@ -110,14 +106,14 @@ };

const params = new URLSearchParams();
params.append('sdk', pkg.version);
params.append("sdk", pkg.version);
if (ui) {
params.append('ui', ui);
params.append("ui", ui);
}
if (language) {
params.append('language', language);
params.append("language", language);
}
if (shouldCallValidateSession) {
params.append('client_side_validation', 'true');
params.append("client_side_validation", "true");
}
if (popOut) {
params.append('role', 'pop_out_launcher');
params.append("role", "pop_out_launcher");
}

@@ -131,6 +127,6 @@ if (endpoint === "https://checkout.dintero.com") {

// serverside view flow.
params.append('sid', sid);
return `${endpoint}/?${params.toString()}`;
params.append("sid", sid);
return `${padTralingSlash(endpoint)}?${params.toString()}`;
};
const padTralingSlash = endpoint => endpoint.endsWith('/') ? endpoint : `${endpoint}/`;
const padTralingSlash = endpoint => endpoint.endsWith("/") ? endpoint : `${endpoint}/`;
const getPopOutUrl = ({

@@ -142,14 +138,15 @@ sid,

}) => {
if (shouldCallValidateSession) {
return `${padTralingSlash(endpoint)}?loader=true`;
}
const params = new URLSearchParams();
params.append('ui', 'fullscreen');
params.append('role', 'pop_out_payment');
params.append('sid', sid);
params.append('sdk', pkg.version);
params.append("ui", "fullscreen");
params.append("role", "pop_out_payment");
params.append("sid", sid);
params.append("sdk", pkg.version);
if (language) {
params.append('language', language);
params.append("language", language);
}
return `${endpoint}/?${params.toString()}`;
if (shouldCallValidateSession) {
params.append("loader", "true");
return `${padTralingSlash(endpoint)}?${params.toString()}`;
}
return `${padTralingSlash(endpoint)}?${params.toString()}`;
};

@@ -381,7 +378,7 @@

// Iterate all DOM items to get current highest element.
const elements = document.getElementsByTagName('*');
const elements = document.getElementsByTagName("*");
const highest = Array.from(elements).reduce((acc, element) => {
try {
const zIndexStr = document.defaultView.getComputedStyle(element, null).getPropertyValue("z-index");
const zIndex = parseInt(zIndexStr || '0');
const zIndex = parseInt(zIndexStr || "0");
if (!isNaN(zIndex) && zIndex > acc) {

@@ -397,11 +394,11 @@ return zIndex;

if (highest < 9999) {
return '9999';
return "9999";
}
return (highest + 1).toString();
};
const STYLE_ID = 'dintero-checkout-sdk-style';
const BACKDROP_ID = 'dintero-checkout-sdk-backdrop';
const BACKDROP_DESCRIPTION = 'dintero-checkout-sdk-backdrop-description';
const FOCUS_CHECKOUT_BUTTON_ID = 'dintero-checkout-sdk-backdrop-focus';
const CLOSE_BACKDROP_BUTTON_ID = 'dintero-checkout-sdk-backdrop-close';
const STYLE_ID = "dintero-checkout-sdk-style";
const BACKDROP_ID = "dintero-checkout-sdk-backdrop";
const BACKDROP_DESCRIPTION = "dintero-checkout-sdk-backdrop-description";
const FOCUS_CHECKOUT_BUTTON_ID = "dintero-checkout-sdk-backdrop-focus";
const CLOSE_BACKDROP_BUTTON_ID = "dintero-checkout-sdk-backdrop-close";
const wrapPreventDefault = fn => {

@@ -423,4 +420,4 @@ // Creates a wrapped function that will invoke preventDefault() to stop

// Add style to DOM
const style = document.createElement('style');
style.setAttribute('id', STYLE_ID);
const style = document.createElement("style");
style.setAttribute("id", STYLE_ID);
style.innerHTML = `

@@ -540,3 +537,3 @@ @keyframes ${BACKDROP_ID}-fade-in {

// Dark translucent backdrop element
const backdrop = document.createElement('div');
const backdrop = document.createElement("div");
backdrop.setAttribute("id", BACKDROP_ID);

@@ -549,3 +546,3 @@ backdrop.setAttribute("role", "dialog");

// Close button for the top right corner
const button = document.createElement('button');
const button = document.createElement("button");
button.setAttribute("id", CLOSE_BACKDROP_BUTTON_ID);

@@ -574,3 +571,3 @@ button.setAttribute("type", "button");

// Close button for the top right corner
const div = document.createElement('div');
const div = document.createElement("div");
div.innerHTML = `

@@ -588,4 +585,4 @@ <svg width="120px" height="22px" viewBox="0 0 630 111" version="1.1" >

// Text about the pop out
const p = document.createElement('p');
p.setAttribute('id', BACKDROP_DESCRIPTION);
const p = document.createElement("p");
p.setAttribute("id", BACKDROP_DESCRIPTION);
p.innerText = text;

@@ -598,3 +595,3 @@ return p;

// checkout.
const button = document.createElement('button');
const button = document.createElement("button");
button.setAttribute("id", FOCUS_CHECKOUT_BUTTON_ID);

@@ -609,3 +606,3 @@ button.setAttribute("type", "button");

const closeButton = document.getElementById(CLOSE_BACKDROP_BUTTON_ID);
if (e.key === 'Tab' || e.code === "Tab") {
if (e.key === "Tab" || e.code === "Tab") {
if (document.activeElement === focusButton) {

@@ -637,3 +634,3 @@ closeButton.focus();

// Add focus trap when backdrop is visible
document.addEventListener('keydown', focusTrap);
document.addEventListener("keydown", focusTrap);

@@ -660,3 +657,3 @@ // Append to document

if (closeButton) {
closeButton.setAttribute('aria-label', event.descriptionLabel);
closeButton.setAttribute("aria-label", event.descriptionLabel);
}

@@ -684,3 +681,3 @@ };

}
document.removeEventListener('keydown', focusTrap);
document.removeEventListener("keydown", focusTrap);
} catch (e) {

@@ -703,10 +700,10 @@ // Ignore errors when closing backdrop. If it fails we should not stop

}) => {
button.setAttribute('id', OPEN_POP_OUT_BUTTON_ID);
button.setAttribute('type', 'button');
button.setAttribute("id", OPEN_POP_OUT_BUTTON_ID);
button.setAttribute("type", "button");
// Is clickable
if (disabled === 'true') {
button.setAttribute('disabled', disabled);
if (disabled === "true") {
button.setAttribute("disabled", disabled);
} else {
button.removeAttribute('disabled');
button.removeAttribute("disabled");
}

@@ -721,3 +718,3 @@

// Update look
button.style.boxShadow = 'inset 0 0 10px rgba(34, 84, 65, 0.9)';
button.style.boxShadow = "inset 0 0 10px rgba(34, 84, 65, 0.9)";

@@ -729,3 +726,3 @@ // Invoke handler

window.setTimeout(() => {
button.style.boxShadow = 'none';
button.style.boxShadow = "none";
}, 200);

@@ -738,6 +735,6 @@ };

// Position
button.style.position = 'absolute';
button.style.top = top + 'px';
button.style.left = left + 'px';
button.style.right = right + 'px';
button.style.position = "absolute";
button.style.top = top + "px";
button.style.left = left + "px";
button.style.right = right + "px";

@@ -755,3 +752,3 @@ // Appearance from checkout

const exists = document.getElementById(OPEN_POP_OUT_BUTTON_ID);
const button = exists || document.createElement('button');
const button = exists || document.createElement("button");
configureButton(button, options);

@@ -767,5 +764,5 @@ if (!exists) {

if (disabled) {
button.setAttribute('disabled', disabled.toString());
button.setAttribute("disabled", disabled.toString());
} else {
button.removeAttribute('disabled');
button.removeAttribute("disabled");
}

@@ -793,27 +790,38 @@ }

let popOutWindow;
const createPopOutWindow = (url, width, height) => {
const createPopOutWindow = (sid, url, width, height) => {
return new Promise(resolve => {
try {
// Opens a centered pop up window
// Creates a centered pop up window
const left = window.screenX + (window.outerWidth - width) / 2;
const top = window.screenY + (window.outerHeight - height) / 2;
const features = `width=${width},height=${height},left=${left},top=${top},location=no,menubar=no,toolbar=no,status=no`;
const popOut = window.open(url, 'dintero-checkout', features);
let popOut;
let timeout = -1;
// Set up listener for application loaded message from pop out window
const handleAppLoaded = event => {
const correctSource = event.source === popOut;
const correctOrigin = event.origin === new URL(url).origin;
const correctMessage = event.data && event.data.type === "AppLoaded";
const correctContext = event.data.context === "popOut";
const correctSid = event.data.sid === sid;
if (correctSource && correctOrigin && correctMessage && correctContext && correctSid) {
clearTimeout(timeout);
resolve(popOut);
window.removeEventListener("message", handleAppLoaded);
}
};
window.addEventListener("message", handleAppLoaded);
// Open pop out
popOut = window.open(url, "dintero-checkout", features);
// Check that pop out was opened
if (!popOut) {
console.log('createPopOutWindow no popOut');
console.log("createPopOutWindow no popOut");
resolve(undefined);
return;
}
const timeout = window.setTimeout(() => {
console.log('createPopOutWindow timeout');
// Trigger timeout if pop out is not loaded
timeout = window.setTimeout(() => {
console.log("createPopOutWindow timeout");
resolve(undefined);
}, 3000);
popOut.addEventListener('load', event => {
console.log('createPopOutWindow loaded', {
popOut,
event
});
clearTimeout(timeout);
resolve(popOut);
});
} catch (err) {

@@ -834,3 +842,3 @@ resolve(undefined);

const url = getPopOutUrl(options);
popOutWindow = await createPopOutWindow(url, WIDTH, HEIGHT);
popOutWindow = await createPopOutWindow(options.sid, url, WIDTH, HEIGHT);
const focusPopOut = () => {

@@ -844,3 +852,3 @@ if (popOutWindow) {

intervalId = -1;
window.removeEventListener('beforeunload', closePopOut);
window.removeEventListener("beforeunload", closePopOut);
popOutWindow = undefined;

@@ -865,3 +873,3 @@ options.onClose();

// Close pop out if current window is closed
window.addEventListener('beforeunload', closePopOut);
window.addEventListener("beforeunload", closePopOut);

@@ -906,4 +914,4 @@ // Check if checkout is still open

checkout.iframe.scrollIntoView({
block: 'start',
behavior: 'smooth'
block: "start",
behavior: "smooth"
});

@@ -967,3 +975,3 @@ } catch (e) {

} else {
console.error('Payment Complete event missing href property');
console.error("Payment Complete event missing href property");
}

@@ -976,3 +984,3 @@ }

// Check that we should handle the message
if (event.source === source && event.data.context === 'popOut' && event.data.sid === checkout.options.sid) {
if (event.source === source && event.data.context === "popOut" && event.data.sid === checkout.options.sid) {
// Check if handler matches incoming event and trigger the handler if so.

@@ -994,7 +1002,7 @@ [

// Add messageRouter event listener to the Pop Out
window.addEventListener('message', messageRouter);
window.addEventListener("message", messageRouter);
// Return unsubscribe function
return () => {
window.removeEventListener('message', messageRouter);
window.removeEventListener("message", messageRouter);
};

@@ -1095,3 +1103,3 @@ };

success: false,
clientValidationError: 'Validation runtime error'
clientValidationError: "Validation runtime error"
});

@@ -1156,5 +1164,5 @@ }

// Create inner container to offset any styling on the container.
const innerContainer = document.createElement('div');
innerContainer.style.position = 'relative';
innerContainer.style['box-sizing'] = 'border-box';
const innerContainer = document.createElement("div");
innerContainer.style.position = "relative";
innerContainer.style["box-sizing"] = "border-box";
const internalOptions = {

@@ -1161,0 +1169,0 @@ endpoint: "https://checkout.dintero.com",

@@ -9,3 +9,3 @@ 'use strict';

name: "@dintero/checkout-web-sdk",
version: "0.6.1",
version: "0.6.2",
description: "Dintero Checkout SDK for web frontends",

@@ -21,4 +21,6 @@ main: "dist/dintero-checkout-web-sdk.cjs.js",

scripts: {
postinstall: "patch -u node_modules/vitest/dist/vendor-node.a7c48fe1.js -i patches/vitest+0.34.6.patch --forward || true",
build: "preconstruct build",
test: "$(yarn bin)/karma start",
lint: "prettier --cache --log-level warn -c --config .prettierrc.yml .",
test: "$(yarn bin)/vitest --browser.name=chrome --browser.headless",
"semantic-release": "semantic-release",

@@ -39,21 +41,15 @@ prepublishOnly: "yarn run build"

devDependencies: {
"@babel/preset-env": "^7.14.1",
"@babel/preset-typescript": "^7.13.0",
"@preconstruct/cli": "^2.1.5",
"@semantic-release/git": "^10.0.1",
chai: "^4.2.0",
karma: "^6.4.2",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^3.1.0",
"karma-mocha": "^2.0.1",
"karma-typescript": "^5.0.3",
mocha: "^8.1.1",
prettier: "^3.0.3",
puppeteer: "^21.1.0",
"semantic-release": "^22.0.1",
sinon: "^15.0.0",
typescript: "^5.2.2"
"@babel/core": "7.13.0",
"@babel/preset-typescript": "7.13.0",
"@preconstruct/cli": "2.8.1",
"@semantic-release/git": "10.0.1",
"@vitest/browser": "0.34.6",
prettier: "3.0.3",
"semantic-release": "22.0.5",
typescript: "5.2.2",
vitest: "0.34.6",
webdriverio: "8.16.22"
},
dependencies: {
"native-promise-only": "^0.8.1"
"native-promise-only": "0.8.1"
}

@@ -110,14 +106,14 @@ };

const params = new URLSearchParams();
params.append('sdk', pkg.version);
params.append("sdk", pkg.version);
if (ui) {
params.append('ui', ui);
params.append("ui", ui);
}
if (language) {
params.append('language', language);
params.append("language", language);
}
if (shouldCallValidateSession) {
params.append('client_side_validation', 'true');
params.append("client_side_validation", "true");
}
if (popOut) {
params.append('role', 'pop_out_launcher');
params.append("role", "pop_out_launcher");
}

@@ -131,6 +127,6 @@ if (endpoint === "https://checkout.dintero.com") {

// serverside view flow.
params.append('sid', sid);
return `${endpoint}/?${params.toString()}`;
params.append("sid", sid);
return `${padTralingSlash(endpoint)}?${params.toString()}`;
};
const padTralingSlash = endpoint => endpoint.endsWith('/') ? endpoint : `${endpoint}/`;
const padTralingSlash = endpoint => endpoint.endsWith("/") ? endpoint : `${endpoint}/`;
const getPopOutUrl = ({

@@ -142,14 +138,15 @@ sid,

}) => {
if (shouldCallValidateSession) {
return `${padTralingSlash(endpoint)}?loader=true`;
}
const params = new URLSearchParams();
params.append('ui', 'fullscreen');
params.append('role', 'pop_out_payment');
params.append('sid', sid);
params.append('sdk', pkg.version);
params.append("ui", "fullscreen");
params.append("role", "pop_out_payment");
params.append("sid", sid);
params.append("sdk", pkg.version);
if (language) {
params.append('language', language);
params.append("language", language);
}
return `${endpoint}/?${params.toString()}`;
if (shouldCallValidateSession) {
params.append("loader", "true");
return `${padTralingSlash(endpoint)}?${params.toString()}`;
}
return `${padTralingSlash(endpoint)}?${params.toString()}`;
};

@@ -381,7 +378,7 @@

// Iterate all DOM items to get current highest element.
const elements = document.getElementsByTagName('*');
const elements = document.getElementsByTagName("*");
const highest = Array.from(elements).reduce((acc, element) => {
try {
const zIndexStr = document.defaultView.getComputedStyle(element, null).getPropertyValue("z-index");
const zIndex = parseInt(zIndexStr || '0');
const zIndex = parseInt(zIndexStr || "0");
if (!isNaN(zIndex) && zIndex > acc) {

@@ -397,11 +394,11 @@ return zIndex;

if (highest < 9999) {
return '9999';
return "9999";
}
return (highest + 1).toString();
};
const STYLE_ID = 'dintero-checkout-sdk-style';
const BACKDROP_ID = 'dintero-checkout-sdk-backdrop';
const BACKDROP_DESCRIPTION = 'dintero-checkout-sdk-backdrop-description';
const FOCUS_CHECKOUT_BUTTON_ID = 'dintero-checkout-sdk-backdrop-focus';
const CLOSE_BACKDROP_BUTTON_ID = 'dintero-checkout-sdk-backdrop-close';
const STYLE_ID = "dintero-checkout-sdk-style";
const BACKDROP_ID = "dintero-checkout-sdk-backdrop";
const BACKDROP_DESCRIPTION = "dintero-checkout-sdk-backdrop-description";
const FOCUS_CHECKOUT_BUTTON_ID = "dintero-checkout-sdk-backdrop-focus";
const CLOSE_BACKDROP_BUTTON_ID = "dintero-checkout-sdk-backdrop-close";
const wrapPreventDefault = fn => {

@@ -423,4 +420,4 @@ // Creates a wrapped function that will invoke preventDefault() to stop

// Add style to DOM
const style = document.createElement('style');
style.setAttribute('id', STYLE_ID);
const style = document.createElement("style");
style.setAttribute("id", STYLE_ID);
style.innerHTML = `

@@ -540,3 +537,3 @@ @keyframes ${BACKDROP_ID}-fade-in {

// Dark translucent backdrop element
const backdrop = document.createElement('div');
const backdrop = document.createElement("div");
backdrop.setAttribute("id", BACKDROP_ID);

@@ -549,3 +546,3 @@ backdrop.setAttribute("role", "dialog");

// Close button for the top right corner
const button = document.createElement('button');
const button = document.createElement("button");
button.setAttribute("id", CLOSE_BACKDROP_BUTTON_ID);

@@ -574,3 +571,3 @@ button.setAttribute("type", "button");

// Close button for the top right corner
const div = document.createElement('div');
const div = document.createElement("div");
div.innerHTML = `

@@ -588,4 +585,4 @@ <svg width="120px" height="22px" viewBox="0 0 630 111" version="1.1" >

// Text about the pop out
const p = document.createElement('p');
p.setAttribute('id', BACKDROP_DESCRIPTION);
const p = document.createElement("p");
p.setAttribute("id", BACKDROP_DESCRIPTION);
p.innerText = text;

@@ -598,3 +595,3 @@ return p;

// checkout.
const button = document.createElement('button');
const button = document.createElement("button");
button.setAttribute("id", FOCUS_CHECKOUT_BUTTON_ID);

@@ -609,3 +606,3 @@ button.setAttribute("type", "button");

const closeButton = document.getElementById(CLOSE_BACKDROP_BUTTON_ID);
if (e.key === 'Tab' || e.code === "Tab") {
if (e.key === "Tab" || e.code === "Tab") {
if (document.activeElement === focusButton) {

@@ -637,3 +634,3 @@ closeButton.focus();

// Add focus trap when backdrop is visible
document.addEventListener('keydown', focusTrap);
document.addEventListener("keydown", focusTrap);

@@ -660,3 +657,3 @@ // Append to document

if (closeButton) {
closeButton.setAttribute('aria-label', event.descriptionLabel);
closeButton.setAttribute("aria-label", event.descriptionLabel);
}

@@ -684,3 +681,3 @@ };

}
document.removeEventListener('keydown', focusTrap);
document.removeEventListener("keydown", focusTrap);
} catch (e) {

@@ -703,10 +700,10 @@ // Ignore errors when closing backdrop. If it fails we should not stop

}) => {
button.setAttribute('id', OPEN_POP_OUT_BUTTON_ID);
button.setAttribute('type', 'button');
button.setAttribute("id", OPEN_POP_OUT_BUTTON_ID);
button.setAttribute("type", "button");
// Is clickable
if (disabled === 'true') {
button.setAttribute('disabled', disabled);
if (disabled === "true") {
button.setAttribute("disabled", disabled);
} else {
button.removeAttribute('disabled');
button.removeAttribute("disabled");
}

@@ -721,3 +718,3 @@

// Update look
button.style.boxShadow = 'inset 0 0 10px rgba(34, 84, 65, 0.9)';
button.style.boxShadow = "inset 0 0 10px rgba(34, 84, 65, 0.9)";

@@ -729,3 +726,3 @@ // Invoke handler

window.setTimeout(() => {
button.style.boxShadow = 'none';
button.style.boxShadow = "none";
}, 200);

@@ -738,6 +735,6 @@ };

// Position
button.style.position = 'absolute';
button.style.top = top + 'px';
button.style.left = left + 'px';
button.style.right = right + 'px';
button.style.position = "absolute";
button.style.top = top + "px";
button.style.left = left + "px";
button.style.right = right + "px";

@@ -755,3 +752,3 @@ // Appearance from checkout

const exists = document.getElementById(OPEN_POP_OUT_BUTTON_ID);
const button = exists || document.createElement('button');
const button = exists || document.createElement("button");
configureButton(button, options);

@@ -767,5 +764,5 @@ if (!exists) {

if (disabled) {
button.setAttribute('disabled', disabled.toString());
button.setAttribute("disabled", disabled.toString());
} else {
button.removeAttribute('disabled');
button.removeAttribute("disabled");
}

@@ -793,27 +790,38 @@ }

let popOutWindow;
const createPopOutWindow = (url, width, height) => {
const createPopOutWindow = (sid, url, width, height) => {
return new Promise(resolve => {
try {
// Opens a centered pop up window
// Creates a centered pop up window
const left = window.screenX + (window.outerWidth - width) / 2;
const top = window.screenY + (window.outerHeight - height) / 2;
const features = `width=${width},height=${height},left=${left},top=${top},location=no,menubar=no,toolbar=no,status=no`;
const popOut = window.open(url, 'dintero-checkout', features);
let popOut;
let timeout = -1;
// Set up listener for application loaded message from pop out window
const handleAppLoaded = event => {
const correctSource = event.source === popOut;
const correctOrigin = event.origin === new URL(url).origin;
const correctMessage = event.data && event.data.type === "AppLoaded";
const correctContext = event.data.context === "popOut";
const correctSid = event.data.sid === sid;
if (correctSource && correctOrigin && correctMessage && correctContext && correctSid) {
clearTimeout(timeout);
resolve(popOut);
window.removeEventListener("message", handleAppLoaded);
}
};
window.addEventListener("message", handleAppLoaded);
// Open pop out
popOut = window.open(url, "dintero-checkout", features);
// Check that pop out was opened
if (!popOut) {
console.log('createPopOutWindow no popOut');
console.log("createPopOutWindow no popOut");
resolve(undefined);
return;
}
const timeout = window.setTimeout(() => {
console.log('createPopOutWindow timeout');
// Trigger timeout if pop out is not loaded
timeout = window.setTimeout(() => {
console.log("createPopOutWindow timeout");
resolve(undefined);
}, 3000);
popOut.addEventListener('load', event => {
console.log('createPopOutWindow loaded', {
popOut,
event
});
clearTimeout(timeout);
resolve(popOut);
});
} catch (err) {

@@ -834,3 +842,3 @@ resolve(undefined);

const url = getPopOutUrl(options);
popOutWindow = await createPopOutWindow(url, WIDTH, HEIGHT);
popOutWindow = await createPopOutWindow(options.sid, url, WIDTH, HEIGHT);
const focusPopOut = () => {

@@ -844,3 +852,3 @@ if (popOutWindow) {

intervalId = -1;
window.removeEventListener('beforeunload', closePopOut);
window.removeEventListener("beforeunload", closePopOut);
popOutWindow = undefined;

@@ -865,3 +873,3 @@ options.onClose();

// Close pop out if current window is closed
window.addEventListener('beforeunload', closePopOut);
window.addEventListener("beforeunload", closePopOut);

@@ -906,4 +914,4 @@ // Check if checkout is still open

checkout.iframe.scrollIntoView({
block: 'start',
behavior: 'smooth'
block: "start",
behavior: "smooth"
});

@@ -967,3 +975,3 @@ } catch (e) {

} else {
console.error('Payment Complete event missing href property');
console.error("Payment Complete event missing href property");
}

@@ -976,3 +984,3 @@ }

// Check that we should handle the message
if (event.source === source && event.data.context === 'popOut' && event.data.sid === checkout.options.sid) {
if (event.source === source && event.data.context === "popOut" && event.data.sid === checkout.options.sid) {
// Check if handler matches incoming event and trigger the handler if so.

@@ -994,7 +1002,7 @@ [

// Add messageRouter event listener to the Pop Out
window.addEventListener('message', messageRouter);
window.addEventListener("message", messageRouter);
// Return unsubscribe function
return () => {
window.removeEventListener('message', messageRouter);
window.removeEventListener("message", messageRouter);
};

@@ -1095,3 +1103,3 @@ };

success: false,
clientValidationError: 'Validation runtime error'
clientValidationError: "Validation runtime error"
});

@@ -1156,5 +1164,5 @@ }

// Create inner container to offset any styling on the container.
const innerContainer = document.createElement('div');
innerContainer.style.position = 'relative';
innerContainer.style['box-sizing'] = 'border-box';
const innerContainer = document.createElement("div");
innerContainer.style.position = "relative";
innerContainer.style["box-sizing"] = "border-box";
const internalOptions = {

@@ -1161,0 +1169,0 @@ endpoint: "https://checkout.dintero.com",

@@ -5,3 +5,3 @@ import 'native-promise-only';

name: "@dintero/checkout-web-sdk",
version: "0.6.1",
version: "0.6.2",
description: "Dintero Checkout SDK for web frontends",

@@ -17,4 +17,6 @@ main: "dist/dintero-checkout-web-sdk.cjs.js",

scripts: {
postinstall: "patch -u node_modules/vitest/dist/vendor-node.a7c48fe1.js -i patches/vitest+0.34.6.patch --forward || true",
build: "preconstruct build",
test: "$(yarn bin)/karma start",
lint: "prettier --cache --log-level warn -c --config .prettierrc.yml .",
test: "$(yarn bin)/vitest --browser.name=chrome --browser.headless",
"semantic-release": "semantic-release",

@@ -35,21 +37,15 @@ prepublishOnly: "yarn run build"

devDependencies: {
"@babel/preset-env": "^7.14.1",
"@babel/preset-typescript": "^7.13.0",
"@preconstruct/cli": "^2.1.5",
"@semantic-release/git": "^10.0.1",
chai: "^4.2.0",
karma: "^6.4.2",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^3.1.0",
"karma-mocha": "^2.0.1",
"karma-typescript": "^5.0.3",
mocha: "^8.1.1",
prettier: "^3.0.3",
puppeteer: "^21.1.0",
"semantic-release": "^22.0.1",
sinon: "^15.0.0",
typescript: "^5.2.2"
"@babel/core": "7.13.0",
"@babel/preset-typescript": "7.13.0",
"@preconstruct/cli": "2.8.1",
"@semantic-release/git": "10.0.1",
"@vitest/browser": "0.34.6",
prettier: "3.0.3",
"semantic-release": "22.0.5",
typescript: "5.2.2",
vitest: "0.34.6",
webdriverio: "8.16.22"
},
dependencies: {
"native-promise-only": "^0.8.1"
"native-promise-only": "0.8.1"
}

@@ -106,14 +102,14 @@ };

const params = new URLSearchParams();
params.append('sdk', pkg.version);
params.append("sdk", pkg.version);
if (ui) {
params.append('ui', ui);
params.append("ui", ui);
}
if (language) {
params.append('language', language);
params.append("language", language);
}
if (shouldCallValidateSession) {
params.append('client_side_validation', 'true');
params.append("client_side_validation", "true");
}
if (popOut) {
params.append('role', 'pop_out_launcher');
params.append("role", "pop_out_launcher");
}

@@ -127,6 +123,6 @@ if (endpoint === "https://checkout.dintero.com") {

// serverside view flow.
params.append('sid', sid);
return `${endpoint}/?${params.toString()}`;
params.append("sid", sid);
return `${padTralingSlash(endpoint)}?${params.toString()}`;
};
const padTralingSlash = endpoint => endpoint.endsWith('/') ? endpoint : `${endpoint}/`;
const padTralingSlash = endpoint => endpoint.endsWith("/") ? endpoint : `${endpoint}/`;
const getPopOutUrl = ({

@@ -138,14 +134,15 @@ sid,

}) => {
if (shouldCallValidateSession) {
return `${padTralingSlash(endpoint)}?loader=true`;
}
const params = new URLSearchParams();
params.append('ui', 'fullscreen');
params.append('role', 'pop_out_payment');
params.append('sid', sid);
params.append('sdk', pkg.version);
params.append("ui", "fullscreen");
params.append("role", "pop_out_payment");
params.append("sid", sid);
params.append("sdk", pkg.version);
if (language) {
params.append('language', language);
params.append("language", language);
}
return `${endpoint}/?${params.toString()}`;
if (shouldCallValidateSession) {
params.append("loader", "true");
return `${padTralingSlash(endpoint)}?${params.toString()}`;
}
return `${padTralingSlash(endpoint)}?${params.toString()}`;
};

@@ -377,7 +374,7 @@

// Iterate all DOM items to get current highest element.
const elements = document.getElementsByTagName('*');
const elements = document.getElementsByTagName("*");
const highest = Array.from(elements).reduce((acc, element) => {
try {
const zIndexStr = document.defaultView.getComputedStyle(element, null).getPropertyValue("z-index");
const zIndex = parseInt(zIndexStr || '0');
const zIndex = parseInt(zIndexStr || "0");
if (!isNaN(zIndex) && zIndex > acc) {

@@ -393,11 +390,11 @@ return zIndex;

if (highest < 9999) {
return '9999';
return "9999";
}
return (highest + 1).toString();
};
const STYLE_ID = 'dintero-checkout-sdk-style';
const BACKDROP_ID = 'dintero-checkout-sdk-backdrop';
const BACKDROP_DESCRIPTION = 'dintero-checkout-sdk-backdrop-description';
const FOCUS_CHECKOUT_BUTTON_ID = 'dintero-checkout-sdk-backdrop-focus';
const CLOSE_BACKDROP_BUTTON_ID = 'dintero-checkout-sdk-backdrop-close';
const STYLE_ID = "dintero-checkout-sdk-style";
const BACKDROP_ID = "dintero-checkout-sdk-backdrop";
const BACKDROP_DESCRIPTION = "dintero-checkout-sdk-backdrop-description";
const FOCUS_CHECKOUT_BUTTON_ID = "dintero-checkout-sdk-backdrop-focus";
const CLOSE_BACKDROP_BUTTON_ID = "dintero-checkout-sdk-backdrop-close";
const wrapPreventDefault = fn => {

@@ -419,4 +416,4 @@ // Creates a wrapped function that will invoke preventDefault() to stop

// Add style to DOM
const style = document.createElement('style');
style.setAttribute('id', STYLE_ID);
const style = document.createElement("style");
style.setAttribute("id", STYLE_ID);
style.innerHTML = `

@@ -536,3 +533,3 @@ @keyframes ${BACKDROP_ID}-fade-in {

// Dark translucent backdrop element
const backdrop = document.createElement('div');
const backdrop = document.createElement("div");
backdrop.setAttribute("id", BACKDROP_ID);

@@ -545,3 +542,3 @@ backdrop.setAttribute("role", "dialog");

// Close button for the top right corner
const button = document.createElement('button');
const button = document.createElement("button");
button.setAttribute("id", CLOSE_BACKDROP_BUTTON_ID);

@@ -570,3 +567,3 @@ button.setAttribute("type", "button");

// Close button for the top right corner
const div = document.createElement('div');
const div = document.createElement("div");
div.innerHTML = `

@@ -584,4 +581,4 @@ <svg width="120px" height="22px" viewBox="0 0 630 111" version="1.1" >

// Text about the pop out
const p = document.createElement('p');
p.setAttribute('id', BACKDROP_DESCRIPTION);
const p = document.createElement("p");
p.setAttribute("id", BACKDROP_DESCRIPTION);
p.innerText = text;

@@ -594,3 +591,3 @@ return p;

// checkout.
const button = document.createElement('button');
const button = document.createElement("button");
button.setAttribute("id", FOCUS_CHECKOUT_BUTTON_ID);

@@ -605,3 +602,3 @@ button.setAttribute("type", "button");

const closeButton = document.getElementById(CLOSE_BACKDROP_BUTTON_ID);
if (e.key === 'Tab' || e.code === "Tab") {
if (e.key === "Tab" || e.code === "Tab") {
if (document.activeElement === focusButton) {

@@ -633,3 +630,3 @@ closeButton.focus();

// Add focus trap when backdrop is visible
document.addEventListener('keydown', focusTrap);
document.addEventListener("keydown", focusTrap);

@@ -656,3 +653,3 @@ // Append to document

if (closeButton) {
closeButton.setAttribute('aria-label', event.descriptionLabel);
closeButton.setAttribute("aria-label", event.descriptionLabel);
}

@@ -680,3 +677,3 @@ };

}
document.removeEventListener('keydown', focusTrap);
document.removeEventListener("keydown", focusTrap);
} catch (e) {

@@ -699,10 +696,10 @@ // Ignore errors when closing backdrop. If it fails we should not stop

}) => {
button.setAttribute('id', OPEN_POP_OUT_BUTTON_ID);
button.setAttribute('type', 'button');
button.setAttribute("id", OPEN_POP_OUT_BUTTON_ID);
button.setAttribute("type", "button");
// Is clickable
if (disabled === 'true') {
button.setAttribute('disabled', disabled);
if (disabled === "true") {
button.setAttribute("disabled", disabled);
} else {
button.removeAttribute('disabled');
button.removeAttribute("disabled");
}

@@ -717,3 +714,3 @@

// Update look
button.style.boxShadow = 'inset 0 0 10px rgba(34, 84, 65, 0.9)';
button.style.boxShadow = "inset 0 0 10px rgba(34, 84, 65, 0.9)";

@@ -725,3 +722,3 @@ // Invoke handler

window.setTimeout(() => {
button.style.boxShadow = 'none';
button.style.boxShadow = "none";
}, 200);

@@ -734,6 +731,6 @@ };

// Position
button.style.position = 'absolute';
button.style.top = top + 'px';
button.style.left = left + 'px';
button.style.right = right + 'px';
button.style.position = "absolute";
button.style.top = top + "px";
button.style.left = left + "px";
button.style.right = right + "px";

@@ -751,3 +748,3 @@ // Appearance from checkout

const exists = document.getElementById(OPEN_POP_OUT_BUTTON_ID);
const button = exists || document.createElement('button');
const button = exists || document.createElement("button");
configureButton(button, options);

@@ -763,5 +760,5 @@ if (!exists) {

if (disabled) {
button.setAttribute('disabled', disabled.toString());
button.setAttribute("disabled", disabled.toString());
} else {
button.removeAttribute('disabled');
button.removeAttribute("disabled");
}

@@ -789,27 +786,38 @@ }

let popOutWindow;
const createPopOutWindow = (url, width, height) => {
const createPopOutWindow = (sid, url, width, height) => {
return new Promise(resolve => {
try {
// Opens a centered pop up window
// Creates a centered pop up window
const left = window.screenX + (window.outerWidth - width) / 2;
const top = window.screenY + (window.outerHeight - height) / 2;
const features = `width=${width},height=${height},left=${left},top=${top},location=no,menubar=no,toolbar=no,status=no`;
const popOut = window.open(url, 'dintero-checkout', features);
let popOut;
let timeout = -1;
// Set up listener for application loaded message from pop out window
const handleAppLoaded = event => {
const correctSource = event.source === popOut;
const correctOrigin = event.origin === new URL(url).origin;
const correctMessage = event.data && event.data.type === "AppLoaded";
const correctContext = event.data.context === "popOut";
const correctSid = event.data.sid === sid;
if (correctSource && correctOrigin && correctMessage && correctContext && correctSid) {
clearTimeout(timeout);
resolve(popOut);
window.removeEventListener("message", handleAppLoaded);
}
};
window.addEventListener("message", handleAppLoaded);
// Open pop out
popOut = window.open(url, "dintero-checkout", features);
// Check that pop out was opened
if (!popOut) {
console.log('createPopOutWindow no popOut');
console.log("createPopOutWindow no popOut");
resolve(undefined);
return;
}
const timeout = window.setTimeout(() => {
console.log('createPopOutWindow timeout');
// Trigger timeout if pop out is not loaded
timeout = window.setTimeout(() => {
console.log("createPopOutWindow timeout");
resolve(undefined);
}, 3000);
popOut.addEventListener('load', event => {
console.log('createPopOutWindow loaded', {
popOut,
event
});
clearTimeout(timeout);
resolve(popOut);
});
} catch (err) {

@@ -830,3 +838,3 @@ resolve(undefined);

const url = getPopOutUrl(options);
popOutWindow = await createPopOutWindow(url, WIDTH, HEIGHT);
popOutWindow = await createPopOutWindow(options.sid, url, WIDTH, HEIGHT);
const focusPopOut = () => {

@@ -840,3 +848,3 @@ if (popOutWindow) {

intervalId = -1;
window.removeEventListener('beforeunload', closePopOut);
window.removeEventListener("beforeunload", closePopOut);
popOutWindow = undefined;

@@ -861,3 +869,3 @@ options.onClose();

// Close pop out if current window is closed
window.addEventListener('beforeunload', closePopOut);
window.addEventListener("beforeunload", closePopOut);

@@ -902,4 +910,4 @@ // Check if checkout is still open

checkout.iframe.scrollIntoView({
block: 'start',
behavior: 'smooth'
block: "start",
behavior: "smooth"
});

@@ -963,3 +971,3 @@ } catch (e) {

} else {
console.error('Payment Complete event missing href property');
console.error("Payment Complete event missing href property");
}

@@ -972,3 +980,3 @@ }

// Check that we should handle the message
if (event.source === source && event.data.context === 'popOut' && event.data.sid === checkout.options.sid) {
if (event.source === source && event.data.context === "popOut" && event.data.sid === checkout.options.sid) {
// Check if handler matches incoming event and trigger the handler if so.

@@ -990,7 +998,7 @@ [

// Add messageRouter event listener to the Pop Out
window.addEventListener('message', messageRouter);
window.addEventListener("message", messageRouter);
// Return unsubscribe function
return () => {
window.removeEventListener('message', messageRouter);
window.removeEventListener("message", messageRouter);
};

@@ -1091,3 +1099,3 @@ };

success: false,
clientValidationError: 'Validation runtime error'
clientValidationError: "Validation runtime error"
});

@@ -1152,5 +1160,5 @@ }

// Create inner container to offset any styling on the container.
const innerContainer = document.createElement('div');
innerContainer.style.position = 'relative';
innerContainer.style['box-sizing'] = 'border-box';
const innerContainer = document.createElement("div");
innerContainer.style.position = "relative";
innerContainer.style["box-sizing"] = "border-box";
const internalOptions = {

@@ -1157,0 +1165,0 @@ endpoint: "https://checkout.dintero.com",

@@ -6,3 +6,3 @@ !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).dintero={})}(this,(function(e){"use strict";var n="undefined"!=typeof globalThis?globalThis:"undefined"!="object"?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};!function(e,n,t){e(t={path:n,exports:{},require:function(e,n){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==n&&t.path)}},t.exports),t.exports}((function(e){

*/
var t,o,i;i=function(){var e,n,t,o=Object.prototype.toString,i="undefined"!=typeof setImmediate?function(e){return setImmediate(e)}:setTimeout;try{Object.defineProperty({},"x",{}),e=function(e,n,t,o){return Object.defineProperty(e,n,{value:t,writable:!0,configurable:!1!==o})}}catch(n){e=function(e,n,t){return e[n]=t,e}}function r(e,o){t.add(e,o),n||(n=i(t.drain))}function s(e){var n,t=typeof e;return null==e||"object"!=t&&"function"!=t||(n=e.then),"function"==typeof n&&n}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,n,t){var o,i;try{!1===n?t.reject(e.msg):(o=!0===n?e.msg:n.call(void 0,e.msg))===t.promise?t.reject(TypeError("Promise-chain cycle")):(i=s(o))?i.call(o,t.resolve,t.reject):t.resolve(o)}catch(e){t.reject(e)}}function c(e){var n,t=this;if(!t.triggered){t.triggered=!0,t.def&&(t=t.def);try{(n=s(e))?r((function(){var o=new u(t);try{n.call(e,(function(){c.apply(o,arguments)}),(function(){l.apply(o,arguments)}))}catch(e){l.call(o,e)}})):(t.msg=e,t.state=1,t.chain.length>0&&r(a,t))}catch(e){l.call(new u(t),e)}}}function l(e){var n=this;n.triggered||(n.triggered=!0,n.def&&(n=n.def),n.msg=e,n.state=2,n.chain.length>0&&r(a,n))}function p(e,n,t,o){for(var i=0;i<n.length;i++)!function(i){e.resolve(n[i]).then((function(e){t(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 n=new f(this);this.then=function(e,t){var o={success:"function"!=typeof e||e,failure:"function"==typeof t&&t};return o.promise=new this.constructor((function(e,n){if("function"!=typeof e||"function"!=typeof n)throw TypeError("Not a function");o.resolve=e,o.reject=n})),n.chain.push(o),0!==n.state&&r(a,n),o.promise},this.catch=function(e){return this.then(void 0,e)};try{e.call(void 0,(function(e){c.call(n,e)}),(function(e){l.call(n,e)}))}catch(e){l.call(n,e)}}t=function(){var e,t,o;function i(e,n){this.fn=e,this.self=n,this.next=void 0}return{add:function(n,r){o=new i(n,r),t?t.next=o:e=o,t=o,o=void 0},drain:function(){var o=e;for(e=t=n=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(n,t){if("function"!=typeof n||"function"!=typeof t)throw TypeError("Not a function");n(e)}))})),e(h,"reject",(function(e){return new this((function(n,t){if("function"!=typeof n||"function"!=typeof t)throw TypeError("Not a function");t(e)}))})),e(h,"all",(function(e){var n=this;return"[object Array]"!=o.call(e)?n.reject(TypeError("Not an array")):0===e.length?n.resolve([]):new n((function(t,o){if("function"!=typeof t||"function"!=typeof o)throw TypeError("Not a function");var i=e.length,r=Array(i),s=0;p(n,e,(function(e,n){r[e]=n,++s===i&&t(r)}),o)}))})),e(h,"race",(function(e){var n=this;return"[object Array]"!=o.call(e)?n.reject(TypeError("Not an array")):new n((function(t,o){if("function"!=typeof t||"function"!=typeof o)throw TypeError("Not a function");p(n,e,(function(e,n){t(n)}),o)}))})),h},(o=n)[t="Promise"]=o[t]||i(),e.exports&&(e.exports=o[t])}));var t="0.6.1";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}({}),i=function(e){return e.HeightChanged="HeightChanged",e.LanguageChanged="LanguageChanged",e.ScrollToTop="ScrollToTop",e.ShowPopOutButton="ShowPopOutButton",e.HidePopOutButton="HidePopOutButton",e}({});const r=e=>{window.location.assign(e)},s=e=>{const{sid:n,endpoint:o,language:i,ui:r,shouldCallValidateSession:s,popOut:a}=e;if(!o)throw new Error("Invalid endpoint");const d=new URLSearchParams;return d.append("sdk",t),r&&d.append("ui",r),i&&d.append("language",i),s&&d.append("client_side_validation","true"),a&&d.append("role","pop_out_launcher"),"https://checkout.dintero.com"===o?`${o}/v1/view/${n}?${d.toString()}`:(d.append("sid",n),`${o}/?${d.toString()}`)},a=({sid:e,endpoint:n,language:o,shouldCallValidateSession:i})=>{if(i)return`${(e=>e.endsWith("/")?e:`${e}/`)(n)}?loader=true`;const r=new URLSearchParams;return r.append("ui","fullscreen"),r.append("role","pop_out_payment"),r.append("sid",e),r.append("sdk",t),o&&r.append("language",o),`${n}/?${r.toString()}`},d=(e,n,t)=>{e.contentWindow&&e.contentWindow.postMessage({type:"ValidationResult",sid:n,...t},"*")},c=e=>{const{sid:n,endpoint:t,handler:o,eventTypes:i,checkout:r}=e,s=new URL(t),a=e=>{const t=e.origin===s.origin,a=e.source===r.iframe.contentWindow,d=e.data&&e.data.sid===n,c=-1!==i.indexOf(e.data&&e.data.type);t&&a&&d&&c&&(((e,n)=>{n.data.mid&&e&&e.postMessage({ack:n.data.mid},n.origin||"*")})(r.iframe.contentWindow,e),o(e.data,r))};window.addEventListener("message",a,!1);return{unsubscribe:()=>{window.removeEventListener("message",a,!1)}}},l="dintero-checkout-sdk-style",p="dintero-checkout-sdk-backdrop",u="dintero-checkout-sdk-backdrop-description",f="dintero-checkout-sdk-backdrop-focus",h="dintero-checkout-sdk-backdrop-close",m=e=>n=>(n.preventDefault(),n.stopPropagation(),e(),!1),g=()=>{const e=document.createElement("div");return e.setAttribute("id",p),e.setAttribute("role","dialog"),e.style.zIndex=(()=>{const e=document.getElementsByTagName("*"),n=Array.from(e).reduce(((e,n)=>{try{const t=document.defaultView.getComputedStyle(n,null).getPropertyValue("z-index"),o=parseInt(t||"0");if(!isNaN(o)&&o>e)return o}catch(e){console.error(e)}return e}),0);return n<9999?"9999":(n+1).toString()})(),e},y=e=>{const n=document.getElementById(f),t=document.getElementById(h);"Tab"!==e.key&&"Tab"!==e.code||(document.activeElement===n?(t.focus(),e.preventDefault()):(n.focus(),e.preventDefault()))},w=e=>{(()=>{if(document.getElementById(l))return;const e=document.createElement("style");e.setAttribute("id",l),e.innerHTML=`\n @keyframes ${p}-fade-in {\n from {opacity: 0;}\n to {opacity: 1;}\n }\n\n #${p} {\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 ${p}-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 #${p} p {\n padding: 0;\n margin: 0;\n border: 0;\n user-select: none;\n }\n\n #${f} {\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 #${f}:hover,\n #${f}: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 #${f}:focus{\n outline-offset: 2px;\n outline: 1px #ffffff solid !important;\n }\n\n #${h} {\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 #${h}:hover,\n #${h}: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 #${h}:focus{\n outline: 1px #ffffff solid !important;\n }\n\n #${p}:before,\n #${p}:after,\n #${p} > *:before,\n #${p} > *:after {\n content: '';\n content: none;\n }\n `,document.head.appendChild(e)})();const n=g(),t=(e=>{const n=document.createElement("button");return n.setAttribute("id",h),n.setAttribute("type","button"),n.setAttribute("aria-label",e),n.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>',n})(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 n=document.createElement("p");return n.setAttribute("id",u),n.innerText=e,n})(e.event.descriptionLabel),r=(e=>{const n=document.createElement("button");return n.setAttribute("id",f),n.setAttribute("type","button"),n.innerText=e,n})(e.event.focusLabel);return n.onclick=m(e.focus),r.onclick=m(e.focus),t.onclick=m(e.close),document.addEventListener("keydown",y),n.appendChild(t),n.appendChild(o),n.appendChild(i),n.appendChild(r),document.body.appendChild(n),n.focus(),n},v=()=>{try{const e=document.getElementById(p);e&&document.body.removeChild(e),document.removeEventListener("keydown",y)}catch(e){console.error(e)}},b="dintero-checkout-sdk-launch-pop-out",L=e=>{const{container:n}=e,t=document.getElementById(b),o=t||document.createElement("button");((e,{label:n,disabled:t,top:o,left:i,right:r,styles:s,onClick:a})=>{e.setAttribute("id",b),e.setAttribute("type","button"),"true"===t?e.setAttribute("disabled",t):e.removeAttribute("disabled"),e.onclick=n=>{n.preventDefault(),n.stopPropagation(),e.style.boxShadow="inset 0 0 10px rgba(34, 84, 65, 0.9)",a(),window.setTimeout((()=>{e.style.boxShadow="none"}),200)},e.innerText=n,e.style.position="absolute",e.style.top=o+"px",e.style.left=i+"px",e.style.right=r+"px";for(const[n,t]of Object.entries(s))e.style[n]=t})(o,e),t||n.appendChild(o)},S=()=>{try{const e=document.getElementById(b);e&&e.remove()}catch(e){console.error(e)}},C=Math.min(480,window.screen.width),k=Math.min(840,window.screen.height);let T;const x=async e=>{let n,t=-1;if(T&&!T.closed)return;const o=a(e);T=await((e,n,t)=>new Promise((o=>{try{const i=window.screenX+(window.outerWidth-n)/2,r=window.screenY+(window.outerHeight-t)/2,s=`width=${n},height=${t},left=${i},top=${r},location=no,menubar=no,toolbar=no,status=no`,a=window.open(e,"dintero-checkout",s);if(!a)return console.log("createPopOutWindow no popOut"),void o(void 0);const d=window.setTimeout((()=>{console.log("createPopOutWindow timeout"),o(void 0)}),3e3);a.addEventListener("load",(e=>{console.log("createPopOutWindow loaded",{popOut:a,event:e}),clearTimeout(d),o(a)}))}catch(e){o(void 0)}})))(o,C,k);const i=()=>{window.clearInterval(t),t=-1,window.removeEventListener("beforeunload",r),T=void 0,e.onClose(),n&&n()},r=()=>{T&&T.close(),i()};return window.addEventListener("beforeunload",r),t=window.setInterval((()=>{T&&T.closed&&i()}),200),n=e.onOpen(T),{close:r,focus:()=>{T&&T.focus()},popOutWindow:T}},P=(e,n)=>{j(n),e.href&&r(e.href)},E=(e,n)=>{(e.height||0===e.height)&&n.iframe.setAttribute("style",`width:100%; height:${e.height}px;`)},O=(e,n)=>{try{n.iframe.scrollIntoView({block:"start",behavior:"smooth"})}catch(e){console.error(e)}},A=(e,n)=>{e.language&&(n.language=e.language)},W=(e,n)=>{const t={internalPopOutHandler:!0,eventTypes:[i.LanguageChanged],handler:(e,n)=>{var t,o,i;t=n.iframe,o=n.options.sid,i=e.language,t.contentWindow&&t.contentWindow.postMessage({type:"SetLanguage",sid:o,language:i},"*")}},r={internalPopOutHandler:!0,eventTypes:[o.SessionCancel,o.SessionPaymentOnHold,o.SessionPaymentAuthorized,o.SessionPaymentError],handler:(n,t)=>{if(n.href){S();try{e.close()}catch(e){console.error(e)}}else console.error("Payment Complete event missing href property")}},s=o=>{o.source===e&&"popOut"===o.data.context&&o.data.sid===n.options.sid&&[t,r,...n.handlers].forEach((e=>{e.eventTypes.includes(o.data.type)&&e.handler&&(e=>{try{e()}catch(e){console.error(e)}})((()=>{e.handler(o.data,n)}))}))};return window.addEventListener("message",s),()=>{window.removeEventListener("message",s)}},$=async(e,n)=>{const{close:t,focus:o,popOutWindow:i}=await x({sid:n.options.sid,endpoint:n.options.endpoint,shouldCallValidateSession:Boolean(n.options.onValidateSession),language:e.language,onOpen:e=>W(e,n),onClose:()=>{var e,t;v(),e=n.iframe,t=n.options.sid,e.contentWindow&&e.contentWindow.postMessage({type:"ClosedPopOut",sid:t},"*"),(e=>{try{const n=document.getElementById(b);n&&(e?n.setAttribute("disabled",e.toString()):n.removeAttribute("disabled"))}catch(e){console.error(e)}})(!1),n.popOutWindow=void 0}});return i?(r=n.iframe,s=n.options.sid,r.contentWindow&&r.contentWindow.postMessage({type:"OpenedPopOut",sid:s},"*"),n.popOutWindow=i,(e=>{try{if(document.getElementById(p))return;return w(e)}catch(e){console.error(e)}})({focus:o,close:t,event:e}),!0):(((e,n)=>{e.contentWindow&&e.contentWindow.postMessage({type:"OpenPopOutFailed",sid:n},"*")})(n.iframe,n.options.sid),!1);var r,s},M=async(e,n)=>{if(await $(e,n)&&n.options.onValidateSession){t=n.iframe,i=n.options.sid,t.contentWindow&&t.contentWindow.postMessage({type:"ValidatingPopOut",sid:i},"*");const r=((e,n)=>t=>{d(n.iframe,n.options.sid,t),t.success&&n.popOutWindow?n.popOutWindow.location.href=a({sid:n.options.sid,endpoint:n.options.endpoint,shouldCallValidateSession:!1,language:e.language}):(n.popOutWindow&&n.popOutWindow.close(),console.error(t.clientValidationError))})(e,n);try{n.options.onValidateSession({type:o.ValidateSession,session:n.session,callback:r},n,r)}catch(e){console.error(e),d(n.iframe,n.options.sid,{success:!1,clientValidationError:"Validation runtime error"})}}var t,i},_=(e,n)=>{(e=>e&&e.type===i.ShowPopOutButton)(e)&&(L({container:n.options.innerContainer,label:e.openLabel,top:e.top,left:e.left,right:e.right,styles:e.styles,disabled:e.disabled,onClick:()=>M(e,n)}),(e=>{const n=document.getElementById(f);n&&(n.innerText=e.focusLabel);const t=document.getElementById(u);t&&(t.innerText=e.descriptionLabel);const o=document.getElementById(h);o&&o.setAttribute("aria-label",e.descriptionLabel)})(e))},V=(e,n)=>{e.type===i.HidePopOutButton&&S()},j=e=>{if(S(),v(),e.popOutWindow)try{e.popOutWindow.close()}catch(e){console.error(e)}};e.embed=async e=>{const n=document.createElement("div");n.style.position="relative",n.style["box-sizing"]="border-box";const r={endpoint:"https://checkout.dintero.com",innerContainer:n,...e},{container:a,sid:l,language:p,endpoint:u,onSession:f,onSessionCancel:h,onPayment:m,onPaymentAuthorized:g,onPaymentError:y,onSessionNotFound:w,onSessionLocked:b,onSessionLockFailed:L,onActivePaymentType:S,onValidateSession:C,popOut:k}=r;let T;const x=[];let W=!1;a.appendChild(n);const{iframe:$,initiate:M}=((e,n,t)=>{if(!e||!e.appendChild)throw new Error("Invalid container");const o=document.createElement("iframe");return o.setAttribute("frameborder","0"),o.setAttribute("allowTransparency","true"),o.setAttribute("style","width:100%; height:0;"),o.setAttribute("sandbox","allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox"),o.setAttribute("allow","payment"),o.setAttribute("importance","high"),o.setAttribute("src",t),{iframe:o,initiate:async()=>new Promise(((n,t)=>{o.onload=()=>n(),o.onerror=()=>t(),e.appendChild(o)}))}})(n,0,s({sid:l,endpoint:u,language:p,ui:"inline",shouldCallValidateSession:void 0!==C,popOut:k})),B=(e,n,t)=>{if(!T)throw new Error("Unable to create action promise: checkout is undefined");return new Promise(((o,i)=>{const r=[];r.push(c({sid:l,endpoint:u,handler:e=>{r.forEach((e=>e.unsubscribe())),o(e)},eventTypes:[n],checkout:T,source:T.iframe.contentWindow})),r.push(c({sid:l,endpoint:u,handler:()=>{r.forEach((e=>e.unsubscribe())),i(`Received unexpected event: ${t}`)},eventTypes:[t],checkout:T,source:T.iframe.contentWindow})),e()}))},I=()=>B((()=>{((e,n)=>{e.contentWindow&&e.contentWindow.postMessage({type:"RefreshSession",sid:n},"*")})($,l)}),o.SessionUpdated,o.SessionNotFound),N=e=>{d($,l,e)},H=(e,n,i)=>(e,r)=>{if(!W){W=!0,j(r);const s=["sid","merchant_reference","transaction_id","error"].map((n=>[n,e[n]]));e.type!==o.SessionCancel||e.error||s.push(["error","cancelled"]),s.push(["language",r.language]),s.push(["sdk",t]);const a=s.filter((([e,n])=>n)).map((([e,n])=>`${e}=${n}`)).join("&");r.iframe.setAttribute("src",`${n}/embedResult/?${a}`),i(e,r)}},F=[{handler:A,eventTypes:[i.LanguageChanged]},{handler:E,eventTypes:[i.HeightChanged]},{handler:O,eventTypes:[i.ScrollToTop]},{handler:(e,n)=>{n.session=e.session,f&&f(e,n)},eventTypes:[o.SessionLoaded,o.SessionUpdated]},{eventTypes:[o.SessionPaymentOnHold],handler:m?H(0,u,m):P},{eventTypes:[o.SessionPaymentAuthorized],handler:g||m?H(0,u,g||m):P},{handler:h?H(0,u,h):P,eventTypes:[o.SessionCancel]},{handler:y?H(0,u,y):P,eventTypes:[o.SessionPaymentError]},{handler:w,eventTypes:[o.SessionNotFound]},{handler:(e,n)=>{b&&b(e,n,I)},eventTypes:[o.SessionLocked]},{handler:L,eventTypes:[o.SessionLockFailed]},{handler:S,eventTypes:[o.ActivePaymentProductType]},{handler:(e,n)=>{if(C)try{C({...e,callback:N},n,N)}catch(e){console.error(e),N({success:!1,clientValidationError:"Validation runtime error"})}},eventTypes:[o.ValidateSession]},{handler:_,eventTypes:[i.ShowPopOutButton]},{handler:V,eventTypes:[i.HidePopOutButton]}];return T={destroy:()=>{j(T),$&&(r.popOut&&v(),x.forEach((e=>e.unsubscribe())),$.parentElement&&n.removeChild($)),n.parentElement&&a.removeChild(n)},iframe:$,language:p,lockSession:()=>B((()=>{((e,n)=>{e.contentWindow&&e.contentWindow.postMessage({type:"LockSession",sid:n},"*")})($,l)}),o.SessionLocked,o.SessionLockFailed),refreshSession:I,setActivePaymentProductType:e=>{((e,n,t)=>{e.contentWindow&&e.contentWindow.postMessage({type:"SetActivePaymentProductType",sid:n,payment_product_type:t},"*")})($,l,e)},submitValidationResult:N,options:r,handlers:F,session:void 0,popOutWindow:void 0},F.forEach((({handler:e,eventTypes:n})=>{e&&x.push(c({sid:l,endpoint:u,handler:e,eventTypes:n,checkout:T,source:T.iframe.contentWindow}))})),await M(),T},e.redirect=e=>{const{sid:n,language:t,endpoint:o="https://checkout.dintero.com"}=e;r(s({sid:n,endpoint:o,language:t,shouldCallValidateSession:!1}))},Object.defineProperty(e,"__esModule",{value:!0})}));
var t,o,i;i=function(){var e,n,t,o=Object.prototype.toString,i="undefined"!=typeof setImmediate?function(e){return setImmediate(e)}:setTimeout;try{Object.defineProperty({},"x",{}),e=function(e,n,t,o){return Object.defineProperty(e,n,{value:t,writable:!0,configurable:!1!==o})}}catch(n){e=function(e,n,t){return e[n]=t,e}}function r(e,o){t.add(e,o),n||(n=i(t.drain))}function s(e){var n,t=typeof e;return null==e||"object"!=t&&"function"!=t||(n=e.then),"function"==typeof n&&n}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,n,t){var o,i;try{!1===n?t.reject(e.msg):(o=!0===n?e.msg:n.call(void 0,e.msg))===t.promise?t.reject(TypeError("Promise-chain cycle")):(i=s(o))?i.call(o,t.resolve,t.reject):t.resolve(o)}catch(e){t.reject(e)}}function c(e){var n,t=this;if(!t.triggered){t.triggered=!0,t.def&&(t=t.def);try{(n=s(e))?r((function(){var o=new u(t);try{n.call(e,(function(){c.apply(o,arguments)}),(function(){l.apply(o,arguments)}))}catch(e){l.call(o,e)}})):(t.msg=e,t.state=1,t.chain.length>0&&r(a,t))}catch(e){l.call(new u(t),e)}}}function l(e){var n=this;n.triggered||(n.triggered=!0,n.def&&(n=n.def),n.msg=e,n.state=2,n.chain.length>0&&r(a,n))}function p(e,n,t,o){for(var i=0;i<n.length;i++)!function(i){e.resolve(n[i]).then((function(e){t(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 n=new f(this);this.then=function(e,t){var o={success:"function"!=typeof e||e,failure:"function"==typeof t&&t};return o.promise=new this.constructor((function(e,n){if("function"!=typeof e||"function"!=typeof n)throw TypeError("Not a function");o.resolve=e,o.reject=n})),n.chain.push(o),0!==n.state&&r(a,n),o.promise},this.catch=function(e){return this.then(void 0,e)};try{e.call(void 0,(function(e){c.call(n,e)}),(function(e){l.call(n,e)}))}catch(e){l.call(n,e)}}t=function(){var e,t,o;function i(e,n){this.fn=e,this.self=n,this.next=void 0}return{add:function(n,r){o=new i(n,r),t?t.next=o:e=o,t=o,o=void 0},drain:function(){var o=e;for(e=t=n=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(n,t){if("function"!=typeof n||"function"!=typeof t)throw TypeError("Not a function");n(e)}))})),e(h,"reject",(function(e){return new this((function(n,t){if("function"!=typeof n||"function"!=typeof t)throw TypeError("Not a function");t(e)}))})),e(h,"all",(function(e){var n=this;return"[object Array]"!=o.call(e)?n.reject(TypeError("Not an array")):0===e.length?n.resolve([]):new n((function(t,o){if("function"!=typeof t||"function"!=typeof o)throw TypeError("Not a function");var i=e.length,r=Array(i),s=0;p(n,e,(function(e,n){r[e]=n,++s===i&&t(r)}),o)}))})),e(h,"race",(function(e){var n=this;return"[object Array]"!=o.call(e)?n.reject(TypeError("Not an array")):new n((function(t,o){if("function"!=typeof t||"function"!=typeof o)throw TypeError("Not a function");p(n,e,(function(e,n){t(n)}),o)}))})),h},(o=n)[t="Promise"]=o[t]||i(),e.exports&&(e.exports=o[t])}));var t="0.6.2";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}({}),i=function(e){return e.HeightChanged="HeightChanged",e.LanguageChanged="LanguageChanged",e.ScrollToTop="ScrollToTop",e.ShowPopOutButton="ShowPopOutButton",e.HidePopOutButton="HidePopOutButton",e}({});const r=e=>{window.location.assign(e)},s=e=>{const{sid:n,endpoint:o,language:i,ui:r,shouldCallValidateSession:s,popOut:d}=e;if(!o)throw new Error("Invalid endpoint");const c=new URLSearchParams;return c.append("sdk",t),r&&c.append("ui",r),i&&c.append("language",i),s&&c.append("client_side_validation","true"),d&&c.append("role","pop_out_launcher"),"https://checkout.dintero.com"===o?`${o}/v1/view/${n}?${c.toString()}`:(c.append("sid",n),`${a(o)}?${c.toString()}`)},a=e=>e.endsWith("/")?e:`${e}/`,d=({sid:e,endpoint:n,language:o,shouldCallValidateSession:i})=>{const r=new URLSearchParams;return r.append("ui","fullscreen"),r.append("role","pop_out_payment"),r.append("sid",e),r.append("sdk",t),o&&r.append("language",o),i?(r.append("loader","true"),`${a(n)}?${r.toString()}`):`${a(n)}?${r.toString()}`},c=(e,n,t)=>{e.contentWindow&&e.contentWindow.postMessage({type:"ValidationResult",sid:n,...t},"*")},l=e=>{const{sid:n,endpoint:t,handler:o,eventTypes:i,checkout:r}=e,s=new URL(t),a=e=>{const t=e.origin===s.origin,a=e.source===r.iframe.contentWindow,d=e.data&&e.data.sid===n,c=-1!==i.indexOf(e.data&&e.data.type);t&&a&&d&&c&&(((e,n)=>{n.data.mid&&e&&e.postMessage({ack:n.data.mid},n.origin||"*")})(r.iframe.contentWindow,e),o(e.data,r))};window.addEventListener("message",a,!1);return{unsubscribe:()=>{window.removeEventListener("message",a,!1)}}},p="dintero-checkout-sdk-style",u="dintero-checkout-sdk-backdrop",f="dintero-checkout-sdk-backdrop-description",h="dintero-checkout-sdk-backdrop-focus",m="dintero-checkout-sdk-backdrop-close",g=e=>n=>(n.preventDefault(),n.stopPropagation(),e(),!1),y=()=>{const e=document.createElement("div");return e.setAttribute("id",u),e.setAttribute("role","dialog"),e.style.zIndex=(()=>{const e=document.getElementsByTagName("*"),n=Array.from(e).reduce(((e,n)=>{try{const t=document.defaultView.getComputedStyle(n,null).getPropertyValue("z-index"),o=parseInt(t||"0");if(!isNaN(o)&&o>e)return o}catch(e){console.error(e)}return e}),0);return n<9999?"9999":(n+1).toString()})(),e},w=e=>{const n=document.getElementById(h),t=document.getElementById(m);"Tab"!==e.key&&"Tab"!==e.code||(document.activeElement===n?(t.focus(),e.preventDefault()):(n.focus(),e.preventDefault()))},v=e=>{(()=>{if(document.getElementById(p))return;const e=document.createElement("style");e.setAttribute("id",p),e.innerHTML=`\n @keyframes ${u}-fade-in {\n from {opacity: 0;}\n to {opacity: 1;}\n }\n\n #${u} {\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 ${u}-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 #${u} p {\n padding: 0;\n margin: 0;\n border: 0;\n user-select: none;\n }\n\n #${h} {\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 #${h}:hover,\n #${h}: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 #${h}:focus{\n outline-offset: 2px;\n outline: 1px #ffffff solid !important;\n }\n\n #${m} {\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 #${m}:hover,\n #${m}: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 #${m}:focus{\n outline: 1px #ffffff solid !important;\n }\n\n #${u}:before,\n #${u}:after,\n #${u} > *:before,\n #${u} > *:after {\n content: '';\n content: none;\n }\n `,document.head.appendChild(e)})();const n=y(),t=(e=>{const n=document.createElement("button");return n.setAttribute("id",m),n.setAttribute("type","button"),n.setAttribute("aria-label",e),n.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>',n})(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 n=document.createElement("p");return n.setAttribute("id",f),n.innerText=e,n})(e.event.descriptionLabel),r=(e=>{const n=document.createElement("button");return n.setAttribute("id",h),n.setAttribute("type","button"),n.innerText=e,n})(e.event.focusLabel);return n.onclick=g(e.focus),r.onclick=g(e.focus),t.onclick=g(e.close),document.addEventListener("keydown",w),n.appendChild(t),n.appendChild(o),n.appendChild(i),n.appendChild(r),document.body.appendChild(n),n.focus(),n},b=()=>{try{const e=document.getElementById(u);e&&document.body.removeChild(e),document.removeEventListener("keydown",w)}catch(e){console.error(e)}},L="dintero-checkout-sdk-launch-pop-out",S=e=>{const{container:n}=e,t=document.getElementById(L),o=t||document.createElement("button");((e,{label:n,disabled:t,top:o,left:i,right:r,styles:s,onClick:a})=>{e.setAttribute("id",L),e.setAttribute("type","button"),"true"===t?e.setAttribute("disabled",t):e.removeAttribute("disabled"),e.onclick=n=>{n.preventDefault(),n.stopPropagation(),e.style.boxShadow="inset 0 0 10px rgba(34, 84, 65, 0.9)",a(),window.setTimeout((()=>{e.style.boxShadow="none"}),200)},e.innerText=n,e.style.position="absolute",e.style.top=o+"px",e.style.left=i+"px",e.style.right=r+"px";for(const[n,t]of Object.entries(s))e.style[n]=t})(o,e),t||n.appendChild(o)},C=()=>{try{const e=document.getElementById(L);e&&e.remove()}catch(e){console.error(e)}},k=Math.min(480,window.screen.width),x=Math.min(840,window.screen.height);let T;const E=async e=>{let n,t=-1;if(T&&!T.closed)return;const o=d(e);T=await((e,n,t,o)=>new Promise((i=>{try{const r=window.screenX+(window.outerWidth-t)/2,s=window.screenY+(window.outerHeight-o)/2,a=`width=${t},height=${o},left=${r},top=${s},location=no,menubar=no,toolbar=no,status=no`;let d,c=-1;const l=t=>{const o=t.source===d,r=t.origin===new URL(n).origin,s=t.data&&"AppLoaded"===t.data.type,a="popOut"===t.data.context,p=t.data.sid===e;o&&r&&s&&a&&p&&(clearTimeout(c),i(d),window.removeEventListener("message",l))};if(window.addEventListener("message",l),d=window.open(n,"dintero-checkout",a),!d)return console.log("createPopOutWindow no popOut"),void i(void 0);c=window.setTimeout((()=>{console.log("createPopOutWindow timeout"),i(void 0)}),3e3)}catch(e){i(void 0)}})))(e.sid,o,k,x);const i=()=>{window.clearInterval(t),t=-1,window.removeEventListener("beforeunload",r),T=void 0,e.onClose(),n&&n()},r=()=>{T&&T.close(),i()};return window.addEventListener("beforeunload",r),t=window.setInterval((()=>{T&&T.closed&&i()}),200),n=e.onOpen(T),{close:r,focus:()=>{T&&T.focus()},popOutWindow:T}},P=(e,n)=>{B(n),e.href&&r(e.href)},O=(e,n)=>{(e.height||0===e.height)&&n.iframe.setAttribute("style",`width:100%; height:${e.height}px;`)},A=(e,n)=>{try{n.iframe.scrollIntoView({block:"start",behavior:"smooth"})}catch(e){console.error(e)}},W=(e,n)=>{e.language&&(n.language=e.language)},$=(e,n)=>{const t={internalPopOutHandler:!0,eventTypes:[i.LanguageChanged],handler:(e,n)=>{var t,o,i;t=n.iframe,o=n.options.sid,i=e.language,t.contentWindow&&t.contentWindow.postMessage({type:"SetLanguage",sid:o,language:i},"*")}},r={internalPopOutHandler:!0,eventTypes:[o.SessionCancel,o.SessionPaymentOnHold,o.SessionPaymentAuthorized,o.SessionPaymentError],handler:(n,t)=>{if(n.href){C();try{e.close()}catch(e){console.error(e)}}else console.error("Payment Complete event missing href property")}},s=o=>{o.source===e&&"popOut"===o.data.context&&o.data.sid===n.options.sid&&[t,r,...n.handlers].forEach((e=>{e.eventTypes.includes(o.data.type)&&e.handler&&(e=>{try{e()}catch(e){console.error(e)}})((()=>{e.handler(o.data,n)}))}))};return window.addEventListener("message",s),()=>{window.removeEventListener("message",s)}},M=async(e,n)=>{const{close:t,focus:o,popOutWindow:i}=await E({sid:n.options.sid,endpoint:n.options.endpoint,shouldCallValidateSession:Boolean(n.options.onValidateSession),language:e.language,onOpen:e=>$(e,n),onClose:()=>{var e,t;b(),e=n.iframe,t=n.options.sid,e.contentWindow&&e.contentWindow.postMessage({type:"ClosedPopOut",sid:t},"*"),(e=>{try{const n=document.getElementById(L);n&&(e?n.setAttribute("disabled",e.toString()):n.removeAttribute("disabled"))}catch(e){console.error(e)}})(!1),n.popOutWindow=void 0}});return i?(r=n.iframe,s=n.options.sid,r.contentWindow&&r.contentWindow.postMessage({type:"OpenedPopOut",sid:s},"*"),n.popOutWindow=i,(e=>{try{if(document.getElementById(u))return;return v(e)}catch(e){console.error(e)}})({focus:o,close:t,event:e}),!0):(((e,n)=>{e.contentWindow&&e.contentWindow.postMessage({type:"OpenPopOutFailed",sid:n},"*")})(n.iframe,n.options.sid),!1);var r,s},_=async(e,n)=>{if(await M(e,n)&&n.options.onValidateSession){t=n.iframe,i=n.options.sid,t.contentWindow&&t.contentWindow.postMessage({type:"ValidatingPopOut",sid:i},"*");const r=((e,n)=>t=>{c(n.iframe,n.options.sid,t),t.success&&n.popOutWindow?n.popOutWindow.location.href=d({sid:n.options.sid,endpoint:n.options.endpoint,shouldCallValidateSession:!1,language:e.language}):(n.popOutWindow&&n.popOutWindow.close(),console.error(t.clientValidationError))})(e,n);try{n.options.onValidateSession({type:o.ValidateSession,session:n.session,callback:r},n,r)}catch(e){console.error(e),c(n.iframe,n.options.sid,{success:!1,clientValidationError:"Validation runtime error"})}}var t,i},V=(e,n)=>{(e=>e&&e.type===i.ShowPopOutButton)(e)&&(S({container:n.options.innerContainer,label:e.openLabel,top:e.top,left:e.left,right:e.right,styles:e.styles,disabled:e.disabled,onClick:()=>_(e,n)}),(e=>{const n=document.getElementById(h);n&&(n.innerText=e.focusLabel);const t=document.getElementById(f);t&&(t.innerText=e.descriptionLabel);const o=document.getElementById(m);o&&o.setAttribute("aria-label",e.descriptionLabel)})(e))},j=(e,n)=>{e.type===i.HidePopOutButton&&C()},B=e=>{if(C(),b(),e.popOutWindow)try{e.popOutWindow.close()}catch(e){console.error(e)}};e.embed=async e=>{const n=document.createElement("div");n.style.position="relative",n.style["box-sizing"]="border-box";const r={endpoint:"https://checkout.dintero.com",innerContainer:n,...e},{container:a,sid:d,language:p,endpoint:u,onSession:f,onSessionCancel:h,onPayment:m,onPaymentAuthorized:g,onPaymentError:y,onSessionNotFound:w,onSessionLocked:v,onSessionLockFailed:L,onActivePaymentType:S,onValidateSession:C,popOut:k}=r;let x;const T=[];let E=!1;a.appendChild(n);const{iframe:$,initiate:M}=((e,n,t)=>{if(!e||!e.appendChild)throw new Error("Invalid container");const o=document.createElement("iframe");return o.setAttribute("frameborder","0"),o.setAttribute("allowTransparency","true"),o.setAttribute("style","width:100%; height:0;"),o.setAttribute("sandbox","allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox"),o.setAttribute("allow","payment"),o.setAttribute("importance","high"),o.setAttribute("src",t),{iframe:o,initiate:async()=>new Promise(((n,t)=>{o.onload=()=>n(),o.onerror=()=>t(),e.appendChild(o)}))}})(n,0,s({sid:d,endpoint:u,language:p,ui:"inline",shouldCallValidateSession:void 0!==C,popOut:k})),_=(e,n,t)=>{if(!x)throw new Error("Unable to create action promise: checkout is undefined");return new Promise(((o,i)=>{const r=[];r.push(l({sid:d,endpoint:u,handler:e=>{r.forEach((e=>e.unsubscribe())),o(e)},eventTypes:[n],checkout:x,source:x.iframe.contentWindow})),r.push(l({sid:d,endpoint:u,handler:()=>{r.forEach((e=>e.unsubscribe())),i(`Received unexpected event: ${t}`)},eventTypes:[t],checkout:x,source:x.iframe.contentWindow})),e()}))},I=()=>_((()=>{((e,n)=>{e.contentWindow&&e.contentWindow.postMessage({type:"RefreshSession",sid:n},"*")})($,d)}),o.SessionUpdated,o.SessionNotFound),N=e=>{c($,d,e)},H=(e,n,i)=>(e,r)=>{if(!E){E=!0,B(r);const s=["sid","merchant_reference","transaction_id","error"].map((n=>[n,e[n]]));e.type!==o.SessionCancel||e.error||s.push(["error","cancelled"]),s.push(["language",r.language]),s.push(["sdk",t]);const a=s.filter((([e,n])=>n)).map((([e,n])=>`${e}=${n}`)).join("&");r.iframe.setAttribute("src",`${n}/embedResult/?${a}`),i(e,r)}},F=[{handler:W,eventTypes:[i.LanguageChanged]},{handler:O,eventTypes:[i.HeightChanged]},{handler:A,eventTypes:[i.ScrollToTop]},{handler:(e,n)=>{n.session=e.session,f&&f(e,n)},eventTypes:[o.SessionLoaded,o.SessionUpdated]},{eventTypes:[o.SessionPaymentOnHold],handler:m?H(0,u,m):P},{eventTypes:[o.SessionPaymentAuthorized],handler:g||m?H(0,u,g||m):P},{handler:h?H(0,u,h):P,eventTypes:[o.SessionCancel]},{handler:y?H(0,u,y):P,eventTypes:[o.SessionPaymentError]},{handler:w,eventTypes:[o.SessionNotFound]},{handler:(e,n)=>{v&&v(e,n,I)},eventTypes:[o.SessionLocked]},{handler:L,eventTypes:[o.SessionLockFailed]},{handler:S,eventTypes:[o.ActivePaymentProductType]},{handler:(e,n)=>{if(C)try{C({...e,callback:N},n,N)}catch(e){console.error(e),N({success:!1,clientValidationError:"Validation runtime error"})}},eventTypes:[o.ValidateSession]},{handler:V,eventTypes:[i.ShowPopOutButton]},{handler:j,eventTypes:[i.HidePopOutButton]}];return x={destroy:()=>{B(x),$&&(r.popOut&&b(),T.forEach((e=>e.unsubscribe())),$.parentElement&&n.removeChild($)),n.parentElement&&a.removeChild(n)},iframe:$,language:p,lockSession:()=>_((()=>{((e,n)=>{e.contentWindow&&e.contentWindow.postMessage({type:"LockSession",sid:n},"*")})($,d)}),o.SessionLocked,o.SessionLockFailed),refreshSession:I,setActivePaymentProductType:e=>{((e,n,t)=>{e.contentWindow&&e.contentWindow.postMessage({type:"SetActivePaymentProductType",sid:n,payment_product_type:t},"*")})($,d,e)},submitValidationResult:N,options:r,handlers:F,session:void 0,popOutWindow:void 0},F.forEach((({handler:e,eventTypes:n})=>{e&&T.push(l({sid:d,endpoint:u,handler:e,eventTypes:n,checkout:x,source:x.iframe.contentWindow}))})),await M(),x},e.redirect=e=>{const{sid:n,language:t,endpoint:o="https://checkout.dintero.com"}=e;r(s({sid:n,endpoint:o,language:t,shouldCallValidateSession:!1}))},Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=dintero-checkout-web-sdk.umd.min.js.map
{
"name": "@dintero/checkout-web-sdk",
"version": "0.6.1",
"description": "Dintero Checkout SDK for web frontends",
"main": "dist/dintero-checkout-web-sdk.cjs.js",
"module": "dist/dintero-checkout-web-sdk.esm.js",
"umd:main": "dist/dintero-checkout-web-sdk.umd.min.js",
"unpkg": "dist/dintero-checkout-web-sdk.umd.min.js",
"types": "dist/dintero-checkout-web-sdk.cjs.d.ts",
"preconstruct": {
"umdName": "dintero"
},
"scripts": {
"build": "preconstruct build",
"test": "$(yarn bin)/karma start",
"semantic-release": "semantic-release",
"prepublishOnly": "yarn run build"
},
"private": false,
"repository": {
"type": "git",
"url": "https://github.com/Dintero/Dintero.Checkout.Web.SDK.git"
},
"homepage": "https://github.com/Dintero/Dintero.Checkout.Web.SDK#readme",
"author": "Sven Nicolai Viig <sven@dintero.com> (http://dintero.com)",
"license": "MIT",
"bugs": {
"url": "https://github.com/Dintero/Dintero.Checkout.Web.SDK/issues"
},
"devDependencies": {
"@babel/preset-env": "^7.14.1",
"@babel/preset-typescript": "^7.13.0",
"@preconstruct/cli": "^2.1.5",
"@semantic-release/git": "^10.0.1",
"chai": "^4.2.0",
"karma": "^6.4.2",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^3.1.0",
"karma-mocha": "^2.0.1",
"karma-typescript": "^5.0.3",
"mocha": "^8.1.1",
"prettier": "^3.0.3",
"puppeteer": "^21.1.0",
"semantic-release": "^22.0.1",
"sinon": "^15.0.0",
"typescript": "^5.2.2"
},
"dependencies": {
"native-promise-only": "^0.8.1"
}
"name": "@dintero/checkout-web-sdk",
"version": "0.6.2",
"description": "Dintero Checkout SDK for web frontends",
"main": "dist/dintero-checkout-web-sdk.cjs.js",
"module": "dist/dintero-checkout-web-sdk.esm.js",
"umd:main": "dist/dintero-checkout-web-sdk.umd.min.js",
"unpkg": "dist/dintero-checkout-web-sdk.umd.min.js",
"types": "dist/dintero-checkout-web-sdk.cjs.d.ts",
"preconstruct": {
"umdName": "dintero"
},
"scripts": {
"postinstall": "patch -u node_modules/vitest/dist/vendor-node.a7c48fe1.js -i patches/vitest+0.34.6.patch --forward || true",
"build": "preconstruct build",
"lint": "prettier --cache --log-level warn -c --config .prettierrc.yml .",
"test": "$(yarn bin)/vitest --browser.name=chrome --browser.headless",
"semantic-release": "semantic-release",
"prepublishOnly": "yarn run build"
},
"private": false,
"repository": {
"type": "git",
"url": "https://github.com/Dintero/Dintero.Checkout.Web.SDK.git"
},
"homepage": "https://github.com/Dintero/Dintero.Checkout.Web.SDK#readme",
"author": "Sven Nicolai Viig <sven@dintero.com> (http://dintero.com)",
"license": "MIT",
"bugs": {
"url": "https://github.com/Dintero/Dintero.Checkout.Web.SDK/issues"
},
"devDependencies": {
"@babel/core": "7.13.0",
"@babel/preset-typescript": "7.13.0",
"@preconstruct/cli": "2.8.1",
"@semantic-release/git": "10.0.1",
"@vitest/browser": "0.34.6",
"prettier": "3.0.3",
"semantic-release": "22.0.5",
"typescript": "5.2.2",
"vitest": "0.34.6",
"webdriverio": "8.16.22"
},
"dependencies": {
"native-promise-only": "0.8.1"
}
}

@@ -61,6 +61,6 @@ # Dintero Checkout JavaScript SDK for frontend applications [![Actions Status](https://github.com/Dintero/Dintero.Checkout.Web.SDK/workflows/CI/badge.svg?branch=master)](https://github.com/Dintero/Dintero.Checkout.Web.SDK/actions?query=branch%3Amaster+workflow%3ACI+) [![npm latest version](https://img.shields.io/npm/v/@dintero/checkout-web-sdk/latest.svg)](https://www.npmjs.com/package/@dintero/checkout-web-sdk)

language: "no", // optional parameter, an ISO 639-1 two-letter language code
onSession: function(event, checkout) {
onSession: function (event, checkout) {
console.log("session", event.session);
},
onPayment: function(event, checkout) {
onPayment: function (event, checkout) {
console.log("transaction_id", event.transaction_id);

@@ -70,33 +70,36 @@ console.log("href", event.href);

},
onPaymentError: function(event, checkout) {
onPaymentError: function (event, checkout) {
console.log("href", event.href);
checkout.destroy();
},
onSessionCancel: function(event, checkout) {
onSessionCancel: function (event, checkout) {
console.log("href", event.href);
checkout.destroy();
},
onSessionNotFound: function(event, checkout) {
onSessionNotFound: function (event, checkout) {
console.log("session not found (expired)", event.type);
checkout.destroy();
},
onSessionLocked: function(event, checkout, callback) {
onSessionLocked: function (event, checkout, callback) {
console.log("pay_lock_id", event.pay_lock_id);
callback(); // refresh session
},
onSessionLockFailed: function(event, checkout) {
onSessionLockFailed: function (event, checkout) {
console.log("session lock failed");
},
onActivePaymentType: function(event, checkout) {
console.log("payment product type selected", event.payment_product_type);
onActivePaymentType: function (event, checkout) {
console.log(
"payment product type selected",
event.payment_product_type,
);
},
onValidateSession: function(event, checkout, callback) {
onValidateSession: function (event, checkout, callback) {
console.log("validating session", event.session);
callback({
success: true,
clientValidationError: undefined,
success: true,
clientValidationError: undefined,
});
},
})
.then(function(checkout) {
.then(function (checkout) {
console.log("checkout", checkout);

@@ -130,3 +133,6 @@ });

},
onPayment: (event: SessionPaymentAuthorized | SessionPaymentOnHold, checkout) => {
onPayment: (
event: SessionPaymentAuthorized | SessionPaymentOnHold,
checkout,
) => {
console.log("transaction_id", event.transaction_id);

@@ -155,6 +161,9 @@ console.log("href", event.href);

},
onActivePaymentType: function(event: ActivePaymentProductType, checkout) {
console.log("payment product type selected", event.payment_product_type);
onActivePaymentType: function (event: ActivePaymentProductType, checkout) {
console.log(
"payment product type selected",
event.payment_product_type,
);
},
onValidateSession: function(event: ValidateSession, checkout, callback) {
onValidateSession: function (event: ValidateSession, checkout, callback) {
console.log("validating session", event.session);

@@ -165,3 +174,3 @@ callback({

});
},
},
});

@@ -175,2 +184,3 @@ ```

Select "vipps" payment product type:
```

@@ -181,2 +191,3 @@ checkout.setActivePaymentProductType("vipps");

Resetting selection (so no option is selected in the checkout):
```

@@ -199,7 +210,10 @@ checkout.setActivePaymentProductType();

```js
checkout.lockSession().then(function(sessionLockedEvent){
// initiate server side session update and then refresh the session
}).catch(function(sessionLockFailedEvent) {
// handle failure to lock
});;
checkout
.lockSession()
.then(function (sessionLockedEvent) {
// initiate server side session update and then refresh the session
})
.catch(function (sessionLockFailedEvent) {
// handle failure to lock
});
```

@@ -233,3 +247,3 @@

callback(); // refresh session
}
};
```

@@ -253,3 +267,3 @@

{
success: true
success: true;
}

@@ -256,0 +270,0 @@ ```

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc