mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-14 23:22:52 +01:00
37892cbe7f
* nullable access payment hash data * add loaders to js * add loaders to authorize * assets build
10 lines
5.1 KiB
JavaScript
Vendored
10 lines
5.1 KiB
JavaScript
Vendored
import{i as o,w as i}from"./wait-8f4ae121.js";/**
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
*
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
*
|
|
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
|
*
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
|
*/class l{constructor(){var t;this.clientKey=(t=document.querySelector("meta[name=paytrace-client-key]"))==null?void 0:t.content}get creditCardStyles(){return{font_color:"#000",border_color:"#a1b1c9",border_style:"dotted",font_size:"13pt",input_border_radius:"3px",input_border_width:"1px",input_font:"Times New Roman, arial, fantasy",input_font_weight:"400",input_margin:"5px 0px 5px 0px",input_padding:"0px 5px 0px 5px",label_color:"#a0aec0",label_size:"16px",label_width:"150px",label_font:"Times New Roman, sans-serif, serif",label_font_weight:"light",label_margin:"5px 0px 0px 0px",label_padding:"0px 5px 0px 5px",background_color:"white",height:"30px",width:"370px",padding_bottom:"0px"}}get codeStyles(){return{font_color:"#000",border_color:"#a1b1c9",border_style:"dotted",font_size:"13pt",input_border_radius:"2px",input_border_width:"1px",input_font:"serif, cursive, fantasy",input_font_weight:"700",input_margin:"5px 0px 5px 20px",input_padding:"0px 5px 0px 5px",label_color:"#a0aec0",label_size:"16px",label_width:"150px",label_font:"sans-serif, arial, serif",label_font_weight:"bold",label_margin:"5px 0px 0px 20px",label_padding:"2px 5px 2px 5px",background_color:"white",height:"30px",width:"150px",padding_bottom:"2px"}}get expStyles(){return{font_color:"#000",border_color:"#a1b1c9",border_style:"dashed",font_size:"12pt",input_border_radius:"0px",input_border_width:"2px",input_font:"arial, cursive, fantasy",input_font_weight:"400",input_margin:"5px 0px 5px 0px",input_padding:"0px 5px 0px 5px",label_color:"#a0aec0",label_size:"16px",label_width:"150px",label_font:"arial, fantasy, serif",label_font_weight:"normal",label_margin:"5px 0px 0px 0px",label_padding:"2px 5px 2px 5px",background_color:"white",height:"30px",width:"85px",padding_bottom:"2px",type:"dropdown"}}updatePayTraceLabels(){window.PTPayment.getControl("securityCode").label.text(document.querySelector("meta[name=ctrans-cvv]").content),window.PTPayment.getControl("creditCard").label.text(document.querySelector("meta[name=ctrans-card_number]").content),window.PTPayment.getControl("expiration").label.text(document.querySelector("meta[name=ctrans-expires]").content)}setupPayTrace(){return window.PTPayment.setup({styles:{code:this.codeStyles,cc:this.creditCardStyles,exp:this.expStyles},authorization:{clientKey:this.clientKey}})}handlePaymentWithCreditCard(t){const e=document.getElementById("pay-now");e.querySelector("svg").classList.remove("hidden"),e.querySelector("span").classList.add("hidden"),t.target.parentElement.disabled=!0,document.getElementById("errors").hidden=!0,window.PTPayment.validate(a=>{if(a.length>=1){let n=document.getElementById("errors");return n.textContent=a[0].description,n.hidden=!1,e.querySelector("svg").classList.add("hidden"),e.querySelector("span").classList.remove("hidden"),t.target.parentElement.disabled=!1}this.ptInstance.process().then(n=>{document.getElementById("HPF_Token").value=n.message.hpf_token,document.getElementById("enc_key").value=n.message.enc_key;let r=document.querySelector('input[name="token-billing-checkbox"]:checked');r&&(document.querySelector('input[name="store_card"]').value=r.value),document.getElementById("server_response").submit()}).catch(n=>{document.getElementById("errors").textContent=JSON.stringify(n),document.getElementById("errors").hidden=!1,e.querySelector("svg").classList.add("hidden"),e.querySelector("span").classList.remove("hidden"),console.log(n)})})}handlePaymentWithToken(t){t.target.parentElement.disabled=!0;const e=document.getElementById("pay-now");e.querySelector("svg").classList.remove("hidden"),e.querySelector("span").classList.add("hidden"),document.getElementById("server_response").submit()}handle(){var t;Array.from(document.getElementsByClassName("toggle-payment-with-token")).forEach(e=>e.addEventListener("click",a=>{document.getElementById("paytrace--credit-card-container").classList.add("hidden"),document.getElementById("save-card--container").style.display="none",document.querySelector("input[name=token]").value=a.target.dataset.token})),(t=document.getElementById("toggle-payment-with-credit-card"))==null||t.addEventListener("click",e=>{document.getElementById("paytrace--credit-card-container").classList.remove("hidden"),document.getElementById("save-card--container").style.display="grid",document.querySelector("input[name=token]").value="",this.setupPayTrace().then(a=>{this.ptInstance=a,this.updatePayTraceLabels()})}),document.getElementById("pay-now").addEventListener("click",e=>document.querySelector("input[name=token]").value===""?this.handlePaymentWithCreditCard(e):this.handlePaymentWithToken(e)),Array.from(document.getElementsByClassName("toggle-payment-with-token")).length===0&&!o()&&document.getElementById("toggle-payment-with-credit-card").click()}}function d(){new l().handle()}o()?d():i("#paytrace-credit-card-payment").then(()=>d());
|