authorizenet 1.9.4 → 1.9.5

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.
Files changed (52) hide show
  1. data/lib/app/helpers/authorize_net_helper.rb +2 -3
  2. data/lib/authorize_net.rb +5 -5
  3. data/lib/authorize_net/addresses/address.rb +15 -19
  4. data/lib/authorize_net/addresses/shipping_address.rb +12 -16
  5. data/lib/authorize_net/aim/response.rb +27 -38
  6. data/lib/authorize_net/aim/transaction.rb +46 -65
  7. data/lib/authorize_net/api/api_transaction.rb +85 -90
  8. data/lib/authorize_net/api/constants.yml +1 -1
  9. data/lib/authorize_net/api/schema.rb +968 -936
  10. data/lib/authorize_net/api/transaction.rb +100 -102
  11. data/lib/authorize_net/arb/fields.rb +21 -21
  12. data/lib/authorize_net/arb/paging.rb +7 -11
  13. data/lib/authorize_net/arb/response.rb +7 -15
  14. data/lib/authorize_net/arb/sorting.rb +6 -10
  15. data/lib/authorize_net/arb/subscription.rb +27 -31
  16. data/lib/authorize_net/arb/subscription_detail.rb +1 -5
  17. data/lib/authorize_net/arb/subscription_list_response.rb +13 -20
  18. data/lib/authorize_net/arb/transaction.rb +50 -56
  19. data/lib/authorize_net/authorize_net.rb +20 -27
  20. data/lib/authorize_net/cim/customer_profile.rb +4 -8
  21. data/lib/authorize_net/cim/payment_profile.rb +10 -12
  22. data/lib/authorize_net/cim/response.rb +19 -24
  23. data/lib/authorize_net/cim/transaction.rb +168 -174
  24. data/lib/authorize_net/customer.rb +11 -14
  25. data/lib/authorize_net/email_receipt.rb +8 -12
  26. data/lib/authorize_net/fields.rb +483 -502
  27. data/lib/authorize_net/key_value_response.rb +54 -62
  28. data/lib/authorize_net/key_value_transaction.rb +87 -97
  29. data/lib/authorize_net/line_item.rb +10 -14
  30. data/lib/authorize_net/order.rb +21 -25
  31. data/lib/authorize_net/payment_methods/credit_card.rb +6 -7
  32. data/lib/authorize_net/payment_methods/echeck.rb +29 -31
  33. data/lib/authorize_net/reporting/batch.rb +4 -7
  34. data/lib/authorize_net/reporting/batch_statistics.rb +2 -6
  35. data/lib/authorize_net/reporting/fds_filter.rb +2 -5
  36. data/lib/authorize_net/reporting/response.rb +54 -60
  37. data/lib/authorize_net/reporting/returned_item.rb +11 -12
  38. data/lib/authorize_net/reporting/transaction.rb +27 -29
  39. data/lib/authorize_net/reporting/transaction_details.rb +3 -6
  40. data/lib/authorize_net/response.rb +6 -10
  41. data/lib/authorize_net/sim/hosted_payment_form.rb +16 -20
  42. data/lib/authorize_net/sim/hosted_receipt_page.rb +18 -23
  43. data/lib/authorize_net/sim/response.rb +24 -33
  44. data/lib/authorize_net/sim/transaction.rb +33 -43
  45. data/lib/authorize_net/transaction.rb +15 -21
  46. data/lib/authorize_net/xml_response.rb +36 -54
  47. data/lib/authorize_net/xml_transaction.rb +115 -134
  48. data/lib/generators/authorize_net/direct_post/direct_post_generator.rb +5 -6
  49. data/lib/generators/authorize_net/sim/sim_generator.rb +6 -7
  50. data/lib/generators/generator_extensions.rb +23 -25
  51. metadata +127 -81
  52. checksums.yaml +0 -7
@@ -1,13 +1,11 @@
1
1
  module AuthorizeNet::ARB
2
-
3
2
  class Sorting
4
-
5
3
  # Models Sorting
6
4
  include AuthorizeNet::Model
7
-
5
+
8
6
  attr_accessor :order_by, :order_descending
9
7
 
10
- # Initializes Sorting object.
8
+ # Initializes Sorting object.
11
9
  #
12
10
  # Typical usage:
13
11
  # sorting = AuthorizeNet::ARB::Sorting.new('name',true)
