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D,QAAS,oBACvC3D,EAAGE,EAAuBQ,sBAAuB8H,YAChD,cAMDxI,EAAG,6EAGDsH,SAEFtH,EAAGE,EAAuBQ,sBAAuBiC,QAASuG,GAI1DlJ,EAAGE,EAAuBQ,sBACxByI,KAAM,uCACNxF,QAAS,YACTqD,OACFhH,EAAGe,SAAS2C,MAAOC,QAAS,iBAAkB,CAAEsF,IAChDjJ,EAAG,cAAeuD,QACjB,CACCC,UACCxD,EAAGE,EAAuBQ,sBAAuB2C,SAC/CC,IAAM,KAEV,OAKHpD,EAAuBY,W","sources":["webpack://dibs-easy-for-woocommerce/./node_modules/@babel/runtime/helpers/esm/typeof.js","webpack://dibs-easy-for-woocommerce/./assets/js/nets-easy-for-woocommerce.js"],"sourcesContent":["export default function _typeof(obj) {\n \"@babel/helpers - typeof\";\n\n return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) {\n return typeof obj;\n } : function (obj) {\n return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n }, _typeof(obj);\n}","/**\n * @member wcDibsEasy\n *\n */\njQuery( function( $ ) {\n\tif ( typeof wcDibsEasy === 'undefined' ) {\n\t\treturn false;\n\t}\n\t/**\n\t * The main object.\n\t *\n\t * @type {Object} dibsEasyForWoocommerce\n\t */\n\tconst dibsEasyForWoocommerce = {\n\t\tbodyEl: $( 'body' ),\n\t\tpaymentMethodEl: $( 'input[name=\"payment_method\"]' ),\n\t\tdibsCheckout: null,\n\t\tblocked: false,\n\t\tselectAnotherSelector: '#dibs-easy-select-other',\n\t\tcheckoutInitiated: wcDibsEasy.checkoutInitiated,\n\t\tdibsOrderProcessing: false,\n\t\tcheckoutFormSelector: 'form.checkout',\n\t\tstandardWooFields: wcDibsEasy.standard_woo_checkout_fields,\n\t\twooTerms: 'form.checkout #terms',\n\n\t\t/**\n\t\t * Initialize the gateway\n\t\t */\n\t\tinit() {\n\t\t\t$( document ).ready( dibsEasyForWoocommerce.loadDibs );\n\t\t\tdibsEasyForWoocommerce.bodyEl.on(\n\t\t\t\t'change',\n\t\t\t\t'input[name=\"payment_method\"]',\n\t\t\t\tdibsEasyForWoocommerce.maybeChangeToDibsEasy\n\t\t\t);\n\t\t\tdibsEasyForWoocommerce.bodyEl.on(\n\t\t\t\t'click',\n\t\t\t\tdibsEasyForWoocommerce.selectAnotherSelector,\n\t\t\t\tdibsEasyForWoocommerce.changeFromDibsEasy\n\t\t\t);\n\t\t},\n\n\t\t/**\n\t\t * Check if DIBS Easy is the selected gateway.\n\t\t */\n\t\tdibsIsSelected() {\n\t\t\tif ( dibsEasyForWoocommerce.paymentMethodEl.length > 0 ) {\n\t\t\t\tdibsEasyForWoocommerce.paymentMethod =\n\t\t\t\t\tdibsEasyForWoocommerce.paymentMethodEl\n\t\t\t\t\t\t.filter( ':checked' )\n\t\t\t\t\t\t.val();\n\t\t\t\tif ( 'dibs_easy' === dibsEasyForWoocommerce.paymentMethod ) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn false;\n\t\t},\n\t\t/**\n\t\t * Triggers on document ready.\n\t\t */\n\t\tloadDibs() {\n\t\t\tif ( dibsEasyForWoocommerce.dibsIsSelected() ) {\n\t\t\t\tdibsEasyForWoocommerce.moveExtraCheckoutFields();\n\t\t\t\tdibsEasyForWoocommerce.initDibsCheckout();\n\t\t\t\tdibsEasyForWoocommerce.bodyEl.on( 'update_checkout', dibsEasyForWoocommerce.updateCheckout );\n\t\t\t\tdibsEasyForWoocommerce.bodyEl.on( 'updated_checkout', dibsEasyForWoocommerce.updatedCheckout );\n\t\t\t}\n\t\t},\n\t\t/**\n\t\t * Triggers after a successful payment.\n\t\t *\n\t\t * @param {Object} response\n\t\t */\n\t\tpaymentCompleted( response ) {\n\t\t\tdibsEasyForWoocommerce.logToFile( `Payment completed is triggered with payment id: ${ response.paymentId }` );\n\t\t\tconst redirectUrl = sessionStorage.getItem( 'redirectNets' );\n\t\t\tif ( redirectUrl ) {\n\t\t\t\twindow.location.href = redirectUrl;\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Display login error\n\t\t *\n\t\t * @param {string} message\n\t\t */\n\t\tdisplayMustLoginError( message ) {\n\t\t\tconst mustLoginClass = 'woocommerce-NoticeGroupwoocommerce-NoticeGroup-updateOrderReview';\n\t\t\tconst mustLoginNotice = `
\n\t\t\t\t\n\t\t\t
`;\n\t\t\tdibsEasyForWoocommerce.checkoutFormSelector.prepend(\n\t\t\t\tmustLoginNotice\n\t\t\t);\n\t\t},\n\t\t/**\n\t\t * Update WC form if needed\n\t\t *\n\t\t * @param {Object} data\n\t\t */\n\t\tupdateAddress( data ) {\n\t\t\tif ( 'yes' === data.updateNeeded ) {\n\t\t\t\t$( '#billing_country' ).val( data.country );\n\t\t\t\t$( '#shipping_country' ).val( data.country );\n\t\t\t\t$( '#billing_postcode' ).val( data.postCode );\n\t\t\t\t$( '#shipping_postcode' ).val( data.postCode );\n\t\t\t}\n\n\t\t\tif ( 'yes' === data.mustLogin ) {\n\t\t\t\t// Customer might need to log in. Inform customer and freeze DIBS checkout.\n\t\t\t\tdibsEasyForWoocommerce.displayMustLoginError( data.mustLoginMessage );\n\t\t\t\tdibsEasyForWoocommerce.dibsCheckout.freezeCheckout();\n\n\t\t\t\tconst etop =\n\t\t\t\t\tdibsEasyForWoocommerce.checkoutFormSelector.offset().top;\n\t\t\t\t$( 'html, body' ).animate(\n\t\t\t\t\t{\n\t\t\t\t\t\tscrollTop: etop,\n\t\t\t\t\t},\n\t\t\t\t\t1000\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\t// All good release checkout and trigger update_checkout event\n\t\t\t\tdibsEasyForWoocommerce.dibsCheckout.thawCheckout();\n\t\t\t\t$( document.body ).trigger( 'update_checkout' );\n\t\t\t}\n\t\t},\n\n\t\tupdateCheckout() {\n\t\t\tconsole.log( 'update_checkout' );\n\t\t\tif ( window.Dibs !== undefined ) {\n\t\t\t\t// lock iframe\n\t\t\t\tdibsEasyForWoocommerce.dibsCheckout.freezeCheckout();\n\t\t\t}\n\t\t},\n\t\tupdatedCheckout() {\n\t\t\tconsole.log( 'updated_checkout' );\n\t\t\tif ( window.Dibs !== undefined ) {\n\t\t\t\t// unlock iframe\n\t\t\t\tdibsEasyForWoocommerce.dibsCheckout.thawCheckout();\n\t\t\t\t$( '#dibs-order-review' ).unblock();\n\t\t\t}\n\t\t},\n\t\t/**\n\t\t * Triggers whenever customer updates address information\n\t\t *\n\t\t * @param {Object} address\n\t\t */\n\t\taddressChanged( address ) {\n\t\t\tdibsEasyForWoocommerce.logToFile( 'Address changed is triggered.' );\n\t\t\tif ( address ) {\n\t\t\t\tconsole.log( 'address-changed' );\n\t\t\t\tconsole.log( address );\n\t\t\t\t$.ajax( {\n\t\t\t\t\ttype: 'POST',\n\t\t\t\t\tdataType: 'json',\n\t\t\t\t\tasync: true,\n\t\t\t\t\turl: wcDibsEasy.customer_address_updated_url,\n\t\t\t\t\tdata: {\n\t\t\t\t\t\taction: 'customer_address_updated',\n\t\t\t\t\t\taddress,\n\t\t\t\t\t\tnonce: wcDibsEasy.nets_checkout_nonce,\n\t\t\t\t\t},\n\t\t\t\t\tsuccess( response ) {},\n\t\t\t\t\terror( response ) {},\n\t\t\t\t\tcomplete( response ) {\n\t\t\t\t\t\tconsole.log( 'COMPLETED' );\n\t\t\t\t\t\tconsole.log( 'customer_address_updated ' );\n\t\t\t\t\t\tconsole.log( response.responseJSON.data );\n\t\t\t\t\t\tdibsEasyForWoocommerce.updateAddress(\n\t\t\t\t\t\t\tresponse.responseJSON.data\n\t\t\t\t\t\t);\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t},\n\t\t/**\n\t\t * Init Dibs Easy Checkout\n\t\t */\n\t\tinitDibsCheckout() {\n\t\t\t// Constructs a new Checkout object.\n\t\t\tdibsEasyForWoocommerce.dibsCheckout = new Dibs.Checkout( {\n\t\t\t\tcheckoutKey: wcDibsEasy.privateKey,\n\t\t\t\tpaymentId: wcDibsEasy.dibs_payment_id,\n\t\t\t\tcontainerId: 'dibs-complete-checkout',\n\t\t\t\tlanguage: wcDibsEasy.locale,\n\t\t\t} );\n\t\t\tdibsEasyForWoocommerce.dibsCheckout.on(\n\t\t\t\t'pay-initialized',\n\t\t\t\tdibsEasyForWoocommerce.getDibsEasyOrder\n\t\t\t);\n\t\t\tdibsEasyForWoocommerce.dibsCheckout.on(\n\t\t\t\t'payment-completed',\n\t\t\t\tdibsEasyForWoocommerce.paymentCompleted\n\t\t\t);\n\t\t\tdibsEasyForWoocommerce.dibsCheckout.on(\n\t\t\t\t'address-changed',\n\t\t\t\tdibsEasyForWoocommerce.addressChanged\n\t\t\t);\n\t\t},\n\t\t/**\n\t\t * Triggers when customer clicks the pay button.\n\t\t * Gets the Nets Easy order and starts the order submission\n\t\t *\n\t\t * @param {string} paymentId\n\t\t */\n\t\tgetDibsEasyOrder( paymentId ) {\n\t\t\tdibsEasyForWoocommerce.dibsOrderProcessing = true;\n\t\t\tdibsEasyForWoocommerce.logToFile( `Pay initialized is triggered with payment id: ${ paymentId }` );\n\t\t\t$( document.body ).trigger( 'dibs_pay_initialized' );\n\t\t\t$.ajax( {\n\t\t\t\ttype: 'POST',\n\t\t\t\tdataType: 'json',\n\t\t\t\tasync: true,\n\t\t\t\turl: wcDibsEasy.get_order_data_url,\n\t\t\t\tdata: {\n\t\t\t\t\taction: 'payment_success',\n\t\t\t\t\tpaymentId,\n\t\t\t\t\tnonce: wcDibsEasy.nets_checkout_nonce,\n\t\t\t\t},\n\t\t\t\tsuccess( data ) {\n\t\t\t\t\tconsole.log( data );\n\t\t\t\t\tif ( false === data.success ) {\n\t\t\t\t\t\tconsole.log( 'PaymentID already exist in order' );\n\t\t\t\t\t\tconsole.log( data );\n\t\t\t\t\t\tif ( data.data.redirect ) {\n\t\t\t\t\t\t\twindow.location.href = data.data.redirect;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdibsEasyForWoocommerce.setAddressData( data );\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\terror( data ) {\n\t\t\t\t\tconsole.log( data, 'error_data' );\n\t\t\t\t},\n\t\t\t\tcomplete( data ) {},\n\t\t\t} );\n\t\t},\n\t\t/**\n\t\t * Sets the customer data.\n\t\t *\n\t\t * @param {Object} data\n\t\t */\n\t\tsetAddressData( data ) {\n\t\t\tdibsEasyForWoocommerce.logToFile( 'Received \"customer data\" from Nets Easy' );\n\t\t\tconst consumer = data.data.payment.consumer;\n\t\t\tconst { billingAddress, shippingAddress } = consumer;\n\n\t\t\t// billingAddress have country with 3 letters.\n\n\t\t\t// check do we have data\n\t\t\tconst hasBillingData = typeof billingAddress === 'object' && ! Array.isArray( billingAddress );\n\t\t\t// Use shipping data if billing data do not exist.\n\t\t\t$( '#billing_address_1' ).val( hasBillingData ? billingAddress.addressLine1 : shippingAddress.addressLine1 );\n\t\t\t$( '#billing_postcode' ).val( hasBillingData ? billingAddress.postalCode : shippingAddress.postalCode );\n\t\t\t$( '#billing_city' ).val( hasBillingData ? billingAddress.city : shippingAddress.city );\n\t\t\t$( '#billing_country' ).val( shippingAddress.country );\n\n\t\t\t$( '#shipping_address_1' ).val( shippingAddress.addressLine1 );\n\t\t\t$( '#shipping_postcode' ).val( shippingAddress.postalCode );\n\t\t\t$( '#shipping_city' ).val( shippingAddress.city );\n\t\t\t$( '#shipping_country' ).val( shippingAddress.country );\n\n\t\t\tif ( consumer.company.hasOwnProperty( 'name' ) ) {\n\t\t\t\t// B2B purchase\n\t\t\t\tconst company = consumer.company;\n\t\t\t\tconst { firstName, lastName, email, phoneNumber } = company.contactDetails;\n\t\t\t\tconst { prefix, number } = phoneNumber;\n\t\t\t\t$( '#billing_company' ).val( company.name );\n\t\t\t\t$( '#shipping_company' ).val( company.name );\n\t\t\t\t$( '#billing_first_name' ).val( firstName );\n\t\t\t\t$( '#billing_last_name' ).val( lastName );\n\t\t\t\t$( '#shipping_first_name' ).val( firstName );\n\t\t\t\t$( '#shipping_last_name' ).val( lastName );\n\t\t\t\t$( '#billing_email' ).val( email );\n\t\t\t\t$( '#billing_phone' ).val( `${ prefix }${ number }` );\n\t\t\t\t// trigger events for 3rd part plugins.\n\t\t\t\t$( '#billing_country' ).change();\n\t\t\t\t$( '#billing_email' ).change();\n\t\t\t\t$( '#billing_email' ).blur();\n\t\t\t} else {\n\t\t\t\t// B2C purchase\n\t\t\t\tconst { firstName, lastName, email, phoneNumber } = consumer.privatePerson;\n\t\t\t\tconst { prefix, number } = phoneNumber;\n\t\t\t\t$( '#billing_company' ).val( '' );\n\t\t\t\t$( '#shipping_company' ).val( '' );\n\t\t\t\t$( '#billing_first_name' ).val( firstName );\n\t\t\t\t$( '#billing_last_name' ).val( lastName );\n\t\t\t\t$( '#shipping_first_name' ).val( firstName );\n\t\t\t\t$( '#shipping_last_name' ).val( lastName );\n\t\t\t\t$( '#billing_email' ).val( email );\n\t\t\t\t// trigger events for 3rd part plugins.\n\t\t\t\t$( '#billing_email' ).change();\n\t\t\t\t$( '#billing_email' ).blur();\n\t\t\t\t$( '#billing_phone' ).val( `${ prefix }${ number }` );\n\t\t\t}\n\n\t\t\t// eslint-disable-next-line eqeqeq\n\t\t\tif ( shippingAddress.addressLine2 != null ) {\n\t\t\t\t$( '#billing_address_2' ).val(\n\t\t\t\t\tshippingAddress.addressLine2\n\t\t\t\t);\n\t\t\t\t$( '#shipping_address_2' ).val(\n\t\t\t\t\tshippingAddress.addressLine2\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Check Terms checkbox, if it exists\n\t\t\tif ( $( dibsEasyForWoocommerce.wooTerms ).length > 0 ) {\n\t\t\t\t$( dibsEasyForWoocommerce.wooTerms ).prop( 'checked', true );\n\t\t\t}\n\t\t\t$( 'input#ship-to-different-address-checkbox' ).prop( 'checked', true );\n\t\t\tdibsEasyForWoocommerce.submitOrder();\n\t\t},\n\t\t/**\n\t\t * When the customer changes to Dibs Easy from other payment methods.\n\t\t */\n\t\tmaybeChangeToDibsEasy() {\n\t\t\tif ( 'dibs_easy' === $( this ).val() ) {\n\t\t\t\t$( '.woocommerce-info' ).remove();\n\t\t\t\t$( dibsEasyForWoocommerce.checkoutFormSelector ).block( {\n\t\t\t\t\tmessage: null,\n\t\t\t\t\toverlayCSS: {\n\t\t\t\t\t\tbackground: '#fff',\n\t\t\t\t\t\topacity: 0.6,\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t\t$.ajax( {\n\t\t\t\t\ttype: 'POST',\n\t\t\t\t\tdata: {\n\t\t\t\t\t\tnonce: wcDibsEasy.nets_checkout_nonce,\n\t\t\t\t\t},\n\t\t\t\t\tdataType: 'json',\n\t\t\t\t\turl: wcDibsEasy.change_payment_method_url,\n\t\t\t\t\tsuccess( data ) {},\n\t\t\t\t\terror( data ) {},\n\t\t\t\t\tcomplete( data ) {\n\t\t\t\t\t\twindow.location.href = data.responseJSON.data.redirect;\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t},\n\t\t/**\n\t\t * Submit the order using the WooCommerce AJAX function.\n\t\t */\n\t\tsubmitOrder() {\n\t\t\t$( '.woocommerce-checkout-review-order-table' ).block( {\n\t\t\t\tmessage: null,\n\t\t\t\toverlayCSS: {\n\t\t\t\t\tbackground: '#fff',\n\t\t\t\t\topacity: 0.6,\n\t\t\t\t},\n\t\t\t} );\n\t\t\t$.ajax( {\n\t\t\t\ttype: 'POST',\n\t\t\t\turl: wcDibsEasy.submitOrder,\n\t\t\t\tdata: $( 'form.checkout' ).serialize(),\n\t\t\t\tdataType: 'json',\n\t\t\t\tsuccess( data ) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tif ( 'success' === data.result ) {\n\t\t\t\t\t\t\tdibsEasyForWoocommerce.logToFile(\n\t\t\t\t\t\t\t\t'Successfully placed order.'\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\twindow.sessionStorage.setItem( 'redirectNets', data.redirect );\n\t\t\t\t\t\t\tdibsEasyForWoocommerce.dibsCheckout.send(\n\t\t\t\t\t\t\t\t'payment-order-finalized',\n\t\t\t\t\t\t\t\ttrue\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthrow 'Result failed';\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch ( err ) {\n\t\t\t\t\t\tif ( data.messages ) {\n\t\t\t\t\t\t\tdibsEasyForWoocommerce.logToFile(\n\t\t\t\t\t\t\t\t'Checkout error | ' + data.messages\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tdibsEasyForWoocommerce.failOrder(\n\t\t\t\t\t\t\t\t'submission',\n\t\t\t\t\t\t\t\tdata.messages\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdibsEasyForWoocommerce.logToFile(\n\t\t\t\t\t\t\t\t'Checkout error | No message'\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tdibsEasyForWoocommerce.failOrder(\n\t\t\t\t\t\t\t\t'submission',\n\t\t\t\t\t\t\t\t'
' +\n\t\t\t\t\t\t\t\t\t'Checkout error' +\n\t\t\t\t\t\t\t\t\t'
'\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\terror( data ) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tdibsEasyForWoocommerce.logToFile( 'AJAX error | ' + JSON.stringify( data ) );\n\t\t\t\t\t} catch ( e ) {\n\t\t\t\t\t\tdibsEasyForWoocommerce.logToFile( 'AJAX error | Failed to parse error message.' );\n\t\t\t\t\t}\n\t\t\t\t\tdibsEasyForWoocommerce.failOrder( 'ajax-error', '
Internal Server Error
', );\n\t\t\t\t},\n\t\t\t} );\n\t\t},\n\t\t/**\n\t\t * When the customer changes from Dibs Easy to other payment methods.\n\t\t *\n\t\t * @param {Event} e\n\t\t */\n\t\tchangeFromDibsEasy( e ) {\n\t\t\te.preventDefault();\n\t\t\t$( dibsEasyForWoocommerce.checkoutFormSelector ).block( {\n\t\t\t\tmessage: null,\n\t\t\t\toverlayCSS: {\n\t\t\t\t\tbackground: '#fff',\n\t\t\t\t\topacity: 0.6,\n\t\t\t\t},\n\t\t\t} );\n\t\t\t$.ajax( {\n\t\t\t\ttype: 'POST',\n\t\t\t\tdataType: 'json',\n\t\t\t\tasync: true,\n\t\t\t\turl: wcDibsEasy.change_payment_method_url,\n\t\t\t\tdata: {\n\t\t\t\t\taction: 'dibs_change_payment_method',\n\t\t\t\t\tdibs_easy: false,\n\t\t\t\t\tnonce: wcDibsEasy.nets_checkout_nonce,\n\t\t\t\t},\n\t\t\t\tsuccess( data ) {},\n\t\t\t\terror( data ) {},\n\t\t\t\tcomplete( data ) {\n\t\t\t\t\tconsole.log( 'Change payment method success' );\n\t\t\t\t\tconsole.log( data.responseJSON.data.redirect );\n\t\t\t\t\tdibsEasyForWoocommerce.bodyEl.removeClass( 'dibs-selected' );\n\t\t\t\t\twindow.location.href = data.responseJSON.data.redirect;\n\t\t\t\t},\n\t\t\t} );\n\t\t},\n\t\t/**\n\t\t * Moves all non-standard fields to the extra checkout fields.\n\t\t */\n\t\tmoveExtraCheckoutFields() {\n\t\t\t// Move order comments.\n\t\t\t$( '.woocommerce-additional-fields' ).appendTo(\n\t\t\t\t'#dibs-extra-checkout-fields'\n\t\t\t);\n\n\t\t\tconst form = $(\n\t\t\t\t'form[name=\"checkout\"] input, form[name=\"checkout\"] select, textarea'\n\t\t\t);\n\t\t\tfor ( let i = 0; i < form.length; i++ ) {\n\t\t\t\tconst name = form[ i ].name;\n\t\t\t\tconst fields = dibsEasyForWoocommerce.standardWooFields;\n\t\t\t\t// Check if this is a standard field.\n\t\t\t\tif ( $.inArray( name, fields ) === -1 ) {\n\t\t\t\t\t// This is not a standard Woo field, move to our div.\n\t\t\t\t\t$( 'p#' + name + '_field' ).appendTo(\n\t\t\t\t\t\t'#dibs-extra-checkout-fields'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t/**\n\t\t * Logs the message to the Dibs Easy log in WooCommerce.\n\t\t *\n\t\t * @param {string} message\n\t\t */\n\t\tlogToFile( message ) {\n\t\t\t$.ajax( {\n\t\t\t\turl: wcDibsEasy.log_to_file_url,\n\t\t\t\ttype: 'POST',\n\t\t\t\tdataType: 'json',\n\t\t\t\tdata: {\n\t\t\t\t\tmessage,\n\t\t\t\t\tnonce: wcDibsEasy.log_to_file_nonce,\n\t\t\t\t},\n\t\t\t} );\n\t\t},\n\t\t/**\n\t\t * Fails the order with Dibs Easy on a checkout error and timeout.\n\t\t *\n\t\t * @param {string} event\n\t\t * @param {string} errorMessage\n\t\t */\n\t\tfailOrder( event, errorMessage ) {\n\t\t\tconst errorClasses = 'woocommerce-NoticeGroup woocommerce-NoticeGroup-checkout';\n\t\t\tconst errorWrapper = `
${ errorMessage }
`;\n\n\t\t\t// Send false and cancel\n\t\t\tdibsEasyForWoocommerce.dibsCheckout.send(\n\t\t\t\t'payment-order-finalized',\n\t\t\t\tfalse\n\t\t\t);\n\t\t\t// Renable the form.\n\t\t\tdibsEasyForWoocommerce.bodyEl.trigger( 'updated_checkout' );\n\t\t\t$( dibsEasyForWoocommerce.checkoutFormSelector ).removeClass(\n\t\t\t\t'processing'\n\t\t\t);\n\t\t\t// $( dibsEasyForWoocommerce.checkoutFormSelector ).unblock();\n\t\t\t// $( '.woocommerce-checkout-review-order-table' ).unblock();\n\n\t\t\t// Print error messages, and trigger checkout_error, and scroll to notices.\n\t\t\t$( '.woocommerce-NoticeGroup-checkout,' +\n\t\t\t\t'.woocommerce-error,' +\n\t\t\t\t'.woocommerce-message'\n\t\t\t).remove();\n\n\t\t\t$( dibsEasyForWoocommerce.checkoutFormSelector ).prepend( errorWrapper );\n\t\t\t// $( dibsEasyForWoocommerce.checkoutFormSelector )\n\t\t\t// \t.removeClass( 'processing' )\n\t\t\t// \t.unblock();\n\t\t\t$( dibsEasyForWoocommerce.checkoutFormSelector )\n\t\t\t\t.find( '.input-text, select, input:checkbox' )\n\t\t\t\t.trigger( 'validate' )\n\t\t\t\t.blur();\n\t\t\t$( document.body ).trigger( 'checkout_error', [ errorMessage ] );\n\t\t\t$( 'html, body' ).animate(\n\t\t\t\t{\n\t\t\t\t\tscrollTop:\n\t\t\t\t\t\t$( dibsEasyForWoocommerce.checkoutFormSelector ).offset()\n\t\t\t\t\t\t\t.top - 100,\n\t\t\t\t},\n\t\t\t\t1000\n\t\t\t);\n\t\t},\n\t};\n\n\tdibsEasyForWoocommerce.init();\n} );\n"],"names":["_typeof","obj","Symbol","iterator","constructor","prototype","jQuery","$","wcDibsEasy","dibsEasyForWoocommerce","bodyEl","paymentMethodEl","dibsCheckout","blocked","selectAnotherSelector","checkoutInitiated","dibsOrderProcessing","checkoutFormSelector","standardWooFields","standard_woo_checkout_fields","wooTerms","init","document","ready","loadDibs","on","maybeChangeToDibsEasy","changeFromDibsEasy","dibsIsSelected","length","paymentMethod","filter","val","moveExtraCheckoutFields","initDibsCheckout","updateCheckout","updatedCheckout","paymentCompleted","response","logToFile","paymentId","redirectUrl","sessionStorage","getItem","window","location","href","displayMustLoginError","message","mustLoginNotice","prepend","updateAddress","data","updateNeeded","country","postCode","mustLogin","mustLoginMessage","freezeCheckout","etop","offset","top","animate","scrollTop","thawCheckout","body","trigger","console","log","undefined","Dibs","unblock","addressChanged","address","ajax","type","dataType","async","url","customer_address_updated_url","action","nonce","nets_checkout_nonce","success","error","complete","responseJSON","Checkout","checkoutKey","privateKey","dibs_payment_id","containerId","language","locale","getDibsEasyOrder","get_order_data_url","redirect","setAddressData","consumer","payment","billingAddress","shippingAddress","hasBillingData","Array","isArray","addressLine1","postalCode","city","company","hasOwnProperty","contactDetails","firstName","lastName","email","phoneNumber","prefix","number","name","change","blur","privatePerson","addressLine2","prop","submitOrder","this","remove","block","overlayCSS","background","opacity","change_payment_method_url","serialize","result","setItem","send","err","messages","failOrder","JSON","stringify","e","preventDefault","dibs_easy","removeClass","appendTo","form","i","fields","inArray","log_to_file_url","log_to_file_nonce","event","errorMessage","errorWrapper","find"],"sourceRoot":""}