module ActiveMerchant::Billing::CreditCardMethods
Convenience methods that can be included into a custom Credit Card object, such as an ActiveRecord based Credit Card object.
Constants
- CARD_COMPANIES
Public Class Methods
# File lib/active_merchant/billing/credit_card_methods.rb, line 20 def self.included(base) base.extend(ClassMethods) end
Public Instance Methods
# File lib/active_merchant/billing/credit_card_methods.rb, line 53 def card_verification_value_length(brand) brand == 'american_express' ? 4 : 3 end
Credit card providers have 3 digit verification values This isn't standardised, these are called various names such as CVC, CVV, CID, CSC and more See: en.wikipedia.org/wiki/Card_security_code American Express is the exception with 4 digits
Below are links from the card providers with their requirements visa: usa.visa.com/personal/security/3-digit-security-code.jsp master: www.mastercard.com/ca/merchant/en/getstarted/Anatomy_MasterCard.html jcb: www.jcbcard.com/security/info.html diners_club: www.dinersclub.com/assets/DinersClub_card_ID_features.pdf discover: www.discover.com/credit-cards/help-center/glossary.html american_express: online.americanexpress.com/myca/fuidfyp/us/action?request_type=un_fuid&Face=en_US
# File lib/active_merchant/billing/credit_card_methods.rb, line 49 def valid_card_verification_value?(cvv, brand) cvv.to_s =~ /^\d{#{card_verification_value_length(brand)}}$/ end
# File lib/active_merchant/billing/credit_card_methods.rb, line 28 def valid_expiry_year?(year) (Time.now.year..Time.now.year + 20).include?(year.to_i) end
# File lib/active_merchant/billing/credit_card_methods.rb, line 57 def valid_issue_number?(number) (number.to_s =~ /^\d{1,2}$/) end
# File lib/active_merchant/billing/credit_card_methods.rb, line 24 def valid_month?(month) (1..12).include?(month.to_i) end
# File lib/active_merchant/billing/credit_card_methods.rb, line 32 def valid_start_year?(year) ((year.to_s =~ /^\d{4}$/) && (year.to_i > 1987)) end