diff --git a/app/Http/Requests/ClientPortal/Payments/PaymentResponseRequest.php b/app/Http/Requests/ClientPortal/Payments/PaymentResponseRequest.php index f7a1195e072c..8afdd0d27d7c 100644 --- a/app/Http/Requests/ClientPortal/Payments/PaymentResponseRequest.php +++ b/app/Http/Requests/ClientPortal/Payments/PaymentResponseRequest.php @@ -55,10 +55,18 @@ class PaymentResponseRequest extends FormRequest 'pay_with_token' => ($this->pay_with_token === 'true' || $this->pay_with_token === true) ? true : false, ]); } + + if($this->has('payment_method_id')) { + + $this->merge([ + 'payment_method_id' => preg_replace('~\D~', '', $this->payment_method_id), + ]); + + } } public function shouldUseToken(): bool { return (bool) $this->token; } -} +} \ No newline at end of file diff --git a/public/build/assets/authorize-checkout-card-9d660182.js b/public/build/assets/authorize-checkout-card-9d660182.js deleted file mode 100644 index 2f29569e9c80..000000000000 --- a/public/build/assets/authorize-checkout-card-9d660182.js +++ /dev/null @@ -1,9 +0,0 @@ -/** - * 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 t{constructor(){this.button=document.querySelector("#pay-button")}init(){this.frames=Frames.init(document.querySelector("meta[name=public-key]").content)}handle(){this.init(),Frames.addEventHandler(Frames.Events.CARD_VALIDATION_CHANGED,e=>{this.button.disabled=!Frames.isCardValid()}),Frames.addEventHandler(Frames.Events.CARD_TOKENIZED,e=>{document.querySelector('input[name="gateway_response"]').value=JSON.stringify(e),document.getElementById("server_response").submit()}),document.querySelector("#authorization-form").addEventListener("submit",e=>{this.button.disabled=!0,e.preventDefault(),Frames.submitCard()})}}new t().handle(); diff --git a/public/build/assets/checkout-credit-card-906a30cd.js b/public/build/assets/checkout-credit-card-906a30cd.js deleted file mode 100644 index e6598e0921be..000000000000 --- a/public/build/assets/checkout-credit-card-906a30cd.js +++ /dev/null @@ -1,9 +0,0 @@ -/** - * 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 o{constructor(){this.tokens=[]}mountFrames(){console.log("Mount checkout frames..")}handlePaymentUsingToken(t){document.getElementById("checkout--container").classList.add("hidden"),document.getElementById("pay-now-with-token--container").classList.remove("hidden"),document.getElementById("save-card--container").style.display="none",document.querySelector("input[name=token]").value=t.target.dataset.token}handlePaymentUsingCreditCard(t){document.getElementById("checkout--container").classList.remove("hidden"),document.getElementById("pay-now-with-token--container").classList.add("hidden"),document.getElementById("save-card--container").style.display="grid",document.querySelector("input[name=token]").value="";const e=document.getElementById("pay-button"),a=document.querySelector('meta[name="public-key"]').content??"",d=document.getElementById("payment-form");Frames.init(a),Frames.addEventHandler(Frames.Events.CARD_VALIDATION_CHANGED,function(n){e.disabled=!Frames.isCardValid()}),Frames.addEventHandler(Frames.Events.CARD_TOKENIZATION_FAILED,function(n){pay.button.disabled=!1}),Frames.addEventHandler(Frames.Events.CARD_TOKENIZED,function(n){e.disabled=!0,document.querySelector('input[name="gateway_response"]').value=JSON.stringify(n),document.querySelector('input[name="store_card"]').value=document.querySelector("input[name=token-billing-checkbox]:checked").value,document.getElementById("server-response").submit()}),d.addEventListener("submit",function(n){n.preventDefault(),Frames.submitCard()})}completePaymentUsingToken(t){let e=document.getElementById("pay-now-with-token");e.disabled=!0,e.querySelector("svg").classList.remove("hidden"),e.querySelector("span").classList.add("hidden"),document.getElementById("server-response").submit()}handle(){this.handlePaymentUsingCreditCard(),Array.from(document.getElementsByClassName("toggle-payment-with-token")).forEach(t=>t.addEventListener("click",this.handlePaymentUsingToken)),document.getElementById("toggle-payment-with-credit-card").addEventListener("click",this.handlePaymentUsingCreditCard),document.getElementById("pay-now-with-token").addEventListener("click",this.completePaymentUsingToken)}}new o().handle(); diff --git a/public/build/manifest.json b/public/build/manifest.json index 62fe8624e99b..103a05041065 100644 --- a/public/build/manifest.json +++ b/public/build/manifest.json @@ -41,7 +41,7 @@ "src": "resources/js/clients/payment_methods/authorize-authorize-card.js" }, "resources/js/clients/payment_methods/authorize-checkout-card.js": { - "file": "assets/authorize-checkout-card-9d660182.js", + "file": "assets/authorize-checkout-card-d561d355.js", "isEntry": true, "src": "resources/js/clients/payment_methods/authorize-checkout-card.js" }, @@ -71,7 +71,7 @@ "src": "resources/js/clients/payments/braintree-paypal.js" }, "resources/js/clients/payments/checkout-credit-card.js": { - "file": "assets/checkout-credit-card-906a30cd.js", + "file": "assets/checkout-credit-card-8a04938c.js", "isEntry": true, "src": "resources/js/clients/payments/checkout-credit-card.js" }, diff --git a/resources/js/clients/payment_methods/authorize-checkout-card.js b/resources/js/clients/payment_methods/authorize-checkout-card.js index 1a6af00dcc95..de25ebf84f69 100644 --- a/resources/js/clients/payment_methods/authorize-checkout-card.js +++ b/resources/js/clients/payment_methods/authorize-checkout-card.js @@ -10,7 +10,9 @@ class CheckoutCreditCardAuthorization { constructor() { - this.button = document.querySelector('#pay-button'); + // this.button = document.querySelector('#pay-button'); + this.button = document.getElementById('pay-button'); + } init() { diff --git a/resources/js/clients/payments/checkout-credit-card.js b/resources/js/clients/payments/checkout-credit-card.js index 13327e62fc2e..bb32fa7337ce 100644 --- a/resources/js/clients/payments/checkout-credit-card.js +++ b/resources/js/clients/payments/checkout-credit-card.js @@ -37,6 +37,7 @@ class CheckoutCreditCard { .value = ''; const payButton = document.getElementById('pay-button'); + const publicKey = document.querySelector('meta[name="public-key"]').content ?? ''; const form = document.getElementById('payment-form'); @@ -47,7 +48,7 @@ class CheckoutCreditCard { }); Frames.addEventHandler(Frames.Events.CARD_TOKENIZATION_FAILED, function (event) { - pay.button.disabled = false; + payButton.disabled = false; }); Frames.addEventHandler(Frames.Events.CARD_TOKENIZED, function (event) { @@ -68,6 +69,7 @@ class CheckoutCreditCard { form.addEventListener('submit', function (event) { event.preventDefault(); + payButton.disabled = true; Frames.submitCard(); }); } diff --git a/tests/Unit/EvaluateStringTest.php b/tests/Unit/EvaluateStringTest.php index d7d61e67f0c8..5e08ccbce2ad 100644 --- a/tests/Unit/EvaluateStringTest.php +++ b/tests/Unit/EvaluateStringTest.php @@ -19,8 +19,18 @@ use Tests\TestCase; */ class EvaluateStringTest extends TestCase { + public function testNumericCleanup() + { + $string = '13/favicon.ico'; + + $number = preg_replace('~\D~', '', $string); + + $this->assertEquals(13, $number); + } + public function testClassNameResolution() { $this->assertEquals(class_basename(Client::class), 'Client'); } + }