virtual_merchant 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ class VMResponse
2
+ attr_accessor :result_message, :result, :blurred_card_number, :exp_date, :approval_code,
3
+ :cvv2_response, :transaction_id, :transaction_time, :error
4
+
5
+ def initialize(info)
6
+ @result_message = info[:result_message]
7
+ if info[:error]
8
+ @result_type = "error"
9
+ @error = info[:error]
10
+ else
11
+ @result_type = "approval"
12
+ @result = info[:result]
13
+ @blurred_card_number = info[:blurred_card_number]
14
+ @exp_date = info[:exp_date]
15
+ @approval_code = info[:approval_code]
16
+ @cvv2_response = info[:cvv2_response]
17
+ @transaction_id = info[:transaction_id]
18
+ @transaction_time = info[:transaction_time]
19
+ end
20
+ end
21
+ end
@@ -4,6 +4,7 @@ class VirtualMerchant
4
4
  require 'virtual_merchant/amount'
5
5
  require 'virtual_merchant/credentials'
6
6
  require 'virtual_merchant/credit_card'
7
+ require 'virtual_merchant/response'
7
8
 
8
9
  def self.hi
9
10
  puts "Hello"
@@ -58,7 +59,7 @@ class VirtualMerchant
58
59
  def self.sendXMLtoVirtualMerchant(xml, creds)
59
60
  if creds.referer
60
61
  headers = {
61
- 'Referer' => creds.referer#"https://rms.lucidfrog.com"
62
+ 'Referer' => creds.referer
62
63
  }
63
64
  end
64
65
  if creds.demo
@@ -81,22 +82,20 @@ class VirtualMerchant
81
82
  REXML::XPath.each(doc, "txn") do |xml|
82
83
  if xml.elements["errorCode"]
83
84
  #Something was wrong with the transaction so an errorCode and errorMessage were sent back
84
- response = {
85
+ response = VMResponse.new(
85
86
  error: xml.elements["errorCode"].text,
86
- result_message: xml.elements["errorMessage"].text
87
- }
87
+ result_message: xml.elements["errorMessage"].text)
88
88
  else
89
89
  #a clean transaction has taken place
90
- response = {
90
+ response = VMResponse.new(
91
91
  result_message: xml.elements["ssl_result_message"].text,
92
92
  result: xml.elements["ssl_result"].text,
93
- cardNumBlurred: xml.elements["ssl_card_number"].text,
93
+ blurred_card_number: xml.elements["ssl_card_number"].text,
94
94
  exp_date: xml.elements["ssl_exp_date"].text,
95
95
  approval_code: xml.elements["ssl_approval_code"].text,
96
96
  cvv2_response: xml.elements["ssl_cvv2_response"].text,
97
97
  transaction_id: xml.elements["ssl_txn_id"].text,
98
- transaction_time: xml.elements["ssl_txn_time"].text
99
- }
98
+ transaction_time: xml.elements["ssl_txn_time"].text)
100
99
  end
101
100
  end
102
101
  response
@@ -104,14 +103,12 @@ class VirtualMerchant
104
103
 
105
104
  def self.printResponse(response)
106
105
  p "!!!!!!!!!!!!!!!!!!!!!!!! Credit Response !!!!!!!!!!!!!!!!!!!!!!!!!!!!"
107
- if response[:result]
108
- p "ssl_result " + response[:result]
109
- p "ssl_result_message " + response[:result_message]
110
- p "ssl_transaction_time " + response[:transaction_time]
111
- elsif response[:error]
112
- p "error " + response[:error]
113
- p "error_message " + response[:error_message] if response[:error_message]
106
+ if response.result
107
+ p "result " + response.result
108
+ elsif response.error
109
+ p "error " + response.error
114
110
  end
111
+ p "result_message " + response.result_message
115
112
  p "!!!!!!!!!!!!!!!!!!!!!!!! End Credit Response !!!!!!!!!!!!!!!!!!!!!!!!!!!!"
116
113
  end
117
114
  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.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -21,7 +21,8 @@ files:
21
21
  - lib/virtual_merchant/amount.rb
22
22
  - lib/virtual_merchant/credentials.rb
23
23
  - lib/virtual_merchant/credit_card.rb
24
- homepage: http://rubygems.org/gems/virtual_merchant_ruby
24
+ - lib/virtual_merchant/response.rb
25
+ homepage: https://github.com/leequarella/VirtualMerchant-Ruby
25
26
  licenses: []
26
27
  post_install_message:
27
28
  rdoc_options: []