virtual_merchant 0.3.9 → 0.3.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b66fbdd061c01dd0fe3616af2b274b50d4cf15af
4
- data.tar.gz: ea8a7a2f2f335dfa46a052d88d39461c950e3542
3
+ metadata.gz: 28da9c31fa38dcda6007436ecf41d42c87b4918a
4
+ data.tar.gz: 02d3b57afec0ba5875295b8f5e7e718bdb4f1a28
5
5
  SHA512:
6
- metadata.gz: bba7caef29bc7de60a0099180a51e5a8a323a2c851d6125b3dfa7d685e38898428658b668bd3efd98b86042e0cf6339e337a84e01e0d34e47a2e68331eb9f462
7
- data.tar.gz: a2ba8491b977ce3dd4484f73a309bb17e07b5cd73b3bace09dcefb0d6a9480a790a2bb98a352bf96ff32b8197043dec722d0ddee50c51215cedbd22b4c223743
6
+ metadata.gz: 47df9fd6c91fd080a7fa3ee94cfe5c54f536f04bc13b6602e739192039ebf043e5e7c1e10252aad0aa20bb9fa65b9951aabddfcd17af1860bc54ea4fe4fa02b0
7
+ data.tar.gz: 39e93ab7239554ddfca3f6717966571d250056489a5c595a8799b040f0f7c36fffe5974a4a478116dc44d6b4fbcf2e6a690fd24848d3a9405db377c9a86521a9
@@ -0,0 +1,49 @@
1
+ module VirtualMerchant
2
+ class SwipeExtractor
3
+ def self.get_card_number(swipe)
4
+ card_number = swipe[2.. swipe.index('^')-1]
5
+ card_number = card_number.split(' ').join('')
6
+ end
7
+
8
+ def self.get_expiration(swipe)
9
+ secondCarrot = swipe.index("^", swipe.index("^")+1)
10
+ card_expiration_year = swipe[secondCarrot+1..secondCarrot+2]
11
+ card_expiration_month = swipe[(secondCarrot + 3)..(secondCarrot + 4)]
12
+ card_expiration = card_expiration_month.to_s + card_expiration_year.to_s
13
+ end
14
+
15
+ def self.get_name(swipe)
16
+ secondCarrot = swipe.index("^", swipe.index("^")+1)
17
+ if swipe.index('/')
18
+ first_name_on_card = swipe[swipe.index('/')+1..secondCarrot-1]
19
+ last_name_on_card = swipe[swipe.index('^')+1..swipe.index('/')-1]
20
+ else
21
+ if !swipe.index(" ")
22
+ first_name_on_card = "Gift"
23
+ last_name_on_card = "Card"
24
+ else
25
+ first_name_on_card = swipe.slice(swipe.index('^') + 1, swipe.index(' '))
26
+ last_name_on_card = swipe.slice(swipe.index(" ") + 1, secondCarrot)
27
+ end
28
+ end
29
+ name_on_card = first_name_on_card + " " + last_name_on_card
30
+ end
31
+
32
+ def self.get_track_2(swipe)
33
+ # Magtek reader: Track 2 starts with a semi-colon and goes to the end
34
+ # I think that is standard for all readers, but not positive. -LQ
35
+ track2 = swipe.slice(swipe.index(";"), swipe.length)
36
+ if track2.index("+")
37
+ # Some AMEX have extra stuff at the end of track 2 that causes
38
+ #virtual merchant to return an INVLD DATA5623 message.
39
+ #Soooo... let's slice that off
40
+ track2 = track2.slice(0, track2.index("+"))
41
+ end
42
+ track2
43
+ end
44
+
45
+ def self.get_last_four(number)
46
+ number[(number.length - 4)..number.length]
47
+ end
48
+ end
49
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: virtual_merchant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.9
4
+ version: 0.3.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Quarella
@@ -24,6 +24,7 @@ files:
24
24
  - lib/virtual_merchant/gateway.rb
25
25
  - lib/virtual_merchant/logger.rb
26
26
  - lib/virtual_merchant/response.rb
27
+ - lib/virtual_merchant/swipe_extractor.rb
27
28
  - lib/virtual_merchant/xml_generator.rb
28
29
  homepage: https://github.com/leequarella/VirtualMerchant-Ruby
29
30
  licenses: