mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Credit card: Authorize
This commit is contained in:
parent
9e146b7ef8
commit
f160b7e1a9
@ -1,13 +1,19 @@
|
||||
@extends('portal.ninja2020.layout.payments', ['gateway_title' => ctrans('texts.credit_card'), 'card_title' => ctrans('texts.credit_card')])
|
||||
|
||||
@section('gateway_head')
|
||||
<meta name="year-invalid" content="{{ ctrans('texts.year_invalid') }}">
|
||||
<meta name="month-invalid" content="{{ ctrans('texts.month_invalid') }}">
|
||||
<meta name="credit-card-invalid" content="{{ ctrans('texts.credit_card_invalid') }}">
|
||||
<meta name="wepay-environment" content="{{ config('ninja.wepay.environment') }}">
|
||||
<meta name="wepay-action" content="authorize">
|
||||
<meta name="wepay-client-id" content="{{ config('ninja.wepay.client_id') }}">
|
||||
|
||||
<meta name="contact-email" content="{{ $contact->email }}">
|
||||
<meta name="client-postal-code" content="{{ $contact->client->postal_code }}">
|
||||
|
||||
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
|
||||
<script src="{{ asset('js/clients/payments/card-js.min.js') }}"></script>
|
||||
|
||||
<link href="{{ asset('css/card-js.min.css') }}" rel="stylesheet" type="text/css">
|
||||
|
||||
<script type="text/javascript" src="https://static.wepay.com/min/js/tokenization.4.latest.js"></script>
|
||||
@endsection
|
||||
|
||||
@section('gateway_content')
|
||||
@ -40,111 +46,5 @@
|
||||
@endsection
|
||||
|
||||
@section('gateway_footer')
|
||||
|
||||
<script type="text/javascript" src="https://static.wepay.com/min/js/tokenization.4.latest.js"></script>
|
||||
<script type="text/javascript">
|
||||
(function() {
|
||||
|
||||
@if(config('ninja.wepay.environment') == 'staging')
|
||||
WePay.set_endpoint("stage");
|
||||
@else
|
||||
WePay.set_endpoint("production");
|
||||
@endif
|
||||
// Shortcuts
|
||||
var d = document;
|
||||
d.id = d.getElementById,
|
||||
valueById = function(id) {
|
||||
return d.id(id).value;
|
||||
};
|
||||
|
||||
// For those not using DOM libraries
|
||||
var addEvent = function(e,v,f) {
|
||||
if (!!window.attachEvent) { e.attachEvent('on' + v, f); }
|
||||
else { e.addEventListener(v, f, false); }
|
||||
};
|
||||
|
||||
let errors = document.getElementById('errors');
|
||||
|
||||
// Attach the event to the DOM
|
||||
addEvent(document.getElementById('card_button'), 'click', function() {
|
||||
|
||||
var myCard = $('#my-card');
|
||||
|
||||
if(document.getElementById('cardholder_name') == "") {
|
||||
document.getElementById('cardholder_name').focus();
|
||||
errors.textContent = "Cardholder name required.";
|
||||
errors.hidden = false;
|
||||
return;
|
||||
}
|
||||
else if(myCard.CardJs('cardNumber') == ""){
|
||||
document.getElementById('card_number').focus();
|
||||
errors.textContent = "Card number required.";
|
||||
errors.hidden = false;
|
||||
return;
|
||||
}
|
||||
else if(myCard.CardJs('cvc') == ""){
|
||||
document.getElementById('cvv').focus();
|
||||
errors.textContent = "CVV number required.";
|
||||
errors.hidden = false;
|
||||
return;
|
||||
}
|
||||
else if(myCard.CardJs('expiryMonth') == ""){
|
||||
// document.getElementById('expiry_month').focus();
|
||||
errors.textContent = "Expiry Month number required.";
|
||||
errors.hidden = false;
|
||||
return;
|
||||
}
|
||||
else if(myCard.CardJs('expiryYear') == ""){
|
||||
// document.getElementById('expiry_year').focus();
|
||||
errors.textContent = "Expiry Year number required.";
|
||||
errors.hidden = false;
|
||||
return;
|
||||
}
|
||||
|
||||
cardButton = document.getElementById('card_button');
|
||||
cardButton.disabled = true;
|
||||
|
||||
cardButton.querySelector('svg').classList.remove('hidden');
|
||||
cardButton.querySelector('span').classList.add('hidden');
|
||||
|
||||
var userName = [valueById('cardholder_name')].join(' ');
|
||||
response = WePay.credit_card.create({
|
||||
"client_id": "{{ config('ninja.wepay.client_id') }}",
|
||||
"user_name": valueById('cardholder_name'),
|
||||
"email": "{{ $contact->email }}",
|
||||
"cc_number": myCard.CardJs('cardNumber'),
|
||||
"cvv": myCard.CardJs('cvc'),
|
||||
"expiration_month": myCard.CardJs('expiryMonth'),
|
||||
"expiration_year": myCard.CardJs('expiryYear'),
|
||||
"address": {
|
||||
"postal_code": "{{ $contact->client->postal_code }}"
|
||||
}
|
||||
}, function(data) {
|
||||
|
||||
if (data.error) {
|
||||
//console.log(data);
|
||||
// handle error response error_description
|
||||
cardButton = document.getElementById('card_button');
|
||||
cardButton.disabled = false;
|
||||
cardButton.querySelector('svg').classList.add('hidden');
|
||||
cardButton.querySelector('span').classList.remove('hidden');
|
||||
|
||||
errors.textContent = '';
|
||||
errors.textContent = data.error_description;
|
||||
errors.hidden = false;
|
||||
|
||||
} else {
|
||||
|
||||
var token = data.credit_card_id;
|
||||
|
||||
document.querySelector('input[name="credit_card_id"]').value = token;
|
||||
document.getElementById('server_response').submit();
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
})();
|
||||
</script>
|
||||
|
||||
@endsection
|
||||
<script src="{{ asset('js/clients/payments/wepay-credit-card.js') }}"></script>
|
||||
@endsection
|
||||
|
Loading…
x
Reference in New Issue
Block a user