2

I need to validate the credit-card details such as

Card Type
Card Number 
Card CVV number 
Card Exper Date

My need is to verify all the above details are valid currently.

Could you help me, how to overcome this?

Sankar Subburaj
  • 4,992
  • 12
  • 48
  • 79

2 Answers2

4

Magento comes with Really Easy Field Validation in place so you only need to add some classes to the fields in question.

  • validate-cc-type or validate-cc-type-select
  • validate-cc-number
  • validate-cc-cvn
  • validate-cc-exp

However the normal payment modules should already be using these so what are you doing that breaks it or otherwise needs CC details?

clockworkgeek
  • 37,650
  • 9
  • 89
  • 127
  • I also need to validate the give card is currently valid or expired. – Sankar Subburaj Jun 28 '11 at 11:48
  • cc-number is a simple modulus 10 lun code calculation easily done in javascript. cc-type is a simple prefix calculation done in javascript. Validation of both is a function already included in the USAePay and Authorize.NET modules. – Fiasco Labs Jun 28 '11 at 21:31
3

To answer your question:

The answer is comprehensive and addresses your question properly.

An alternate is to fully hand-off the details and the processing to a 3rd party, which removes the risk on your and the obligation to be PCI-DSS compliant

CVV validation can only be performed through interaction with a provider. Simple rules do exist, for example:

  • AMEX -- 4 digit CVV
  • Everyone else -- 3 digit CVV

Of course, let me state, that this may not be entirely accurate and you should refer to other, slightly more accurate resources:

Community
  • 1
  • 1
sdolgy
  • 6,963
  • 3
  • 41
  • 61
  • While you can check string length, the number is arbitrary and non-calculable which is the point of the exercise. It must match against the card processor's database info. – Fiasco Labs Jun 28 '11 at 21:40
  • I need to validate the given card is active now. It is to restrict users to give inactive/expired cards. – Sankar Subburaj Jun 29 '11 at 07:55