Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRM-20166: Making CVV always required for front-end pages. #11205

Merged
merged 1 commit into from
Nov 14, 2017

Conversation

agilewarealok
Copy link
Contributor

@agilewarealok agilewarealok commented Oct 27, 2017

Overview

Setting "CVV required for backoffice" to NO results in it setting all front facing forms to 'not require' CVV site wide, ie on all public facing contribution pages.

Before

A single setting was there to disable/enable CVV on front office and back office pages.

After

Now we don't consider back-office setting for front-end contribution pages by making CVV always required for front-end pages.

Agileware Ref: CIVICRM-689


@mlutfy
Copy link
Member

mlutfy commented Oct 27, 2017

Is there a legitimate use-case for allowing the front-end forms to not validate cvv2? Seems dangerous. Folks might disable it thinking that it's more convenient, not realizing how interesting this will become for people testing stolen card numbers.

(I agree with the fix, and realize that not having a setting might cause regressions.. but we could also consider it a security issue).

@KarinG
Copy link
Contributor

KarinG commented Oct 27, 2017

@mlufty - agreed - giving admins the option to
allow users to not enter CVV comes with high risk; not to mention that many payment processors will not allow no CVV via webservices; In my opinion CVV should always be required for backoffice too;

@jusfreeman
Copy link
Contributor

jusfreeman commented Oct 27, 2017

@mlutfy @KarinG - thanks for your comments.

The situation currently in CiviCRM is that there is one setting: "CVV required for backoffice" which determines if CVV is required on:

  • backoffice data entry AND
  • front end processing

This does not make sense and is counter-intuitive. Why impact on front-end at all? It's not even what the field label states!

This PR separates the functionality so that:

  • Backoffice - CVV can be enabled/disabled, OR
  • Frontend - CVV can be enabled/disabled

There are very legitimate situations where backoffice processing requires CVV to be DISABLED. But you want the frontend CVV to still be ENABLED.

This PR provides the flexibility to determine when CVV should be required.

@KarinG
Copy link
Contributor

KarinG commented Oct 27, 2017

If CiviCRM currently disables CVV on front end contribution forms when people check a box that says disable CVV on backoffice forms, then that’s a bug - and should be fixed urgently. CVV on front end should -always- be enabled as non-CVV public contribution pages are all but certainly going to be subjected to card tumbling and the org is going to risk having their merchant account closed;

@jusfreeman
Copy link
Contributor

jusfreeman commented Oct 27, 2017

Is there a legitimate use-case for allowing the front-end forms to not validate cvv2? Seems dangerous.

@mlutfy Personally, I don't object to that idea - frontend CVV being ALWAYS enabled.

Would people in the CiviCRM community would object to that change? Possibly, because it is a change to the existing behaviour.

This is why we are suggesting making it a separate setting for frontend, so CiviCRM sites using the current CVV frontend disabled approach can still do so - for whatever reasons they have.

@jusfreeman
Copy link
Contributor

If CiviCRM allows CVV on front end contribution forms to be disabled

@KarinG that's the current situation. As described in the PR overview and linked JIRA issue.

@KarinG
Copy link
Contributor

KarinG commented Oct 27, 2017

Exactly - that’s the bug; let’s fix the bug & fix the security issue

@KarinG
Copy link
Contributor

KarinG commented Oct 27, 2017

@jusfreeman
Copy link
Contributor

@KarinG We will revise this PR and re-submit to remove the setting for front-end. Making it always required. Since this is also the behaviour in CiviCRM 4.6 now, we will do a related PR for that too.

@petednz
Copy link

petednz commented Oct 30, 2017

@jitendrapurohit can you take a look at this PR thx

@davejenx
Copy link
Contributor

Agree with KarinG.

@agilewarealok agilewarealok changed the title CRM-20166: New setting to make CVV required for front office separately. CRM-20166: Making CVV always required for front-end pages. Oct 31, 2017
@agilewarealok
Copy link
Contributor Author

We've updated the PR to make CVV always required for front end pages.

Copy link
Contributor

@jitendrapurohit jitendrapurohit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just tested these changes by disabling the setting on backend form and found a minor issue. To replicate -

  • Disable the setting and click on Submit credit card contribution on contribution tab of any contact summary page.
  • The required field marker(*) was not shown on CVV code input(correct).
  • Don't enter any value for cvv and click on Save.
  • Formrule error displays which need a value for cvv.

image