@@ -29,15 +27,13 @@ module AuthorizeNet::ARB
29
27
  @order_by = order_by
30
28
  @order_descending = order_descending
31
29
  end
32
-
30
+
33
31
  def to_hash
34
32
  hash = {
35
- :order_by => @order_by,
36
- :order_descending => @order_descending
33
+ order_by: @order_by,
34
+ order_descending: @order_descending
37
35
  }
38
- hash.delete_if {|k, v| v.nil?}
36
+ hash.delete_if { |_k, v| v.nil? }
39
37
  end
40
-
41
38
  end
42
-
43
39
  end
@@ -1,30 +1,28 @@
1
1
  module AuthorizeNet::ARB
2
-
3
2
  # Models an ARB subscription.
4
3
  class Subscription
5
-
6
4
  # Use this constant for the value of total_occurrences to get a subscription with no end.
7
5
  UNLIMITED_OCCURRENCES = 9999
8
-
6
+
9
7
  # Constants for the various interval units supported by the ARB API.
10
8
  module IntervalUnits
11
- MONTH = 'months'
12
- DAY = 'days'
9
+ MONTH = 'months'.freeze
10
+ DAY = 'days'.freeze
13
11
  end
14
-
12
+
15
13
  # Constants for the various statuses a subscription can have. These are returned by the get_status call.
16
14
  module Status
17
- ACTIVE = 'active'
18
- EXPIRED = 'expired'
19
- SUSPENDED = 'suspended'
20
- CANCELED = 'canceled'
21
- TERMINATED = 'terminated'
15
+ ACTIVE = 'active'.freeze
16
+ EXPIRED = 'expired'.freeze
17
+ SUSPENDED = 'suspended'.freeze
18
+ CANCELED = 'canceled'.freeze
19
+ TERMINATED = 'terminated'.freeze
22
20
  end
23
-
21
+
24
22
  include AuthorizeNet::Model
25
-
23
+
26
24
  attr_accessor :name, :length, :unit, :start_date, :total_occurrences, :trial_occurrences, :amount, :trial_amount, :invoice_number, :description, :subscription_id, :credit_card, :billing_address, :shipping_address, :customer
27
-
25
+
28
26
  # Override the total_occurrences setter to provide support for :unlimited shortcut.
29
27
  def total_occurrences=(new_total_occurrences) #:nodoc:
30
28
  if new_total_occurrences == :unlimited
@@ -33,7 +31,7 @@ module AuthorizeNet::ARB
33
31
  @total_occurrences = new_total_occurrences
34
32
  end
35
33
  end
36
-
34
+
37
35
  # Override the unit setter to provide support for :day, :days, :month, :months shortcut. Do not document this method in rdoc.
38
36
  def unit=(new_unit) #:nodoc:
39
37
  case new_unit
@@ -45,28 +43,26 @@ module AuthorizeNet::ARB
45
43
  @unit = new_unit
46
44
  end
47
45
  end
48
-
46
+
49
47
  def to_hash
50
48
  hash = {
51
- :subscription_name => @name,
52
- :subscription_length => @length,
53
- :subscription_unit => @unit,
54
- :subscription_start_date => @start_date,
55
- :subscription_total_occurrences => @total_occurrences,
56
- :subscription_trial_occurrences => @trial_occurrences,
57
- :subscription_amount => @amount,
58
- :subscription_trial_amount => @trial_amount,
59
- :invoice_num => @invoice_number,
60
- :description => @description,
61
- :subscription_id => @subscription_id
49
+ subscription_name: @name,
50
+ subscription_length: @length,
51
+ subscription_unit: @unit,
52
+ subscription_start_date: @start_date,
53
+ subscription_total_occurrences: @total_occurrences,
54
+ subscription_trial_occurrences: @trial_occurrences,
55
+ subscription_amount: @amount,
56
+ subscription_trial_amount: @trial_amount,
57
+ invoice_num: @invoice_number,
58
+ description: @description,
59
+ subscription_id: @subscription_id
62
60
  }
63
61
  hash.merge!(@credit_card.to_hash) unless @credit_card.nil?
64
62
  hash.merge!(@billing_address.to_hash) unless @billing_address.nil?
65
63
  hash.merge!(@shipping_address.to_hash) unless @shipping_address.nil?
66
64
  hash.merge!(@customer.to_hash) unless @customer.nil?
67
- hash.delete_if {|k, v| v.nil?}
65
+ hash.delete_if { |_k, v| v.nil? }
68
66
  end
