CRM-15756, more fixes for validation
authorkurund <kurund@civicrm.org>
Sat, 28 Feb 2015 13:34:46 +0000 (19:04 +0530)
committerkurund <kurund@civicrm.org>
Sat, 28 Feb 2015 13:34:46 +0000 (19:04 +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/Contribute/Form/Contribution.php

index 35ca917350d9e82e23b8e60cce40c63064e4f4fc..da3cbdc61edea7afa44f334646181148db995d77 100644 (file)
@@ -923,6 +923,10 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
       if (empty($fields['payment_processor_id'])) {
         $errors['payment_processor_id'] = ts('Payment Processor is a required field.');
       }
+      else {
+        // validate payment instrument (e.g. credit card number)
+        CRM_Core_Payment_Form::validatePaymentInstrument($fields['payment_processor_id'], $fields, $errors, $self);
+      }
     }
 
     // Do the amount validations.
@@ -946,7 +950,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
     }
 
     //FIXME FOR NEW DATA FLOW http://wiki.civicrm.org/confluence/display/CRM/CiviAccounts+4.3+Data+Flow
-    if (!empty($fields['fee_amount']) && $financialType = CRM_Contribute_BAO_Contribution::validateFinancialType($fields['financial_type_id'])) {
+    if (!empty($fields['fee_amount']) && !empty($fields['financial_type_id']) && $financialType = CRM_Contribute_BAO_Contribution::validateFinancialType($fields['financial_type_id'])) {
       $errors['financial_type_id'] = ts("Financial Account of account relationship of 'Expense Account is' is not configured for Financial Type : ") . $financialType;
     }