1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-13 22:54:25 +01:00

Fixes for CBA Powerboard

This commit is contained in:
David Bomba 2024-09-24 17:38:47 +10:00
parent bc8ce0af09
commit d7e41a5428
3 changed files with 14 additions and 14 deletions

View File

@ -1,13 +0,0 @@
import{i,w as u}from"./wait-8f4ae121.js";/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/let a=!1;function l(){const n=document.querySelector("meta[name=public_key]"),e=document.querySelector("meta[name=gateway_id]"),o=document.querySelector("meta[name=environment]"),t=new cba.HtmlWidget("#widget",n==null?void 0:n.content,e==null?void 0:e.content);t.setEnv(o==null?void 0:o.content),t.useAutoResize(),t.interceptSubmitForm("#stepone"),t.onFinishInsert('#server-response input[name="gateway_response"]',"payment_source"),t.setFormFields(["card_name*"]),t.reload();let r=document.getElementById("pay-now");return r.disabled=!1,r.querySelector("svg").classList.add("hidden"),r.querySelector("span").classList.remove("hidden"),document.querySelector('#server-response input[name="gateway_response"]').value="",t}function m(){var n,e,o;(n=document.querySelector("#widget"))==null||n.replaceChildren(),(e=document.querySelector("#widget"))==null||e.classList.remove("hidden"),(o=document.querySelector("#widget-3dsecure"))==null||o.replaceChildren()}function d(){var t;m();const n=l();n.on("finish",()=>{document.getElementById("errors").hidden=!0,y()}),n.on("submit",function(r){document.getElementById("errors").hidden=!0});let e=document.getElementById("pay-now");e.addEventListener("click",()=>{const r=document.getElementById("widget");if(n.getValidationState(),!n.isValidForm()&&r.offsetParent!==null){e.disabled=!1,e.querySelector("svg").classList.add("hidden"),e.querySelector("span").classList.remove("hidden");return}e.disabled=!0,e.querySelector("svg").classList.remove("hidden"),e.querySelector("span").classList.add("hidden");let s=document.querySelector("input[name=token-billing-checkbox]:checked");s&&(document.getElementById("store_card").value=s.value),r.offsetParent!==null?document.getElementById("stepone_submit").click():document.getElementById("server-response").submit()}),document.getElementById("toggle-payment-with-credit-card").addEventListener("click",r=>{var c;document.getElementById("widget").classList.remove("hidden"),document.getElementById("save-card--container").style.display="grid",document.querySelector("input[name=token]").value="",(c=document.querySelector("#powerboard-payment-container"))==null||c.classList.remove("hidden")}),Array.from(document.getElementsByClassName("toggle-payment-with-token")).forEach(r=>r.addEventListener("click",s=>{var c;document.getElementById("widget").classList.add("hidden"),document.getElementById("save-card--container").style.display="none",document.querySelector("input[name=token]").value=s.target.dataset.token,(c=document.querySelector("#powerboard-payment-container"))==null||c.classList.add("hidden")}));const o=document.querySelector('input[name="payment-type"]');o&&o.click(),console.log({focusCreditCard:a}),a&&((t=document.getElementById("toggle-payment-with-credit-card"))==null||t.click())}async function y(){try{const n=await g();if(n.status==="not_authenticated"||n==="not_authenticated")throw a=!0,d(),new Error("There was an issue authenticating this payment method.");if(n.status==="authentication_not_supported"){document.querySelector('input[name="browser_details"]').value=null,document.querySelector('input[name="charge"]').value=JSON.stringify(n);let t=document.querySelector("input[name=token-billing-checkbox]:checked");return t&&(document.getElementById("store_card").value=t.value),document.getElementById("server-response").submit()}const e=new cba.Canvas3ds("#widget-3dsecure",n._3ds.token);e.load(),document.getElementById("widget").classList.add("hidden"),e.on("chargeAuthSuccess",function(t){document.querySelector('input[name="browser_details"]').value=null,document.querySelector('input[name="charge"]').value=JSON.stringify(t);let r=document.querySelector("input[name=token-billing-checkbox]:checked");r&&(document.getElementById("store_card").value=r.value),document.getElementById("server-response").submit()}),e.on("chargeAuthReject",function(t){document.getElementById("errors").textContent="Sorry, your transaction could not be processed...",document.getElementById("errors").hidden=!1,a=!0,d()}),e.load()}catch(n){const e=n.message??"Unknown error.";document.getElementById("errors").textContent=`Sorry, your transaction could not be processed...
${e}`,document.getElementById("errors").hidden=!1,a=!0,d()}}async function g(){const n={name:navigator.userAgent.substring(0,100),java_enabled:navigator.javaEnabled()?"true":"false",language:navigator.language||navigator.userLanguage,screen_height:window.screen.height.toString(),screen_width:window.screen.width.toString(),time_zone:(new Date().getTimezoneOffset()*-1).toString(),color_depth:window.screen.colorDepth.toString()};document.querySelector('input[name="browser_details"]').value=JSON.stringify(n);const e=JSON.stringify(Object.fromEntries(new FormData(document.getElementById("server-response")))),o=document.querySelector("meta[name=payments_route]");try{const t=await fetch(o.content,{method:"POST",headers:{"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest",Accept:"application/json","X-CSRF-Token":document.querySelector('meta[name="csrf-token"]').content},body:e});return t.ok?await t.json():await t.json().then(r=>{throw new Error(r.message??"Unknown error.")})}catch(t){document.getElementById("errors").textContent=`Sorry, your transaction could not be processed...
${t}`,document.getElementById("errors").hidden=!1,a=!0,d()}}i()?d():u("#powerboard-credit-card-payment").then(()=>d());