69
-
70
67
  end
71
-
72
- end
68
+ end
@@ -1,14 +1,10 @@
1
1
  module AuthorizeNet::ARB
2
-
3
2
  # Models Subscription Detail.
4
3
  class SubscriptionDetail
5
-
6
4
  include AuthorizeNet::Model
7
-
5
+
8
6
  attr_accessor :id, :name, :status, :create_time_stamp_utc, :first_name,
9
7
  :last_name, :total_occurrences, :past_occurrences,
10
8
  :payment_method, :account_number, :invoice, :amount, :currency_id
11
-
12
9
  end
13
-
14
10
  end
@@ -1,5 +1,4 @@
1
1
  module AuthorizeNet::ARB
2
-
3
2
  class SubscriptionListResponse < AuthorizeNet::XmlResponse
4
3
  # Constructs a new response object from a +raw_response. You don't typically
5
4
  # construct this object yourself, as AuthorizeNet::ARB::Transaction will
@@ -8,36 +7,30 @@ module AuthorizeNet::ARB
8
7
  super
9
8
  unless connection_failure?
10
9
  begin
11
- @subscription_details = @root.at_css('subscriptionDetails')
10
+ @subscription_details = @root.at_css('subscriptionDetails')
12
11
  @subscription_detail = @root.at_css('subscriptionDetail')
13
12
  @total_num_in_resultset = node_content_unless_nil(@root.at_css('totalNumInResultSet'))
14
-
15
- rescue
16
- @raw_response = $!
13
+ rescue StandardError
14
+ @raw_response = $ERROR_INFO
17
15
  end
18
16
  end
19
17
  end
20
18
 
21
19
  # Returns total number of subscriptions matching the search criteria
22
- def total_num_in_resultset
23
- @total_num_in_resultset
24
- end
20
+ attr_reader :total_num_in_resultset
25
21
 
26
22
  # Returns an Array of SubscriptionDetail objects built from the entities returned in the response. Returns nil if no subscriptions were returned.
27
23
  def subscription_details
28
24
  unless @subscription_details.nil?
29
- subscription_details = []
30
- @subscription_details.element_children.each do |child|
31
- unless child.nil?
32
- subscription_detail = build_entity(child, Fields::SUBSCRIPTION_DETAIL_ENTITY_DESCRIPTION)
33
-
34
- subscription_details <<= subscription_detail
35
- end
36
- end
37
- return subscription_details unless subscription_details.length == 0
25
+ subscription_details = []
26
+ @subscription_details.element_children.each do |child|
27
+ next if child.nil?
28
+ subscription_detail = build_entity(child, Fields::SUBSCRIPTION_DETAIL_ENTITY_DESCRIPTION)
29
+
30
+ subscription_details <<= subscription_detail
31
+ end
32
+ return subscription_details unless subscription_details.empty?
38
33
  end
39
34
  end
40
-
41
- end
42
-
35
+ end
43
36
  end
@@ -1,54 +1,53 @@
1
1
  module AuthorizeNet::ARB
2
-
3
2
  # The ARB transaction class.
4
3
  class Transaction < AuthorizeNet::XmlTransaction
5
-
6
4
  include AuthorizeNet::ARB::Fields
7
-
5
+
8
6
  # The default options for the constructor.
9
7
  @@option_defaults = {
10
- :gateway => :production,
11
- :verify_ssl => true,
12
- :reference_id => nil
8
+ gateway: :production,
9
+ verify_ssl: true,
10
+ reference_id: nil
13
11
  }
14
-
12
+
15
13
  # Fields to convert to/from booleans.
16
14
  @@boolean_fields = []
17
-
15
+
18
16
  # Fields to convert to/from BigDecimal.
19
- @@decimal_fields = [:amount, :trial_amount]
20
-
17
+ @@decimal_fields = %i[amount trial_amount]
18
+
21
19
  # Fields to convert to/from Date.
22
20
  @@date_fields = [:subscription_start_date]
23
-
21
+
24
22
  # The class to wrap our response in.
25
- @response_class = AuthorizeNet::ARB::Response
26
-
23
+ @response_class = AuthorizeNet::ARB::Response
24
+
27
25
  # Constructs an ARB transaction. You can use the new ARB transaction object
28
26
  # to issue a request to the payment gateway and parse the response into a new
