From 604c132a3a0405657a4d3eeee252bdb7c9f67ebf Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sun, 24 Apr 2016 16:14:35 +0300 Subject: [PATCH] Temporary workaround to support not setting the CVC/CVV --- app/Services/PaymentService.php | 8 ++++++-- resources/views/payments/payment.blade.php | 11 ++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/app/Services/PaymentService.php b/app/Services/PaymentService.php index 61af6cd2336c..858a175f8954 100644 --- a/app/Services/PaymentService.php +++ b/app/Services/PaymentService.php @@ -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']); diff --git a/resources/views/payments/payment.blade.php b/resources/views/payments/payment.blade.php index 48ff913c4ea3..274361938bac 100644 --- a/resources/views/payments/payment.blade.php +++ b/resources/views/payments/payment.blade.php @@ -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();