vaulted_billing 0.0.14 → 0.0.15

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.
@@ -1,13 +1,34 @@
1
+
1
2
  module VaultedBilling
3
+ ##
4
+ # This configuration holds the default values to use when instantiating
5
+ # VaultedBilling gateways. This configuration is accessed via
6
+ # VaultedBilling.config, or set en mass via a Hash with
7
+ # VaultedBilling.set_config(...).
8
+ #
2
9
  class Configuration
3
- class GatewayConfiguration #:nodoc:
10
+ ##
11
+ # This class holds default configuration options for a specific
12
+ # gateway in the library.
13
+ #
14
+ class GatewayConfiguration
4
15
  attr_accessor :username, :password, :test_mode
5
16
 
17
+ ##
18
+ # Possible options are:
19
+ #
20
+ # * password - The default password for the gateway.
21
+ # * test_mode - A boolean indicating whether or not to use the test mode of the gateway (sandbox server, test API, etc.)
22
+ # * username - The default username for the gateway.
23
+ #
24
+ # Unless otherwise defined, test_mode will default to being true.
25
+ #
6
26
  def initialize(options = {}, &block)
7
27
  options = options.with_indifferent_access
8
28
  self.username = options[:username]
9
29
  self.password = options[:password]
10
- self.test_mode = options.has_key?(:test_mode) ? options[:test_mode] : true
30
+ self.test_mode = options.has_key?(:test_mode) ?
31
+ options[:test_mode] : true
11
32
  yield(self) if block_given?
12
33
  end
13
34
  end
@@ -15,24 +36,50 @@ module VaultedBilling
15
36
  attr_accessor :logger
16
37
  alias :logger? :logger
17
38
 
39
+ attr_accessor :ca_file
40
+
18
41
  attr_accessor :test_mode
19
42
 
43
+ ##
44
+ # Possible options are as follows:
45
+ #
46
+ # * authorize_net_cim - A hash of GatewayConfiguration options for the Authorize.net CIM
47
+ # * bogus - A hash of GatewayConfiguration options for the Bogus gateway
48
+ # * nmi_customer_vault - A hash of GatewayConfiguration options for the NMI Customer Vault
49
+ # * test_mode - A boolean indicating whether or not the system defaults to using the test end points on the gateways.
50
+ #
20
51
  def initialize(options = {})
21
52
  options = options.with_indifferent_access
22
53
  self.test_mode = options.has_key?(:test_mode) ? options[:test_mode] : true
23
54
  @_authorize_net_cim = GatewayConfiguration.new(options[:authorize_net_cim]) if options[:authorize_net_cim]
24
55
  @_nmi_customer_vault = GatewayConfiguration.new(options[:nmi_customer_vault]) if options[:nmi_customer_vault]
25
56
  @_bogus = GatewayConfiguration.new(options[:bogus]) if options[:bogus]
57
+ @ca_file = File.expand_path('../../ext/cacert.pem', __FILE__)
26
58
  end
27
59
 
60
+ ##
61
+ # Returns a VaultedBilling::Configuration::GatewayConfiguration
62
+ # instance to be used for defining default settings for the
63
+ # Authorize.net CIM gateway.
64
+ #
28
65
  def authorize_net_cim
29
66
  @_authorize_net_cim ||= GatewayConfiguration.new
30
67
  end
31
68
 
69
+ ##
70
+ # Returns a VaultedBilling::Configuration::GatewayConfiguration
71
+ # instance to be used for defining default settings for the
72
+ # NMI Customer Vault gateway.
73
+ #
32
74
  def nmi_customer_vault
33
75
  @_nmi_customer_vault ||= GatewayConfiguration.new
34
76
  end
35
77
 
78
+ ##
79
+ # Returns a VaultedBilling::Configuration::GatewayConfiguration
80
+ # instance to be used for defining default settings for the
81
+ # Bogus gateway.
82
+ #
36
83
  def bogus
37
84
  @_bogus ||= GatewayConfiguration.new
38
85
  end
@@ -1,19 +1,40 @@
1
1
  module VaultedBilling