View File

@ -0,0 +1,13 @@
import{i,w as u}from"./wait-8f4ae121.js";/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/let a=!1;function l(){const e=document.querySelector("meta[name=public_key]"),t=document.querySelector("meta[name=gateway_id]"),r=document.querySelector("meta[name=environment]"),n=new cba.HtmlWidget("#widget",e==null?void 0:e.content,t==null?void 0:t.content);n.setEnv(r==null?void 0:r.content),n.useAutoResize(),n.interceptSubmitForm("#stepone"),n.onFinishInsert('#server-response input[name="gateway_response"]',"payment_source"),n.setFormFields(["card_name*"]),n.reload();let o=document.getElementById("pay-now");return o.disabled=!1,o.querySelector("svg").classList.add("hidden"),o.querySelector("span").classList.remove("hidden"),document.querySelector('#server-response input[name="gateway_response"]').value="",n}function m(){var e,t,r;(e=document.querySelector("#widget"))==null||e.replaceChildren(),(t=document.querySelector("#widget"))==null||t.classList.remove("hidden"),(r=document.querySelector("#widget-3dsecure"))==null||r.replaceChildren()}function d(){var n;m();const e=l();e.on("finish",()=>{document.getElementById("errors").hidden=!0,y()}),e.on("submit",function(o){document.getElementById("errors").hidden=!0});let t=document.getElementById("pay-now");t.addEventListener("click",()=>{const o=document.getElementById("widget");if(e.getValidationState(),!e.isValidForm()&&o.offsetParent!==null){t.disabled=!1,t.querySelector("svg").classList.add("hidden"),t.querySelector("span").classList.remove("hidden");return}t.disabled=!0,t.querySelector("svg").classList.remove("hidden"),t.querySelector("span").classList.add("hidden");let s=document.querySelector("input[name=token-billing-checkbox]:checked");s&&(document.getElementById("store_card").value=s.value),o.offsetParent!==null?document.getElementById("stepone_submit").click():document.getElementById("server-response").submit()}),document.getElementById("toggle-payment-with-credit-card").addEventListener("click",o=>{var c;document.getElementById("widget").classList.remove("hidden"),document.getElementById("save-card--container").style.display="grid",document.querySelector("input[name=token]").value="",(c=document.querySelector("#powerboard-payment-container"))==null||c.classList.remove("hidden")}),Array.from(document.getElementsByClassName("toggle-payment-with-token")).forEach(o=>o.addEventListener("click",s=>{var c;document.getElementById("widget").classList.add("hidden"),document.getElementById("save-card--container").style.display="none",document.querySelector("input[name=token]").value=s.target.dataset.token,(c=document.querySelector("#powerboard-payment-container"))==null||c.classList.add("hidden")}));const r=document.querySelector('input[name="payment-type"]');r&&r.click(),console.log({focusCreditCard:a}),a&&((n=document.getElementById("toggle-payment-with-credit-card"))==null||n.click())}async function y(){try{const e=await g();if(console.log(e),!e.status||e.status==="not_authenticated"||e==="not_authenticated")throw a=!0,d(),new Error("There was an issue authenticating this payment method.");if(e.status==="authentication_not_supported"){document.querySelector('input[name="browser_details"]').value=null,document.querySelector('input[name="charge"]').value=JSON.stringify(e);let n=document.querySelector("input[name=token-billing-checkbox]:checked");return n&&(document.getElementById("store_card").value=n.value),document.getElementById("server-response").submit()}const t=new cba.Canvas3ds("#widget-3dsecure",e._3ds.token);t.load(),document.getElementById("widget").classList.add("hidden"),t.on("chargeAuthSuccess",function(n){document.querySelector('input[name="browser_details"]').value=null,document.querySelector('input[name="charge"]').value=JSON.stringify(n);let o=document.querySelector("input[name=token-billing-checkbox]:checked");o&&(document.getElementById("store_card").value=o.value),document.getElementById("server-response").submit()}),t.on("chargeAuthReject",function(n){document.getElementById("errors").textContent="Sorry, your transaction could not be processed...",document.getElementById("errors").hidden=!1,a=!0,d()}),t.load()}catch(e){const t=e.message??"Unknown error.";document.getElementById("errors").textContent=`Sorry, your transaction could not be processed...
${t}`,document.getElementById("errors").hidden=!1,a=!0,d()}}async function g(){const e={name:navigator.userAgent.substring(0,100),java_enabled:navigator.javaEnabled()?"true":"false",language:navigator.language||navigator.userLanguage,screen_height:window.screen.height.toString(),screen_width:window.screen.width.toString(),time_zone:(new Date().getTimezoneOffset()*-1).toString(),color_depth:window.screen.colorDepth.toString()};document.querySelector('input[name="browser_details"]').value=JSON.stringify(e);const t=JSON.stringify(Object.fromEntries(new FormData(document.getElementById("server-response")))),r=document.querySelector("meta[name=payments_route]");try{const n=await fetch(r.content,{method:"POST",headers:{"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest",Accept:"application/json","X-CSRF-Token":document.querySelector('meta[name="csrf-token"]').content},body:t});return n.ok?await n.json():await n.json().then(o=>{throw new Error(o.message??"Unknown error.")})}catch(n){document.getElementById("errors").textContent=`Sorry, your transaction could not be processed...
${n}`,document.getElementById("errors").hidden=!1,a=!0,d()}}i()?d():u("#powerboard-credit-card-payment").then(()=>d());

View File

@ -158,7 +158,7 @@
"src": "resources/js/clients/payments/paytrace-credit-card.js" "src": "resources/js/clients/payments/paytrace-credit-card.js"
}, },
"resources/js/clients/payments/powerboard-credit-card.js": { "resources/js/clients/payments/powerboard-credit-card.js": {
"file": "assets/powerboard-credit-card-0495858a.js", "file": "assets/powerboard-credit-card-18721694.js",
"imports": [ "imports": [
"_wait-8f4ae121.js" "_wait-8f4ae121.js"
], ],