File "checkin.min.js.map"

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

{"version":3,"file":"checkin.min.js","names":["jQuery","$","window","wc_sb_checkin","customer_identified","init","this","isCheckinEnabled","self","loadCheckIn","document","body","on","event","preventDefault","showAddressFields","hideAddressFields","WC_Gateway_Swedbank_Pay_Checkin","enabled","isCheckinRequired","checkin_required","isCustomerIdentified","ajax","type","url","ajax_url","data","action","nonce","dataType","done","success","wc_sb_common","logError","alert","details","hasOwnProperty","payex","loadJs","initCheckIn","waitForLoading","err","console","warn","hostedView","consumer","container","culture","style","checkInStyle","JSON","parse","onConsumerIdentified","log","onNewConsumer","onConsumerRemoved","onBillingDetailsAvailable","onAddressDetailsAvailable","onShippingDetailsAvailable","needs_shipping_address","ship_to_billing_address_only","onError","open","consumerProfileRef","always","response","message","show","checkout_form","find","remove","append","isInstantCheckout","wc_sb_checkout","initCheckout","block","unblock","each","key","value","forEach","section","el","length","prop","closest","removeClass","val","change","el1","Select2","select2","fn","chosen","trigger","hide","ready"],"sources":["checkin.js"],"sourcesContent":["/* global wc_checkout_params */\njQuery( function( $ ) {\n    'use strict';\n\n    window.wc_sb_checkin = {\n        customer_identified: false,\n\n        /**\n         * Initialize\n         */\n        init: function() {\n            if ( this.isCheckinEnabled() ) {\n                var self = this;\n\n                self.loadCheckIn();\n\n                $( document.body ).on( 'click', '#change-address-info', function ( event ) {\n                    event.preventDefault();\n\n                    // Show Address Fields\n                    self.showAddressFields();\n                } );\n\n                self.hideAddressFields();\n            }\n        },\n\n        /**\n         * Check if the Checkin is active\n         * @return {boolean}\n         */\n        isCheckinEnabled() {\n            return 'yes' === WC_Gateway_Swedbank_Pay_Checkin.enabled;\n        },\n\n        /**\n         * Check if the Checkin is required\n         * @return {boolean}\n         */\n        isCheckinRequired() {\n            return this.isCheckinEnabled() && 'yes' === WC_Gateway_Swedbank_Pay_Checkin.checkin_required;\n        },\n\n        /**\n         * Check if customer was identified\n         * @return {boolean}\n         */\n        isCustomerIdentified() {\n            return this.customer_identified === true;\n        },\n\n        /**\n         * Load CheckIn\n         * @returns {*}\n         */\n        loadCheckIn: function() {\n            return $.ajax( {\n                type: 'POST',\n                url: WC_Gateway_Swedbank_Pay_Checkin.ajax_url,\n                data: {\n                    action: 'swedbank_pay_checkin',\n                    nonce: WC_Gateway_Swedbank_Pay_Checkin.nonce,\n                },\n                dataType: 'json'\n            } ).done( function ( data ) {\n                if ( ! data.success ) {\n                    wc_sb_common.logError( 'sb-checkin-loader', data );\n                    alert( data.details );\n                    return;\n                }\n\n                // Destroy\n                if ( window.hasOwnProperty( 'payex' ) && window.payex.hasOwnProperty( 'hostedView' ) ) {\n                    //if ( typeof window.payex.hostedView.consumer !== 'undefined' ) {\n                        //window.payex.hostedView.consumer().close();\n                    //}\n                }\n\n                // Destroy JS\n                //$( \"script[src*='px.consumer.client']\" ).remove();\n                //$( '#swedbank-pay-checkin iframe' ).remove();\n                wc_sb_common.loadJs( data.data, function () {\n                    wc_sb_checkin.initCheckIn();\n                } );\n            } );\n        },\n\n        /**\n         * Initialize CheckIn\n         */\n        initCheckIn: function() {\n            if ( typeof payex === 'undefined') {\n                return;\n            }\n\n            wc_sb_common.waitForLoading('payex.hostedView.consumer', function ( err ) {\n                if ( err ) {\n                    console.warn( err );\n                    return;\n                }\n\n                // Init PayEx hostedView\n                window.payex.hostedView.consumer( {\n                    container: 'swedbank-pay-checkin',\n                    culture: WC_Gateway_Swedbank_Pay_Checkin.culture,\n                    style: WC_Gateway_Swedbank_Pay_Checkin.checkInStyle ? JSON.parse( WC_Gateway_Swedbank_Pay_Checkin.checkInStyle ) : null,\n                    onConsumerIdentified: function( data ) {\n                        console.log( 'hostedView: onConsumerIdentified' );\n                        wc_sb_checkin.onConsumerIdentified( data );\n                    },\n                    onNewConsumer: function( data ) {\n                        console.log( 'hostedView: onNewConsumer' );\n                        wc_sb_checkin.onConsumerIdentified( data );\n                    },\n                    onConsumerRemoved: function( data ) {\n                        console.log( 'hostedView: onConsumerRemoved' );\n                        console.log ( data );\n                    },\n                    onBillingDetailsAvailable: function( data ) {\n                        wc_sb_checkin.onAddressDetailsAvailable( 'billing', data );\n                    },\n                    onShippingDetailsAvailable: function( data ) {\n                        if ( WC_Gateway_Swedbank_Pay_Checkin.needs_shipping_address === 'yes' ||\n                            WC_Gateway_Swedbank_Pay_Checkin.ship_to_billing_address_only === 'yes'\n                        ) {\n                            wc_sb_checkin.onAddressDetailsAvailable( 'billing', data );\n                        }\n\n                        wc_sb_checkin.onAddressDetailsAvailable( 'shipping', data );\n                    },\n                    onError: function ( data ) {\n                        wc_sb_common.logError( 'sb-checkin', data );\n                        alert( data.details );\n                    }\n                } ).open();\n            });\n        },\n\n        /**\n         * On Consumer Identified\n         * @param data\n         * @returns {*}\n         */\n        onConsumerIdentified: function ( data ) {\n            console.log( 'onConsumerIdentified', data );\n\n            var self = this;\n\n            return $.ajax( {\n                type: 'POST',\n                url: WC_Gateway_Swedbank_Pay_Checkin.ajax_url,\n                data: {\n                    action: 'swedbank_pay_checkout_customer_profile',\n                    nonce: WC_Gateway_Swedbank_Pay_Checkin.nonce,\n                    consumerProfileRef: data.consumerProfileRef\n                },\n                dataType: 'json'\n            } ).always( function ( response ) {\n                //\n            } ).done( function ( response) {\n                if (!response.success) {\n                    alert(response.data.message);\n                    return;\n                }\n\n                self.customer_identified = true;\n\n                // Show button witch allows to edit the address\n                $('#swedbank-pay-checkin-edit').show();\n\n                // Add the reference to the checkout form\n                let checkout_form = $( \"form.checkout, form#order_review, form#add_payment_method\" );\n                checkout_form.find( '.swedbank_pay_customer_reference' ).remove();\n                checkout_form.append( \"<input type='hidden' class='swedbank_pay_customer_reference' name='swedbank_pay_customer_reference' value='\" + data.consumerProfileRef + \"'/>\" );\n\n                // Initiate Instant Checkout if active\n                if ( wc_sb_common.isInstantCheckout() ) {\n                    wc_sb_checkout.initCheckout( data.consumerProfileRef );\n                }\n            } );\n        },\n\n        /**\n         * On Address Details Available\n         * @param type\n         * @param data\n         * @returns {*}\n         */\n        onAddressDetailsAvailable: function( type, data ) {\n            console.log( 'onAddressDetailsAvailable', type, data );\n\n            wc_sb_common.block();\n            return $.ajax( {\n                type: 'POST',\n                url: WC_Gateway_Swedbank_Pay_Checkin.ajax_url,\n                data: {\n                    action: 'swedbank_pay_checkout_get_address',\n                    nonce: WC_Gateway_Swedbank_Pay_Checkin.nonce,\n                    type: type,\n                    url: data.url\n                },\n                dataType: 'json'\n            } ).always( function () {\n                wc_sb_common.unblock();\n            } ).done( function ( response ) {\n                console.log( response );\n                if ( ! response.success ) {\n                    wc_sb_common.logError( 'sb-address-details', response );\n                    alert( response.data.message );\n                    return;\n                }\n\n                // Process address\n                let data = response.data;\n                $.each( data, function ( key, value ) {\n                    [type].forEach( function( section ) {\n                        let el = $( 'input[name=\"' + section + '_' + key + '\"]' );\n                        if ( el.length === 0 ) {\n                            return;\n                        }\n\n                        el.prop( 'readonly', false );\n                        el.closest( '.form-row' ).removeClass( 'swedbank-pay-locked' );\n                        el.val( value ).change();\n\n                        if ( key === 'country' || key === 'state' ) {\n                            let el1 = $( '#' + section + '_' + key );\n                            if ( typeof window.Select2 !== 'undefined' ) {\n                                el1.select2('val', value);\n                            } else if ( typeof $.fn.chosen !== 'undefined' ) {\n                                // Chosen\n                                el1.val( value ).trigger( 'chosen:updated' );\n                                //el1.chosen().change();\n                            } else {\n                                el1.change();\n                            }\n                        }\n                    } );\n                } );\n\n                $( document.body ).trigger( 'update_checkout' );\n            } );\n        },\n        /**\n         * Hide Address Fields on the checkout\n         */\n        hideAddressFields: function () {\n            $( '.woocommerce-billing-fields__field-wrapper, .woocommerce-shipping-fields' ).hide();\n        },\n        /**\n         * Show Address Fields on the checkout\n         */\n        showAddressFields: function () {\n            $( '.woocommerce-billing-fields__field-wrapper, .woocommerce-shipping-fields' ).show();\n        }\n    }\n\n    $( document ).ready( function () {\n        wc_sb_checkin.init( $( \"form.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