2
+ ##
3
+ # Intermediary class used to translate your local credit card information
4
+ # into data which VaultedBilling can recognize and use.
5
+ #
6
+ # Generally - and this is gateway specific - the only data which is
7
+ # actually required is the card number and expiration date (expires_on).
8
+ # Most of the other data is optional and may or may not be stored by
9
+ # your gateway.
10
+ #
11
+ # Note: The vault_id is the unique identifier generated by your gateway
12
+ # when you initially store the customer information. This should be
13
+ # kept and stored locally, related to your local credit card information.
14
+ # If you generate a CreditCard object with a vault_id, it is assumed that
15
+ # the card is already stored on the gateway and is not new information.
16
+ #
2
17
  class CreditCard
3
- attr_accessor :vault_id
4
- attr_accessor :currency
5
- attr_accessor :card_number
6
- attr_accessor :cvv_number
7
- attr_accessor :expires_on
8
- attr_accessor :first_name
9
- attr_accessor :last_name
10
- attr_accessor :street_address
11
- attr_accessor :locality
12
- attr_accessor :region
13
- attr_accessor :postal_code
14
- attr_accessor :country
15
- attr_accessor :phone
18
+ attr_accessor :card_number # The customer's credit card number
19
+ attr_accessor :country # The country of the credit card address.
20
+ attr_accessor :currency # The currency used by the credit card.
21
+ attr_accessor :cvv_number # The verification number (CVV2) on the card.
22
+ attr_accessor :expires_on # The date on which the credit card expires.
23
+ attr_accessor :first_name # The first name of the cardholder.
24
+ attr_accessor :last_name # The last name of the cardholder.
25
+ attr_accessor :locality # The "city" of the address on the card.
26
+ attr_accessor :phone # A phone number for the cardholder.
27
+ attr_accessor :postal_code # The postal code (zipcode) for the card.
28
+ attr_accessor :region # The "state" of the address on the card.
29
+ attr_accessor :street_address # The house number and street name of the card address.
30
+ attr_accessor :vault_id # The unique, gateway-generated identifier for this credit card.
16
31
 
32
+ ##
33
+ # You may define any of the CreditCard attributes by passing a hash
34
+ # with the attribute name as the key:
35
+ #
36
+ # CreditCard.new(:card_number => '4111....')
37
+ #
17
38
  def initialize(attributes = {})
18
39
  attributes = HashWithIndifferentAccess.new(attributes)
19
40
  attributes.each_pair do |key, value|
@@ -1,9 +1,24 @@
1
1
  module VaultedBilling
2
+ ##
3
+ # An intermediary object for VaultedBilling which represents a single
4
+ # customer on the gateway.
5
+ #
6
+ # Many gateways support you in defining multiple credit cards or payment
7
+ # methods under a single customer object. To support this, they will
8
+ # generate one identifier for the top-level customer, and then separate
9
+ # identifiers for each payment method (see VaultedBilling::CreditCard).
10
+ #
2
11
  class Customer
3
- attr_accessor :vault_id
4
- attr_accessor :merchant_id
5
- attr_accessor :email
12
+ attr_accessor :email # Optional email address for the customer.
13
+ attr_accessor :merchant_id # Optional custom identifier for the customer (i.e. your database key).
14
+ attr_accessor :vault_id # Gateway generated unique identifier for this customer in their system.
6
15
 
16
+ ##
17
+ # You can mass assign the attributes by passing a hash with keys
18
+ # matching attributes of the Customer:
19
+ #
20
+ # Customer.new(:merchant_id => 1)
21
+ #
7
22
  def initialize(attributes = {})
8
23
  attributes = HashWithIndifferentAccess.new(attributes)
9
24
  @vault_id = attributes[:vault_id]
@@ -13,7 +13,6 @@ module VaultedBilling
13
13
  def initialize(options = {})
14
14
  self.test_uri = 'https://apitest.authorize.net/xml/v1/request.api'
15
15
  self.live_uri = 'https://api.authorize.net/xml/v1/request.api'
16
- self.ssl_pem = File.read(File.expand_path(File.join(File.dirname(__FILE__), '..', 'certificate_authorities', 'entrust.pem')))
17
16
 
18
17
  options = HashWithIndifferentAccess.new(options)
19
18
  @login = options[:username] || VaultedBilling.config.authorize_net_cim.username
