virtual_merchant 0.4.0 → 0.4.1

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: e30717bdee04d446b5cc2417afcc1f9150a6192d
4
- data.tar.gz: b6fd4d4393eac6a25c7ab0c30a809da460d74e43
3
+ metadata.gz: dab2530964fc6d14d4f3c26c1f1fb77858009b73
4
+ data.tar.gz: d39e6c5d3b72c4e85d10243eae9571b15abd0c32
5
5
  SHA512:
6
- metadata.gz: 945cbe1b26950f5a61cd8a5375cb52d589cede8b9a9bbedeb5a09c4911e0aefa6ff2a68a5a6040177b6624de90fb08eb3baf2d4771598cf7990709a019693da9
7
- data.tar.gz: 9cfecd9fa7316803cfed450af806750f46e5807366fc9bcb395cf8124d20cf1c443bb3bf999472b50c83e62f53e5f656ed2dd965dd17ac07985a7ca11b3cbd78
6
+ metadata.gz: 1808dd81109f9cfca43b4dc0f744e3ac1116975a4f981b62cea2ed59dcc3f6e5cdde0f81ba1cd08d38ccf9576d1e1c88de84c2c092b260bb83a3b0db5f386059
7
+ data.tar.gz: 752579a21497d52e4b2a359b5fa6d1a34aa4ca7454b676e9a00b75cea26a217931ee33ee8bce59b6ae1b6be6768efc223b5ddd51367e0d44e555f1ec1b8088f7
@@ -1,5 +1,6 @@
1
1
  require 'virtual_merchant/swipe_extractor'
2
2
  require 'virtual_merchant/user_input'
3
+
3
4
  module VirtualMerchant
4
5
  class CreditCard
5
6
  attr_accessor :name_on_card, :number, :expiration, :security_code, :swipe, :track2,
@@ -19,10 +20,6 @@ module VirtualMerchant
19
20
  end
20
21
  end
21
22
 
22
- def check_for_errors info
23
- @errors = VirtualMerchant::UserInput.new(info).errors
24
- end
25
-
26
23
  def encrypted?
27
24
  self.encrypted
28
25
  end
@@ -32,7 +29,7 @@ module VirtualMerchant
32
29
  end
33
30
 
34
31
  def valid?
35
- errors.count == 0
32
+ self.errors.count == 0
36
33
  end
37
34
 
38
35
  def blurred_number
@@ -53,6 +50,10 @@ module VirtualMerchant
53
50
  end
54
51
 
55
52
  private
53
+ def check_for_errors info
54
+ @errors = VirtualMerchant::UserInput.new(info).errors
55
+ end
56
+
56
57
  def from_encrypted (info)
57
58
  @encrypted = true
58
59
  @encrypted_track_1 = info[:track_1]
@@ -61,7 +61,7 @@ class Gateway
61
61
  communication = VirtualMerchant::Communication.new(
62
62
  {xml: xml, url: url(creds.demo), referer: creds.referer})
63
63
  vm_response = communication.send
64
- response = VirtualMerchant::Response.new(vm_response)
64
+ response = VirtualMerchant::Response.new(xml_string: vm_response)
65
65
  VirtualMerchant::Logger.log_response(response)
66
66
  response
67
67
  end
@@ -76,11 +76,6 @@ class Gateway
76
76
  end
77
77
 
78
78
  def gen_cc_errors(card)
79
- card.errors.each do |code, msg|
80
- xml = VirtualMerchant::XMLGenerator.error(code, msg)
81
- response = VirtualMerchant::Response.new(xml)
82
- VirtualMerchant::Logger.log_response(response)
83
- response
84
- end
79
+ response = VirtualMerchant::Response.new(type: :invalid_credit_card, errors: card.errors)
85
80
  end
86
81
  end
@@ -8,7 +8,16 @@ module VirtualMerchant
8
8
 
9
9
  alias_method :approved?, :approved
10
10
 
11
- def initialize(xml_string)
11
+ def initialize(data)
12
+ if data[:type] == :invalid_credit_card
13
+ bad_card_error(data[:errors])
14
+ else
15
+ read_xml(data[:xml_string])
16
+ end
17
+ end
18
+
19
+ private
20
+ def read_xml(xml_string)
12
21
  if xml_string == false
13
22
  error_response("-1", "VirtualMerchant did not respond.")
14
23
  else
@@ -16,8 +25,6 @@ module VirtualMerchant
16
25
  end
17
26
  end
18
27
 
19
-
20
- private
21
28
  def decode_xml(xml_string)
22
29
  doc = REXML::Document.new(xml_string)
23
30
  REXML::XPath.each(doc, "txn") do |xml|
@@ -37,6 +44,12 @@ module VirtualMerchant
37
44
  end
38
45
  end
39
46
 
47
+ def bad_card_error(errors)
48
+ @approved = false
49
+ @result_message = errors.first[1]
50
+ @error = errors.first[0]
51
+ end
52
+
40
53
  def error_response(code, message)
41
54
  @approved = false
42
55
  @result_message = message
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: virtual_merchant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Quarella
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-16 00:00:00.000000000 Z
11
+ date: 2014-06-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Makes it easy to charge credit cards with the VirtualMerchant API.
14
14
  email: leequarella@gmail.com