diff --git a/assets/js/monei.min.js b/assets/js/monei.min.js index 1e36803..c84a925 100644 --- a/assets/js/monei.min.js +++ b/assets/js/monei.min.js @@ -1 +1 @@ -!function(e){"use strict";e(document.body).on("updated_checkout",(function(e,t){"object"==typeof t&&t.fragments&&t.fragments.monei_new_total&&(n.total=t.fragments.monei_new_total),n.is_monei_selected()&&(n.init_checkout_monei(),n.init_apple_google_pay())})),e("form#add_payment_method").on("click payment_methods",(function(){n.is_monei_selected()&&n.init_checkout_monei()})),e("form#order_review").on("click",(function(){n.is_monei_selected()&&n.init_checkout_monei()}));var n={$checkout_form:e("form.woocommerce-checkout"),$add_payment_form:e("form#add_payment_method"),$order_pay_form:e("form#order_review"),$cardInput:null,$container:null,$payment_request_container:"#payment_request_container",$errorContainer:null,$paymentForm:null,is_checkout:!1,is_add_payment_method:!1,is_order_pay:!1,form:null,submitted:!1,init_counter:0,total:wc_monei_params.total,init:function(){this.$checkout_form.length&&(this.is_checkout=!0,this.form=this.$checkout_form,this.form.on("checkout_place_order",this.place_order)),this.$add_payment_form.length&&(this.is_add_payment_method=!0,this.form=this.$add_payment_form,this.form.on("submit",this.place_order)),this.$order_pay_form.length&&(n.is_monei_selected()&&n.init_checkout_monei(),this.is_order_pay=!0,this.form=this.$order_pay_form,this.form.on("submit",this.place_order)),this.form&&this.form.on("change",this.on_change)},submit_form:function(){n.form.submit()},on_change:function(){e("[name='payment_method']").on("change",(function(){n.on_payment_selected()})),e("[name='wc-monei-payment-token']").on("change",(function(){n.on_payment_selected()}))},on_payment_selected(){n.is_monei_selected()?(n.init_checkout_monei(),n.is_checkout&&e("[name='woocommerce_checkout_place_order']").attr("data-monei","submit"),n.is_checkout&&wc_monei_params.apple_google_pay&&(n.is_tokenized_cc_selected()?n.hide_payment_request_container():n.show_payment_request_container())):n.is_checkout&&e("[name='woocommerce_checkout_place_order']").removeAttr("data-monei")},is_monei_selected:function(){return e("#payment_method_monei").is(":checked")},is_tokenized_cc_selected:function(){return e('input[name="wc-monei-payment-token"]').is(":checked")&&"new"!==e('input[name="wc-monei-payment-token"]:checked').val()},is_monei_saved_cc_selected:function(){return n.is_monei_selected()&&n.is_tokenized_cc_selected()},init_apple_google_pay:function(){wc_monei_params.apple_google_pay&&(window.paymentRequest&&window.paymentRequest.close(),n.instantiate_payment_request())},instantiate_payment_request:function(){var e=monei.PaymentRequest({accountId:wc_monei_params.account_id,sessionId:wc_monei_params.session_id,amount:parseInt(n.total),currency:wc_monei_params.currency,onSubmit(e){n.apple_google_token_handler(e.token)},onError(e){console.log(e)}});e.render("#payment-request-container"),window.paymentRequest=e},hide_payment_request_container:function(){e("#payment-request-container").hide()},show_payment_request_container:function(){e("#payment-request-container").show()},init_checkout_monei:function(){if(n.$container&&0===n.$container.childElementCount&&(n.init_counter=0),0===this.init_counter&&!n.is_monei_saved_cc_selected()){n.is_checkout&&e("[name='woocommerce_checkout_place_order']").attr("data-monei","submit"),n.init_apple_google_pay(),n.$container=document.getElementById("card-input"),n.$errorContainer=document.getElementById("monei-card-error");n.$cardInput=monei.CardInput({accountId:wc_monei_params.account_id,sessionId:wc_monei_params.session_id,style:{input:{fontFamily:'"Helvetica Neue", Helvetica, sans-serif',fontSmoothing:"antialiased",fontSize:"15px"},invalid:{color:"#fa755a"},icon:{marginRight:"0.4em"}},onChange:function(e){e.isTouched&&e.error?n.print_errors(e.error):n.clear_errors()},onEnter:function(){n.form.submit()},onFocus:function(){n.$container.classList.add("is-focused")},onBlur:function(){n.$container.classList.remove("is-focused")}}),n.$cardInput.render(n.$container),this.init_counter++}},place_order:function(t){return!!e("#monei_payment_token").length||(!!e("#monei_payment_request_token").length||(!n.is_monei_selected()||(!!n.is_monei_saved_cc_selected()||(t.preventDefault(),monei.createToken(n.$cardInput).then((function(e){e.error?(console.log("error",e.error),n.print_errors(e.error)):n.monei_token_handler(e.token)})).catch((function(e){console.log(e),n.print_errors(e.message)})),!1))))},print_errors:function(t){e(n.$errorContainer).html('
'),e(n.$errorContainer).find("li").text(t),e(".monei-error").length&&e("html, body").animate({scrollTop:e(".monei-error").offset().top-200},200)},clear_errors:function(){e(".monei-error").remove()},monei_token_handler:function(e){n.create_hidden_input("monei_payment_token",e),n.form.submit()},apple_google_token_handler:function(e){n.create_hidden_input("monei_payment_request_token",e),n.form.submit()},create_hidden_input:function(e,t){console.log("token",t);var o=document.createElement("input");o.setAttribute("type","hidden"),o.setAttribute("name",e),o.setAttribute("id",e),o.setAttribute("value",t),n.$paymentForm=document.getElementById("payment-form"),n.$paymentForm.appendChild(o)},get_form:function(){return this.form}};e((function(){n.init()}))}(jQuery); +!function(e){"use strict";e(document.body).on("updated_checkout",(function(e,n){"object"==typeof n&&n.fragments&&n.fragments.monei_new_total&&(t.total=n.fragments.monei_new_total),t.is_monei_selected()&&(t.init_checkout_monei(),t.init_apple_google_pay())})),e("form#add_payment_method").on("click payment_methods",(function(){t.is_monei_selected()&&t.init_checkout_monei()})),e("form#order_review").on("click",(function(){t.is_monei_selected()&&t.init_checkout_monei()}));var n=document.getElementById("order_review");n&&new MutationObserver((function(e,n){for(var o of e)"childList"===o.type&&t.is_monei_selected()&&t.init_checkout_monei()})).observe(n,{childList:!0,subtree:!0});var t={$checkout_form:e("form.woocommerce-checkout"),$add_payment_form:e("form#add_payment_method"),$order_pay_form:e("form#order_review"),$cardInput:null,$container:null,$payment_request_container:"#payment_request_container",$errorContainer:null,$paymentForm:null,is_checkout:!1,is_add_payment_method:!1,is_order_pay:!1,form:null,submitted:!1,init_counter:0,total:wc_monei_params.total,init:function(){this.$checkout_form.length&&(this.is_checkout=!0,this.form=this.$checkout_form,this.form.on("checkout_place_order",this.place_order)),this.$add_payment_form.length&&(this.is_add_payment_method=!0,this.form=this.$add_payment_form,this.form.on("submit",this.place_order)),this.$order_pay_form.length&&(t.is_monei_selected()&&t.init_checkout_monei(),this.is_order_pay=!0,this.form=this.$order_pay_form,this.form.on("submit",this.place_order)),this.form&&this.form.on("change",this.on_change)},submit_form:function(){t.form.submit()},on_change:function(){e("[name='payment_method']").on("change",(function(){t.on_payment_selected()})),e("[name='wc-monei-payment-token']").on("change",(function(){t.on_payment_selected()}))},on_payment_selected(){t.is_monei_selected()?(t.init_checkout_monei(),t.is_checkout&&e("[name='woocommerce_checkout_place_order']").attr("data-monei","submit"),t.is_checkout&&wc_monei_params.apple_google_pay&&(t.is_tokenized_cc_selected()?t.hide_payment_request_container():t.show_payment_request_container())):t.is_checkout&&e("[name='woocommerce_checkout_place_order']").removeAttr("data-monei")},is_monei_selected:function(){return e("#payment_method_monei").is(":checked")},is_tokenized_cc_selected:function(){return e('input[name="wc-monei-payment-token"]').is(":checked")&&"new"!==e('input[name="wc-monei-payment-token"]:checked').val()},is_monei_saved_cc_selected:function(){return t.is_monei_selected()&&t.is_tokenized_cc_selected()},init_apple_google_pay:function(){wc_monei_params.apple_google_pay&&(window.paymentRequest&&window.paymentRequest.close(),t.instantiate_payment_request())},instantiate_payment_request:function(){var e=monei.PaymentRequest({accountId:wc_monei_params.account_id,sessionId:wc_monei_params.session_id,amount:parseInt(t.total),currency:wc_monei_params.currency,onSubmit(e){t.apple_google_token_handler(e.token)},onError(e){console.log(e)}});e.render("#payment-request-container"),window.paymentRequest=e},hide_payment_request_container:function(){e("#payment-request-container").hide()},show_payment_request_container:function(){e("#payment-request-container").show()},init_checkout_monei:function(){if(t.$container&&0===t.$container.childElementCount&&(t.init_counter=0),0===this.init_counter&&!t.is_monei_saved_cc_selected()){t.is_checkout&&e("[name='woocommerce_checkout_place_order']").attr("data-monei","submit"),t.init_apple_google_pay(),t.$container=document.getElementById("card-input"),t.$errorContainer=document.getElementById("monei-card-error");t.$cardInput=monei.CardInput({accountId:wc_monei_params.account_id,sessionId:wc_monei_params.session_id,style:{input:{fontFamily:'"Helvetica Neue", Helvetica, sans-serif',fontSmoothing:"antialiased",fontSize:"15px"},invalid:{color:"#fa755a"},icon:{marginRight:"0.4em"}},onChange:function(e){e.isTouched&&e.error?t.print_errors(e.error):t.clear_errors()},onEnter:function(){t.form.submit()},onFocus:function(){t.$container.classList.add("is-focused")},onBlur:function(){t.$container.classList.remove("is-focused")}}),t.$cardInput.render(t.$container),this.init_counter++}},place_order:function(n){return!!e("#monei_payment_token").length||(!!e("#monei_payment_request_token").length||(!t.is_monei_selected()||(!!t.is_monei_saved_cc_selected()||(n.preventDefault(),monei.createToken(t.$cardInput).then((function(e){e.error?(console.log("error",e.error),t.print_errors(e.error)):t.monei_token_handler(e.token)})).catch((function(e){console.log(e),t.print_errors(e.message)})),!1))))},print_errors:function(n){e(t.$errorContainer).html('
'),e(t.$errorContainer).find("li").text(n),e(".monei-error").length&&e("html, body").animate({scrollTop:e(".monei-error").offset().top-200},200)},clear_errors:function(){e(".monei-error").remove()},monei_token_handler:function(e){t.create_hidden_input("monei_payment_token",e),t.form.submit()},apple_google_token_handler:function(e){t.create_hidden_input("monei_payment_request_token",e),t.form.submit()},create_hidden_input:function(e,n){console.log("token",n);var o=document.createElement("input");o.setAttribute("type","hidden"),o.setAttribute("name",e),o.setAttribute("id",e),o.setAttribute("value",n),t.$paymentForm=document.getElementById("payment-form"),t.$paymentForm.appendChild(o)},get_form:function(){return this.form}};e((function(){t.init()}))}(jQuery); \ No newline at end of file diff --git a/build/package.json b/build/package.json index a82e73a..490e78a 100644 --- a/build/package.json +++ b/build/package.json @@ -1,6 +1,6 @@ { "name": "monei-woocommerce", - "version": "5.8.12", + "version": "5.8.13", "main": "index.js", "repository": "git@github.com:MONEI/MONEI-WooCommerce.git", "author": "MONEI ", diff --git a/readme.txt b/readme.txt index 3b2d723..c10e5b2 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Tags: woocommerce, credit card, payment gateway, payments, ecommerce Contributors: monei, furi3r Requires at least: 5.0 Tested up to: 6.5.3 -Stable tag: 5.8.12 +Stable tag: 5.8.13 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html WC requires at least: 3.0 @@ -101,10 +101,10 @@ By using this plugin you agree with MONEI [Terms of Service](https://monei.com/l 2. Google Pay, Bizum, PayPal, credit Card == Changelog == -= 5.8.12 = += 5.8.13 = * Fix partial refunds -= 5.8.12 = += 5.8.13 = * Update dependencies = 5.7.0 =