diff --git a/app/Http/Controllers/CompanyGatewayController.php b/app/Http/Controllers/CompanyGatewayController.php index 5d25533dec..4d1ce5f8e3 100644 --- a/app/Http/Controllers/CompanyGatewayController.php +++ b/app/Http/Controllers/CompanyGatewayController.php @@ -251,6 +251,12 @@ class CompanyGatewayController extends BaseController $company_gateway->driver()->init()->settings()->updateSettings(); })->afterResponse(); + $config = $company_gateway->getConfig(); + $config->visa = true; + $config->mastercard = true; + $company_gateway->setConfig($config); + $company_gateway->save(); + break; default: diff --git a/app/PaymentDrivers/CBAPowerBoard/CreditCard.php b/app/PaymentDrivers/CBAPowerBoard/CreditCard.php index 512e7cb2f6..fa7141f08d 100644 --- a/app/PaymentDrivers/CBAPowerBoard/CreditCard.php +++ b/app/PaymentDrivers/CBAPowerBoard/CreditCard.php @@ -218,8 +218,27 @@ class CreditCard implements LivewireMethodInterface { $this->powerboard->init(); - // if(!isset($this->cba_gateway->verification_status) || $this->cba_gateway->verification_status != "completed") - // throw new PaymentFailed("This payment method is not configured as yet. Reference Powerboard portal for further information", 400); + $available_cards = [ + "amex", + "ausbc", + "discover", + "japcb", + "laser", + "mastercard", + "solo", + "visa", + "visa_white", + ]; + + $supported_cards = $this->powerboard->company_gateway->getConfig(); + + $supported_cards_array = []; + + foreach($available_cards as $card){ + if($supported_cards->{$card}){ + $supported_cards_array[] = $card; + } + } $merge = [ 'public_key' => $this->powerboard->company_gateway->getConfigField('publicKey'), @@ -227,6 +246,7 @@ class CreditCard implements LivewireMethodInterface 'gateway' => $this->powerboard, 'environment' => $this->powerboard->environment, 'gateway_id' => $this->cba_gateway->_id ?? false, + 'supported_cards' => $supported_cards_array, ]; return array_merge($data, $merge); diff --git a/database/migrations/2024_09_06_042040_cba_powerboard.php b/database/migrations/2024_09_06_042040_cba_powerboard.php index 255438b064..fe39ea8cef 100644 --- a/database/migrations/2024_09_06_042040_cba_powerboard.php +++ b/database/migrations/2024_09_06_042040_cba_powerboard.php @@ -22,6 +22,16 @@ return new class extends Migration $fields->secretKey = ''; $fields->testMode = false; $fields->gatewayId = ''; + $fields->amex = false; + $fields->ausbc = false; + $fields->discover = false; + $fields->japcb = false; + $fields->laser = false; + $fields->mastercard = true; + $fields->solo = false; + $fields->visa = true; + $fields->visa_white = false; + if($gateway = Gateway::find(64)){ $gateway->fields = json_encode($fields); diff --git a/database/seeders/PaymentLibrariesSeeder.php b/database/seeders/PaymentLibrariesSeeder.php index d4cf01d696..edd1d050ef 100644 --- a/database/seeders/PaymentLibrariesSeeder.php +++ b/database/seeders/PaymentLibrariesSeeder.php @@ -89,7 +89,7 @@ class PaymentLibrariesSeeder extends Seeder ['id' => 61, 'name' => 'PayPal Platform', 'provider' => 'PayPal_PPCP', 'key' => '80af24a6a691230bbec33e930ab40666', 'fields' => '{"testMode":false}'], ['id' => 62, 'name' => 'BTCPay', 'provider' => 'BTCPay', 'key' => 'vpyfbmdrkqcicpkjqdusgjfluebftuva', 'fields' => '{"btcpayUrl":"", "apiKey":"", "storeId":"", "webhookSecret":""}'], ['id' => 63, 'name' => 'Rotessa', 'is_offsite' => false, 'sort_order' => 22, 'provider' => 'Rotessa', 'key' => '91be24c7b792230bced33e930ac61676', 'fields' => '{"apiKey":"", "testMode":false}'], - ['id' => 64, 'name' => 'CBA PowerBoard', 'is_offsite' => false, 'sort_order' => 26, 'provider' => 'CBAPowerBoard', 'key' => 'b67581d804dbad1743b61c57285142ad', 'fields' => '{"publicKey":"", "secretKey":"", "testMode":false, "gatewayId":""}'], + ['id' => 64, 'name' => 'CBA PowerBoard', 'is_offsite' => false, 'sort_order' => 26, 'provider' => 'CBAPowerBoard', 'key' => 'b67581d804dbad1743b61c57285142ad', 'fields' => '{"publicKey":"", "secretKey":"", "testMode":false, "gatewayId":"", "amex":false, "ausbc":false, "discover":false, "japcb":false, "laser":false, "mastercard":true, "solo":false, "visa":true, "visa_white":false}'], ['id' => 65, 'name' => 'Blockonomics', 'is_offsite' => false, 'sort_order' => 27, 'provider' => 'Blockonomics', 'key' => 'wbhf02us6owgo7p4nfjd0ymssdshks4d', 'fields' => '{"apiKey":"", "callbackSecret":""}'], ]; diff --git a/public/build/assets/powerboard-credit-card-f4852d3b.js b/public/build/assets/powerboard-credit-card-f4852d3b.js new file mode 100644 index 0000000000..da41a5aff9 --- /dev/null +++ b/public/build/assets/powerboard-credit-card-f4852d3b.js @@ -0,0 +1,13 @@ +import{i as l,w as m}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 u=!1;function y(){const t=document.querySelector("meta[name=public_key]"),e=document.querySelector("meta[name=gateway_id]"),r=document.querySelector("meta[name=environment]"),n=document.querySelector("meta[name=supported_cards]"),o=new cba.HtmlWidget("#widget",t==null?void 0:t.content,e==null?void 0:e.content);if(o.setEnv(r==null?void 0:r.content),o.useAutoResize(),n!=null&&n.content)try{const a=JSON.parse(n.content);o.setSupportedCardIcons(a,!0)}catch{}o.interceptSubmitForm("#stepone"),o.onFinishInsert('#server-response input[name="gateway_response"]',"payment_source"),o.setFormFields(["card_name*"]),o.reload();let d=document.getElementById("pay-now");return d.disabled=!1,d.querySelector("svg").classList.add("hidden"),d.querySelector("span").classList.remove("hidden"),document.querySelector('#server-response input[name="gateway_response"]').value="",o}function g(){var t,e,r;(t=document.querySelector("#widget"))==null||t.replaceChildren(),(e=document.querySelector("#widget"))==null||e.classList.remove("hidden"),(r=document.querySelector("#widget-3dsecure"))==null||r.replaceChildren()}function s(){var o,d;if(g(),!((o=document.querySelector("meta[name=gateway_id]"))==null?void 0:o.content)){let a=document.getElementById("pay-now");a.disabled=!0,a.querySelector("svg").classList.remove("hidden"),a.querySelector("span").classList.add("hidden"),document.getElementById("errors").textContent="Gateway not found or verified",document.getElementById("errors").hidden=!1}const e=y();e.on("finish",()=>{document.getElementById("errors").hidden=!0,p()}),e.on("submit",function(a){document.getElementById("errors").hidden=!0});let r=document.getElementById("pay-now");r.addEventListener("click",()=>{const a=document.getElementById("widget");if(e.getValidationState(),!e.isValidForm()&&a.offsetParent!==null){r.disabled=!1,r.querySelector("svg").classList.add("hidden"),r.querySelector("span").classList.remove("hidden");return}r.disabled=!0,r.querySelector("svg").classList.remove("hidden"),r.querySelector("span").classList.add("hidden");let c=document.querySelector("input[name=token-billing-checkbox]:checked");c&&(document.getElementById("store_card").value=c.value),a.offsetParent!==null?document.getElementById("stepone_submit").click():document.getElementById("server-response").submit()}),document.getElementById("toggle-payment-with-credit-card").addEventListener("click",a=>{var i;document.getElementById("widget").classList.remove("hidden"),document.getElementById("save-card--container").style.display="grid",document.querySelector("input[name=token]").value="",(i=document.querySelector("#powerboard-payment-container"))==null||i.classList.remove("hidden")}),Array.from(document.getElementsByClassName("toggle-payment-with-token")).forEach(a=>a.addEventListener("click",c=>{var i;document.getElementById("widget").classList.add("hidden"),document.getElementById("save-card--container").style.display="none",document.querySelector("input[name=token]").value=c.target.dataset.token,(i=document.querySelector("#powerboard-payment-container"))==null||i.classList.add("hidden")}));const n=document.querySelector('input[name="payment-type"]');n&&n.click(),u&&((d=document.getElementById("toggle-payment-with-credit-card"))==null||d.click())}async function p(){try{const t=await h();if(!t||!t.status||t.status==="not_authenticated"||t==="not_authenticated")throw u=!0,s(),new Error("There was an issue authenticating this payment method.");if(t.status==="authentication_not_supported"){document.querySelector('input[name="browser_details"]').value=null,document.querySelector('input[name="charge"]').value=JSON.stringify(t);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 e=new cba.Canvas3ds("#widget-3dsecure",t._3ds.token);e.load(),document.getElementById("widget").classList.add("hidden"),e.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()}),e.on("chargeAuthReject",function(n){document.getElementById("errors").textContent="Sorry, your transaction could not be processed...",document.getElementById("errors").hidden=!1,u=!0,s()}),e.load()}catch(t){const e=t.message??"Unknown error.";document.getElementById("errors").textContent=`Sorry, your transaction could not be processed... + +${e}`,document.getElementById("errors").hidden=!1,u=!0,s()}}async function h(){const t={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(t);const e=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:e});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.message}`,document.getElementById("errors").hidden=!1,u=!0,s()}}l()?s():m("#powerboard-credit-card-payment").then(()=>s()); diff --git a/public/build/assets/powerboard-credit-card-f5f23291.js b/public/build/assets/powerboard-credit-card-f5f23291.js deleted file mode 100644 index 4bfbe65cea..0000000000 --- a/public/build/assets/powerboard-credit-card-f5f23291.js +++ /dev/null @@ -1,13 +0,0 @@ -import{i as l,w as m}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 i=!1;function y(){const n=document.querySelector("meta[name=public_key]"),t=document.querySelector("meta[name=gateway_id]"),r=document.querySelector("meta[name=environment]"),e=new cba.HtmlWidget("#widget",n==null?void 0:n.content,t==null?void 0:t.content);e.setEnv(r==null?void 0:r.content),e.useAutoResize(),e.interceptSubmitForm("#stepone"),e.onFinishInsert('#server-response input[name="gateway_response"]',"payment_source"),e.setFormFields(["card_name*"]),e.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="",e}function g(){var n,t,r;(n=document.querySelector("#widget"))==null||n.replaceChildren(),(t=document.querySelector("#widget"))==null||t.classList.remove("hidden"),(r=document.querySelector("#widget-3dsecure"))==null||r.replaceChildren()}function a(){var o,u;if(g(),!((o=document.querySelector("meta[name=gateway_id]"))==null?void 0:o.content)){let d=document.getElementById("pay-now");d.disabled=!0,d.querySelector("svg").classList.remove("hidden"),d.querySelector("span").classList.add("hidden"),document.getElementById("errors").textContent="Gateway not found or verified",document.getElementById("errors").hidden=!1}const t=y();t.on("finish",()=>{document.getElementById("errors").hidden=!0,p()}),t.on("submit",function(d){document.getElementById("errors").hidden=!0});let r=document.getElementById("pay-now");r.addEventListener("click",()=>{const d=document.getElementById("widget");if(t.getValidationState(),!t.isValidForm()&&d.offsetParent!==null){r.disabled=!1,r.querySelector("svg").classList.add("hidden"),r.querySelector("span").classList.remove("hidden");return}r.disabled=!0,r.querySelector("svg").classList.remove("hidden"),r.querySelector("span").classList.add("hidden");let s=document.querySelector("input[name=token-billing-checkbox]:checked");s&&(document.getElementById("store_card").value=s.value),d.offsetParent!==null?document.getElementById("stepone_submit").click():document.getElementById("server-response").submit()}),document.getElementById("toggle-payment-with-credit-card").addEventListener("click",d=>{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(d=>d.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 e=document.querySelector('input[name="payment-type"]');e&&e.click(),i&&((u=document.getElementById("toggle-payment-with-credit-card"))==null||u.click())}async function p(){try{const n=await h();if(!n||!n.status||n.status==="not_authenticated"||n==="not_authenticated")throw i=!0,a(),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 e=document.querySelector("input[name=token-billing-checkbox]:checked");return e&&(document.getElementById("store_card").value=e.value),document.getElementById("server-response").submit()}const t=new cba.Canvas3ds("#widget-3dsecure",n._3ds.token);t.load(),document.getElementById("widget").classList.add("hidden"),t.on("chargeAuthSuccess",function(e){document.querySelector('input[name="browser_details"]').value=null,document.querySelector('input[name="charge"]').value=JSON.stringify(e);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(e){document.getElementById("errors").textContent="Sorry, your transaction could not be processed...",document.getElementById("errors").hidden=!1,i=!0,a()}),t.load()}catch(n){const t=n.message??"Unknown error.";document.getElementById("errors").textContent=`Sorry, your transaction could not be processed... - -${t}`,document.getElementById("errors").hidden=!1,i=!0,a()}}async function h(){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 t=JSON.stringify(Object.fromEntries(new FormData(document.getElementById("server-response")))),r=document.querySelector("meta[name=payments_route]");try{const e=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 e.ok?await e.json():await e.json().then(o=>{throw new Error(o.message??"Unknown error.")})}catch(e){document.getElementById("errors").textContent=`Sorry, your transaction could not be processed... - -${e.message}`,document.getElementById("errors").hidden=!1,i=!0,a()}}l()?a():m("#powerboard-credit-card-payment").then(()=>a()); diff --git a/public/build/manifest.json b/public/build/manifest.json index 9718036576..46e006a2c3 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-f5f23291.js", + "file": "assets/powerboard-credit-card-f4852d3b.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 f18bd63b88..cadd483723 100644 --- a/resources/js/clients/payments/powerboard-credit-card.js +++ b/resources/js/clients/payments/powerboard-credit-card.js @@ -16,6 +16,7 @@ function setup() { const publicKey = document.querySelector('meta[name=public_key]'); const gatewayId = document.querySelector('meta[name=gateway_id]'); const env = document.querySelector('meta[name=environment]'); + const supportedCards = document.querySelector('meta[name=supported_cards]'); const widget = new cba.HtmlWidget( '#widget', @@ -25,6 +26,15 @@ function setup() { widget.setEnv(env?.content); widget.useAutoResize(); + + if (supportedCards?.content) { + try { + const supportedCardsArray = JSON.parse(supportedCards.content); + widget.setSupportedCardIcons(supportedCardsArray, true); + } catch (error) { + } + } + widget.interceptSubmitForm('#stepone'); widget.onFinishInsert( '#server-response input[name="gateway_response"]', diff --git a/resources/views/portal/ninja2020/gateways/powerboard/credit_card/pay.blade.php b/resources/views/portal/ninja2020/gateways/powerboard/credit_card/pay.blade.php index 8f0f1996f7..132fdd1991 100644 --- a/resources/views/portal/ninja2020/gateways/powerboard/credit_card/pay.blade.php +++ b/resources/views/portal/ninja2020/gateways/powerboard/credit_card/pay.blade.php @@ -6,6 +6,7 @@ + @endsection @section('gateway_content') diff --git a/resources/views/portal/ninja2020/gateways/powerboard/credit_card/pay_livewire.blade.php b/resources/views/portal/ninja2020/gateways/powerboard/credit_card/pay_livewire.blade.php index 5a4e7e440f..d0215dab2a 100644 --- a/resources/views/portal/ninja2020/gateways/powerboard/credit_card/pay_livewire.blade.php +++ b/resources/views/portal/ninja2020/gateways/powerboard/credit_card/pay_livewire.blade.php @@ -4,6 +4,7 @@ +