// source --> https://edelhanf.de/wp-content/plugins/woocommerce-novalnet-gateway/assets/js/novalnet-wallet.min.js?ver=12.10.3 
!function(e){wc_novalnet_wallet={initiate_wallet:function(t,a){if("undefined"!=typeof NovalnetPayment){var n=a+"Instance";if(void 0!==t){n=NovalnetPayment().createPaymentObject();var o=a.toUpperCase();n.setPaymentIntent(wc_novalnet_wallet.walletPaymentRequest(t,o)),n.isPaymentMethodAvailable((function(o){if(o){const o=e("#"+t);o.empty(),n.addPaymentButton("#"+t),e(".wallet_seperator").show();const i=["product_page_googlepay_button","product_page_applepay_button"].includes(t),l=["mini_cart_page_applepay_button","mini_cart_page_googlepay_button"].includes(t),_="apple-pay-button",p="button";if(i){const t=e("#product_page_"+a+"_button").width()-5+"px";o.find("applepay"===a?_:p).css({width:t})}else if(l)"applepay"===a?o.find(_).css({"min-width":"84%",width:"84%","margin-left":"7.6%"}):o.find(p).css({"min-width":"85%",width:"20%","margin-left":"7%"});else{if(t.includes("paylater")){const a=e("#"+t);e(".shop_table").after(a),a.css({marginBottom:"20px"})}e(".wallet_seperator").show();const n=["#shopping_cart_page_googlepay_button","#checkout_page_googlepay_button","#guest_checkout_page_googlepay_button","#paylater_page_googlepay_button"],o="applepay"===a?["#shopping_cart_page_applepay_button","#checkout_page_applepay_button","#guest_checkout_page_applepay_button","#paylater_page_applepay_button"].join(", "):n.join(", ");e(o).find("applepay"===a?_:p).css({width:"100%"})}}else e("#"+t).hide()}))}}else setTimeout((function(){wc_novalnet_wallet.initiate_wallet(t,a)}),300)},walletPaymentRequest:function(t,a){if("applepay"==a.toLowerCase())var n=my_ajax_object.applepay_setting.apple_pay_button_height,o=my_ajax_object.applepay_setting.apple_pay_button_theme,i=my_ajax_object.applepay_setting.apple_pay_button_type,l=e("<textarea/>").html(my_ajax_object.applepay_setting.seller_name).text(),_=my_ajax_object.applepay_setting.apple_pay_button_corner_radius,p="yes"==my_ajax_object.applepay_setting.enforce_3d,r="yes"==my_ajax_object.applepay_setting.test_mode?"SANDBOX":"PRODUCTION",s="border-box";else{n=my_ajax_object.googlepay_setting.google_pay_button_height,i=my_ajax_object.googlepay_setting.google_pay_button_type,l=e("<textarea/>").html(my_ajax_object.googlepay_setting.seller_name).text(),p="yes"==my_ajax_object.googlepay_setting.enforce_3d;var d=my_ajax_object.googlepay_setting.partner_id;r="yes"==my_ajax_object.googlepay_setting.test_mode?"SANDBOX":"PRODUCTION",_=0,s="fill"}var c=my_ajax_object.needs_payer_phone,u=["postalAddress","phone","email"],y=t.indexOf("product_page")>-1?e("#product_has_virtual_product").val():e("#cart_has_virtual").val();if(1==y)if(1==c)u=["email","phone"];else u=["email"];var g={width:"auto",cornerRadius:parseInt(_),height:parseInt(n)},m="1"==e("#setpending").val()||1==y,b={clientKey:my_ajax_object.client_key,paymentIntent:{transaction:{amount:String(e("#"+t).attr("data-total")),currency:String(e("#"+t).attr("data-currency")),paymentMethod:a,enforce3d:p,environment:r,setPendingPayment:m},merchant:{countryCode:String(e("#"+t).attr("data-country")),paymentDataPresent:!1},custom:{lang:"de"===e("#"+t).attr("data-storeLang")?"de-DE":"en-US"},order:{paymentDataPresent:!1,merchantName:l,lineItems:JSON.parse(e("#novalnet_wallet_article_details").val()),billing:{requiredFields:["postalAddress","phone","email"]},shipping:{requiredFields:u,methodsUpdatedLater:!0}},button:{dimensions:g,locale:"de"===e("#"+t).attr("data-storeLang")?"de-DE":"en-US",type:i,boxSizing:s},callbacks:{onProcessCompletion:function(t,n){let o={},i={},l=t?.order?.billing?.contact||{},_=t?.order?.shipping?.contact||{},p=l.phoneNumber||_.phoneNumber||"";const r=Array.isArray(l.addressLines)?l.addressLines.join(" "):l.addressLines||"",s=Array.isArray(_.addressLines)?_.addressLines.join(" "):_.addressLines||"";if(o={first_name:l.firstName||"",last_name:l.lastName||"",address_1:r,city:l.locality||"",email:l.email||_.email||"",postcode:l.postalCode||"",country:l.countryCode||"",phone:p},(_.firstName||_.lastName)&&(i={first_name:_.firstName||"",last_name:_.lastName||"",address_1:s,city:_.locality||"",email:l.email||_.email||"",postcode:_.postalCode||"",country:_.countryCode||"",phone:_.phoneNumber||""}),"SUCCESS"==t.result.status){t={response:t};var d={action:"novalnet_order_creation",payment:a.toLowerCase(),customer_billing:o,customer_shipping:i,billing:l,shipping:_,variable_name:t};""!==e("#pay_for_order_id").val()&&(d.pay_for_order_id=e("#pay_for_order_id").val()),1==y&&(d.is_virtual_order=1),e.ajax({url:my_ajax_object.ajax_url,type:"POST",data:d,success:function(e){"success"==e.result?(n({status:"SUCCESS",statusText:""}),wc_novalnet_wallet.blockDocumentBody(),window.location.replace(e.redirect)):"error"==e.result&&(n({status:"FAILURE",statusText:e.redirect}),"applepay"==a.toLowerCase()&&alert(e.redirect))},error:function(e){alert(e.responseText)}})}},onShippingContactChange:function(a,n){var o={address:a},i={action:"novalnet_shipping_address_update",shippingInfo:JSON.stringify(o),shippingAddressChange:"1",simple_product_id:e("#novalnet_product_id").val(),variable_product_id:e("input[name=product_id]").val(),variable_variant_id:e("input[name=variation_id]").val(),source_page:t};e.ajax({url:my_ajax_object.ajax_url,type:"POST",data:i,success:function(e){let t={};0==e.shipping_address.length?t.methodsNotFound="There are no shipping options available. Please ensure that your address has been entered correctly, or contact us if you need any help.":null!=e.shipping_address&&e.shipping_address.length&&(t.amount=e.amount,t.lineItems=e.article_details,t.methods=e.shipping_address,t.defaultIdentifier=e.shipping_address[0].identifier),n(t)}})},onShippingMethodChange:function(t,a){var n={shippingMethod:t},o={action:"novalnet_shipping_method_update",shippingInfo:JSON.stringify(n),shippingAddressChange:"1"};e.ajax({url:my_ajax_object.ajax_url,type:"POST",data:o,success:function(e){var t={amount:e.amount,lineItems:e.order_info};a(t)}})},onPaymentButtonClicked:function(a){if(""==e("#pay_for_order_id").val()){let o=e(".single_add_to_cart_button").attr("class");if(null!=o){let i=["product_page_googlepay_button","mini_cart_page_googlepay_button","product_page_applepay_button","mini_cart_page_applepay_button"];if(i.includes(t)&&o.includes("wc-variation-selection-needed"))return e(".single_add_to_cart_button").click(),a({status:"FAILURE"}),!1;if(1==y&&i.includes(t)){var n={action:"add_virtual_product_in_cart",simple_product_id:e("#novalnet_product_id").val(),variable_product_id:e("input[name=product_id]").val(),variable_variant_id:e("input[name=variation_id]").val()};e.ajax({url:my_ajax_object.ajax_url,type:"POST",data:n,success:function(e){console.log("Product added")}})}a({status:"SUCCESS"})}else a({status:"SUCCESS"})}else a({status:"SUCCESS"})}}}};return"googlepay"==a.toLowerCase()?((1==y||e("#pay_for_order").val()||1==e("#cart_has_one_time_shipping").val())&&delete b.paymentIntent.order.shipping,delete b.paymentIntent.button.dimensions.cornerRadius,b.paymentIntent.merchant.partnerId=d):(b.paymentIntent.button.style=o,delete b.paymentIntent.transaction.enforce3d),"applepay"!=a.toLowerCase()||1!=y&&!e("#pay_for_order").val()||delete b.paymentIntent.order.shipping.methodsUpdatedLater,b},blockDocumentBody:function(){1!==e(document.body).data("blockUI.isBlocked")&&e(document.body).block({message:null,overlayCSS:{background:"#fff",opacity:.6}})},walletInitiator:function(){var t=jQuery("div").find('[data-id = "googlepay_wallet_button"]').attr("id");e("#"+t).empty(),null!=t&&null!=e("#novalnet_wallet_article_details").val()&&wc_novalnet_wallet.initiate_wallet(t,"googlepay");t=jQuery("div").find('[data-id = "applepay_wallet_button"]').attr("id");e("#"+t).empty(),null!=t&&null!=e("#novalnet_wallet_article_details").val()&&wc_novalnet_wallet.initiate_wallet(t,"applepay")}},e(document).ready((function(){e(document.body).on("update_checkout wc_fragments_refreshed updated_cart_totals",(function(e){wc_novalnet_wallet.walletInitiator()})),e(document.body).on("mouseenter",".cart-contents",(function(){var t;null!=(t=jQuery("div").find('[data-id = "googlepay_wallet_button"]').attr("id"))&&"mini_cart_page_googlepay_button"==t&&(e("#mini_cart_page_googlepay_button :button").remove(),wc_novalnet_wallet.initiate_wallet(t,"googlepay")),null!=(t=jQuery("div").find('[data-id = "applepay_wallet_button"]').attr("id"))&&"mini_cart_page_applepay_button"==t&&(e("#mini_cart_page_applepay_button :button").remove(),wc_novalnet_wallet.initiate_wallet(t,"applepay"))}))}))}(jQuery);