authorizenet 1.9.7 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +5 -5
  2. data/lib/app/helpers/authorize_net_helper.rb +23 -23
  3. data/lib/authorize_net.rb +62 -107
  4. data/lib/authorize_net/api/LogHelper.rb +97 -97
  5. data/lib/authorize_net/api/SensitiveDataFilter.rb +92 -92
  6. data/lib/authorize_net/api/api_transaction.rb +129 -129
  7. data/lib/authorize_net/api/constants.yml +1 -1
  8. data/lib/authorize_net/api/schema.rb +5421 -5421
  9. data/lib/authorize_net/api/transaction.rb +265 -265
  10. data/lib/authorize_net/authorize_net.rb +154 -154
  11. data/lib/authorize_net/response.rb +23 -25
  12. data/lib/authorize_net/transaction.rb +64 -66
  13. data/lib/authorize_net/xml_response.rb +154 -154
  14. data/lib/authorize_net/xml_transaction.rb +279 -279
  15. data/lib/authorizenet.rb +4 -4
  16. metadata +3 -61
  17. data/lib/authorize_net/addresses/address.rb +0 -25
  18. data/lib/authorize_net/addresses/shipping_address.rb +0 -22
  19. data/lib/authorize_net/aim/response.rb +0 -120
  20. data/lib/authorize_net/aim/transaction.rb +0 -171
  21. data/lib/authorize_net/arb/fields.rb +0 -24
  22. data/lib/authorize_net/arb/paging.rb +0 -29
  23. data/lib/authorize_net/arb/response.rb +0 -26
  24. data/lib/authorize_net/arb/sorting.rb +0 -39
  25. data/lib/authorize_net/arb/subscription.rb +0 -68
  26. data/lib/authorize_net/arb/subscription_detail.rb +0 -10
  27. data/lib/authorize_net/arb/subscription_list_response.rb +0 -36
  28. data/lib/authorize_net/arb/transaction.rb +0 -171
  29. data/lib/authorize_net/cim/customer_profile.rb +0 -15
  30. data/lib/authorize_net/cim/payment_profile.rb +0 -35
  31. data/lib/authorize_net/cim/response.rb +0 -111
  32. data/lib/authorize_net/cim/transaction.rb +0 -721
  33. data/lib/authorize_net/customer.rb +0 -24
  34. data/lib/authorize_net/email_receipt.rb +0 -20
  35. data/lib/authorize_net/fields.rb +0 -760
  36. data/lib/authorize_net/key_value_response.rb +0 -109
  37. data/lib/authorize_net/key_value_transaction.rb +0 -281
  38. data/lib/authorize_net/line_item.rb +0 -21
  39. data/lib/authorize_net/order.rb +0 -38
  40. data/lib/authorize_net/payment_methods/credit_card.rb +0 -61
  41. data/lib/authorize_net/payment_methods/echeck.rb +0 -70
  42. data/lib/authorize_net/reporting/batch.rb +0 -16
  43. data/lib/authorize_net/reporting/batch_statistics.rb +0 -15
  44. data/lib/authorize_net/reporting/fds_filter.rb +0 -8
  45. data/lib/authorize_net/reporting/response.rb +0 -157
  46. data/lib/authorize_net/reporting/returned_item.rb +0 -45
  47. data/lib/authorize_net/reporting/transaction.rb +0 -131
  48. data/lib/authorize_net/reporting/transaction_details.rb +0 -22
  49. data/lib/authorize_net/sim/hosted_payment_form.rb +0 -34
  50. data/lib/authorize_net/sim/hosted_receipt_page.rb +0 -32
  51. data/lib/authorize_net/sim/response.rb +0 -133
  52. data/lib/authorize_net/sim/transaction.rb +0 -128
  53. data/lib/generators/authorize_net/direct_post/direct_post_generator.rb +0 -52
  54. data/lib/generators/authorize_net/direct_post/templates/README-AuthorizeNet +0 -49
  55. data/lib/generators/authorize_net/direct_post/templates/config.yml.erb +0 -8
  56. data/lib/generators/authorize_net/direct_post/templates/config.yml.rails3.erb +0 -8
  57. data/lib/generators/authorize_net/direct_post/templates/controller.rb.erb +0 -31
  58. data/lib/generators/authorize_net/direct_post/templates/initializer.rb +0 -4
  59. data/lib/generators/authorize_net/direct_post/templates/layout.erb +0 -18
  60. data/lib/generators/authorize_net/direct_post/templates/payment.erb +0 -10
  61. data/lib/generators/authorize_net/direct_post/templates/payment.rails3.erb +0 -10
  62. data/lib/generators/authorize_net/direct_post/templates/receipt.erb +0 -1
  63. data/lib/generators/authorize_net/direct_post/templates/relay_response.erb +0 -1
  64. data/lib/generators/authorize_net/sim/sim_generator.rb +0 -46
  65. data/lib/generators/authorize_net/sim/templates/README-AuthorizeNet +0 -52
  66. data/lib/generators/authorize_net/sim/templates/config.yml.erb +0 -8
  67. data/lib/generators/authorize_net/sim/templates/config.yml.rails3.erb +0 -8
  68. data/lib/generators/authorize_net/sim/templates/controller.rb.erb +0 -21
  69. data/lib/generators/authorize_net/sim/templates/initializer.rb +0 -4
  70. data/lib/generators/authorize_net/sim/templates/layout.erb +0 -18
  71. data/lib/generators/authorize_net/sim/templates/payment.erb +0 -6
  72. data/lib/generators/authorize_net/sim/templates/payment.rails3.erb +0 -6
  73. data/lib/generators/authorize_net/sim/templates/thank_you.erb +0 -1
  74. data/lib/generators/generator_extensions.rb +0 -73
