Skip to content
Closed
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 scripts/modal.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion scripts/processout.js

Large diffs are not rendered by default.

30 changes: 28 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,13 @@ 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 +247,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 All @@ -254,6 +262,24 @@ module ProcessOut {
}
}

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;
}

/**
* Handle will execute the customer action
* @param {callback} success
Expand Down
Loading