29
27
  # AuthorizeNet::ARB::Response object.
30
- #
28
+ #
31
29
  # +api_login_id+:: Your API login ID, as a string.
32
30
  # +api_transaction_key+:: Your API transaction key, as a string.
33
31
  # +options+:: A hash of options. See below for values.
34
- #
32
+ #
35
33
  # Options
36
- # +gateway+:: The gateway to submit the transaction to. Can be a URL string, an AuthorizeNet::ARB::Transaction::Gateway constant, or one of the convenience symbols :sandbox, :test, :production, or :live (:test is an alias for :sandbox, and :live is an alias for :production).
34
+ # +gateway+:: The gateway to submit the transaction to. Can be a URL string, an AuthorizeNet::ARB::Transaction::Gateway constant, or one of the convenience symbols :sandbox, :test, :production, or :live (:test is an alias for :sandbox, and :live is an alias for :production).
37
35
  # +verify_ssl+:: A boolean indicating if the SSL certificate of the +gateway+ should be verified. Defaults to true.
38
36
  # +reference_id+:: A string that can be used to identify a particular transaction with its response. Will be echo'd in the response, only if it was provided in the transaction. Defaults to nil.
39
37
  #
40
38
  def initialize(api_login_id, api_transaction_key, options = {})
39
+ ActiveSupport::Deprecation.warn "use AuthorizeNet::API::Transaction"
41
40
  super
42
41
  end
43
-
42
+
44
43
  # Sets up and submits a start of subscription (ARBCreateSubscriptionRequest) transaction. Returns a response object. If the transaction
45
44
  # has already been run, it will return nil.
46
- #
45
+ #
47
46
  # +subscription+:: An instance of AuthorizeNet::ARB::Subscription describing the recurring payment you would like to create.
48
- #
49
- #
47
+ #
48
+ #
50
49
  # Typical usage:
51
- #
50
+ #
52
51
  # subscription = AuthorizeNet::ARB::Subscription.new(
53
52
  # :name => "Monthly Gift Basket",
54
53
  # :length => 1,
@@ -68,15 +67,15 @@ module AuthorizeNet::ARB
68
67
  set_fields(subscription.to_hash)
69
68
  run
70
69
  end
71
-
70
+
72
71
  # Sets up and submits a subscription update (ARBUpdateSubscriptionRequest) transaction. Returns a response object. If the transaction
73
72
  # has already been run, it will return nil.
74
- #
73
+ #
75
74
  # +subscription+:: An instance of AuthorizeNet::ARB::Subscription describing the changes to make. It must have a value for subscription_id so that the API knows what subscription to update. Note that some information (intervals, start dates, etc) can't be changed. See the ARB guide for more details.
76
- #
77
- #
75
+ #
76
+ #
78
77
  # Typical usage:
79
- #
78
+ #
80
79
  # subscription = AuthorizeNet::ARB::Subscription.new(
81
80
  # :billing_address => AuthorizeNet::Address.new(:first_name => 'Jane', :last_name => 'Doe'),
82
81
  # :subscription_id => '123456'
@@ -88,15 +87,15 @@ module AuthorizeNet::ARB
88
87
  set_fields(subscription.to_hash)
89
88
  run
90
89
  end
91
-
90
+
92
91
  # Sets up and submits a subscription status query (ARBGetSubscriptionStatusRequest) transaction. Returns a response object (which contains the subscription status). If the transaction
93
92
  # has already been run, it will return nil.
94
- #
93
+ #
95
94
  # +subscription_id+:: Either the subscription id of the subscription to get the status of as a string, or a Subscription instance with a value for subscription_id set on it.
96
- #
97
- #
95
+ #
96
+ #
98
97
  # Typical usage:
99
- #
98
+ #
100
99
  # response = transaction.get_status('123456')
101
100
  # response.subscription_status # A value from AuthorizeNet::ARB::Subscription::Status
102
101
  #
@@ -106,8 +105,8 @@ module AuthorizeNet::ARB
106
105
  run
107
106
  end
108
107
 
109
- # Sets up and submits a subscription list query (ARBGetSubscriptionListRequest). Returns a response object
110
- # which contains the list of subscription details and the total number of subscriptions matching the search
108
+ # Sets up and submits a subscription list query (ARBGetSubscriptionListRequest). Returns a response object
109
+ # which contains the list of subscription details and the total number of subscriptions matching the search
111
110
  # criteria. Sorting and Paging are optional parameters.
