@@ -84,6 +84,9 @@ module ProcessOut {
8484 public static ThreeDSChallengeFlowNoIframe = "three-d-s-challenge-flow-no-iframe" ;
8585 public static ThreeDSFingerprintFlow = "three-d-s-fingerprint-flow" ;
8686
87+ // Specifies if merchant provided iframe override
88+ public iframeOverriden : boolean = false ;
89+
8790 /**
8891 *
8992 * @param actionType gateway string
@@ -146,6 +149,7 @@ module ProcessOut {
146149 this . flow = ActionFlow . IFrame ;
147150 this . iframeWidth = override . width ;
148151 this . iframeHeight = override . height ;
152+ this . iframeOverriden = true
149153 }
150154 }
151155 }
@@ -228,9 +232,12 @@ module ProcessOut {
228232 iframeWrapper . style . width = "100%" ;
229233 iframeWrapper . setAttribute ( "style" , "position: fixed; top: 0; left: 0; background: rgba(0, 0, 0, 0.5); z-index: 9999999; overflow: auto;" ) ;
230234
235+ const cancelButtonWrapperHeight = 80 ;
236+ const calculatedIframeHeight = this . calculateIframeHeight ( cancelButtonWrapperHeight ) ;
237+
231238 // Create the iframe to be used later
232239 var iframe = document . createElement ( "iframe" ) ;
233- 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;")` ) ;
240+ 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;")` ) ;
234241 iframe . setAttribute ( "frameborder" , "0" ) ;
235242 iframe . onload = function ( ) {
236243 // Remove the background loader once it is actually loaded
@@ -239,7 +246,7 @@ module ProcessOut {
239246
240247 // And create the cancel button
241248 var buttonWrapper = document . createElement ( "div" ) ;
242- buttonWrapper . setAttribute ( "style" , " width: 150px; text-align: center; margin: 0 auto 1em auto;" ) ;
249+ buttonWrapper . setAttribute ( "style" , ` width: 150px; height: ${ cancelButtonWrapperHeight } px; text-align: center; margin: 0 auto 1em auto;` ) ;
243250 var button = document . createElement ( "div" ) ;
244251 button . setAttribute ( "style" , "cursor: pointer; color: white;" ) ;
245252 button . innerHTML = Translator . translateMessage ( "label.cancel" , "Cancel" ) ;
@@ -551,6 +558,24 @@ module ProcessOut {
551558 return this . canceled ;
552559 }
553560
561+ private calculateIframeHeight ( cancelButtonWrapperHeight : number ) {
562+ const defaultIframeHeight = `${ this . options . iframeHeight } px` ;
563+
564+ // always respect merchant specified height
565+ if ( this . options . iframeOverriden ) {
566+ return defaultIframeHeight ;
567+ }
568+
569+ // For mobile devices we want to make iframe stretch for the whole height of screen
570+ // minus the cancel button wrapper height. This is to make sure that content of iframe
571+ // is not cut off.
572+ if ( window && window . innerWidth < 500 ) {
573+ return `calc(100% - ${ cancelButtonWrapperHeight } px)` ;
574+ }
575+
576+ return defaultIframeHeight ;
577+ }
578+
554579 }
555580
556581}
0 commit comments