diff --git a/CRM/Admin/Form/Preferences/Contribute.php b/CRM/Admin/Form/Preferences/Contribute.php index 9fb2377ccc66..ce07171df2e1 100644 --- a/CRM/Admin/Form/Preferences/Contribute.php +++ b/CRM/Admin/Form/Preferences/Contribute.php @@ -37,6 +37,7 @@ class CRM_Admin_Form_Preferences_Contribute extends CRM_Admin_Form_Preferences { protected $_settings = array( 'cvv_backoffice_required' => CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, + 'cvv_frontoffice_required' => CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'update_contribution_on_membership_type_change' => CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'acl_financial_type' => CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'always_post_to_accounts_receivable' => CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, @@ -177,7 +178,7 @@ public function buildQuickForm() { public function setDefaultValues() { $defaults = Civi::settings()->get('contribution_invoice_settings'); //CRM-16691: Changes made related to settings of 'CVV'. - foreach (array('cvv_backoffice_required') as $setting) { + foreach (array('cvv_backoffice_required', 'cvv_frontoffice_required') as $setting) { $defaults[$setting] = civicrm_api3('setting', 'getvalue', array( 'name' => $setting, @@ -225,7 +226,7 @@ public function postProcess() { Civi::settings()->set('user_dashboard_options', $settingName); } //CRM-16691: Changes made related to settings of 'CVV'. - $settings = array_intersect_key($params, array('cvv_backoffice_required' => 1)); + $settings = array_intersect_key($params, array('cvv_backoffice_required' => 1, 'cvv_frontoffice_required' => 1)); $result = civicrm_api3('setting', 'create', $settings); CRM_Core_Session::setStatus(ts('Your changes have been saved.'), ts('Changes Saved'), "success"); } diff --git a/CRM/Core/Payment.php b/CRM/Core/Payment.php index 822b6bcc88c3..9965a621a687 100644 --- a/CRM/Core/Payment.php +++ b/CRM/Core/Payment.php @@ -659,9 +659,13 @@ protected function getDirectDebitFormFields() { * @return array * field metadata */ - public function getPaymentFormFieldsMetadata() { + public function getPaymentFormFieldsMetadata($isBackOffice = FALSE) { //@todo convert credit card type into an option value $creditCardType = array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::creditCard(); + $isCVVRequired = Civi::settings()->get('cvv_backoffice_required'); + if (!$isBackOffice) { + $isCVVRequired = Civi::settings()->get('cvv_frontoffice_required'); + } return array( 'credit_card_number' => array( 'htmlType' => 'text', @@ -686,7 +690,7 @@ public function getPaymentFormFieldsMetadata() { 'maxlength' => 10, 'autocomplete' => 'off', ), - 'is_required' => Civi::settings()->get('cvv_backoffice_required'), + 'is_required' => $isCVVRequired, 'rules' => array( array( 'rule_message' => ts('Please enter a valid value for your card security code. This is usually the last 3-4 digits on the card\'s signature panel.'), diff --git a/CRM/Core/Payment/Form.php b/CRM/Core/Payment/Form.php index 4988ee531c79..4ae5a0e56cf5 100644 --- a/CRM/Core/Payment/Form.php +++ b/CRM/Core/Payment/Form.php @@ -71,7 +71,7 @@ static public function setPaymentFieldsByProcessor(&$form, $processor, $billing_ $paymentTypeLabel = self::getPaymentTypeLabel($processor); $form->assign('paymentTypeLabel', $paymentTypeLabel); $form->assign('isBackOffice', $isBackOffice); - $form->_paymentFields = $form->billingFieldSets[$paymentTypeName]['fields'] = self::getPaymentFieldMetadata($processor); + $form->_paymentFields = $form->billingFieldSets[$paymentTypeName]['fields'] = self::getPaymentFieldMetadata($processor, $isBackOffice); $form->_paymentFields = array_merge($form->_paymentFields, self::getBillingAddressMetadata($processor, $form->_bltID)); $form->assign('paymentFields', self::getPaymentFields($processor)); self::setBillingAddressFields($form, $processor); @@ -156,8 +156,8 @@ public static function getPaymentFields($paymentProcessor) { * * @return array */ - public static function getPaymentFieldMetadata($paymentProcessor) { - return array_intersect_key($paymentProcessor['object']->getPaymentFormFieldsMetadata(), array_flip(self::getPaymentFields($paymentProcessor))); + public static function getPaymentFieldMetadata($paymentProcessor, $isBackOffice = FALSE) { + return array_intersect_key($paymentProcessor['object']->getPaymentFormFieldsMetadata($isBackOffice), array_flip(self::getPaymentFields($paymentProcessor))); } /** diff --git a/api/v3/examples/Setting/GetFields.php b/api/v3/examples/Setting/GetFields.php index 3d2c08eaf8b3..4dbec39447d0 100644 --- a/api/v3/examples/Setting/GetFields.php +++ b/api/v3/examples/Setting/GetFields.php @@ -198,6 +198,21 @@ function setting_getfields_expectedresult() { 'description' => 'Is the CVV code required for back office credit card transactions', 'help_text' => 'If set it back-office credit card transactions will required a cvv code. Leave as required unless you have a very strong reason to change', ), + 'cvv_frontoffice_required' => array( + 'group_name' => 'Contribute Preferences', + 'group' => 'contribute', + 'name' => 'cvv_frontoffice_required', + 'type' => 'Boolean', + 'quick_form_type' => 'YesNo', + 'default' => '1', + 'add' => '4.1', + 'title' => 'CVV required for front office?', + 'is_domain' => 1, + 'default' => 1, + 'is_contact' => 0, + 'description' => 'Is the CVV code required for front office credit card transactions', + 'help_text' => 'If set it front-office credit card transactions will required a cvv code. Leave as required unless you have a very strong reason to change', + ), 'contribution_invoice_settings' => array( 'group_name' => 'Contribute Preferences', 'group' => 'contribute', diff --git a/settings/Contribute.setting.php b/settings/Contribute.setting.php index a9b510998806..71252d413bc9 100644 --- a/settings/Contribute.setting.php +++ b/settings/Contribute.setting.php @@ -51,6 +51,21 @@ 'description' => 'Is the CVV code required for back office credit card transactions', 'help_text' => 'If set it back-office credit card transactions will required a cvv code. Leave as required unless you have a very strong reason to change', ), + 'cvv_frontoffice_required' => array( + 'group_name' => 'Contribute Preferences', + 'group' => 'contribute', + 'name' => 'cvv_frontoffice_required', + 'type' => 'Boolean', + 'quick_form_type' => 'YesNo', + 'default' => '1', + 'add' => '4.1', + 'title' => 'CVV required for front office?', + 'is_domain' => 1, + 'default' => 1, + 'is_contact' => 0, + 'description' => 'Is the CVV code required for front office credit card transactions', + 'help_text' => 'If set it front-office credit card transactions will required a cvv code. Leave as required unless you have a very strong reason to change', + ), 'contribution_invoice_settings' => array( 'group_name' => 'Contribute Preferences', 'group' => 'contribute',