Skip to content

Commit

Permalink
CRM-20166: Making CVV always required for front-end contribution pages.
Browse files Browse the repository at this point in the history
  • Loading branch information
agilewarealok committed Oct 31, 2017
1 parent f118998 commit 6393279
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions CRM/Core/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = TRUE;
}
return array(
'credit_card_number' => array(
'htmlType' => 'text',
Expand All @@ -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.'),
Expand Down
6 changes: 3 additions & 3 deletions CRM/Core/Payment/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)));
}

/**
Expand Down

0 comments on commit 6393279

Please sign in to comment.