diff --git a/public/js/clients/payments/wepay-credit-card.js b/public/js/clients/payments/wepay-credit-card.js index e482339a851a..c3f2a8fcebf0 100644 --- a/public/js/clients/payments/wepay-credit-card.js +++ b/public/js/clients/payments/wepay-credit-card.js @@ -1,2 +1,2 @@ /*! For license information please see wepay-credit-card.js.LICENSE.txt */ -(()=>{var e;function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:"payment";t(this,e),this.action=n,this.errors=document.getElementById("errors")}var r,o,a;return r=e,(o=[{key:"initializeWePay",value:function(){var e,t=null===(e=document.querySelector('meta[name="wepay-environment"]'))||void 0===e?void 0:e.content;return WePay.set_endpoint("staging"===t?"stage":"production"),this}},{key:"validateCreditCardFields",value:function(){return this.myCard=$("#my-card"),""===document.getElementById("cardholder_name")?(document.getElementById("cardholder_name").focus(),this.errors.textContent="Cardholder name required.",void(this.errors.hidden=!1)):""===this.myCard.CardJs("cardNumber").replace(/[^\d]/g,"")?(document.getElementById("card_number").focus(),this.errors.textContent="Card number required.",void(this.errors.hidden=!1)):""===this.myCard.CardJs("cvc").replace(/[^\d]/g,"")?(document.getElementById("cvv").focus(),this.errors.textContent="CVV number required.",void(this.errors.hidden=!1)):""===this.myCard.CardJs("expiryMonth").replace(/[^\d]/g,"")?(this.errors.textContent="Expiry Month number required.",void(this.errors.hidden=!1)):""!==this.myCard.CardJs("expiryYear").replace(/[^\d]/g,"")||(this.errors.textContent="Expiry Year number required.",void(this.errors.hidden=!1))}},{key:"handleAuthorization",value:function(){var e=this;if(this.validateCreditCardFields()){var t=document.getElementById("card_button");t.disabled=!0,t.querySelector("svg").classList.remove("hidden"),t.querySelector("span").classList.add("hidden");var n={};n.country=document.querySelector(["meta[name=country_code"]).content,"US"==document.querySelector(["meta[name=country_code"]).content&&(n.postal_code=document.querySelector(["meta[name=client-postal-code"]).content),console.log(n),WePay.credit_card.create({client_id:document.querySelector("meta[name=wepay-client-id]").content,user_name:document.getElementById("cardholder_name").value,email:document.querySelector("meta[name=contact-email]").content,cc_number:this.myCard.CardJs("cardNumber").replace(/[^\d]/g,""),cvv:this.myCard.CardJs("cvc").replace(/[^\d]/g,""),expiration_month:this.myCard.CardJs("expiryMonth").replace(/[^\d]/g,""),expiration_year:this.myCard.CardJs("expiryYear").replace(/[^\d]/g,""),address:n},(function(n){n.error?((t=document.getElementById("card_button")).disabled=!1,t.querySelector("svg").classList.add("hidden"),t.querySelector("span").classList.remove("hidden"),e.errors.textContent="",e.errors.textContent=n.error_description,e.errors.hidden=!1):(document.querySelector('input[name="credit_card_id"]').value=n.credit_card_id,document.getElementById("server_response").submit())}))}}},{key:"completePaymentUsingToken",value:function(e){document.querySelector('input[name="credit_card_id"]').value=null,document.querySelector('input[name="token"]').value=e,document.getElementById("server-response").submit()}},{key:"completePaymentWithoutToken",value:function(){var e=this;if(!this.validateCreditCardFields())return this.payNowButton=document.getElementById("pay-now"),this.payNowButton.disabled=!1,this.payNowButton.querySelector("svg").classList.add("hidden"),void this.payNowButton.querySelector("span").classList.remove("hidden");var t={};t.country=document.querySelector(["meta[name=country_code"]).content,"US"==document.querySelector(["meta[name=country_code"]).content&&(t.postal_code=document.querySelector(["meta[name=client-postal-code"]).content),console.log(t),WePay.credit_card.create({client_id:document.querySelector("meta[name=wepay-client-id]").content,user_name:document.getElementById("cardholder_name").value,email:document.querySelector("meta[name=contact-email]").content,cc_number:this.myCard.CardJs("cardNumber").replace(/[^\d]/g,""),cvv:this.myCard.CardJs("cvc").replace(/[^\d]/g,""),expiration_month:this.myCard.CardJs("expiryMonth").replace(/[^\d]/g,""),expiration_year:this.myCard.CardJs("expiryYear").replace(/[^\d]/g,""),address:t},(function(t){t.error?(e.payNowButton.disabled=!1,e.payNowButton.querySelector("svg").classList.add("hidden"),e.payNowButton.querySelector("span").classList.remove("hidden"),e.errors.textContent="",e.errors.textContent=t.error_description,e.errors.hidden=!1):(document.querySelector('input[name="credit_card_id"]').value=t.credit_card_id,document.querySelector('input[name="token"]').value=null,document.getElementById("server-response").submit())}))}},{key:"handle",value:function(){var e=this;this.initializeWePay(),"authorize"===this.action?document.getElementById("card_button").addEventListener("click",(function(){return e.handleAuthorization()})):"payment"===this.action&&(Array.from(document.getElementsByClassName("toggle-payment-with-token")).forEach((function(e){return e.addEventListener("click",(function(e){document.getElementById("save-card--container").style.display="none",document.getElementById("wepay--credit-card-container").style.display="none",document.getElementById("token").value=e.target.dataset.token}))})),document.getElementById("toggle-payment-with-credit-card").addEventListener("click",(function(e){document.getElementById("save-card--container").style.display="grid",document.getElementById("wepay--credit-card-container").style.display="flex",document.getElementById("token").value=null})),document.getElementById("pay-now").addEventListener("click",(function(){e.payNowButton=document.getElementById("pay-now"),e.payNowButton.disabled=!0,e.payNowButton.querySelector("svg").classList.remove("hidden"),e.payNowButton.querySelector("span").classList.add("hidden");var t=document.querySelector("input[name=token]"),n=document.querySelector("input[name=token-billing-checkbox]:checked");return n&&(document.getElementById("store_card").value=n.value),t.value?e.completePaymentUsingToken(t.value):e.completePaymentWithoutToken()})))}}])&&n(r.prototype,o),a&&n(r,a),Object.defineProperty(r,"prototype",{writable:!1}),e}();new o(r).handle()})(); \ No newline at end of file +(()=>{var e;function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:"payment";t(this,e),this.action=n,this.errors=document.getElementById("errors")}var r,o,a;return r=e,(o=[{key:"initializeWePay",value:function(){var e,t=null===(e=document.querySelector('meta[name="wepay-environment"]'))||void 0===e?void 0:e.content;return WePay.set_endpoint("staging"===t?"stage":"production"),this}},{key:"validateCreditCardFields",value:function(){return this.myCard=$("#my-card"),""===document.getElementById("cardholder_name")?(document.getElementById("cardholder_name").focus(),this.errors.textContent="Cardholder name required.",void(this.errors.hidden=!1)):""===this.myCard.CardJs("cardNumber").replace(/[^\d]/g,"")?(document.getElementById("card_number").focus(),this.errors.textContent="Card number required.",void(this.errors.hidden=!1)):""===this.myCard.CardJs("cvc").replace(/[^\d]/g,"")?(document.getElementById("cvv").focus(),this.errors.textContent="CVV number required.",void(this.errors.hidden=!1)):""===this.myCard.CardJs("expiryMonth").replace(/[^\d]/g,"")?(this.errors.textContent="Expiry Month number required.",void(this.errors.hidden=!1)):""!==this.myCard.CardJs("expiryYear").replace(/[^\d]/g,"")||(this.errors.textContent="Expiry Year number required.",void(this.errors.hidden=!1))}},{key:"handleAuthorization",value:function(){var e=this;if(this.validateCreditCardFields()){var t=document.getElementById("card_button");t.disabled=!0,t.querySelector("svg").classList.remove("hidden"),t.querySelector("span").classList.add("hidden");var n={};n.country=document.querySelector(["meta[name=country_code"]).content,n.postal_code=document.querySelector(["meta[name=client-postal-code"]).content,console.log(JSON.stringify(n)),WePay.credit_card.create({client_id:document.querySelector("meta[name=wepay-client-id]").content,user_name:document.getElementById("cardholder_name").value,email:document.querySelector("meta[name=contact-email]").content,cc_number:this.myCard.CardJs("cardNumber").replace(/[^\d]/g,""),cvv:this.myCard.CardJs("cvc").replace(/[^\d]/g,""),expiration_month:this.myCard.CardJs("expiryMonth").replace(/[^\d]/g,""),expiration_year:this.myCard.CardJs("expiryYear").replace(/[^\d]/g,""),address:JSON.stringify(n)},(function(n){n.error?((t=document.getElementById("card_button")).disabled=!1,t.querySelector("svg").classList.add("hidden"),t.querySelector("span").classList.remove("hidden"),e.errors.textContent="",e.errors.textContent=n.error_description,e.errors.hidden=!1):(document.querySelector('input[name="credit_card_id"]').value=n.credit_card_id,document.getElementById("server_response").submit())}))}}},{key:"completePaymentUsingToken",value:function(e){document.querySelector('input[name="credit_card_id"]').value=null,document.querySelector('input[name="token"]').value=e,document.getElementById("server-response").submit()}},{key:"completePaymentWithoutToken",value:function(){var e=this;if(!this.validateCreditCardFields())return this.payNowButton=document.getElementById("pay-now"),this.payNowButton.disabled=!1,this.payNowButton.querySelector("svg").classList.add("hidden"),void this.payNowButton.querySelector("span").classList.remove("hidden");var t={};t.country=document.querySelector(["meta[name=country_code"]).content,t.postal_code=document.querySelector(["meta[name=client-postal-code"]).content,console.log(JSON.stringify(t)),WePay.credit_card.create({client_id:document.querySelector("meta[name=wepay-client-id]").content,user_name:document.getElementById("cardholder_name").value,email:document.querySelector("meta[name=contact-email]").content,cc_number:this.myCard.CardJs("cardNumber").replace(/[^\d]/g,""),cvv:this.myCard.CardJs("cvc").replace(/[^\d]/g,""),expiration_month:this.myCard.CardJs("expiryMonth").replace(/[^\d]/g,""),expiration_year:this.myCard.CardJs("expiryYear").replace(/[^\d]/g,""),address:JSON.stringify(t)},(function(t){t.error?(e.payNowButton.disabled=!1,e.payNowButton.querySelector("svg").classList.add("hidden"),e.payNowButton.querySelector("span").classList.remove("hidden"),e.errors.textContent="",e.errors.textContent=t.error_description,e.errors.hidden=!1):(document.querySelector('input[name="credit_card_id"]').value=t.credit_card_id,document.querySelector('input[name="token"]').value=null,document.getElementById("server-response").submit())}))}},{key:"handle",value:function(){var e=this;this.initializeWePay(),"authorize"===this.action?document.getElementById("card_button").addEventListener("click",(function(){return e.handleAuthorization()})):"payment"===this.action&&(Array.from(document.getElementsByClassName("toggle-payment-with-token")).forEach((function(e){return e.addEventListener("click",(function(e){document.getElementById("save-card--container").style.display="none",document.getElementById("wepay--credit-card-container").style.display="none",document.getElementById("token").value=e.target.dataset.token}))})),document.getElementById("toggle-payment-with-credit-card").addEventListener("click",(function(e){document.getElementById("save-card--container").style.display="grid",document.getElementById("wepay--credit-card-container").style.display="flex",document.getElementById("token").value=null})),document.getElementById("pay-now").addEventListener("click",(function(){e.payNowButton=document.getElementById("pay-now"),e.payNowButton.disabled=!0,e.payNowButton.querySelector("svg").classList.remove("hidden"),e.payNowButton.querySelector("span").classList.add("hidden");var t=document.querySelector("input[name=token]"),n=document.querySelector("input[name=token-billing-checkbox]:checked");return n&&(document.getElementById("store_card").value=n.value),t.value?e.completePaymentUsingToken(t.value):e.completePaymentWithoutToken()})))}}])&&n(r.prototype,o),a&&n(r,a),Object.defineProperty(r,"prototype",{writable:!1}),e}();new o(r).handle()})(); \ No newline at end of file diff --git a/public/mix-manifest.json b/public/mix-manifest.json index 6a35c5bcede8..36f1c81158d3 100755 --- a/public/mix-manifest.json +++ b/public/mix-manifest.json @@ -22,7 +22,7 @@ "/js/clients/linkify-urls.js": "/js/clients/linkify-urls.js?id=2b2fe55f926789abc52f19111006e1ec", "/js/clients/payments/braintree-credit-card.js": "/js/clients/payments/braintree-credit-card.js?id=cf25867ef09115b7f5a209819ba79bbf", "/js/clients/payments/braintree-paypal.js": "/js/clients/payments/braintree-paypal.js?id=5764a8d406c1eda848d073f10d178626", - "/js/clients/payments/wepay-credit-card.js": "/js/clients/payments/wepay-credit-card.js?id=c0ee01b19ede597c4529cf72f57ace85", + "/js/clients/payments/wepay-credit-card.js": "/js/clients/payments/wepay-credit-card.js?id=119fdd060747388adb10db0a2e83c785", "/js/clients/payment_methods/wepay-bank-account.js": "/js/clients/payment_methods/wepay-bank-account.js?id=b8706d7de6127f184ad19b2a810880be", "/js/clients/payments/paytrace-credit-card.js": "/js/clients/payments/paytrace-credit-card.js?id=e0b1231a7bf6252672836222285c0f52", "/js/clients/payments/mollie-credit-card.js": "/js/clients/payments/mollie-credit-card.js?id=bbab588ed009a93345bec520cbe66869", diff --git a/resources/js/clients/payments/wepay-credit-card.js b/resources/js/clients/payments/wepay-credit-card.js index 0a010fdf8da4..02477cbdfa7a 100644 --- a/resources/js/clients/payments/wepay-credit-card.js +++ b/resources/js/clients/payments/wepay-credit-card.js @@ -76,11 +76,11 @@ class WePayCreditCard { var client_address = {}; client_address['country'] = document.querySelector(['meta[name=country_code']).content; - if(document.querySelector(['meta[name=country_code']).content == 'US'){ + // if(document.querySelector(['meta[name=country_code']).content == 'US'){ client_address['postal_code'] = document.querySelector(['meta[name=client-postal-code']).content; - } + // } - console.log(client_address); + console.log(JSON.stringify(client_address)); WePay.credit_card.create({ client_id: document.querySelector('meta[name=wepay-client-id]').content, @@ -90,7 +90,7 @@ class WePayCreditCard { cvv: this.myCard.CardJs('cvc').replace(/[^\d]/g, ''), expiration_month: this.myCard.CardJs('expiryMonth').replace(/[^\d]/g, ''), expiration_year: this.myCard.CardJs('expiryYear').replace(/[^\d]/g, ''), - address: client_address + address: JSON.stringify(client_address) }, (data) => { if (data.error) { cardButton = document.getElementById('card_button'); @@ -128,11 +128,11 @@ class WePayCreditCard { var client_address = {}; client_address['country'] = document.querySelector(['meta[name=country_code']).content; - if(document.querySelector(['meta[name=country_code']).content == 'US'){ + // if(document.querySelector(['meta[name=country_code']).content == 'US'){ client_address['postal_code'] = document.querySelector(['meta[name=client-postal-code']).content; - } + // } - console.log(client_address); + console.log(JSON.stringify(client_address)); WePay.credit_card.create({ @@ -143,7 +143,7 @@ class WePayCreditCard { cvv: this.myCard.CardJs('cvc').replace(/[^\d]/g, ''), expiration_month: this.myCard.CardJs('expiryMonth').replace(/[^\d]/g, ''), expiration_year: this.myCard.CardJs('expiryYear').replace(/[^\d]/g, ''), - address: client_address + address: JSON.stringify(client_address) }, (data) => { if (data.error) { this.payNowButton.disabled = false;