1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-24 10:21:35 +02:00
invoiceninja/public/build/assets/braintree-ach-b29d040e.js
2023-09-26 08:24:51 +10:00

10 lines
2.3 KiB
JavaScript
Vendored

/**
* 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
*/var a;window.braintree.client.create({authorization:(a=document.querySelector('meta[name="client-token"]'))==null?void 0:a.content}).then(function(t){return braintree.usBankAccount.create({client:t})}).then(function(t){var o;(o=document.getElementById("authorize-bank-account"))==null||o.addEventListener("click",r=>{r.target.parentElement.disabled=!0,document.getElementById("errors").hidden=!0,document.getElementById("errors").textContent="";let n={accountNumber:document.getElementById("account-number").value,routingNumber:document.getElementById("routing-number").value,accountType:document.querySelector('input[name="account-type"]:checked').value,ownershipType:document.querySelector('input[name="ownership-type"]:checked').value,billingAddress:{streetAddress:document.getElementById("billing-street-address").value,extendedAddress:document.getElementById("billing-extended-address").value,locality:document.getElementById("billing-locality").value,region:document.getElementById("billing-region").value,postalCode:document.getElementById("billing-postal-code").value}};if(n.ownershipType==="personal"){let e=document.getElementById("account-holder-name").value.split(" ",2);n.firstName=e[0],n.lastName=e[1]}else n.businessName=document.getElementById("account-holder-name").value;t.tokenize({bankDetails:n,mandateText:'By clicking ["Checkout"], I authorize Braintree, a service of PayPal, on behalf of [your business name here] (i) to verify my bank account information using bank information and consumer reports and (ii) to debit my bank account.'}).then(function(e){document.querySelector("input[name=nonce]").value=e.nonce,document.getElementById("server_response").submit()}).catch(function(e){r.target.parentElement.disabled=!1,document.getElementById("errors").textContent=`${e.details.originalError.message} ${e.details.originalError.details.originalError[0].message}`,document.getElementById("errors").hidden=!1})})}).catch(function(t){document.getElementById("errors").textContent=t.message,document.getElementById("errors").hidden=!1});