112
111
  #
113
112
  # Valid values for search type parameter:
@@ -117,35 +116,31 @@ module AuthorizeNet::ARB
117
116
  # subscriptionInactive
118
117
  #
119
118
  # Typical usage:
120
- #
119
+ #
121
120
  # sorting = AuthorizeNet::ARB::Sorting.new('name',true)
122
121
  # paging = AuthorizeNet::ARB::Paging.new(1,1000)
123
122
  # response = transaction.get_subscription_list('subscriptionActive',sorting,paging)
124
123
  #
125
124
  def get_subscription_list(search_type, sorting = nil, paging = nil)
126
125
  unless search_type.nil?
127
- self.class.instance_variable_set(:@response_class,SubscriptionListResponse)
126
+ self.class.instance_variable_set(:@response_class, SubscriptionListResponse)
128
127
  @type = Type::ARB_GET_SUBSCRIPTION_LIST
129
- set_fields(:search_type => search_type.to_s)
130
- unless sorting.nil?
131
- set_fields(sorting.to_hash)
132
- end
133
- unless paging.nil?
134
- set_fields(paging.to_hash)
135
- end
136
- run
128
+ set_fields(search_type: search_type.to_s)
129
+ set_fields(sorting.to_hash) unless sorting.nil?
130
+ set_fields(paging.to_hash) unless paging.nil?
131
+ run
137
132
  end
138
- return response
133
+ response
139
134
  end
140
-
135
+
141
136
  # Sets up and submits a subscription cancelation (ARBCancelSubscriptionRequest) transaction. Returns a response object. If the transaction
142
137
  # has already been run, it will return nil.
143
- #
138
+ #
144
139
  # +subscription_id+:: Either the subscription id of the subscription to get the status of as a string, or a Subscription instance with a value for subscription_id set on it.
145
- #
146
- #
140
+ #
141
+ #
147
142
  # Typical usage:
148
- #
143
+ #
149
144
  # response = transaction.cancel('123456')
150
145
  #
151
146
  def cancel(subscription_id)
@@ -153,25 +148,24 @@ module AuthorizeNet::ARB
153
148
  handle_subscription_id(subscription_id)
154
149
  run
155
150
  end
156
-
151
+
157
152
  #:enddoc:
158
153
  protected
159
-
154
+
160
155
  # Internal method to handle multiple types of subscription id arguments.
161
156
  def handle_subscription_id(subscription_id)
162
157
  case subscription_id
163
158
  when Subscription
164
- set_fields(:subscription_id => subscription_id.subscription_id.to_s)
159
+ set_fields(subscription_id: subscription_id.subscription_id.to_s)
165
160
  else
166
- set_fields(:subscription_id => subscription_id.to_s)
161
+ set_fields(subscription_id: subscription_id.to_s)
167
162
  end
168
163
  end
169
-
164
+
170
165
  # An internal method that builds the POST body, submits it to the gateway, and constructs a Response object with the response.
171
166
  def make_request
172
- set_fields(:reference_id => @reference_id)
167
+ set_fields(reference_id: @reference_id)
173
168
  super
174
169
  end
175
-
176
170
  end
177
171
  end
@@ -2,12 +2,10 @@
2
2
  # The core AuthoizeNet module.
3
3
  # The entire SDK is name-spaced inside of this module.
4
4
  module AuthorizeNet
5
-
6
5
  # Some type conversion routines that will be injected into our
7
6
  # Transaction/Response classes.
8
7
  module TypeConversions
9
-
10
- API_FIELD_PREFIX = 'x_'
8
+ API_FIELD_PREFIX = 'x_'.freeze
11
9
 
12
10
  # Converts a value received from Authorize.Net into a boolean if
13
11
  # possible. This is designed to handle the wide range of boolean
@@ -22,7 +20,7 @@ module AuthorizeNet
22
20
  value
23
21
  end
24
22
  end
25
-
23
+
26
24
  # Converts a boolean into an Authorize.Net boolean value string.
27
25
  # This is designed to handle the wide range of boolean formats that
28
26
  # Authorize.Net uses. If bool isn't a Boolean, its converted to a
@@ -35,32 +33,32 @@ module AuthorizeNet
35
33
  bool.to_s
36
34
  end
37
35
  end
38
-
36
+
39
37
  # Converts a value received from Authorize.Net into a BigDecimal.