@@ -2,6 +2,16 @@ require 'digest/md5'
2
2
 
3
3
  module VaultedBilling
4
4
  module Gateways
5
+ ##
6
+ # The Bogus gateway should only be used for simple interface testing
7
+ # to the VaultedBilling library. All customer and credit card requests
8
+ # will always return successfully. All transaction requests (purchase,
9
+ # authorize, capture, etc.) will always return successfully.
10
+ #
11
+ # The primary purpose of this gateway is to provide you with an end
12
+ # point for testing your interface, as well as a fairly reasonable
13
+ # gateway for performing simple, non-network based tests against.
14
+ #
5
15
  class Bogus
6
16
  include VaultedBilling::Gateway
7
17
 
@@ -69,4 +79,4 @@ module VaultedBilling
69
79
  end
70
80
  end
71
81
  end
72
- end
82
+ end
@@ -17,7 +17,6 @@ module VaultedBilling
17
17
 
18
18
  def initialize(options = {})
19
19
  self.live_uri = self.test_uri = "https://secure.nmi.com/api/transact.php"
20
- self.ssl_pem = File.read(File.expand_path(File.join(File.dirname(__FILE__), '..', 'certificate_authorities', 'verisign.pem')))
21
20
 
22
21
  options = HashWithIndifferentAccess.new(options)
23
22
  @username = options[:username] || VaultedBilling.config.nmi_customer_vault.username
@@ -41,7 +41,6 @@ module VaultedBilling
41
41
  end
42
42
 
43
43
  attr_writer :use_test_uri
44
- attr_writer :ssl_pem
45
44
 
46
45
  def live_uri=(input)
47
46
  @live_uri = input ? URI.parse(input) : nil
@@ -70,12 +69,8 @@ module VaultedBilling
70
69
  request.body = data
71
70
  response = Net::HTTP.new(uri.host, uri.port).tap do |https|
72
71
  https.use_ssl = true
73
- if @ssl_pem
74
- https.cert = OpenSSL::X509::Certificate.new(@ssl_pem)
75
- https.verify_mode = OpenSSL::SSL::VERIFY_PEER
76
- else
77
- https.verify_mode = OpenSSL::SSL::VERIFY_NONE
78
- end
72
+ https.ca_file = VaultedBilling.config.ca_file
73
+ https.verify_mode = OpenSSL::SSL::VERIFY_PEER
79
74
  end
80
75
 
81
76
  before_post_caller(data)
@@ -1,11 +1,30 @@
1
1
  module VaultedBilling
2
+ ##
3
+ # This class encapsulates the data returned by the gateway / payment
4
+ # processor for transaction requests. An instance of this class will
5
+ # be returned from all transaction requests (authorize, capture,
6
+ # refund, void, etc.) performed against a gateway.
7
+ #
2
8
  class Transaction
9
+ # The transaction identifier from the processor
3
10
  attr_accessor :id
11
+
12
+ # The authorization code for the transaction
4
13
  attr_accessor :authcode
14
+
15
+ # The address verification service response
5
16
  attr_accessor :avs_response
17
+
18
+ # The card verification number response
6
19
  attr_accessor :cvv_response
20
+
21
+ # The response code from the processor
7
22
  attr_accessor :code
23
+
24
+ # The message from the processor
8
25
  attr_accessor :message
26
+
27
+ # The masked card number used in the transaction, if available
9
28
  attr_accessor :masked_card_number
10
29
 
11
30
  def initialize(attributes = {})
@@ -1,3 +1,3 @@
1
1
  module VaultedBilling
2
- Version = '0.0.14'
2
+ Version = '0.0.15'
3
3
  end
@@ -8,8 +8,6 @@ module VaultedBilling
8
8
  autoload :Transaction, 'vaulted_billing/transaction'
9
9
  autoload :HttpsInterface, 'vaulted_billing/https_interface'
10
10
 
11
- mattr_accessor :config
12
-
13
11
  Dir[File.expand_path('../vaulted_billing/core_ext/**/*.rb', __FILE__)].each do |extension|
14
12
  require extension
15
13
  end
@@ -25,10 +23,27 @@ module VaultedBilling
25
23
  Gateways.const_get(name.to_s.camelize)
