X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FPayment%2FForm.php;h=f193753892eec2a6cd9adccebf3f10871b953902;hb=15c6517d363aa473403fec9c8a7df4d9e4b01da1;hp=9f61ac2276d0db6106e6beb5a319f38f3a047384;hpb=c8950569c8c39745086e5a6c9df08b36441b5662;p=civicrm-core.git diff --git a/CRM/Core/Payment/Form.php b/CRM/Core/Payment/Form.php index 9f61ac2276..f193753892 100644 --- a/CRM/Core/Payment/Form.php +++ b/CRM/Core/Payment/Form.php @@ -1,7 +1,7 @@ ts('Card Type'), 'cc_field' => TRUE, 'attributes' => $creditCardType, - 'is_required' => TRUE, + 'is_required' => FALSE, ); } @@ -237,7 +237,7 @@ class CRM_Core_Payment_Form { /** * Function to add all the credit card fields * - * @return None + * @return void * @access public */ static function buildCreditCard(&$form, $useRequired = FALSE) { @@ -272,24 +272,6 @@ class CRM_Core_Payment_Form { 'state_province' => "billing_state_province_id-{$form->_bltID}", )); CRM_Core_BAO_Address::addStateCountryMap($stateCountryMap); - - // Add JS to show icons for the accepted credit cards - // the credit card pseudo constant results only the CC label, not the key ID - // so we normalize the name to use it as a CSS class. - $creditCardTypes = array(); - foreach (CRM_Contribute_PseudoConstant::creditCard() as $key => $name) { - // Replace anything not css-friendly by an underscore - // Non-latin names will not like this, but so many things are wrong with - // the credit-card type configurations already. - $key = str_replace(' ', '', $key); - $key = preg_replace('/[^a-zA-Z0-9]/', '_', $key); - $key = strtolower($key); - $creditCardTypes[$key] = $name; - } - - CRM_Core_Resources::singleton() - ->addSetting(array('config' => array('creditCardTypes' => $creditCardTypes))) - ->addScriptFile('civicrm', 'templates/CRM/Core/BillingBlock.js', 10, 'billing-block'); } if ($form->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_BUTTON) { @@ -303,6 +285,24 @@ class CRM_Core_Payment_Form { } } + /** + * The credit card pseudo constant results only the CC label, not the key ID + * So we normalize the name to use it as a CSS class. + */ + static function getCreditCardCSSNames() { + $creditCardTypes = array(); + foreach (CRM_Contribute_PseudoConstant::creditCard() as $key => $name) { + // Replace anything not css-friendly by an underscore + // Non-latin names will not like this, but so many things are wrong with + // the credit-card type configurations already. + $key = str_replace(' ', '', $key); + $key = preg_replace('/[^a-zA-Z0-9]/', '_', $key); + $key = strtolower($key); + $creditCardTypes[$key] = $name; + } + return $creditCardTypes; + } + /** * Function to add all the direct debit fields * @@ -363,6 +363,9 @@ class CRM_Core_Payment_Form { $errors['cvv2'] = ts('Please enter a valid Credit Card Verification Number'); } } + elseif (!empty($values['credit_card_number'])) { + $errors['credit_card_number'] = ts('Please enter a valid Credit Card Number and Type'); + } } /**