Maybe, we also need to handle the setting assigned at https://github.com/civicrm/civicrm-core/blob/master/CRM/Core/Payment.php#L689

@mattwire
Copy link
Contributor

@jitendrapurohit Which payment processor? Payment processors can override validatePaymentInstrument() and I think this can make fields required even if the UI doesn't show them as required.

@jitendrapurohit
Copy link
Contributor

jitendrapurohit commented Nov 1, 2017

I tested this on my local environment with a test processor.

Seems to be because getAllFields() also calls getPaymentFormFieldsMetadata() without any value for $backOffice and hence cvv is always set to required.

@jusfreeman
Copy link
Contributor

@jitendrapurohit thanks for testing. Confirmed, we'll rework the PR.

@agilewarealok
Copy link
Contributor Author

@jitendrapurohit We've updated the validatePaymentInstrument method to distinguish backoffice pages and front facing pages.

@jusfreeman
Copy link
Contributor

Ping @jitendrapurohit @mattwire @KarinG

Would someone mind verifying our PR?

@mattwire
Copy link
Contributor

mattwire commented Nov 3, 2017

@jusfreeman @agilewarealok On first glance I'm a little bit worried about adding $isBackOffice to all those functions. A lot of those functions can and are overridden by payments processors (particularly validatePaymentInstrument) - changing the method signatures could cause errors. Would it be possible to pass isBackOffice via one of the existing parameters - $values? @eileenmcnaughton may have a view..

@eileenmcnaughton
Copy link
Contributor

eileenmcnaughton commented Nov 4, 2017

At least with the functions on CRM_Core_Payment class we should not pass it in - we should use these functions

  /**
   * Set back office property.
   *
   * @param bool $isBackOffice
   */
  public function setBackOffice($isBackOffice) {
    $this->backOffice = $isBackOffice;
  }

  /**
   * Is this a back office transaction.
   *
   * @var bool
   */
  protected $backOffice = FALSE;

  /**
   * @return bool
   */
  public function isBackOffice() {
    return $this->backOffice;
  }

@agilewarealok
Copy link
Contributor Author

@eileenmcnaughton Thanks for the hint. We can use isBackOffice directly without passing $isBackOffice as a separate parameter in functions.
We've updated the PR accordingly.

@jitendrapurohit @mattwire @KarinG Can you guys please verify this ?

Copy link
Contributor

@jitendrapurohit jitendrapurohit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use-case I mentioned works fine and the code changes looks good to me. @agilewarealok Any chances of adding a simple unit test which asserts this fix? For eg-

  • Set 0/1 for cvv_backoffice_required .
  • Call getPaymentFormFieldsMetadata() function
  • Assert the value returned is as expected.

@mattwire
Copy link
Contributor

mattwire commented Nov 7, 2017

@agilewarealok Code looks clean. +1 for a unit test if possible as this is payment related.

@eileenmcnaughton eileenmcnaughton added the merge ready PR will be merged after a few days if there are no objections label Nov 7, 2017
@eileenmcnaughton
Copy link
Contributor

I've given this the merge-ready label. I think the fix is right per previous comments. I would be preferable to get a unit test, so I'm hanging off merging now in hope...

@agilewarealok
Copy link
Contributor Author

@jitendrapurohit @mattwire @eileenmcnaughton
Thanks for the review guys, We will write UT for this. :)

@agilewarealok agilewarealok force-pushed the CRM-20166 branch 2 times, most recently from c4f8b09 to 41480ca Compare November 8, 2017 08:52
@agilewarealok
Copy link
Contributor Author

@jitendrapurohit @mattwire @eileenmcnaughton
We've written Unit test for this. Can you please verify ?

@mattwire
Copy link
Contributor

@agilewarealok Unit test looks good. Just to be really picky, can you extend the unit test to check for the setting the other way too - add:
+ Civi::settings()->set('cvv_backoffice_required', 1);
which should return required for both front and backend.

@agilewarealok
Copy link
Contributor Author

@mattwire We've updated the UnitTest to test it the other way too.

@eileenmcnaughton
Copy link
Contributor

Ok I think this has met reviewer requirements and it has had solid & engaged review. I also think it's a good change, clean code, nice test. Gold star

@eileenmcnaughton eileenmcnaughton merged commit b56bdc7 into civicrm:master Nov 14, 2017
sluc23 pushed a commit to ixiam/civicrm-core that referenced this pull request Jan 10, 2018
CRM-20166: Making CVV always required for front-end pages.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
master merge ready PR will be merged after a few days if there are no objections
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants