vaulted_billing 0.0.11 → 0.0.12
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.
data/lib/vaulted_billing.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
module VaultedBilling
|
2
2
|
autoload :Version, 'vaulted_billing/version'
|
3
|
+
autoload :Configuration, 'vaulted_billing/configuration'
|
3
4
|
autoload :Gateway, 'vaulted_billing/gateway'
|
4
5
|
autoload :Gateways, 'vaulted_billing/gateways'
|
5
6
|
autoload :Customer, 'vaulted_billing/customer'
|
@@ -7,24 +8,32 @@ module VaultedBilling
|
|
7
8
|
autoload :Transaction, 'vaulted_billing/transaction'
|
8
9
|
autoload :HttpsInterface, 'vaulted_billing/https_interface'
|
9
10
|
|
10
|
-
mattr_accessor :
|
11
|
+
mattr_accessor :config
|
11
12
|
|
12
|
-
Dir[File.expand_path(
|
13
|
+
Dir[File.expand_path('../vaulted_billing/core_ext/**/*.rb', __FILE__)].each do |extension|
|
13
14
|
require extension
|
14
15
|
end
|
15
16
|
|
16
17
|
##
|
17
18
|
# Return the matching gateway for the name provided.
|
18
19
|
#
|
19
|
-
# * <tt
|
20
|
-
# * <tt
|
20
|
+
# * <tt>:bogus</tt>:: Bogus - always successful, does nothing.
|
21
|
+
# * <tt>:nmi_customer_vault</tt>:: NmiCustomerVault
|
22
|
+
# * <tt>:authorize_net_cim</tt>:: AuthorizeNetCim
|
21
23
|
#
|
22
24
|
def self.gateway(name)
|
23
25
|
Gateways.const_get(name.to_s.camelize)
|
24
26
|
end
|
25
27
|
|
26
|
-
def self.
|
27
|
-
@@
|
28
|
+
def self.config
|
29
|
+
@@config ||= VaultedBilling::Configuration.new
|
28
30
|
end
|
29
31
|
|
32
|
+
def self.set_config(options = {})
|
33
|
+
@@config = VaultedBilling::Configuration.new(options)
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.logger; config.logger; end
|
37
|
+
def self.logger=(input); config.logger = input; end
|
38
|
+
def self.logger?; config.logger?; end
|
30
39
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module VaultedBilling
|
2
|
+
class Configuration
|
3
|
+
class GatewayConfiguration #:nodoc:
|
4
|
+
attr_accessor :username, :password, :test_mode
|
5
|
+
|
6
|
+
def initialize(options = {}, &block)
|
7
|
+
options = options.with_indifferent_access
|
8
|
+
self.username = options[:username]
|
9
|
+
self.password = options[:password]
|
10
|
+
self.test_mode = options.has_key?(:test_mode) ? options[:test_mode] : true
|
11
|
+
yield(self) if block_given?
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
attr_accessor :logger
|
16
|
+
alias :logger? :logger
|
17
|
+
|
18
|
+
attr_accessor :test_mode
|
19
|
+
|
20
|
+
def initialize(options = {})
|
21
|
+
options = options.with_indifferent_access
|
22
|
+
self.test_mode = options.has_key?(:test_mode) ? options[:test_mode] : true
|
23
|
+
@_authorize_net_cim = GatewayConfiguration.new(options[:authorize_net_cim]) if options[:authorize_net_cim]
|
24
|
+
@_nmi_customer_vault = GatewayConfiguration.new(options[:nmi_customer_vault]) if options[:nmi_customer_vault]
|
25
|
+
@_bogus = GatewayConfiguration.new(options[:bogus]) if options[:bogus]
|
26
|
+
end
|
27
|
+
|
28
|
+
def authorize_net_cim
|
29
|
+
@_authorize_net_cim ||= GatewayConfiguration.new
|
30
|
+
end
|
31
|
+
|
32
|
+
def nmi_customer_vault
|
33
|
+
@_nmi_customer_vault ||= GatewayConfiguration.new
|
34
|
+
end
|
35
|
+
|
36
|
+
def bogus
|
37
|
+
@_bogus ||= GatewayConfiguration.new
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -16,9 +16,9 @@ module VaultedBilling
|
|
16
16
|
self.ssl_pem = File.read(File.expand_path(File.join(File.dirname(__FILE__), '..', 'certificate_authorities', 'entrust.pem')))
|
17
17
|
|
18
18
|
options = HashWithIndifferentAccess.new(options)
|
19
|
-
@login = options[:username]
|
20
|
-
@password = options[:password]
|
21
|
-
self.use_test_uri = options[:test]
|
19
|
+
@login = options[:username] || VaultedBilling.config.authorize_net_cim.username
|
20
|
+
@password = options[:password] || VaultedBilling.config.authorize_net_cim.password
|
21
|
+
self.use_test_uri = options.has_key?(:test) ? options[:test] : (VaultedBilling.config.authorize_net_cim.test_mode || VaultedBilling.config.test_mode)
|
22
22
|
end
|
23
23
|
|
24
24
|
def add_customer(customer)
|
@@ -20,9 +20,9 @@ module VaultedBilling
|
|
20
20
|
self.ssl_pem = File.read(File.expand_path(File.join(File.dirname(__FILE__), '..', 'certificate_authorities', 'verisign.pem')))
|
21
21
|
|
22
22
|
options = HashWithIndifferentAccess.new(options)
|
23
|
-
@username = options[:username]
|
24
|
-
@password = options[:password]
|
25
|
-
self.use_test_uri = options[:test]
|
23
|
+
@username = options[:username] || VaultedBilling.config.nmi_customer_vault.username
|
24
|
+
@password = options[:password] || VaultedBilling.config.nmi_customer_vault.password
|
25
|
+
self.use_test_uri = options.has_key?(:test) ? options[:test] : (VaultedBilling.config.nmi_customer_vault.test_mode || VaultedBilling.config.test_mode)
|
26
26
|
end
|
27
27
|
|
28
28
|
##
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vaulted_billing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 12
|
10
|
+
version: 0.0.12
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Nathaniel Bibler
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-12-
|
18
|
+
date: 2010-12-18 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -157,6 +157,7 @@ extra_rdoc_files: []
|
|
157
157
|
files:
|
158
158
|
- lib/vaulted_billing/certificate_authorities/entrust.pem
|
159
159
|
- lib/vaulted_billing/certificate_authorities/verisign.pem
|
160
|
+
- lib/vaulted_billing/configuration.rb
|
160
161
|
- lib/vaulted_billing/core_ext/hash.rb
|
161
162
|
- lib/vaulted_billing/credit_card.rb
|
162
163
|
- lib/vaulted_billing/customer.rb
|