Class: VirtualMerchant::CreditCard
- Inherits:
-
Object
- Object
- VirtualMerchant::CreditCard
- Defined in:
- lib/virtual_merchant/credit_card.rb
Instance Attribute Summary collapse
-
#encrypted ⇒ Object
Returns the value of attribute encrypted.
-
#encrypted_track_1 ⇒ Object
Returns the value of attribute encrypted_track_1.
-
#encrypted_track_2 ⇒ Object
Returns the value of attribute encrypted_track_2.
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#expiration ⇒ Object
Returns the value of attribute expiration.
-
#last_four ⇒ Object
Returns the value of attribute last_four.
-
#name_on_card ⇒ Object
Returns the value of attribute name_on_card.
-
#number ⇒ Object
Returns the value of attribute number.
-
#security_code ⇒ Object
Returns the value of attribute security_code.
-
#swipe ⇒ Object
Returns the value of attribute swipe.
-
#swiped ⇒ Object
Returns the value of attribute swiped.
-
#track2 ⇒ Object
Returns the value of attribute track2.
-
#valid ⇒ Object
Returns the value of attribute valid.
Instance Method Summary collapse
- #blurred_number ⇒ Object
- #check_for_errors(info) ⇒ Object
- #encrypted? ⇒ Boolean
-
#initialize(info) ⇒ CreditCard
constructor
A new instance of CreditCard.
- #swiped? ⇒ Boolean
- #valid? ⇒ Boolean
Constructor Details
#initialize(info) ⇒ CreditCard
Returns a new instance of CreditCard.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/virtual_merchant/credit_card.rb', line 9 def initialize(info) @errors = {} check_for_errors(info) unless info[:encrypted] return unless valid? if info[:encrypted] from_encrypted(info) elsif info[:swipe] from_unencrypted_swipe(info[:swipe]) else from_manual(info) end end |
Instance Attribute Details
#encrypted ⇒ Object
Returns the value of attribute encrypted.
5 6 7 |
# File 'lib/virtual_merchant/credit_card.rb', line 5 def encrypted @encrypted end |
#encrypted_track_1 ⇒ Object
Returns the value of attribute encrypted_track_1.
5 6 7 |
# File 'lib/virtual_merchant/credit_card.rb', line 5 def encrypted_track_1 @encrypted_track_1 end |
#encrypted_track_2 ⇒ Object
Returns the value of attribute encrypted_track_2.
5 6 7 |
# File 'lib/virtual_merchant/credit_card.rb', line 5 def encrypted_track_2 @encrypted_track_2 end |
#errors ⇒ Object
Returns the value of attribute errors.
5 6 7 |
# File 'lib/virtual_merchant/credit_card.rb', line 5 def errors @errors end |
#expiration ⇒ Object
Returns the value of attribute expiration.
5 6 7 |
# File 'lib/virtual_merchant/credit_card.rb', line 5 def expiration @expiration end |
#last_four ⇒ Object
Returns the value of attribute last_four.
5 6 7 |
# File 'lib/virtual_merchant/credit_card.rb', line 5 def last_four @last_four end |
#name_on_card ⇒ Object
Returns the value of attribute name_on_card.
5 6 7 |
# File 'lib/virtual_merchant/credit_card.rb', line 5 def name_on_card @name_on_card end |
#number ⇒ Object
Returns the value of attribute number.
5 6 7 |
# File 'lib/virtual_merchant/credit_card.rb', line 5 def number @number end |
#security_code ⇒ Object
Returns the value of attribute security_code.
5 6 7 |
# File 'lib/virtual_merchant/credit_card.rb', line 5 def security_code @security_code end |
#swipe ⇒ Object
Returns the value of attribute swipe.
5 6 7 |
# File 'lib/virtual_merchant/credit_card.rb', line 5 def swipe @swipe end |
#swiped ⇒ Object
Returns the value of attribute swiped.
5 6 7 |
# File 'lib/virtual_merchant/credit_card.rb', line 5 def swiped @swiped end |
#track2 ⇒ Object
Returns the value of attribute track2.
5 6 7 |
# File 'lib/virtual_merchant/credit_card.rb', line 5 def track2 @track2 end |
#valid ⇒ Object
Returns the value of attribute valid.
5 6 7 |
# File 'lib/virtual_merchant/credit_card.rb', line 5 def valid @valid end |
Instance Method Details
#blurred_number ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/virtual_merchant/credit_card.rb', line 38 def begin number = self.number.to_s leng = number.length n = number[0..1] (leng-6).times {n+= "*"} n += number[number.length-4..number.length] n rescue Exception => e puts "-" puts "Error in VirtualMerchant-Ruby Gem when trying to blur card number: #{e}." puts "You either passed a nil value for card_number or a number that is too short." puts caller puts "-" end end |
#check_for_errors(info) ⇒ Object
22 23 24 |
# File 'lib/virtual_merchant/credit_card.rb', line 22 def check_for_errors info @errors = VirtualMerchant::UserInput.new(info).errors end |
#encrypted? ⇒ Boolean
26 27 28 |
# File 'lib/virtual_merchant/credit_card.rb', line 26 def encrypted? self.encrypted end |
#swiped? ⇒ Boolean
30 31 32 |
# File 'lib/virtual_merchant/credit_card.rb', line 30 def swiped? self.swiped end |
#valid? ⇒ Boolean
34 35 36 |
# File 'lib/virtual_merchant/credit_card.rb', line 34 def valid? errors.count == 0 end |