1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-16 08:02:40 +01:00
invoiceninja/resources/views/payments/paymill/credit_card.blade.php

82 lines
2.5 KiB
PHP
Raw Normal View History

2018-03-07 16:23:25 +01:00
@extends('payments.credit_card')
@section('head')
@parent
<style type="text/css">
.paymill-form {
margin-left: 16px;
}
</style>
<script type="text/javascript">
var PAYMILL_PUBLIC_KEY = '{{ $accountGateway->getPublishableKey() }}';
</script>
<script type="text/javascript" src = "https://bridge.paymill.com/"></script>
<script type="text/javascript">
$(function() {
var options = {
lang: '{{ App::getLocale() }}',
resize: false,
};
var callback = function(error){
if (error){
console.log(error.apierror, error.message);
} else {
}
};
2018-03-15 19:24:42 +01:00
2018-03-07 16:23:25 +01:00
paymill.embedFrame('paymillCardFields', options, callback);
$('.payment-form').unbind('submit').submit(function(event) {
if ($('#sourceToken').val()) {
// do nothing
} else {
event.preventDefault();
var data = {
amount_int: {{ $invitation->invoice->getRequestedAmount() * 100 }},
currency: '{{ $invitation->invoice->getCurrencyCode() }}',
email: '{{ $contact->email }}',
};
var callback = function(error, result) {
if (error) {
if (error.apierror == 'field_invalid_card_number') {
var message = "{{ trans('texts.invalid_card_number') }}";
} else {
var message = error.apierror;
if (error.message) {
message += ': ' + error.message;
}
}
$('.payment-form').find('button').prop('disabled', false);
$('#js-error-message').html(message).fadeIn();
} else {
$('#sourceToken').val(result.token);
$('.payment-form').submit();
}
}
2018-03-15 19:24:42 +01:00
if ($('.payment-form').find('button').is(':disabled')) {
2018-03-07 16:23:25 +01:00
return false;
}
// Disable the submit button to prevent repeated clicks
$('.payment-form').find('button').prop('disabled', true);
$('#js-error-message').hide();
paymill.createTokenViaFrame(data, callback);
}
});
})
</script>
@stop