@@ -1,154 +1,154 @@
1
- # :title: Authorize.Net Ruby SDK
2
- # The core AuthoizeNet module.
3
- # The entire SDK is name-spaced inside of this module.
4
- module AuthorizeNet
5
- # Some type conversion routines that will be injected into our
6
- # Transaction/Response classes.
7
- module TypeConversions
8
- API_FIELD_PREFIX = 'x_'.freeze
9
-
10
- # Converts a value received from Authorize.Net into a boolean if
11
- # possible. This is designed to handle the wide range of boolean
12
- # formats that Authorize.Net uses.
13
- def value_to_boolean(value)
14
- case value
15
- when "TRUE", "T", "YES", "Y", "1", "true"
16
- true
17
- when "FALSE", "F", "NO", "N", "0", "false"
18
- false
19
- else
20
- value
21
- end
22
- end
23
-
24
- # Converts a boolean into an Authorize.Net boolean value string.
25
- # This is designed to handle the wide range of boolean formats that
26
- # Authorize.Net uses. If bool isn't a Boolean, its converted to a
27
- # string and passed along.
28
- def boolean_to_value(bool)
29
- case bool
30
- when TrueClass, FalseClass
31
- bool ? 'TRUE' : 'FALSE'
32
- else
33
- bool.to_s
34
- end
35
- end
36
-
37
- # Converts a value received from Authorize.Net into a BigDecimal.
38
- def value_to_decimal(value)
39
- value = 0 if value == '' # Ruby 2.4+ does not accept ""
40
- BigDecimal(value)
41
- end
42
-
43
- # Converts a BigDecimal (or Float) into an Authorize.Net float value
44
- # string. If float isn't a BigDecimal (or Float), its converted to a
45
- # string and passed along.
46
- def decimal_to_value(float)
47
- case float
48
- when Float
49
- format("%0.2f", float)
50
- when BigDecimal
51
- float.truncate(2).to_s('F')
52
- else
53
- float.to_s
54
- end
55
- end
56
-
57
- # Converts a value received from Authorize.Net into a Date.
58
- def value_to_date(value)
59
- Date.strptime(value, '%Y-%m-%d')
60
- end
61
-
62
- # Converts a Date (or DateTime, or Time) into an Authorize.Net date
63
- # value string. If date isn't a Date (or DateTime, or Time), its
64
- # converted to a string and passed along.
65
- def date_to_value(date)
66
- case date
67
- when Date, DateTime, Time
68
- date.strftime('%Y-%m-%d')
69
- else
70
- date.to_s
71
- end
72
- end
73
-
74
- # Converts a value received from Authorize.Net into a DateTime.
75
- def value_to_datetime(value)
76
- DateTime.strptime(value, '%Y-%m-%dT%H:%M:%S')
77
- end
78
-
79
- # Converts a Date (or DateTime, or Time) into an Authorize.Net datetime
80
- # value string. If date isn't a Date (or DateTime, or Time), it's
81
- # converted to a string and passed along.
82
- def datetime_to_value(datetime)
83
- case datetime
84
- when Date, DateTime
85
- datetime.new_offset(0).strftime('%Y-%m-%dT%H:%M:%SZ')
86
- when Time
87
- datetime.utc.strftime('%Y-%m-%dT%H:%M:%SZ')
88
- else
89
- datetime.to_s
90
- end
91
- end
92
-
93
- # Converts a value received from Authorize.Net into an Integer.
94
- def value_to_integer(value)
95
- value.to_s.to_i
96
- end
97
-
98
- # Converts an Integer into an Authorize.Net integer string.
99
- def integer_to_value(int)
100
- int.to_s
101
- end
102
-
103
- # Converts a key value pair into a HTTP POST parameter. The key is
104
- # prefixed with key_prefix when being converted to a parameter name.
105
- def to_param(key, value, key_prefix = API_FIELD_PREFIX)
106
- key_str = "#{key_prefix}#{key}="
107
- if value.is_a?(Array)
108
- (value.collect do |v|
109
- key_str + CGI.escape(v.to_s)
110
- end).join('&')
111
- else
112
- key_str + CGI.escape(value.to_s)
113
- end
114
- end
115
-
116
- # Converts an internal field name (Symbol) into an external field
117
- # name (Symbol) that can be consumed by the Authorize.Net API.
118
- def to_external_field(key)
119
- (API_FIELD_PREFIX + key.to_s).to_sym
120
- end
121
-
122
- # Converts an external field name (Symbol) into an internal field
123
- # name (Symbol). This is the exact inverse of to_external_field.
124
- # Running to_internal_field(to_external_field(:foo)) would return
125
- # :foo back.
126
- def to_internal_field(key)
127
- k_str = key.to_s
128
- k_str[API_FIELD_PREFIX.length..k_str.length].to_sym
129
- end
130
- end
131
-
132
- # Provides some basic methods used by the various model classes.
133
- module Model
134
- # The constructor for models. Takes any of the supported attributes
135
- # as key/value pairs.
136
- def initialize(fields = {})
137
- fields.each do |k, v|
138
- method_name = (k.to_s + '=').to_sym
139
- send(method_name, v) if respond_to?(method_name)
140
- end
141
- end
142
-
143
- def to_a
144
- [self]
145
- end
146
-
147
- #:enddoc:
148
- protected
149
-
150
- def handle_multivalue_hashing(obj)
151
- obj.to_a.collect(&:to_hash)
152
- end
153
- end
154
- end
1
+ # :title: Authorize.Net Ruby SDK
2
+ # The core AuthoizeNet module.
3
+ # The entire SDK is name-spaced inside of this module.
4
+ module AuthorizeNet
5
+ # Some type conversion routines that will be injected into our
6
+ # Transaction/Response classes.
7
+ module TypeConversions
8
+ API_FIELD_PREFIX = 'x_'.freeze
9
+
10
+ # Converts a value received from Authorize.Net into a boolean if
11
+ # possible. This is designed to handle the wide range of boolean
12
+ # formats that Authorize.Net uses.
13
+ def value_to_boolean(value)
14
+ case value
15
+ when "TRUE", "T", "YES", "Y", "1", "true"
16
+ true
17
+ when "FALSE", "F", "NO", "N", "0", "false"
18
+ false
19
+ else
20
+ value
21
+ end
22
+ end
23
+
24
+ # Converts a boolean into an Authorize.Net boolean value string.
25
+ # This is designed to handle the wide range of boolean formats that
26
+ # Authorize.Net uses. If bool isn't a Boolean, its converted to a
27
+ # string and passed along.
28
+ def boolean_to_value(bool)
29
+ case bool
30
+ when TrueClass, FalseClass
31
+ bool ? 'TRUE' : 'FALSE'
32
+ else
33
+ bool.to_s
34
+ end
35
+ end
36
+
37
+ # Converts a value received from Authorize.Net into a BigDecimal.
38
+ def value_to_decimal(value)
39
+ value = 0 if value == '' # Ruby 2.4+ does not accept ""
40
+ BigDecimal(value)
41
+ end
42
+
43
+ # Converts a BigDecimal (or Float) into an Authorize.Net float value
44
+ # string. If float isn't a BigDecimal (or Float), its converted to a
45
+ # string and passed along.
46
+ def decimal_to_value(float)
47
+ case float
48
+ when Float
49
+ format("%0.2f", float)
50
+ when BigDecimal
51
+ float.truncate(2).to_s('F')
52
+ else
53
+ float.to_s
54
+ end
55
+ end
56
+
57
+ # Converts a value received from Authorize.Net into a Date.
58
+ def value_to_date(value)
59
+ Date.strptime(value, '%Y-%m-%d')
60
+ end
61
+
62
+ # Converts a Date (or DateTime, or Time) into an Authorize.Net date
63
+ # value string. If date isn't a Date (or DateTime, or Time), its
64
+ # converted to a string and passed along.
65
+ def date_to_value(date)
66
+ case date
67
+ when Date, DateTime, Time
68
+ date.strftime('%Y-%m-%d')
69
+ else
70
+ date.to_s
71
+ end
72
+ end
73
+
74
+ # Converts a value received from Authorize.Net into a DateTime.
75
+ def value_to_datetime(value)
76
+ DateTime.strptime(value, '%Y-%m-%dT%H:%M:%S')
77
+ end
78
+
79
+ # Converts a Date (or DateTime, or Time) into an Authorize.Net datetime
80
+ # value string. If date isn't a Date (or DateTime, or Time), it's
81
+ # converted to a string and passed along.
82
+ def datetime_to_value(datetime)
83
+ case datetime
84
+ when Date, DateTime
85
+ datetime.new_offset(0).strftime('%Y-%m-%dT%H:%M:%SZ')
86
+ when Time
87
+ datetime.utc.strftime('%Y-%m-%dT%H:%M:%SZ')
88
+ else
89
+ datetime.to_s
90
+ end
91
+ end
92
+
93
+ # Converts a value received from Authorize.Net into an Integer.
94
+ def value_to_integer(value)
95
+ value.to_s.to_i
96
+ end
97
+
98
+ # Converts an Integer into an Authorize.Net integer string.
99
+ def integer_to_value(int)
100
+ int.to_s
101
+ end
102
+
103
+ # Converts a key value pair into a HTTP POST parameter. The key is
104
+ # prefixed with key_prefix when being converted to a parameter name.
105
+ def to_param(key, value, key_prefix = API_FIELD_PREFIX)
106
+ key_str = "#{key_prefix}#{key}="
107
+ if value.is_a?(Array)
108
+ (value.collect do |v|
109
+ key_str + CGI.escape(v.to_s)
110
+ end).join('&')
111
+ else
112
+ key_str + CGI.escape(value.to_s)
113
+ end
114
+ end
115
+
116
+ # Converts an internal field name (Symbol) into an external field
117
+ # name (Symbol) that can be consumed by the Authorize.Net API.
118
+ def to_external_field(key)
119
+ (API_FIELD_PREFIX + key.to_s).to_sym
120
+ end
121
+
122
+ # Converts an external field name (Symbol) into an internal field
123
+ # name (Symbol). This is the exact inverse of to_external_field.
124
+ # Running to_internal_field(to_external_field(:foo)) would return
125
+ # :foo back.
126
+ def to_internal_field(key)
127
+ k_str = key.to_s
128
+ k_str[API_FIELD_PREFIX.length..k_str.length].to_sym
129
+ end
130
+ end
131
+
132
+ # Provides some basic methods used by the various model classes.
133
+ module Model
134
+ # The constructor for models. Takes any of the supported attributes
135
+ # as key/value pairs.
136
+ def initialize(fields = {})
137
+ fields.each do |k, v|
138
+ method_name = (k.to_s + '=').to_sym
139
+ send(method_name, v) if respond_to?(method_name)
140
+ end
141
+ end
142
+
143
+ def to_a
144
+ [self]
145
+ end
146
+
147
+ #:enddoc:
148
+ protected
149
+
150
+ def handle_multivalue_hashing(obj)
151
+ obj.to_a.collect(&:to_hash)
152
+ end
153
+ end
154
+ end
@@ -1,25 +1,23 @@
1
- module AuthorizeNet
2
- # The core, API agnostic response class. You shouldn't instantiate
3
- # this one. Instead you should use AuthorizeNet::AIM::Response,
4
- # AuthorizeNet::ARB::Response or AuthorizeNet::SIM::Response.
5
- class Response
6
- include AuthorizeNet::TypeConversions
7
-
8
- # Fields to convert to/from booleans.
9
- @@boolean_fields = []
10
-
11
- # Fields to convert to/from BigDecimal.
12
- @@decimal_fields = []
13
-
14
- # DO NOT USE. Instantiate AuthorizeNet::AIM::Response or
15
- # AuthorizeNet::SIM::Response instead.
16
- def initialize
17
- raise "#{self.class} should not be instantiated directly."
18
- end
19
-
20
- # Check to see if the response indicated success.
21
- def success?
22
- false
23
- end
24
- end
25
- end
1
+ module AuthorizeNet
2
+ # The core, API agnostic response class.
3
+ # You shouldn't instantiate this one.
4
+ class Response
5
+ include AuthorizeNet::TypeConversions
6
+
7
+ # Fields to convert to/from booleans.
8
+ @@boolean_fields = []
9
+
10
+ # Fields to convert to/from BigDecimal.
11
+ @@decimal_fields = []
12
+
13
+ # DO NOT USE.
14
+ def initialize
15
+ raise "#{self.class} should not be instantiated directly."
16
+ end
17
+
18
+ # Check to see if the response indicated success.
19
+ def success?
20
+ false
21
+ end
22
+ end
23
+ end
@@ -1,66 +1,64 @@
1
- module AuthorizeNet
2
- # The core, API agnostic transaction class. You shouldn't instantiate this one.
3
- # Instead you should use AuthorizeNet::AIM::Transaction,
4
- # AuthorizeNet::SIM::Transaction or AuthorizeNet::ARB::Transaction.
5
- class Transaction
6
- include AuthorizeNet::TypeConversions
7
-
8
- # Fields to convert to/from booleans.
9
- @@boolean_fields = []
10
-
11
- # Fields to convert to/from BigDecimal.
12
- @@decimal_fields = []
13
-
14
- # DO NOT USE. Instantiate AuthorizeNet::AIM::Transaction,
15
- # AuthorizeNet::SIM::Transaction or AuthorizeNet::ARB::Transaction instead.
16
- def initialize
17
- @fields ||= {}
18
- end
19
-
20
- # Sets arbitrary API fields, overwriting existing values if they exist.
21
- # Takes a hash of key/value pairs, where the keys are the field names
22
- # without the "x_" prefix. You can set a field to Nil to unset it. If the
23
- # value is an array, each value in the array will be added. For example,
24
- # set_fields({:line_item => ["item1<|>golf balls<|><|>2<|>18.95<|>Y",
25
- # "item2<|>golf bag<|>Wilson golf carry bag, red<|>1<|>39.99<|>"]})
26
- # would generate two x_line_item fields in the transaction, one for
27
- # each value in the array.
28
- def set_fields(fields = {})
29
- @fields.merge!(fields)
30
- @fields.reject! { |_k, v| v.nil? }
31
- @fields
32
- end
33
-
34
- # Returns the current hash of API fields.
35
- attr_reader :fields
36
-
37
- # Takes an instance of AuthorizeNet::Address and adds it to the transaction.
38
- def set_address(address)
39
- @fields.merge!(address.to_hash)
40
- end
41
-
42
- # Takes an instance of AuthorizeNet::ShippingAddress and adds it to the
43
- # transaction.
44
- def set_shipping_address(address)
45
- @fields.merge!(address.to_hash)
46
- end
47
-
48
- # Takes an instance of AuthorizeNet::Customer and adds it to the transaction.
49
- def set_customer(customer)
50
- @fields.merge!(customer.to_hash)
51
- end
52
-
53
- #:enddoc:
54
- protected
55
-
56
- # Internal method to handle multiple types of payment arguments.
57
- def handle_payment_argument(payment)
58
- case payment
59
- when AuthorizeNet::CreditCard, AuthorizeNet::ECheck
60
- set_fields(payment.to_hash)
61
- else
62
- set_fields(card_num: payment)
63
- end
64
- end
65
- end
66
- end
1
+ module AuthorizeNet
2
+ # The core, API agnostic transaction class.
3
+ # You shouldn't instantiate this one.
4
+ class Transaction
5
+ include AuthorizeNet::TypeConversions
6
+
7
+ # Fields to convert to/from booleans.
8
+ @@boolean_fields = []
9
+
10
+ # Fields to convert to/from BigDecimal.
11
+ @@decimal_fields = []
12
+
13
+ # DO NOT USE.
14
+ def initialize
15
+ @fields ||= {}
16
+ end
17
+
18
+ # Sets arbitrary API fields, overwriting existing values if they exist.
19
+ # Takes a hash of key/value pairs, where the keys are the field names
20
+ # without the "x_" prefix. You can set a field to Nil to unset it. If the
21
+ # value is an array, each value in the array will be added. For example,
22
+ # set_fields({:line_item => ["item1<|>golf balls<|><|>2<|>18.95<|>Y",
23
+ # "item2<|>golf bag<|>Wilson golf carry bag, red<|>1<|>39.99<|>"]})
24
+ # would generate two x_line_item fields in the transaction, one for
25
+ # each value in the array.
26
+ def set_fields(fields = {})
27
+ @fields.merge!(fields)
28
+ @fields.reject! { |_k, v| v.nil? }
29
+ @fields
30
+ end
31
+
32
+ # Returns the current hash of API fields.
33
+ attr_reader :fields
34
+
35
+ # Takes an instance of AuthorizeNet::Address and adds it to the transaction.
36
+ def set_address(address)
37
+ @fields.merge!(address.to_hash)
38
+ end
39
+
40
+ # Takes an instance of AuthorizeNet::ShippingAddress and adds it to the
41
+ # transaction.
42
+ def set_shipping_address(address)
43
+ @fields.merge!(address.to_hash)
44
+ end
45
+
46
+ # Takes an instance of AuthorizeNet::Customer and adds it to the transaction.
47
+ def set_customer(customer)
48
+ @fields.merge!(customer.to_hash)
49
+ end
50
+
51
+ #:enddoc:
52
+ protected
53
+
54
+ # Internal method to handle multiple types of payment arguments.
55
+ def handle_payment_argument(payment)
56
+ case payment
57
+ when AuthorizeNet::CreditCard, AuthorizeNet::ECheck
58
+ set_fields(payment.to_hash)
59
+ else
60
+ set_fields(card_num: payment)
61
+ end
62
+ end
63
+ end
64
+ end