40
38
  def value_to_decimal(value)
41
39
  value = 0 if value == '' # Ruby 2.4+ does not accept ""
42
- BigDecimal.new(value)
40
+ BigDecimal(value)
43
41
  end
44
-
42
+
45
43
  # Converts a BigDecimal (or Float) into an Authorize.Net float value
46
44
  # string. If float isn't a BigDecimal (or Float), its converted to a
47
45
  # string and passed along.
48
46
  def decimal_to_value(float)
49
47
  case float
50
48
  when Float
51
- "%0.2f" % float
49
+ format("%0.2f", float)
52
50
  when BigDecimal
53
51
  float.truncate(2).to_s('F')
54
52
  else
55
53
  float.to_s
56
54
  end
57
55
  end
58
-
56
+
59
57
  # Converts a value received from Authorize.Net into a Date.
60
58
  def value_to_date(value)
61
59
  Date.strptime(value, '%Y-%m-%d')
62
60
  end
63
-
61
+
64
62
  # Converts a Date (or DateTime, or Time) into an Authorize.Net date
65
63
  # value string. If date isn't a Date (or DateTime, or Time), its
66
64
  # converted to a string and passed along.
@@ -72,12 +70,12 @@ module AuthorizeNet
72
70
  date.to_s
73
71
  end
74
72
  end
75
-
73
+
76
74
  # Converts a value received from Authorize.Net into a DateTime.
77
75
  def value_to_datetime(value)
78
76
  DateTime.strptime(value, '%Y-%m-%dT%H:%M:%S')
79
77
  end
80
-
78
+
81
79
  # Converts a Date (or DateTime, or Time) into an Authorize.Net datetime
82
80
  # value string. If date isn't a Date (or DateTime, or Time), it's
83
81
  # converted to a string and passed along.
@@ -91,36 +89,36 @@ module AuthorizeNet
91
89
  datetime.to_s
92
90
  end
93
91
  end
94
-
92
+
95
93
  # Converts a value received from Authorize.Net into an Integer.
96
94
  def value_to_integer(value)
97
95
  value.to_s.to_i
98
96
  end
99
-
97
+
100
98
  # Converts an Integer into an Authorize.Net integer string.
101
99
  def integer_to_value(int)
102
100
  int.to_s
103
101
  end
104
-
102
+
105
103
  # Converts a key value pair into a HTTP POST parameter. The key is
106
104
  # prefixed with key_prefix when being converted to a parameter name.
107
105
  def to_param(key, value, key_prefix = API_FIELD_PREFIX)
108
106
  key_str = "#{key_prefix}#{key}="
109
- if value.kind_of?(Array)
107
+ if value.is_a?(Array)
110
108
  (value.collect do |v|
111
- key_str + CGI::escape(v.to_s)
109
+ key_str + CGI.escape(v.to_s)
112
110
  end).join('&')
113
111
  else
114
- key_str + CGI::escape(value.to_s)
112
+ key_str + CGI.escape(value.to_s)
115
113
  end
116
- end
117
-
114
+ end
115
+
118
116
  # Converts an internal field name (Symbol) into an external field
119
117
  # name (Symbol) that can be consumed by the Authorize.Net API.
120
118
  def to_external_field(key)
121
119
  (API_FIELD_PREFIX + key.to_s).to_sym
122
120
  end
123
-
121
+
124
122
  # Converts an external field name (Symbol) into an internal field
125
123
  # name (Symbol). This is the exact inverse of to_external_field.
126
124
  # Running to_internal_field(to_external_field(:foo)) would return
@@ -133,15 +131,12 @@ module AuthorizeNet
133
131
 
134
132
  # Provides some basic methods used by the various model classes.
135
133
  module Model
136
-
137
134
  # The constructor for models. Takes any of the supported attributes
138
135
  # as key/value pairs.
139
136
  def initialize(fields = {})
140
137
  fields.each do |k, v|
141
138
  method_name = (k.to_s + '=').to_sym
142
- if self.respond_to?(method_name)
143
- self.send(method_name, v)
144
- end
139
+ send(method_name, v) if respond_to?(method_name)
145
140
  end
146
141
  end
147
142
 
@@ -155,7 +150,5 @@ module AuthorizeNet
155
150
  def handle_multivalue_hashing(obj)
156
151
  obj.to_a.collect(&:to_hash)
157
152
  end
158
-
159
153
  end
160
-
161
154
  end