26
24
  end
27
25
 
26
+ ##
27
+ # Returns the VaultedBilling::Configuration. This is primarily used to
28
+ # modify the default settings used when new gateways are instantiated.
29
+ #
28
30
  def self.config
29
31
  @@config ||= VaultedBilling::Configuration.new
30
32
  end
31
33
 
34
+ ##
35
+ # A helper method to allow you to set the configuration en mass via
36
+ # a properly formatted Hash of options:
37
+ #
38
+ # VaultedBilling.set_config({
39
+ # :test_mode => false,
40
+ # :authorize_net_cim => {
41
+ # :username => 'APIName',
42
+ # :password => 'APIPassword',
43
+ # :test_mode => false,
44
+ # :nmi_customer_vault => { ... }
45
+ # })
46
+ #
32
47
  def self.set_config(options = {})
33
48
  @@config = VaultedBilling::Configuration.new(options)
34
49
  end
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vaulted_billing
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 0
9
- - 14
10
- version: 0.0.14
8
+ - 15
9
+ version: 0.0.15
11
10
  platform: ruby
12
11
  authors:
13
12
  - Nathaniel Bibler
@@ -15,7 +14,7 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2010-12-21 00:00:00 -05:00
17
+ date: 2011-01-03 00:00:00 -05:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
@@ -26,7 +25,6 @@ dependencies:
26
25
  requirements:
27
26
  - - ">="
28
27
  - !ruby/object:Gem::Version
29
- hash: 5
30
28
  segments:
31
29
  - 2
32
30
  - 3
@@ -41,7 +39,6 @@ dependencies:
41
39
  requirements:
42
40
  - - ">="
43
41
  - !ruby/object:Gem::Version
44
- hash: 15
45
42
  segments:
46
43
  - 2
47
44
  - 1
@@ -57,7 +54,6 @@ dependencies:
57
54
  requirements:
58
55
  - - ">="
59
56
  - !ruby/object:Gem::Version
60
- hash: 3
61
57
  segments:
62
58
  - 2
63
59
  - 3
@@ -73,7 +69,6 @@ dependencies:
73
69
  requirements:
74
70
  - - ">="
75
71
  - !ruby/object:Gem::Version
76
- hash: 25
77
72
  segments:
78
73
  - 0
79
74
  - 0
@@ -89,7 +84,6 @@ dependencies:
89
84
  requirements:
90
85
  - - ">="
91
86
  - !ruby/object:Gem::Version
92
- hash: 7
93
87
  segments:
94
88
  - 1
95
89
  - 4
@@ -105,7 +99,6 @@ dependencies:
105
99
  requirements:
106
100
  - - ">="
107
101
  - !ruby/object:Gem::Version
108
- hash: 13
109
102
  segments:
110
103
  - 1
111
104
  - 6
@@ -121,7 +114,6 @@ dependencies:
121
114
  requirements:
122
115
  - - ">="
123
116
  - !ruby/object:Gem::Version
124
- hash: 31
125
117
  segments:
126
118
  - 1
127
119
  - 3
@@ -137,7 +129,6 @@ dependencies:
137
129
  requirements:
138
130
  - - ">="
139
131
  - !ruby/object:Gem::Version
140
- hash: 17
141
132
  segments:
142
133
  - 0
143
134
  - 3
@@ -155,6 +146,7 @@ extensions: []
155
146
  extra_rdoc_files: []
156
147
 
157
148
  files:
149
+ - lib/ext/cacert.pem
158
150
  - lib/vaulted_billing/certificate_authorities/entrust.pem
159
151
  - lib/vaulted_billing/certificate_authorities/verisign.pem
160
152
  - lib/vaulted_billing/configuration.rb
@@ -185,7 +177,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
185
177
  requirements:
186
178
  - - ">="
187
179
  - !ruby/object:Gem::Version
188
- hash: 3
189
180
  segments:
190
181
  - 0
191
182
  version: "0"
@@ -194,7 +185,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
194
185
  requirements:
195
186
  - - ">="
196
187
  - !ruby/object:Gem::Version
197
- hash: 23
198
188
  segments:
199
189
  - 1
200
190
  - 3