CRM-15756, validation for CC fixes
authorkurund <kurund@civicrm.org>
Fri, 27 Feb 2015 21:28:54 +0000 (02:58 +0530)
committerkurund <kurund@civicrm.org>
Fri, 27 Feb 2015 21:28:54 +0000 (02:58 +0530)
----------------------------------------
* CRM-15756: Back-office Submit Credit Card Contribution form: card # validation is no longer working
  https://issues.civicrm.org/jira/browse/CRM-15756

CRM/Core/Payment/Form.php
CRM/Member/Form.php

index 6c9182369bf79c61e5e0e24ed5fc86597ae92fc5..8b81511e939cb260af291221eeff849184b12bfb 100644 (file)
@@ -254,7 +254,7 @@ class CRM_Core_Payment_Form {
    *
    * @return bool
    */
-  public static function buildPaymentForm($form, $processor, $isBillingDataOptional) {
+  public static function buildPaymentForm(&$form, $processor, $isBillingDataOptional) {
     //if the form has address fields assign to the template so the js can decide what billing fields to show
     $profileAddressFields = $form->get('profileAddressFields');
     if (!empty($profileAddressFields)) {
@@ -353,7 +353,7 @@ class CRM_Core_Payment_Form {
    * Called within the scope of a QF formRule function
    */
   public static function validateCreditCard($values, &$errors) {
-    if (!empty($values['credit_card_type'])) {
+    if (!empty($values['credit_card_type']) || !empty($values['credit_card_number'])) {
       if (!empty($values['credit_card_number']) &&
         !CRM_Utils_Rule::creditCardNumber($values['credit_card_number'], $values['credit_card_type'])
       ) {
@@ -365,9 +365,6 @@ class CRM_Core_Payment_Form {
         $errors['cvv2'] = ts('Please enter a valid Card Verification Number');
       }
     }
-    elseif (!empty($values['credit_card_number'])) {
-      $errors['credit_card_number'] = ts('Please enter a valid Card Number');
-    }
   }
 
   /**
index cb933329be69972ce7f56e94f9c2f94080618376..d8e1c9e39e2c713bdc923075f70ffc293fe5b740 100644 (file)
@@ -129,7 +129,7 @@ class CRM_Member_Form extends CRM_Contribute_Form_AbstractEditPayment {
         $this->_processors, TRUE,
         array('onChange' => "buildAutoRenew( null, this.value );")
       );
-      CRM_Core_Payment_Form::buildPaymentForm($this, $this->_paymentProcessor, TRUE);
+      CRM_Core_Payment_Form::buildPaymentForm($this, $this->_paymentProcessor, FALSE);
     }
     if ($this->_action & CRM_Core_Action::RENEW) {
       $this->addButtons(array(