vaulted_billing 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
@@ -149,12 +149,21 @@ module VaultedBilling
|
|
149
149
|
super(data, {'Content-Type' => 'text/xml'}.merge(headers))
|
150
150
|
end
|
151
151
|
|
152
|
-
def
|
153
|
-
|
152
|
+
def after_post_on_exception(response, exception)
|
153
|
+
response.body = {
|
154
|
+
'ErrorResponse' => {
|
155
|
+
'directResponse' => ',,,There was a problem communicating with the card processor.,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,',
|
156
|
+
'messages' => {
|
157
|
+
'resultCode' => 'Error',
|
158
|
+
'text' => 'A communication problem has occurred.',
|
159
|
+
'code' => 'E00000'
|
160
|
+
}
|
161
|
+
}
|
162
|
+
}
|
163
|
+
response.success = false
|
154
164
|
end
|
155
165
|
|
156
|
-
def
|
157
|
-
VaultedBilling.logger.info { "Response code %s (HTTP %d), %s" % [response.message, response.code, response.body.inspect] } if VaultedBilling.logger?
|
166
|
+
def after_post_on_success(response)
|
158
167
|
response.body = Hash.from_xml(response.body)
|
159
168
|
response.success = response.body[response.body.keys.first]['messages']['resultCode'] == 'Ok'
|
160
169
|
end
|
@@ -200,23 +209,20 @@ module VaultedBilling
|
|
200
209
|
|
201
210
|
def new_transaction_from_response(response)
|
202
211
|
root = response.keys.first
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
:message => response[root]['messages']['text'],
|
213
|
-
:code => response[root]['messages']['code']
|
214
|
-
})
|
215
|
-
end
|
212
|
+
direct_response = parse_direct_response(response[root]['directResponse'])
|
213
|
+
Transaction.new({
|
214
|
+
:id => direct_response['transaction_id'],
|
215
|
+
:avs_response => direct_response['avs_response'],
|
216
|
+
:cvv_response => direct_response['cvv_response'],
|
217
|
+
:authcode => direct_response['approval_code'],
|
218
|
+
:message => direct_response['message'] || response[root]['messages']['text'],
|
219
|
+
:code => response[root]['messages']['code']
|
220
|
+
})
|
216
221
|
end
|
217
222
|
|
218
223
|
def parse_direct_response(string)
|
219
|
-
|
224
|
+
return {} unless string
|
225
|
+
fields = string.split(',', 100).collect { |v| v == '' ? nil : v }
|
220
226
|
{
|
221
227
|
'message' => fields[3],
|
222
228
|
'approval_code' => fields[4],
|
@@ -111,12 +111,7 @@ module VaultedBilling
|
|
111
111
|
protected
|
112
112
|
|
113
113
|
|
114
|
-
def before_post(data)
|
115
|
-
VaultedBilling.logger.debug { "Posting %s to %s" % [data.inspect, uri.to_s] } if VaultedBilling.logger?
|
116
|
-
end
|
117
|
-
|
118
114
|
def after_post(response)
|
119
|
-
VaultedBilling.logger.info { "Response code %s (HTTP %d), %s" % [response.message, response.code, response.body.inspect] } if VaultedBilling.logger?
|
120
115
|
response.body = Hash.from_querystring(response.body)
|
121
116
|
response.success = response.body['response'] == '1'
|
122
117
|
end
|
@@ -73,17 +73,19 @@ module VaultedBilling
|
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
|
-
|
76
|
+
before_post_caller(data)
|
77
77
|
|
78
78
|
begin
|
79
79
|
PostResponse.new(response.request(request)).tap do |post_response|
|
80
|
-
|
80
|
+
after_post_caller(post_response)
|
81
|
+
after_post_on_success(post_response)
|
81
82
|
end
|
82
83
|
rescue *HTTP_ERRORS
|
83
84
|
PostResponse.new(nil).tap do |post_response|
|
84
85
|
post_response.success = false
|
85
86
|
post_response.message = "%s - %s" % [$!.class.name, $!.message]
|
86
87
|
after_post(post_response)
|
88
|
+
after_post_on_exception(post_response, $!)
|
87
89
|
end
|
88
90
|
end
|
89
91
|
end
|
@@ -93,8 +95,32 @@ module VaultedBilling
|
|
93
95
|
end
|
94
96
|
protected :before_post
|
95
97
|
|
98
|
+
def before_post_caller(data)
|
99
|
+
if VaultedBilling.logger?
|
100
|
+
VaultedBilling.logger.debug { "Posting %s to %s" % [data.inspect, uri.to_s] }
|
101
|
+
end
|
102
|
+
before_post(data)
|
103
|
+
end
|
104
|
+
private :before_post_caller
|
105
|
+
|
96
106
|
def after_post(response)
|
97
107
|
end
|
98
108
|
protected :after_post
|
109
|
+
|
110
|
+
def after_post_caller(response)
|
111
|
+
if VaultedBilling.logger?
|
112
|
+
VaultedBilling.logger.info { "Response code %s (HTTP %d), %s" % [response.message, response.code, response.body.inspect] }
|
113
|
+
end
|
114
|
+
after_post(response)
|
115
|
+
end
|
116
|
+
private :after_post_caller
|
117
|
+
|
118
|
+
def after_post_on_success(response)
|
119
|
+
end
|
120
|
+
protected :after_post_on_success
|
121
|
+
|
122
|
+
def after_post_on_exception(response, exception)
|
123
|
+
end
|
124
|
+
protected :after_post_on_exception
|
99
125
|
end
|
100
126
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 5
|
9
|
+
version: 0.0.5
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Nathaniel Bibler
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-08-
|
17
|
+
date: 2010-08-31 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|