mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 16:24:35 -04:00
some modification implemented for removing double submission.
This commit is contained in:
parent
4fc565960b
commit
e7331c9e21
81
resources/js/clients/payments/forte-ach-payment.js
vendored
Normal file
81
resources/js/clients/payments/forte-ach-payment.js
vendored
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
/**
|
||||||
|
* 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://opensource.org/licenses/AAL
|
||||||
|
*/
|
||||||
|
|
||||||
|
class ForteAuthorizeACH {
|
||||||
|
constructor(apiLoginId) {
|
||||||
|
this.apiLoginId = apiLoginId;
|
||||||
|
}
|
||||||
|
|
||||||
|
handleAuthorization = () => {
|
||||||
|
var account_number = document.getElementById('account-number').value;
|
||||||
|
var routing_number = document.getElementById('routing-number').value;
|
||||||
|
|
||||||
|
var data = {
|
||||||
|
api_login_id: this.apiLoginId,
|
||||||
|
account_number: account_number,
|
||||||
|
routing_number: routing_number,
|
||||||
|
account_type: 'checking',
|
||||||
|
};
|
||||||
|
|
||||||
|
let payNowButton = document.getElementById('pay-now');
|
||||||
|
|
||||||
|
if (payNowButton) {
|
||||||
|
document.getElementById('pay-now').disabled = true;
|
||||||
|
document.querySelector('#pay-now > svg').classList.remove('hidden');
|
||||||
|
document.querySelector('#pay-now > span').classList.add('hidden');
|
||||||
|
}
|
||||||
|
// console.log(data);
|
||||||
|
forte
|
||||||
|
.createToken(data)
|
||||||
|
.success(this.successResponseHandler)
|
||||||
|
.error(this.failedResponseHandler);
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
successResponseHandler = (response) => {
|
||||||
|
document.getElementById('payment_token').value = response.onetime_token;
|
||||||
|
|
||||||
|
document.getElementById('server_response').submit();
|
||||||
|
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
failedResponseHandler = (response) => {
|
||||||
|
var errors =
|
||||||
|
'<div class="alert alert-failure mb-4"><ul><li>' +
|
||||||
|
response.response_description +
|
||||||
|
'</li></ul></div>';
|
||||||
|
document.getElementById('forte_errors').innerHTML = errors;
|
||||||
|
document.getElementById('pay-now').disabled = false;
|
||||||
|
document.querySelector('#pay-now > svg').classList.add('hidden');
|
||||||
|
document.querySelector('#pay-now > span').classList.remove('hidden');
|
||||||
|
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
handle = () => {
|
||||||
|
let payNowButton = document.getElementById('pay-now');
|
||||||
|
|
||||||
|
if (payNowButton) {
|
||||||
|
payNowButton.addEventListener('click', (e) => {
|
||||||
|
this.handleAuthorization();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const apiLoginId = document.querySelector(
|
||||||
|
'meta[name="forte-api-login-id"]'
|
||||||
|
).content;
|
||||||
|
|
||||||
|
/** @handle */
|
||||||
|
new ForteAuthorizeACH(apiLoginId).handle();
|
83
resources/js/clients/payments/forte-credit-card-payment.js
vendored
Normal file
83
resources/js/clients/payments/forte-credit-card-payment.js
vendored
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
/**
|
||||||
|
* 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://opensource.org/licenses/AAL
|
||||||
|
*/
|
||||||
|
|
||||||
|
class ForteAuthorizeCard {
|
||||||
|
constructor(apiLoginId) {
|
||||||
|
this.apiLoginId = apiLoginId;
|
||||||
|
this.cardHolderName = document.getElementById('cardholder_name');
|
||||||
|
}
|
||||||
|
|
||||||
|
handleAuthorization = () => {
|
||||||
|
var myCard = $('#my-card');
|
||||||
|
|
||||||
|
var data = {
|
||||||
|
api_login_id: this.apiLoginId,
|
||||||
|
card_number: myCard.CardJs('cardNumber').replace(/[^\d]/g, ''),
|
||||||
|
expire_year: myCard.CardJs('expiryYear').replace(/[^\d]/g, ''),
|
||||||
|
expire_month: myCard.CardJs('expiryMonth').replace(/[^\d]/g, ''),
|
||||||
|
cvv: document.getElementById('cvv').value.replace(/[^\d]/g, ''),
|
||||||
|
};
|
||||||
|
|
||||||
|
let payNowButton = document.getElementById('pay-now');
|
||||||
|
|
||||||
|
if (payNowButton) {
|
||||||
|
document.getElementById('pay-now').disabled = true;
|
||||||
|
document.querySelector('#pay-now > svg').classList.remove('hidden');
|
||||||
|
document.querySelector('#pay-now > span').classList.add('hidden');
|
||||||
|
}
|
||||||
|
|
||||||
|
forte
|
||||||
|
.createToken(data)
|
||||||
|
.success(this.successResponseHandler)
|
||||||
|
.error(this.failedResponseHandler);
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
successResponseHandler = (response) => {
|
||||||
|
document.getElementById('payment_token').value = response.onetime_token;
|
||||||
|
document.getElementById('card_brand').value = response.card_type;
|
||||||
|
|
||||||
|
document.getElementById('server_response').submit();
|
||||||
|
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
failedResponseHandler = (response) => {
|
||||||
|
var errors =
|
||||||
|
'<div class="alert alert-failure mb-4"><ul><li>' +
|
||||||
|
response.response_description +
|
||||||
|
'</li></ul></div>';
|
||||||
|
document.getElementById('forte_errors').innerHTML = errors;
|
||||||
|
document.getElementById('pay-now').disabled = false;
|
||||||
|
document.querySelector('#pay-now > svg').classList.add('hidden');
|
||||||
|
document.querySelector('#pay-now > span').classList.remove('hidden');
|
||||||
|
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
handle = () => {
|
||||||
|
let payNowButton = document.getElementById('pay-now');
|
||||||
|
|
||||||
|
if (payNowButton) {
|
||||||
|
payNowButton.addEventListener('click', (e) => {
|
||||||
|
this.handleAuthorization();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const apiLoginId = document.querySelector(
|
||||||
|
'meta[name="forte-api-login-id"]'
|
||||||
|
).content;
|
||||||
|
|
||||||
|
/** @handle */
|
||||||
|
new ForteAuthorizeCard(apiLoginId).handle();
|
@ -1,11 +1,7 @@
|
|||||||
@extends('portal.ninja2020.layout.payments', ['gateway_title' => 'Bank Transfer', 'card_title' => 'Bank Transfer'])
|
@extends('portal.ninja2020.layout.payments', ['gateway_title' => 'Bank Transfer', 'card_title' => 'Bank Transfer'])
|
||||||
|
|
||||||
@section('gateway_head')
|
@section('gateway_head')
|
||||||
@if($gateway->forte->company_gateway->getConfigField('testMode'))
|
<meta name="forte-api-login-id" content="{{$gateway->forte->company_gateway->getConfigField("apiLoginId")}}">
|
||||||
<script type="text/javascript" src="https://sandbox.forte.net/api/js/v1"></script>
|
|
||||||
@else
|
|
||||||
<script type="text/javascript" src="https://api.forte.net/js/v1"></script>
|
|
||||||
@endif
|
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
@section('gateway_content')
|
@section('gateway_content')
|
||||||
@ -41,46 +37,17 @@
|
|||||||
<input class="input w-full" id="account-number" type="text" placeholder="{{ctrans('texts.account_number')}}" required>
|
<input class="input w-full" id="account-number" type="text" placeholder="{{ctrans('texts.account_number')}}" required>
|
||||||
</div>
|
</div>
|
||||||
@endcomponent
|
@endcomponent
|
||||||
<div class="bg-white px-4 py-5 flex justify-end">
|
|
||||||
<button type="button"
|
@include('portal.ninja2020.gateways.includes.pay_now')
|
||||||
onclick="submitPay()"
|
|
||||||
class="button button-primary bg-primary {{ $class ?? '' }}">
|
|
||||||
<svg class="animate-spin h-5 w-5 text-white hidden" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
|
|
||||||
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
|
|
||||||
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
|
|
||||||
</svg>
|
|
||||||
<span>{{ $slot ?? ctrans('texts.pay_now') }}</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
@section('gateway_footer')
|
@section('gateway_footer')
|
||||||
<script>
|
@if($gateway->forte->company_gateway->getConfigField('testMode'))
|
||||||
function onTokenCreated(params) {
|
<script type="text/javascript" src="https://sandbox.forte.net/api/js/v1"></script>
|
||||||
document.getElementById('payment_token').value=params.onetime_token;
|
@else
|
||||||
let button = document.querySelector("#form_btn");
|
<script type="text/javascript" src="https://api.forte.net/js/v1"></script>
|
||||||
button.click();
|
@endif
|
||||||
}
|
|
||||||
function onTokenFailed(params) {
|
<script src="{{ asset('js/clients/payments/forte-ach-payment.js') }}"></script>
|
||||||
var errors = '<div class="alert alert-failure mb-4"><ul><li>'+ params.response_description +'</li></ul></div>';
|
|
||||||
document.getElementById("forte_errors").innerHTML = errors;
|
|
||||||
}
|
|
||||||
function submitPay(){
|
|
||||||
var account_number=document.getElementById('account-number').value;
|
|
||||||
var routing_number=document.getElementById('routing-number').value;
|
|
||||||
|
|
||||||
var data = {
|
|
||||||
api_login_id: '{{$gateway->forte->company_gateway->getConfigField("apiLoginId")}}',
|
|
||||||
account_number: account_number,
|
|
||||||
routing_number: routing_number,
|
|
||||||
account_type: "checking",
|
|
||||||
}
|
|
||||||
|
|
||||||
forte.createToken(data)
|
|
||||||
.success(onTokenCreated)
|
|
||||||
.error(onTokenFailed);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@endsection
|
@endsection
|
||||||
|
@ -1,16 +1,11 @@
|
|||||||
@extends('portal.ninja2020.layout.payments', ['gateway_title' => ctrans('texts.payment_type_credit_card'), 'card_title' => ctrans('texts.payment_type_credit_card')])
|
@extends('portal.ninja2020.layout.payments', ['gateway_title' => ctrans('texts.payment_type_credit_card'), 'card_title' => ctrans('texts.payment_type_credit_card')])
|
||||||
|
|
||||||
@section('gateway_head')
|
@section('gateway_head')
|
||||||
|
<meta name="forte-api-login-id" content="{{$gateway->forte->company_gateway->getConfigField("apiLoginId")}}">
|
||||||
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
|
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
|
||||||
<script src="{{ asset('js/clients/payments/forte-card-js.min.js') }}"></script>
|
<script src="{{ asset('js/clients/payments/forte-card-js.min.js') }}"></script>
|
||||||
|
|
||||||
<link href="{{ asset('css/card-js.min.css') }}" rel="stylesheet" type="text/css">
|
<link href="{{ asset('css/card-js.min.css') }}" rel="stylesheet" type="text/css">
|
||||||
|
|
||||||
@if($gateway->forte->company_gateway->getConfigField('testMode'))
|
|
||||||
<script type="text/javascript" src="https://sandbox.forte.net/api/js/v1"></script>
|
|
||||||
@else
|
|
||||||
<script type="text/javascript" src="https://api.forte.net/js/v1"></script>
|
|
||||||
@endif
|
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
@section('gateway_content')
|
@section('gateway_content')
|
||||||
@ -41,50 +36,16 @@
|
|||||||
@include('portal.ninja2020.gateways.forte.includes.credit_card')
|
@include('portal.ninja2020.gateways.forte.includes.credit_card')
|
||||||
@endcomponent
|
@endcomponent
|
||||||
|
|
||||||
<div class="bg-white px-4 py-5 flex justify-end">
|
@include('portal.ninja2020.gateways.includes.pay_now')
|
||||||
<button type="button"
|
|
||||||
onclick="submitPay()"
|
|
||||||
class="button button-primary bg-primary {{ $class ?? '' }}">
|
|
||||||
<svg class="animate-spin h-5 w-5 text-white hidden" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
|
|
||||||
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
|
|
||||||
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
|
|
||||||
</svg>
|
|
||||||
<span>{{ $slot ?? ctrans('texts.pay_now') }}</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
@section('gateway_footer')
|
@section('gateway_footer')
|
||||||
<script>
|
@if($gateway->forte->company_gateway->getConfigField('testMode'))
|
||||||
function onTokenCreated(params) {
|
<script type="text/javascript" src="https://sandbox.forte.net/api/js/v1"></script>
|
||||||
document.getElementById('payment_token').value=params.onetime_token;
|
@else
|
||||||
document.getElementById('card_brand').value=params.card_type;
|
<script type="text/javascript" src="https://api.forte.net/js/v1"></script>
|
||||||
let button = document.querySelector("#form_btn");
|
@endif
|
||||||
button.click();
|
|
||||||
}
|
<script src="{{ asset('js/clients/payments/forte-credit-card-payment.js') }}"></script>
|
||||||
function onTokenFailed(params) {
|
|
||||||
var errors = '<div class="alert alert-failure mb-4"><ul><li>'+ params.response_description +'</li></ul></div>';
|
|
||||||
document.getElementById("forte_errors").innerHTML = errors;
|
|
||||||
}
|
|
||||||
function submitPay(){
|
|
||||||
var month=document.querySelector('input[name=expiry-month]').value;
|
|
||||||
var year=document.querySelector('input[name=expiry-year]').value;
|
|
||||||
var cc=document.getElementById('card_number').value.replaceAll(' ','');
|
|
||||||
var cvv=document.getElementById('cvv').value;
|
|
||||||
|
|
||||||
var data = {
|
|
||||||
api_login_id: '{{$gateway->forte->company_gateway->getConfigField("apiLoginId")}}',
|
|
||||||
card_number: cc,
|
|
||||||
expire_year: year,
|
|
||||||
expire_month: month,
|
|
||||||
cvv: cvv,
|
|
||||||
}
|
|
||||||
|
|
||||||
forte.createToken(data)
|
|
||||||
.success(onTokenCreated)
|
|
||||||
.error(onTokenFailed);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@endsection
|
@endsection
|
||||||
|
8
webpack.mix.js
vendored
8
webpack.mix.js
vendored
@ -10,6 +10,14 @@ mix.js("resources/js/app.js", "public/js")
|
|||||||
"resources/js/clients/payments/authorize-credit-card-payment.js",
|
"resources/js/clients/payments/authorize-credit-card-payment.js",
|
||||||
"public/js/clients/payments/authorize-credit-card-payment.js"
|
"public/js/clients/payments/authorize-credit-card-payment.js"
|
||||||
)
|
)
|
||||||
|
.js(
|
||||||
|
"resources/js/clients/payments/forte-credit-card-payment.js",
|
||||||
|
"public/js/clients/payments/forte-credit-card-payment.js"
|
||||||
|
)
|
||||||
|
.js(
|
||||||
|
"resources/js/clients/payments/forte-ach-payment.js",
|
||||||
|
"public/js/clients/payments/forte-ach-payment.js"
|
||||||
|
)
|
||||||
.js(
|
.js(
|
||||||
"resources/js/clients/payments/stripe-ach.js",
|
"resources/js/clients/payments/stripe-ach.js",
|
||||||
"public/js/clients/payments/stripe-ach.js"
|
"public/js/clients/payments/stripe-ach.js"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user