third_party/gpay/src/pay_frame_helper.js
/**
   * Creates a hidden iframe for logging and appends it to the top level
   * document.
   */
Creates a hidden iframe for logging and appends it to the top level
document.
Creates a hidden iframe for logging and appends it to the top level document .
static load() {
    if (iframe) {
      return;
    }
    const initOptions =
         (window['gpayInitParams']) || {};
    environment = initOptions.environment || Constants.Environment.PRODUCTION;
    iframe = document.createElement('iframe');
    iframe.src = PayFrameHelper.getIframeUrl_(
            window.location.origin,
            initOptions.merchantInfo && initOptions.merchantInfo.merchantId);
    PayFrameHelper.postMessage({
      'eventType': PostMessageEventType.LOG_PAY_FRAME_REQUESTED,
      'clientLatencyStartMs': Date.now(),
    });
    iframe.height = '0';
    iframe.width = '0';
    iframe.style.display = 'none';
    iframe.style.visibility = 'hidden';
    iframe.onload = function() {
      PayFrameHelper.postMessage({
        'eventType': PostMessageEventType.LOG_PAY_FRAME_LOADED_WITH_ALL_JS,
        'clientLatencyStartMs': Date.now(),
      });
      PayFrameHelper.iframeLoaded();
    };
    if (document.body) {
      PayFrameHelper.initialize_();
    } else {
      document.addEventListener(
          'DOMContentLoaded', () => PayFrameHelper.initialize_());
    }
  }
static load ( ) { if ( iframe ) { return ; } const initOptions = ( window [ 'gpayInitParams' ] ) || { } ; environment = initOptions . environment || Constants . Environment . PRODUCTION ; iframe = document . createElement ( 'iframe' ) ; iframe . src = PayFrameHelper . getIframeUrl_ ( window . location . origin , initOptions . merchantInfo && initOptions . merchantInfo . merchantId ) ; PayFrameHelper . postMessage ( { 'eventType' : PostMessageEventType . LOG_PAY_FRAME_REQUESTED , 'clientLatencyStartMs' : Date . now ( ) , } ) ; iframe . height = '0' ; iframe . width = '0' ; iframe . style . display = 'none' ; iframe . style . visibility = 'hidden' ; iframe . onload = function ( ) { PayFrameHelper . postMessage ( { 'eventType' : PostMessageEventType . LOG_PAY_FRAME_LOADED_WITH_ALL_JS , 'clientLatencyStartMs' : Date . now ( ) , } ) ; PayFrameHelper . iframeLoaded ( ) ; } ; if ( document . body ) { PayFrameHelper . initialize_ ( ) ; } else { document . addEventListener ( 'DOMContentLoaded' , ( ) => PayFrameHelper . initialize_ ( ) ) ; } }
Creates a hidden iframe for logging and appends it to the top level
 document.
Creates a hidden iframe for logging and appends it to the top level document .
/** @type {!PaymentOptions} */ // Pass in origin because document.referrer inside iframe is empty in // certain cases // Can be replaced by iframe.src=... in non Google context. // If the body is already loaded, just append the iframe. Otherwise, we wait // until the DOM has loaded to append the iframe, otherwise document.body is // null.