1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-11 13:42:49 +01:00
invoiceninja/public/js/clients/payments/wepay-credit-card.js

2 lines
6.3 KiB
JavaScript
Raw Normal View History

2021-06-21 14:04:56 +02:00
/*! For license information please see wepay-credit-card.js.LICENSE.txt */
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s=19)}({19:function(e,t,n){e.exports=n("6+GV")},"6+GV":function(e,t){var n;function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var a=null===(n=document.querySelector('meta[name="wepay-action"]'))||void 0===n?void 0:n.content;new(function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"payment";r(this,e),this.action=t,this.errors=document.getElementById("errors")}var t,n,a;return t=e,(n=[{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")?(document.getElementById("card_number").focus(),this.errors.textContent="Card number required.",void(this.errors.hidden=!1)):""===this.myCard.CardJs("cvc")?(document.getElementById("cvv").focus(),this.errors.textContent="CVV number required.",void(this.errors.hidden=!1)):""===this.myCard.CardJs("expiryMonth")?(this.errors.textContent="Expiry Month number required.",void(this.errors.hidden=!1)):""!==this.myCard.CardJs("expiryYear")||(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"),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"),cvv:this.myCard.CardJs("cvc"),expiration_month:this.myCard.CardJs("expiryMonth"),expiration_year:this.myCard.CardJs("expiryYear"),address:{postal_code:document.querySelector(["meta[name=client-postal-code"]).content}},(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;this.validateCreditCardFields()&&WePay.credit_card.create({client_id:document.querySelector("meta[name=wepay