mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Disable payment buttons on submit
This commit is contained in:
parent
d78264f8b7
commit
4a8987cf8f
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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();
|
@ -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();
|
@ -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"
|
||||
},
|
||||
|
@ -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() {
|
||||
|
@ -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();
|
||||
});
|
||||
}
|
||||
|
@ -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');
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user