mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-11 13:42:49 +01:00
10 lines
2.6 KiB
JavaScript
Vendored
10 lines
2.6 KiB
JavaScript
Vendored
var m=Object.defineProperty;var d=(n,e,t)=>e in n?m(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var r=(n,e,t)=>(d(n,typeof e!="symbol"?e+"":e,t),t);/**
|
|
* 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(e,t){r(this,"setupStripe",()=>(this.stripeConnect?this.stripe=Stripe(this.key,{stripeAccount:this.stripeConnect}):this.stripe=Stripe(this.key),this));r(this,"handleError",e=>{document.getElementById("pay-now").disabled=!1,document.querySelector("#pay-now > svg").classList.add("hidden"),document.querySelector("#pay-now > span").classList.remove("hidden"),this.errors.textContent="",this.errors.textContent=e,this.errors.hidden=!1});r(this,"handle",()=>{document.getElementById("pay-now").addEventListener("click",e=>{let t=document.getElementById("errors"),o=document.getElementById("klarna-name").value;/^[A-Za-z\s]*$/.test(o)?(document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),this.stripe.confirmKlarnaPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{billing_details:{name:o,email:document.querySelector("meta[name=email]").content,address:{line1:document.querySelector("meta[name=address-1]").content,line2:document.querySelector("meta[name=address-2]").content,city:document.querySelector("meta[name=city]").content,postal_code:document.querySelector("meta[name=postal_code]").content,state:document.querySelector("meta[name=state]").content,country:document.querySelector("meta[name=country]").content}}},return_url:document.querySelector('meta[name="return-url"]').content}).then(a=>{if(a.hasOwnProperty("error"))return this.handleError(a.error.message)})):(document.getElementById("klarna-name-correction").hidden=!1,document.getElementById("klarna-name").textContent=o.replace(/^[A-Za-z\s]*$/,""),document.getElementById("klarna-name").focus(),t.textContent=document.querySelector("meta[name=translation-name-without-special-characters]").content,t.hidden=!1)})});this.key=e,this.errors=document.getElementById("errors"),this.stripeConnect=t}}var c;const i=((c=document.querySelector('meta[name="stripe-publishable-key"]'))==null?void 0:c.content)??"";var s;const u=((s=document.querySelector('meta[name="stripe-account-id"]'))==null?void 0:s.content)??"";new l(i,u).setupStripe().handle();
|