From fb82c204f2bb58370081ec0aea045c56323e5eeb Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 24 Sep 2024 17:41:13 +1000 Subject: [PATCH] Fixes for CBA Powerboard --- .../build/assets/powerboard-credit-card-18721694.js | 13 ------------- public/build/manifest.json | 2 +- .../js/clients/payments/powerboard-credit-card.js | 5 ++--- 3 files changed, 3 insertions(+), 17 deletions(-) delete mode 100644 public/build/assets/powerboard-credit-card-18721694.js diff --git a/public/build/assets/powerboard-credit-card-18721694.js b/public/build/assets/powerboard-credit-card-18721694.js deleted file mode 100644 index 7f211f6d2b7d..000000000000 --- a/public/build/assets/powerboard-credit-card-18721694.js +++ /dev/null @@ -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 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()); diff --git a/public/build/manifest.json b/public/build/manifest.json index af3ca1cffd5f..7a1aa7762d17 100644 --- a/public/build/manifest.json +++ b/public/build/manifest.json @@ -158,7 +158,7 @@ "src": "resources/js/clients/payments/paytrace-credit-card.js" }, "resources/js/clients/payments/powerboard-credit-card.js": { - "file": "assets/powerboard-credit-card-18721694.js", + "file": "assets/powerboard-credit-card-946f4b98.js", "imports": [ "_wait-8f4ae121.js" ], diff --git a/resources/js/clients/payments/powerboard-credit-card.js b/resources/js/clients/payments/powerboard-credit-card.js index 3bf49a26f53f..f4d62c70b9a9 100644 --- a/resources/js/clients/payments/powerboard-credit-card.js +++ b/resources/js/clients/payments/powerboard-credit-card.js @@ -280,15 +280,14 @@ async function get3dsToken() { throw new Error(errorData.message ?? 'Unknown error.'); }); - // const text = await response.text(); - // throw new Error(`Network response was not ok: ${response.statusText}. Response text: ${text}`); } return await response.json(); } catch (error) { + document.getElementById( 'errors' - ).textContent = `Sorry, your transaction could not be processed...\n\n${error}`; + ).textContent = `Sorry, your transaction could not be processed...\n\n${error.message}`; document.getElementById('errors').hidden = false; focusCreditCard = true;