Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "processout.js",
"version": "1.0.5",
"version": "1.0.6",
"description": "ProcessOut.js is a JavaScript library for ProcessOut's payment processing API.",
"scripts": {
"build:processout": "tsc -p src/processout && uglifyjs --compress --keep-fnames --ie8 dist/processout.js -o dist/processout.js",
Expand Down
29 changes: 27 additions & 2 deletions src/processout/actionhandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ module ProcessOut {
public static ThreeDSChallengeFlowNoIframe = "three-d-s-challenge-flow-no-iframe";
public static ThreeDSFingerprintFlow = "three-d-s-fingerprint-flow";

// Specifies if merchant provided iframe override
public iframeOverriden: boolean = false;

/**
*
* @param actionType gateway string
Expand Down Expand Up @@ -146,6 +149,7 @@ module ProcessOut {
this.flow = ActionFlow.IFrame;
this.iframeWidth = override.width;
this.iframeHeight = override.height;
this.iframeOverriden = true
}
}
}
Expand Down Expand Up @@ -228,9 +232,12 @@ module ProcessOut {
iframeWrapper.style.width = "100%";
iframeWrapper.setAttribute("style", "position: fixed; top: 0; left: 0; background: rgba(0, 0, 0, 0.5); z-index: 9999999; overflow: auto;");

const cancelButtonWrapperHeight = 80;
const calculatedIframeHeight = this.calculateIframeHeight(cancelButtonWrapperHeight);

// Create the iframe to be used later
var iframe = document.createElement("iframe");
iframe.setAttribute("style", `margin: 1em auto; width: ${this.options.iframeWidth}px; height: ${this.options.iframeHeight}px; max-width: 100%; max-height: 100%; display: block; box-shadow: 0 15px 35px rgba(50, 50, 93, 0.1), 0 5px 15px rgba(0, 0, 0, 0.07); background-color: #ECEFF1; background-image: url("${this.instance.endpoint("js", "/images/loader.gif")}"); background-repeat: no-repeat; background-position: center;")`);
iframe.setAttribute("style", `margin: 1em auto; width: ${this.options.iframeWidth}px; height: ${calculatedIframeHeight}; max-width: 100%; max-height: 100%; display: block; box-shadow: 0 15px 35px rgba(50, 50, 93, 0.1), 0 5px 15px rgba(0, 0, 0, 0.07); background-color: #ECEFF1; background-image: url("${this.instance.endpoint("js", "/images/loader.gif")}"); background-repeat: no-repeat; background-position: center;")`);
iframe.setAttribute("frameborder", "0");
iframe.onload = function() {
// Remove the background loader once it is actually loaded
Expand All @@ -239,7 +246,7 @@ module ProcessOut {

// And create the cancel button
var buttonWrapper = document.createElement("div");
buttonWrapper.setAttribute("style", "width: 150px; text-align: center; margin: 0 auto 1em auto;");
buttonWrapper.setAttribute("style", `width: 150px; height: ${cancelButtonWrapperHeight}px; text-align: center; margin: 0 auto 1em auto;`);
var button = document.createElement("div");
button.setAttribute("style", "cursor: pointer; color: white;");
button.innerHTML = Translator.translateMessage("label.cancel", "Cancel");
Expand Down Expand Up @@ -551,6 +558,24 @@ module ProcessOut {
return this.canceled;
}

private calculateIframeHeight(cancelButtonWrapperHeight: number) {
const defaultIframeHeight = `${this.options.iframeHeight}px`;

// always respect merchant specified height
if (this.options.iframeOverriden) {
return defaultIframeHeight;
}

// For mobile devices we want to make iframe stretch for the whole height of screen
// minus the cancel button wrapper height. This is to make sure that content of iframe
// is not cut off.
if (window && window.innerWidth < 500) {
return `calc(100% - ${cancelButtonWrapperHeight}px)`;
}

return defaultIframeHeight;
}

}

}