Temporary workaround to support not setting the CVC/CVV

This commit is contained in:
Hillel Coren 2016-04-24 16:14:35 +03:00
parent 07f50d188f
commit 604c132a3a
2 changed files with 14 additions and 5 deletions

View File

@ -98,9 +98,13 @@ class PaymentService extends BaseService
'number' => isset($input['card_number']) ? $input['card_number'] : null,
'expiryMonth' => isset($input['expiration_month']) ? $input['expiration_month'] : null,
'expiryYear' => isset($input['expiration_year']) ? $input['expiration_year'] : null,
'cvv' => isset($input['cvv']) ? $input['cvv'] : '',
];
// allow space until there's a setting to disable
if (isset($input['cvv']) && $input['cvv'] != ' ') {
$data['cvv'] = $input['cvv'];
}
if (isset($input['country_id'])) {
$country = Country::find($input['country_id']);

View File

@ -20,10 +20,14 @@
address_zip: $('#postal_code').val(),
address_country: $("#country_id option:selected").text(),
number: $('#card_number').val(),
cvc: $('#cvv').val(),
exp_month: $('#expiration_month').val(),
exp_year: $('#expiration_year').val()
};
// allow space until there's a setting to disable
if ($('#cvv').val() != ' ') {
data.cvc = $('#cvv').val();
}
// Validate the card details
if (!Stripe.card.validateCardNumber(data.number)) {
@ -34,11 +38,12 @@
$('#js-error-message').html('{{ trans('texts.invalid_expiry') }}').fadeIn();
return false;
}
if (!Stripe.card.validateCVC(data.cvc)) {
if (data.hasOwnProperty('cvc') && !Stripe.card.validateCVC(data.cvc)) {
$('#js-error-message').html('{{ trans('texts.invalid_cvv') }}').fadeIn();
return false;
}
// Disable the submit button to prevent repeated clicks
$form.find('button').prop('disabled', true);
$('#js-error-message').hide();