vaulted_billing 1.0.2 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +44 -34
- data/lib/vaulted_billing/chainable_hash.rb +7 -0
- data/lib/vaulted_billing/configuration.rb +13 -3
- data/lib/vaulted_billing/errors.rb +4 -0
- data/lib/vaulted_billing/gateway.rb +4 -4
- data/lib/vaulted_billing/gateways/authorize_net_cim.rb +60 -36
- data/lib/vaulted_billing/gateways/ipcommerce.rb +372 -0
- data/lib/vaulted_billing/gateways/nmi_customer_vault.rb +43 -24
- data/lib/vaulted_billing/http.rb +157 -0
- data/lib/vaulted_billing/version.rb +1 -1
- data/lib/vaulted_billing.rb +5 -2
- metadata +139 -138
- data/lib/vaulted_billing/https_interface.rb +0 -127
data/lib/vaulted_billing.rb
CHANGED
@@ -1,23 +1,26 @@
|
|
1
1
|
begin
|
2
2
|
require 'active_support/core_ext/object/blank'
|
3
3
|
require 'active_support/core_ext/object/try'
|
4
|
-
require 'active_support/core_ext/hash/conversions'
|
5
4
|
require 'active_support/core_ext/hash/indifferent_access'
|
6
5
|
require 'active_support/core_ext/hash/reverse_merge'
|
7
6
|
require 'active_support/core_ext/string/inflections'
|
7
|
+
require 'active_support/time'
|
8
8
|
rescue LoadError
|
9
9
|
require 'active_support'
|
10
10
|
end
|
11
11
|
|
12
|
+
require 'vaulted_billing/errors'
|
13
|
+
|
12
14
|
module VaultedBilling
|
13
15
|
autoload :Version, 'vaulted_billing/version'
|
16
|
+
autoload :ChainableHash, 'vaulted_billing/chainable_hash'
|
14
17
|
autoload :Configuration, 'vaulted_billing/configuration'
|
15
18
|
autoload :Gateway, 'vaulted_billing/gateway'
|
16
19
|
autoload :Gateways, 'vaulted_billing/gateways'
|
17
20
|
autoload :Customer, 'vaulted_billing/customer'
|
18
21
|
autoload :CreditCard, 'vaulted_billing/credit_card'
|
19
22
|
autoload :Transaction, 'vaulted_billing/transaction'
|
20
|
-
autoload :
|
23
|
+
autoload :HTTP, 'vaulted_billing/http'
|
21
24
|
|
22
25
|
Dir[File.expand_path('../vaulted_billing/core_ext/**/*.rb', __FILE__)].each do |extension|
|
23
26
|
require extension
|
metadata
CHANGED
@@ -1,208 +1,209 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: vaulted_billing
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.0
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 0
|
9
|
-
- 2
|
10
|
-
version: 1.0.2
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Nathaniel Bibler
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2011-08-17 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: activesupport
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &2168747560 !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
segments:
|
30
|
-
- 2
|
31
|
-
- 3
|
32
|
-
version: "2.3"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '2.3'
|
33
22
|
type: :runtime
|
34
|
-
version_requirements: *id001
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: builder
|
37
23
|
prerelease: false
|
38
|
-
|
24
|
+
version_requirements: *2168747560
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: builder
|
27
|
+
requirement: &2168747100 !ruby/object:Gem::Requirement
|
39
28
|
none: false
|
40
|
-
requirements:
|
41
|
-
- -
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
hash: 15
|
44
|
-
segments:
|
45
|
-
- 2
|
46
|
-
- 1
|
47
|
-
- 2
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
48
32
|
version: 2.1.2
|
49
33
|
type: :runtime
|
50
|
-
version_requirements: *id002
|
51
|
-
- !ruby/object:Gem::Dependency
|
52
|
-
name: rspec
|
53
34
|
prerelease: false
|
54
|
-
|
35
|
+
version_requirements: *2168747100
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: multi_json
|
38
|
+
requirement: &2168746640 !ruby/object:Gem::Requirement
|
55
39
|
none: false
|
56
|
-
requirements:
|
40
|
+
requirements:
|
57
41
|
- - ~>
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '1.0'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *2168746640
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: multi_xml
|
49
|
+
requirement: &2168746180 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.3.0
|
55
|
+
type: :runtime
|
69
56
|
prerelease: false
|
70
|
-
|
57
|
+
version_requirements: *2168746180
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: rspec
|
60
|
+
requirement: &2168745720 !ruby/object:Gem::Requirement
|
71
61
|
none: false
|
72
|
-
requirements:
|
62
|
+
requirements:
|
73
63
|
- - ~>
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
|
76
|
-
segments:
|
77
|
-
- 0
|
78
|
-
- 0
|
79
|
-
- 0
|
80
|
-
version: 0.0.0
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '2.4'
|
81
66
|
type: :development
|
82
|
-
version_requirements: *id004
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: vcr
|
85
67
|
prerelease: false
|
86
|
-
|
68
|
+
version_requirements: *2168745720
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: vcr
|
71
|
+
requirement: &2168745260 !ruby/object:Gem::Requirement
|
87
72
|
none: false
|
88
|
-
requirements:
|
73
|
+
requirements:
|
89
74
|
- - ~>
|
90
|
-
- !ruby/object:Gem::Version
|
91
|
-
|
92
|
-
segments:
|
93
|
-
- 1
|
94
|
-
- 5
|
95
|
-
- 0
|
96
|
-
version: 1.5.0
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '1.7'
|
97
77
|
type: :development
|
98
|
-
version_requirements: *id005
|
99
|
-
- !ruby/object:Gem::Dependency
|
100
|
-
name: webmock
|
101
78
|
prerelease: false
|
102
|
-
|
79
|
+
version_requirements: *2168745260
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: webmock
|
82
|
+
requirement: &2168744800 !ruby/object:Gem::Requirement
|
103
83
|
none: false
|
104
|
-
requirements:
|
84
|
+
requirements:
|
105
85
|
- - ~>
|
106
|
-
- !ruby/object:Gem::Version
|
107
|
-
|
108
|
-
segments:
|
109
|
-
- 1
|
110
|
-
- 6
|
111
|
-
- 0
|
112
|
-
version: 1.6.0
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '1.6'
|
113
88
|
type: :development
|
114
|
-
version_requirements: *id006
|
115
|
-
- !ruby/object:Gem::Dependency
|
116
|
-
name: factory_girl
|
117
89
|
prerelease: false
|
118
|
-
|
90
|
+
version_requirements: *2168744800
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: factory_girl
|
93
|
+
requirement: &2168744340 !ruby/object:Gem::Requirement
|
119
94
|
none: false
|
120
|
-
requirements:
|
95
|
+
requirements:
|
121
96
|
- - ~>
|
122
|
-
- !ruby/object:Gem::Version
|
123
|
-
|
124
|
-
segments:
|
125
|
-
- 1
|
126
|
-
- 3
|
127
|
-
- 0
|
128
|
-
version: 1.3.0
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '1.3'
|
129
99
|
type: :development
|
130
|
-
|
131
|
-
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: *2168744340
|
102
|
+
- !ruby/object:Gem::Dependency
|
132
103
|
name: faker
|
104
|
+
requirement: &2168743880 !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0.9'
|
110
|
+
type: :development
|
133
111
|
prerelease: false
|
134
|
-
|
112
|
+
version_requirements: *2168743880
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
name: rake
|
115
|
+
requirement: &2168763880 !ruby/object:Gem::Requirement
|
135
116
|
none: false
|
136
|
-
requirements:
|
117
|
+
requirements:
|
137
118
|
- - ~>
|
138
|
-
- !ruby/object:Gem::Version
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0.9'
|
121
|
+
type: :development
|
122
|
+
prerelease: false
|
123
|
+
version_requirements: *2168763880
|
124
|
+
- !ruby/object:Gem::Dependency
|
125
|
+
name: watchr
|
126
|
+
requirement: &2168763500 !ruby/object:Gem::Requirement
|
127
|
+
none: false
|
128
|
+
requirements:
|
129
|
+
- - ! '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
145
132
|
type: :development
|
146
|
-
|
147
|
-
|
148
|
-
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: *2168763500
|
135
|
+
- !ruby/object:Gem::Dependency
|
136
|
+
name: open4
|
137
|
+
requirement: &2168763040 !ruby/object:Gem::Requirement
|
138
|
+
none: false
|
139
|
+
requirements:
|
140
|
+
- - ! '>='
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
type: :development
|
144
|
+
prerelease: false
|
145
|
+
version_requirements: *2168763040
|
146
|
+
- !ruby/object:Gem::Dependency
|
147
|
+
name: appraisal
|
148
|
+
requirement: &2168762620 !ruby/object:Gem::Requirement
|
149
|
+
none: false
|
150
|
+
requirements:
|
151
|
+
- - ! '>='
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0'
|
154
|
+
type: :development
|
155
|
+
prerelease: false
|
156
|
+
version_requirements: *2168762620
|
157
|
+
description: Several card processors and gateways support offloading the storage of
|
158
|
+
credit card information onto their service. This offloads PCI compliance to the
|
159
|
+
gateway rather than keeping it with each retailer. This library abstracts the interface
|
160
|
+
to many of them, making it trivial to work with any or all of them.
|
161
|
+
email:
|
149
162
|
- nate@envylabs.com
|
150
163
|
executables: []
|
151
|
-
|
152
164
|
extensions: []
|
153
|
-
|
154
165
|
extra_rdoc_files: []
|
155
|
-
|
156
|
-
files:
|
166
|
+
files:
|
157
167
|
- lib/ext/cacert.pem
|
168
|
+
- lib/vaulted_billing/chainable_hash.rb
|
158
169
|
- lib/vaulted_billing/configuration.rb
|
159
170
|
- lib/vaulted_billing/core_ext/hash.rb
|
160
171
|
- lib/vaulted_billing/credit_card.rb
|
161
172
|
- lib/vaulted_billing/customer.rb
|
173
|
+
- lib/vaulted_billing/errors.rb
|
162
174
|
- lib/vaulted_billing/gateway.rb
|
163
175
|
- lib/vaulted_billing/gateways/authorize_net_cim.rb
|
164
176
|
- lib/vaulted_billing/gateways/bogus.rb
|
177
|
+
- lib/vaulted_billing/gateways/ipcommerce.rb
|
165
178
|
- lib/vaulted_billing/gateways/nmi_customer_vault.rb
|
166
179
|
- lib/vaulted_billing/gateways.rb
|
167
|
-
- lib/vaulted_billing/
|
180
|
+
- lib/vaulted_billing/http.rb
|
168
181
|
- lib/vaulted_billing/transaction.rb
|
169
182
|
- lib/vaulted_billing/version.rb
|
170
183
|
- lib/vaulted_billing.rb
|
171
184
|
- README.md
|
172
185
|
homepage: http://github.com/envylabs/vaulted_billing
|
173
186
|
licenses: []
|
174
|
-
|
175
187
|
post_install_message:
|
176
188
|
rdoc_options: []
|
177
|
-
|
178
|
-
require_paths:
|
189
|
+
require_paths:
|
179
190
|
- lib
|
180
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
191
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
181
192
|
none: false
|
182
|
-
requirements:
|
183
|
-
- -
|
184
|
-
- !ruby/object:Gem::Version
|
185
|
-
|
186
|
-
|
187
|
-
- 0
|
188
|
-
version: "0"
|
189
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
193
|
+
requirements:
|
194
|
+
- - ! '>='
|
195
|
+
- !ruby/object:Gem::Version
|
196
|
+
version: '0'
|
197
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
190
198
|
none: false
|
191
|
-
requirements:
|
192
|
-
- -
|
193
|
-
- !ruby/object:Gem::Version
|
194
|
-
hash: 23
|
195
|
-
segments:
|
196
|
-
- 1
|
197
|
-
- 3
|
198
|
-
- 6
|
199
|
+
requirements:
|
200
|
+
- - ! '>='
|
201
|
+
- !ruby/object:Gem::Version
|
199
202
|
version: 1.3.6
|
200
203
|
requirements: []
|
201
|
-
|
202
204
|
rubyforge_project:
|
203
|
-
rubygems_version: 1.8.
|
205
|
+
rubygems_version: 1.8.7
|
204
206
|
signing_key:
|
205
207
|
specification_version: 3
|
206
208
|
summary: A library for working with credit card storage gateways
|
207
209
|
test_files: []
|
208
|
-
|
@@ -1,127 +0,0 @@
|
|
1
|
-
require 'net/https'
|
2
|
-
require 'uri'
|
3
|
-
|
4
|
-
module VaultedBilling
|
5
|
-
module HttpsInterface
|
6
|
-
|
7
|
-
HTTP_ERRORS = [
|
8
|
-
Timeout::Error,
|
9
|
-
Errno::ETIMEDOUT,
|
10
|
-
Errno::EINVAL,
|
11
|
-
Errno::ECONNRESET,
|
12
|
-
Errno::ECONNREFUSED,
|
13
|
-
Errno::EHOSTUNREACH,
|
14
|
-
EOFError,
|
15
|
-
Net::HTTPBadResponse,
|
16
|
-
Net::HTTPHeaderSyntaxError,
|
17
|
-
Net::ProtocolError
|
18
|
-
] unless defined?(HTTP_ERRORS)
|
19
|
-
|
20
|
-
class PostResponse
|
21
|
-
attr_accessor :code
|
22
|
-
attr_accessor :message
|
23
|
-
attr_accessor :body
|
24
|
-
attr_accessor :success
|
25
|
-
attr_accessor :raw_response
|
26
|
-
attr_accessor :connection_error
|
27
|
-
|
28
|
-
def initialize(http_response)
|
29
|
-
if http_response
|
30
|
-
self.raw_response = http_response
|
31
|
-
self.code = http_response.code
|
32
|
-
self.message = http_response.message
|
33
|
-
self.body = http_response.body
|
34
|
-
self.success = ((http_response.code =~ /^2\d{2}/) == 0)
|
35
|
-
self.connection_error = false
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
alias :success? :success
|
40
|
-
alias :status_code :code
|
41
|
-
end
|
42
|
-
|
43
|
-
attr_writer :use_test_uri
|
44
|
-
|
45
|
-
def live_uri=(input)
|
46
|
-
@live_uri = input ? URI.parse(input) : nil
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_uri=(input)
|
50
|
-
@test_uri = input ? URI.parse(input) : nil
|
51
|
-
end
|
52
|
-
|
53
|
-
##
|
54
|
-
# Returns the protocol and host and any path details that is used
|
55
|
-
# when making communications.
|
56
|
-
#
|
57
|
-
def uri
|
58
|
-
@use_test_uri ? @test_uri : @live_uri
|
59
|
-
end
|
60
|
-
|
61
|
-
##
|
62
|
-
# Posts the given data to the uri and returns the response.
|
63
|
-
#
|
64
|
-
def post_data(data, request_headers = {})
|
65
|
-
request = Net::HTTP::Post.new(uri.path)
|
66
|
-
request.initialize_http_header({
|
67
|
-
'User-Agent' => "vaulted_billing/#{VaultedBilling::Version}"
|
68
|
-
}.reverse_merge(request_headers))
|
69
|
-
request.body = data
|
70
|
-
response = Net::HTTP.new(uri.host, uri.port).tap do |https|
|
71
|
-
https.use_ssl = true
|
72
|
-
https.ca_file = VaultedBilling.config.ca_file
|
73
|
-
https.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
74
|
-
end
|
75
|
-
|
76
|
-
before_post_caller(data)
|
77
|
-
|
78
|
-
begin
|
79
|
-
PostResponse.new(response.request(request)).tap do |post_response|
|
80
|
-
after_post_caller(post_response)
|
81
|
-
after_post_on_success(post_response)
|
82
|
-
end
|
83
|
-
rescue *HTTP_ERRORS
|
84
|
-
PostResponse.new(nil).tap do |post_response|
|
85
|
-
post_response.success = false
|
86
|
-
post_response.message = "%s - %s" % [$!.class.name, $!.message]
|
87
|
-
post_response.connection_error = true
|
88
|
-
after_post_caller(post_response)
|
89
|
-
after_post_on_exception(post_response, $!)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
protected :post_data
|
94
|
-
|
95
|
-
def before_post(data)
|
96
|
-
end
|
97
|
-
protected :before_post
|
98
|
-
|
99
|
-
def before_post_caller(data)
|
100
|
-
if VaultedBilling.logger?
|
101
|
-
VaultedBilling.logger.debug { "Posting %s to %s" % [data.inspect, uri.to_s] }
|
102
|
-
end
|
103
|
-
before_post(data)
|
104
|
-
end
|
105
|
-
private :before_post_caller
|
106
|
-
|
107
|
-
def after_post(response)
|
108
|
-
end
|
109
|
-
protected :after_post
|
110
|
-
|
111
|
-
def after_post_caller(response)
|
112
|
-
if VaultedBilling.logger?
|
113
|
-
VaultedBilling.logger.info { "Response code %s (HTTP %s), %s" % [response.message, response.code.presence || '0', response.body.inspect] }
|
114
|
-
end
|
115
|
-
after_post(response)
|
116
|
-
end
|
117
|
-
private :after_post_caller
|
118
|
-
|
119
|
-
def after_post_on_success(response)
|
120
|
-
end
|
121
|
-
protected :after_post_on_success
|
122
|
-
|
123
|
-
def after_post_on_exception(response, exception)
|
124
|
-
end
|
125
|
-
protected :after_post_on_exception
|
126
|
-
end
|
127
|
-
end
|