File "seamless.min.js.map"

Full Path: /home/siazco/grocery.siazco.se/wp-content/plugins/swedbank-pay-payments/assets/js/seamless.min.js.map
File size: 14.6 KB
MIME-type: application/json
Charset: utf-8

{"version":3,"file":"seamless.min.js","names":["jQuery","$","window","wc_sb_seamless","xhr","init","form","this","form_submit","js_url","on","obj","onSubmit","gateway_id","addAjaxHook","event","data","validateForm","console","log","is","waitForJsUrl","$required_inputs","validated","find","not","length","each","$this","$parent","closest","validate_required","validate_email","attr","val","RegExp","test","setJsUrl","url","self","interval","setInterval","clearInterval","initFrame","callback","remove","loadJs","featherlight","variant","persist","closeOnClick","closeOnEsc","afterOpen","initPaymentMenu","afterClose","removeClass","unblock","js","script","document","createElement","setAttribute","addEventListener","oHead","getElementsByTagName","appendChild","id","paymentMenu","payex","hostedView","container","culture","onApplicationConfigured","onPaymentCreated","onPaymentCompleted","location","href","redirectUrl","onPaymentCanceled","onPaymentFailed","onError","open","ajaxComplete","settings","wc_checkout_params","checkout_url","indexOf","responseText","result","JSON","parse","hasOwnProperty","key","e"],"sources":["seamless.js"],"sourcesContent":["/* global wc_checkout_params */\njQuery( function( $ ) {\n    'use strict';\n\n    /**\n     * Object to handle Seamless payment forms.\n     */\n    window.wc_sb_seamless = {\n        xhr: false,\n\n        /**\n         * Initialize e handlers and UI state.\n         */\n        init: function( form ) {\n            this.form         = form;\n            this.form_submit  = false;\n            this.js_url       = null;\n\n            // We need to bind directly to the click (and not checkout_place_order_{gateway}) to avoid popup blockers\n            // especially on mobile devices (like on Chrome for iOS) from blocking payex.hostedView from opening a tab\n            $( this.form )\n                .on( 'click', '#place_order', {'obj': this}, this.onSubmit );\n\n            // WooCommerce lets us return a false on checkout_place_order_{gateway} to keep the form from submitting\n            $( this.form ).on( 'submit checkout_place_order_' + this.gateway_id );\n\n            this.addAjaxHook();\n        },\n\n        onSubmit: function( event ) {\n            if ( event.data.obj.form_submit ) {\n                return true;\n            }\n\n            if ( ! event.data.obj.validateForm() ) {\n                return false;\n            }\n\n            console.log( 'onSubmit' );\n\n            if ( event.data.obj.form.is( '.processing' ) ) {\n                return false;\n            }\n\n            console.log(this.js_url);\n            event.data.obj.waitForJsUrl();\n        },\n\n        /**\n         * Validate checkout fields on the checkout form\n         * @return {boolean}\n         */\n        validateForm: function () {\n            var $required_inputs,\n                validated = true;\n\n            // check to see if we need to validate shipping address\n            if ( $( '#ship-to-different-address-checkbox' ).is( ':checked' ) ) {\n                $required_inputs = $( '.woocommerce-billing-fields .validate-required, .woocommerce-shipping-fields .validate-required' ).find('input, select').not( $( '#account_password, #account_username' ) );\n            } else {\n                $required_inputs = $( '.woocommerce-billing-fields .validate-required' ).find('input, select').not( $( '#account_password, #account_username' ) );\n            }\n\n            if ( $required_inputs.length ) {\n                $required_inputs.each( function() {\n                    var $this = $( this ),\n                        $parent           = $this.closest( '.form-row' ),\n                        validate_required = $parent.is( '.validate-required' ),\n                        validate_email    = $parent.is( '.validate-email' );\n\n                    if ( validate_required ) {\n                        if ( 'checkbox' === $this.attr( 'type' ) && ! $this.is( ':checked' ) ) {\n                            validated = false;\n                        } else if ( $this.val() === '' ) {\n                            validated = false;\n                        }\n                    }\n\n                    if ( validate_email ) {\n                        if ( $this.val() ) {\n                            /* https://stackoverflow.com/questions/2855865/jquery-validate-e-mail-address-regex */\n                            var pattern = new RegExp(/^((([a-z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])+(\\.([a-z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])+)*)|((\\x22)((((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(([\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]|\\x21|[\\x23-\\x5b]|[\\x5d-\\x7e]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(\\\\([\\x01-\\x09\\x0b\\x0c\\x0d-\\x7f]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]))))*(((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(\\x22)))@((([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])*([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])))\\.)+(([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])*([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])))\\.?$/i);\n                            if ( ! pattern.test( $this.val()  ) ) {\n                                validated = false;\n                            }\n                        }\n                    }\n                });\n            }\n\n            return validated;\n        },\n\n        /**\n         * Set Js url.\n         *\n         * @param url\n         */\n        setJsUrl: function ( url ) {\n            console.log( 'setJsUrl' );\n            console.log( url );\n            this.js_url = url;\n        },\n\n        /**\n         * Wait for JS url availability\n         */\n        waitForJsUrl: function () {\n            var self = this;\n            let interval = window.setInterval( function () {\n                if ( self.js_url ) {\n                    console.log( 'waitForJsUrl: ' + self.js_url )\n                    window.clearInterval( interval );\n                    self.initFrame( self.js_url, function () {\n                        self.js_url = null;\n                    } );\n                }\n            }, 1000 );\n        },\n\n        /**\n         * Init frame.\n         *\n         * @param url\n         * @param callback\n         */\n        initFrame: function ( url, callback ) {\n            if ( typeof callback === 'undefined' ) {\n                callback = function () {};\n            }\n\n            // Destroy old script instances\n            $( \"script[src*='px.creditcard.client.js']\" ).remove();\n            $( \"script[src*='px.invoice.client.js']\" ).remove();\n            $( \"script[src*='px.mobilepay.client.js']\" ).remove();\n            $( \"script[src*='px.swish.client.js']\" ).remove();\n            $( \"script[src*='px.trustly.client.js']\" ).remove();\n            $( \"script[src*='px.vipps.client.js']\" ).remove();\n\n            // Load JS\n            var self = this;\n            this.loadJs( url, function () {\n                $( '.swedbank-pay-seamless iframe' ).remove();\n\n                $.featherlight( '<div class=\"swedbank-pay-seamless\" id=\"swedbank-pay-seamless' + self.gateway_id + '\">&nbsp;</div>', {\n                    variant: 'featherlight-swedbank-seamless',\n                    persist: false,\n                    closeOnClick: false,\n                    closeOnEsc: false,\n                    afterOpen: function () {\n                        console.log(self);\n                        self.initPaymentMenu( 'swedbank-pay-seamless' + self.gateway_id );\n                    },\n                    afterClose: function () {\n                        $( '.swedbank-pay-seamless iframe' ).remove();\n                        self.form.removeClass( 'processing' ).unblock();\n                    }\n                } );\n\n                callback()\n            } );\n        },\n\n        /**\n         * Load JS\n         * @param js\n         * @param callback\n         */\n        loadJs: function ( js, callback ) {\n            // Creates a new script tag\n            let script = document.createElement( 'script' );\n\n            // Set script tag params\n            script.setAttribute( 'src', js );\n            script.setAttribute( 'type', 'text/javascript' );\n            script.setAttribute( 'async', '' );\n            script.addEventListener( 'load', function () {\n                callback();\n            }, false );\n\n            // Gets document head element\n            let oHead = document.getElementsByTagName( 'head' )[0];\n            if ( oHead ) {\n                // Add script tag to head\n                oHead.appendChild( script );\n            }\n\n            return script;\n        },\n\n        /**\n         * Initiate Payment Menu.\n         * Payment Javascript must be loaded.\n         *\n         * @param id\n         * @param callback\n         */\n        initPaymentMenu: function ( id, callback ) {\n            console.log( 'initPaymentMenu' );\n\n            if ( typeof callback === 'undefined' ) {\n                callback = function () {};\n            }\n\n            // Load payment frame\n            // @see https://developer.swedbankpay.com/payment-instruments/card/other-features#seamless-view-events\n            this.paymentMenu = window.payex.hostedView[this.hostedView]( {\n                container: id,\n                culture: this.culture,\n                onApplicationConfigured: function( data ) {\n                    console.log( 'onApplicationConfigured' );\n                    console.log( data );\n                    callback( null );\n                },\n                onPaymentCreated: function ( data ) {\n                    console.log( 'onPaymentCreated' );\n                    console.log( data.id );\n                },\n                onPaymentCompleted: function ( data ) {\n                    console.log( 'onPaymentCompleted' );\n                    console.log( data );\n\n                    self.location.href = data.redirectUrl;\n                },\n                onPaymentCanceled: function ( data ) {\n                    console.log( 'onPaymentCanceled' );\n                    console.log( data );\n                },\n                onPaymentFailed: function ( data ) {\n                    console.log( 'onPaymentFailed' );\n                    console.log( data );\n\n                    self.location.href = data.redirectUrl;\n                },\n                onError: function ( data ) {\n                    console.log( data );\n                    callback( data );\n                }\n            } );\n\n            this.paymentMenu.open();\n        },\n\n        addAjaxHook: function () {\n            var self = this;\n\n            $( document ).ajaxComplete( function ( event, xhr, settings ) {\n                if ( ( settings.url === wc_checkout_params.checkout_url ) || ( settings.url.indexOf( 'wc-ajax=complete_order' ) > -1 ) ) {\n                    const data = xhr.responseText;\n\n                    // Parse\n                    try {\n                        const result = JSON.parse( data );\n\n                        // Check is response from payment gateway\n                        if ( ! result.hasOwnProperty( self.key ) ) {\n                            return false;\n                        }\n\n                        // Save js_url value\n                        self.setJsUrl( result.js_url );\n                    } catch ( e ) {\n                        return false;\n                    }\n                }\n            } );\n        }\n    }\n} );\n"],"mappings":"AACAA,QAAQ,SAAUC,GACd,aAKAC,OAAOC,eAAiB,CACpBC,KAAK,EAKLC,KAAM,SAAUC,GACZC,KAAKD,KAAeA,EACpBC,KAAKC,aAAe,EACpBD,KAAKE,OAAe,KAIpBR,EAAGM,KAAKD,MACHI,GAAI,QAAS,eAAgB,CAACC,IAAOJ,MAAOA,KAAKK,UAGtDX,EAAGM,KAAKD,MAAOI,GAAI,+BAAiCH,KAAKM,YAEzDN,KAAKO,aACT,EAEAF,SAAU,SAAUG,GAChB,QAAKA,EAAMC,KAAKL,I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