mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Working on payment gateways
This commit is contained in:
parent
2bbebcf9a4
commit
b243a41c05
@ -7,6 +7,7 @@
|
|||||||
<script type="text/javascript" >
|
<script type="text/javascript" >
|
||||||
$(function() {
|
$(function() {
|
||||||
var $form = $('.payment-form');
|
var $form = $('.payment-form');
|
||||||
|
$form.unbind('submit');
|
||||||
braintree.setup("{{ $transactionToken }}", "custom", {
|
braintree.setup("{{ $transactionToken }}", "custom", {
|
||||||
id: "payment-form",
|
id: "payment-form",
|
||||||
hostedFields: {
|
hostedFields: {
|
||||||
@ -56,6 +57,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onPaymentMethodReceived: function(event) {
|
onPaymentMethodReceived: function(event) {
|
||||||
|
if ($form.find('button').is(':disabled')) {
|
||||||
|
event.preventDefault();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Disable the submit button to prevent repeated clicks
|
// Disable the submit button to prevent repeated clicks
|
||||||
$form.find('button').prop('disabled', true);
|
$form.find('button').prop('disabled', true);
|
||||||
$('#js-error-message').hide();
|
$('#js-error-message').hide();
|
||||||
|
@ -10,9 +10,16 @@
|
|||||||
var countries = {!! Cache::get('countries')->pluck('iso_3166_2','id') !!};
|
var countries = {!! Cache::get('countries')->pluck('iso_3166_2','id') !!};
|
||||||
WePay.set_endpoint('{{ WEPAY_ENVIRONMENT }}');
|
WePay.set_endpoint('{{ WEPAY_ENVIRONMENT }}');
|
||||||
var $form = $('.payment-form');
|
var $form = $('.payment-form');
|
||||||
$('.payment-form').submit(function(event) {
|
$('.payment-form').unbind('submit').submit(function(event) {
|
||||||
|
if ($('#sourceToken').val()) {
|
||||||
|
// do nothing
|
||||||
|
} else {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
|
if ($form.find('button').is(':disabled')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
var data = {
|
var data = {
|
||||||
client_id: {{ WEPAY_CLIENT_ID }},
|
client_id: {{ WEPAY_CLIENT_ID }},
|
||||||
user_name: $('#first_name').val() + ' ' + $('#last_name').val(),
|
user_name: $('#first_name').val() + ' ' + $('#last_name').val(),
|
||||||
@ -47,9 +54,6 @@
|
|||||||
$form.find('button').prop('disabled', false);
|
$form.find('button').prop('disabled', false);
|
||||||
$('#js-error-message').text(error).fadeIn();
|
$('#js-error-message').text(error).fadeIn();
|
||||||
} else {
|
} else {
|
||||||
if ($form.find('button').is(':disabled')) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// response contains id and card, which contains additional card details
|
// response contains id and card, which contains additional card details
|
||||||
var token = response.credit_card_id;
|
var token = response.credit_card_id;
|
||||||
// Insert the token into the form so it gets submitted to the server
|
// Insert the token into the form so it gets submitted to the server
|
||||||
@ -68,6 +72,7 @@
|
|||||||
|
|
||||||
// Prevent the form from submitting with the default action
|
// Prevent the form from submitting with the default action
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user