Skip to content

Commit

Permalink
Improvements for square payments
Browse files Browse the repository at this point in the history
  • Loading branch information
turbo124 committed Oct 10, 2024
1 parent 124904c commit 9b80f74
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 13 deletions.
1 change: 1 addition & 0 deletions public/build/assets/app-ee6f3b1c.css

Large diffs are not rendered by default.

9 changes: 0 additions & 9 deletions public/build/assets/square-credit-card-2fc5c3fa.js

This file was deleted.

9 changes: 9 additions & 0 deletions public/build/assets/square-credit-card-9e88c754.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion public/build/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
"src": "resources/js/clients/payments/razorpay-aio.js"
},
"resources/js/clients/payments/square-credit-card.js": {
"file": "assets/square-credit-card-2fc5c3fa.js",
"file": "assets/square-credit-card-9e88c754.js",
"imports": [
"_wait-8f4ae121.js"
],
Expand Down
29 changes: 28 additions & 1 deletion resources/js/clients/payments/square-credit-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ class SquareCreditCard {
document.getElementById('errors').hidden = true;
e.target.parentElement.disabled = true;

let payNowButton = document.getElementById('pay-now');
this.payNowButton = payNowButton;

this.payNowButton.disabled = true;

this.payNowButton.querySelector('svg').classList.remove('hidden');
this.payNowButton.querySelector('span').classList.add('hidden');

let result = await this.card.tokenize();

/* SCA */
Expand Down Expand Up @@ -99,11 +107,23 @@ class SquareCreditCard {
document.getElementById('errors').hidden = false;

e.target.parentElement.disabled = false;
this.payNowButton.disabled = false;

this.payNowButton.querySelector('svg').classList.add('hidden');
this.payNowButton.querySelector('span').classList.remove('hidden');
}

async completePaymentUsingToken(e) {
e.target.parentElement.disabled = true;

let payNowButton = document.getElementById('pay-now');
this.payNowButton = payNowButton;

this.payNowButton.disabled = true;

this.payNowButton.querySelector('svg').classList.remove('hidden');
this.payNowButton.querySelector('span').classList.add('hidden');

return document.getElementById('server_response').submit();
}

Expand Down Expand Up @@ -173,7 +193,14 @@ class SquareCreditCard {
document.querySelector('input[name=token]').value = '';
});

document.getElementById('loader').classList.add('hidden');
Array.from(
document.getElementsByClassName('loader')
).forEach((element) => {

element.classList.add('hidden');

});

document.getElementById('payment-list').classList.remove('hidden');
document.getElementById('toggle-payment-with-credit-card')?.click();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
@include('portal.ninja2020.gateways.includes.payment_details')

@component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.pay_with')])
<div class="flex flex-col" id="loader">
<div class="loader ease-linear rounded-full border-4 border-t-4 border-gray-200 h-12 w-12 mb-4" id="loader"></div>
<div class="flex flex-col" >
<div class="loader ease-linear rounded-full border-4 border-t-4 border-gray-200 h-12 w-12 mb-4"></div>
</div>

<ul class="list-none space-y-2" id="payment-list">
Expand Down

0 comments on commit 9b80f74

Please sign in to comment.