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,24 +0,0 @@
1
- module AuthorizeNet::ARB
2
- module Fields
3
- EntityDescription = Struct.new(:node_structure, :entity_class, :arg_mapping)
4
-
5
- SUBSCRIPTION_DETAIL_ENTITY_DESCRIPTION = EntityDescription.new(
6
- [
7
- { id: :id },
8
- { name: :name },
9
- { status: :status },
10
- { createTimeStampUTC: :create_time_stamp_utc },
11
- { firstName: :first_name },
12
- { lastName: :last_name },
13
- { totalOccurrences: :total_occurrences },
14
- { pastOccurrences: :past_occurrences },
15
- { paymentMethod: :payment_method },
16
- { accountNumber: :account_number },
17
- { invoice: :invoice },
18
- { amount: :amount },
19
- { currencyId: :currency_id }
20
- ],
21
- AuthorizeNet::ARB::SubscriptionDetail
22
- )
23
- end
24
- end
@@ -1,29 +0,0 @@
1
- module AuthorizeNet::ARB
2
- class Paging
3
- # Models Paging
4
- include AuthorizeNet::Model
5
-
6
- attr_accessor :offset, :limit
7
-
8
- # Initializes Paging object.
9
- #
10
- # Typical usage:
11
- # paging = AuthorizeNet::ARB::Paging.new(1,1000)
12
- #
13
- # Valid values for offset: 1 to 100000
14
- # Valid values for limit: 1 to 1000
15
- #
16
- def initialize(offset, limit)
17
- @offset = offset
18
- @limit = limit
19
- end
20
-
21
- def to_hash
22
- hash = {
23
- offset: @offset,
24
- limit: @limit
25
- }
26
- hash.delete_if { |_k, v| v.nil? }
27
- end
28
- end
29
- end
@@ -1,26 +0,0 @@
1
- module AuthorizeNet::ARB
2
- # The ARB response class.
3
- class Response < AuthorizeNet::XmlResponse
4
- # Constructs a new response object from a +raw_response. You don't typically
5
- # construct this object yourself, as AuthorizeNet::ARB::Transaction will
6
- # build one for you when it makes the request to the gateway.
7
- def initialize(raw_response, transaction)
8
- super
9
- unless connection_failure?
10
- begin
11
- @subscription_id = node_content_unless_nil(@root.at_css('subscriptionId'))
12
- @subscription_status = node_content_unless_nil(@root.at_css('Status'))
13
- rescue StandardError
14
- @raw_response = $ERROR_INFO
15
- end
16
- end
17
- end
18
-
19
- # Returns the subscriptionId from the response if there is one. Otherwise returns nil.
20
- attr_reader :subscription_id
21
-
22
- # Returns the status of the Subscription from the response if there is one. Otherwise returns nil. This value
23
- # is only returned in response to a get_status transaction.
24
- attr_reader :subscription_status
25
- end
26
- end
@@ -1,39 +0,0 @@
1
- module AuthorizeNet::ARB
2
- class Sorting
3
- # Models Sorting
4
- include AuthorizeNet::Model
5
-
6
- attr_accessor :order_by, :order_descending
7
-
8
- # Initializes Sorting object.
9
- #
10
- # Typical usage:
11
- # sorting = AuthorizeNet::ARB::Sorting.new('name',true)
12
- #
13
- # Valid values for order_by values of the AuthorizeNet::ARB::Sorting:
14
- # id
15
- # name
16
- # status
17
- # createTimeStampUTC
18
- # lastName
19
- # firstName
20
- # accountNumber
21
- # amount
22
- # pastOccurrences
23
- #
24
- # Valid values for order_descending: true, false, 1, 0
25
- #
26
- def initialize(order_by, order_descending)
27
- @order_by = order_by
28
- @order_descending = order_descending
29
- end
30
-
31
- def to_hash
32
- hash = {
33
- order_by: @order_by,
34
- order_descending: @order_descending
35
- }
36
- hash.delete_if { |_k, v| v.nil? }
37
- end
38
- end
39
- end
@@ -1,68 +0,0 @@
1
- module AuthorizeNet::ARB
2
- # Models an ARB subscription.
3
- class Subscription
4
- # Use this constant for the value of total_occurrences to get a subscription with no end.
5
- UNLIMITED_OCCURRENCES = 9999
6
-
7
- # Constants for the various interval units supported by the ARB API.
8
- module IntervalUnits
9
- MONTH = 'months'.freeze
10
- DAY = 'days'.freeze
11
- end
12
-
13
- # Constants for the various statuses a subscription can have. These are returned by the get_status call.
14
- module Status
15
- ACTIVE = 'active'.freeze
16
- EXPIRED = 'expired'.freeze
17
- SUSPENDED = 'suspended'.freeze
18
- CANCELED = 'canceled'.freeze
19
- TERMINATED = 'terminated'.freeze
20
- end
21
-
22
- include AuthorizeNet::Model
23
-
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
25
-
26
- # Override the total_occurrences setter to provide support for :unlimited shortcut.
27
- def total_occurrences=(new_total_occurrences) #:nodoc:
28
- if new_total_occurrences == :unlimited
29
- @total_occurrences = UNLIMITED_OCCURRENCES
30
- else
31
- @total_occurrences = new_total_occurrences
32
- end
33
- end
34
-
35
- # Override the unit setter to provide support for :day, :days, :month, :months shortcut. Do not document this method in rdoc.
36
- def unit=(new_unit) #:nodoc:
37
- case new_unit
38
- when :day, :days
39
- @unit = IntervalUnits::DAY
40
- when :month, :months
41
- @unit = IntervalUnits::MONTH
42
- else
43
- @unit = new_unit
44
- end
45
- end
46
-
47
- def to_hash
48
- hash = {
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
60
- }
61
- hash.merge!(@credit_card.to_hash) unless @credit_card.nil?
62
- hash.merge!(@billing_address.to_hash) unless @billing_address.nil?
63
- hash.merge!(@shipping_address.to_hash) unless @shipping_address.nil?
64
- hash.merge!(@customer.to_hash) unless @customer.nil?
65
- hash.delete_if { |_k, v| v.nil? }
66
- end
67
- end
68
- end
@@ -1,10 +0,0 @@
1
- module AuthorizeNet::ARB
2
- # Models Subscription Detail.
3
- class SubscriptionDetail
4
- include AuthorizeNet::Model
5
-
6
- attr_accessor :id, :name, :status, :create_time_stamp_utc, :first_name,
7
- :last_name, :total_occurrences, :past_occurrences,
8
- :payment_method, :account_number, :invoice, :amount, :currency_id
9
- end
10
- end
@@ -1,36 +0,0 @@
1
- module AuthorizeNet::ARB
2
- class SubscriptionListResponse < AuthorizeNet::XmlResponse
3
- # Constructs a new response object from a +raw_response. You don't typically
4
- # construct this object yourself, as AuthorizeNet::ARB::Transaction will
5
- # build one for you when it makes the request to the gateway.
6
- def initialize(raw_response, transaction)
7
- super
8
- unless connection_failure?
9
- begin
10
- @subscription_details = @root.at_css('subscriptionDetails')
11
- @subscription_detail = @root.at_css('subscriptionDetail')
12
- @total_num_in_resultset = node_content_unless_nil(@root.at_css('totalNumInResultSet'))
13
- rescue StandardError
14
- @raw_response = $ERROR_INFO
15
- end
16
- end
17
- end
18
-
19
- # Returns total number of subscriptions matching the search criteria
20
- attr_reader :total_num_in_resultset
21
-
22
- # Returns an Array of SubscriptionDetail objects built from the entities returned in the response. Returns nil if no subscriptions were returned.
23
- def subscription_details
24
- unless @subscription_details.nil?
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?
33
- end
34
- end
35
- end
36
- end
@@ -1,171 +0,0 @@
1
- module AuthorizeNet::ARB
2
- # The ARB transaction class.
3
- class Transaction < AuthorizeNet::XmlTransaction
4
- include AuthorizeNet::ARB::Fields
5
-
6
- # The default options for the constructor.
7
- @@option_defaults = {
8
- gateway: :production,
9
- verify_ssl: true,
10
- reference_id: nil
11
- }
12
-
13
- # Fields to convert to/from booleans.
14
- @@boolean_fields = []
15
-
16
- # Fields to convert to/from BigDecimal.
17
- @@decimal_fields = %i[amount trial_amount]
18
-
19
- # Fields to convert to/from Date.
20
- @@date_fields = [:subscription_start_date]
21
-
22
- # The class to wrap our response in.
23
- @response_class = AuthorizeNet::ARB::Response
24
-
25
- # Constructs an ARB transaction. You can use the new ARB transaction object
26
- # to issue a request to the payment gateway and parse the response into a new
27
- # AuthorizeNet::ARB::Response object.
28
- #
29
- # +api_login_id+:: Your API login ID, as a string.
30
- # +api_transaction_key+:: Your API transaction key, as a string.
31
- # +options+:: A hash of options. See below for values.
32
- #
33
- # Options
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).
35
- # +verify_ssl+:: A boolean indicating if the SSL certificate of the +gateway+ should be verified. Defaults to true.
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.
37
- #
38
- def initialize(api_login_id, api_transaction_key, options = {})
39
- ActiveSupport::Deprecation.warn "use AuthorizeNet::API::Transaction"
40
- super
41
- end
42
-
43
- # Sets up and submits a start of subscription (ARBCreateSubscriptionRequest) transaction. Returns a response object. If the transaction
44
- # has already been run, it will return nil.
45
- #
46
- # +subscription+:: An instance of AuthorizeNet::ARB::Subscription describing the recurring payment you would like to create.
47
- #
48
- #
49
- # Typical usage:
50
- #
51
- # subscription = AuthorizeNet::ARB::Subscription.new(
52
- # :name => "Monthly Gift Basket",
53
- # :length => 1,
54
- # :unit => :month,
55
- # :start_date => Date.today,
56
- # :total_occurrences => :unlimited,
57
- # :amount => 100.00,
58
- # :invoice_number => '1234567',
59
- # :description => "John Doe's Monthly Gift Basket",
60
- # :credit_card => AuthorizeNet::CreditCard.new('4111111111111111', '1120'),
61
- # :billing_address => AuthorizeNet::Address.new(:first_name => 'John', :last_name => 'Doe')
62
- # )
63
- # response = transaction.create(subscription)
64
- #
65
- def create(subscription)
66
- @type = Type::ARB_CREATE
67
- set_fields(subscription.to_hash)
68
- run
69
- end
70
-
71
- # Sets up and submits a subscription update (ARBUpdateSubscriptionRequest) transaction. Returns a response object. If the transaction
72
- # has already been run, it will return nil.
73
- #
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.
75
- #
76
- #
77
- # Typical usage:
78
- #
79
- # subscription = AuthorizeNet::ARB::Subscription.new(
80
- # :billing_address => AuthorizeNet::Address.new(:first_name => 'Jane', :last_name => 'Doe'),
81
- # :subscription_id => '123456'
82
- # )
83
- # response = transaction.update(subscription)
84
- #
85
- def update(subscription)
86
- @type = Type::ARB_UPDATE
87
- set_fields(subscription.to_hash)
88
- run
89
- end
90
-
91
- # Sets up and submits a subscription status query (ARBGetSubscriptionStatusRequest) transaction. Returns a response object (which contains the subscription status). If the transaction
92
- # has already been run, it will return nil.
93
- #
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.
95
- #
96
- #
97
- # Typical usage:
98
- #
99
- # response = transaction.get_status('123456')
100
- # response.subscription_status # A value from AuthorizeNet::ARB::Subscription::Status
101
- #
102
- def get_status(subscription_id)
103
- @type = Type::ARB_GET_STATUS
104
- handle_subscription_id(subscription_id)
105
- run
106
- end
107
-
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
110
- # criteria. Sorting and Paging are optional parameters.
111
- #
112
- # Valid values for search type parameter:
113
- # cardExpiringThisMonth
114
- # subscriptionActive
115
- # subscriptionExpiringThisMonth
116
- # subscriptionInactive
117
- #
118
- # Typical usage:
119
- #
120
- # sorting = AuthorizeNet::ARB::Sorting.new('name',true)
121
- # paging = AuthorizeNet::ARB::Paging.new(1,1000)
122
- # response = transaction.get_subscription_list('subscriptionActive',sorting,paging)
123
- #
124
- def get_subscription_list(search_type, sorting = nil, paging = nil)
125
- unless search_type.nil?
126
- self.class.instance_variable_set(:@response_class, SubscriptionListResponse)
127
- @type = Type::ARB_GET_SUBSCRIPTION_LIST
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
132
- end
133
- response
134
- end
135
-
136
- # Sets up and submits a subscription cancelation (ARBCancelSubscriptionRequest) transaction. Returns a response object. If the transaction
137
- # has already been run, it will return nil.
138
- #
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.
140
- #
141
- #
142
- # Typical usage:
143
- #
144
- # response = transaction.cancel('123456')
145
- #
146
- def cancel(subscription_id)
147
- @type = Type::ARB_CANCEL
148
- handle_subscription_id(subscription_id)
149
- run
150
- end
151
-
152
- #:enddoc:
153
- protected
154
-
155
- # Internal method to handle multiple types of subscription id arguments.
156
- def handle_subscription_id(subscription_id)
157
- case subscription_id
158
- when Subscription
159
- set_fields(subscription_id: subscription_id.subscription_id.to_s)
160
- else
161
- set_fields(subscription_id: subscription_id.to_s)
162
- end
163
- end
164
-
165
- # An internal method that builds the POST body, submits it to the gateway, and constructs a Response object with the response.
166
- def make_request
167
- set_fields(reference_id: @reference_id)
168
- super
169
- end
170
- end
171
- end
@@ -1,15 +0,0 @@
1
- module AuthorizeNet::CIM
2
- # Models a customer profile.
3
- class CustomerProfile < AuthorizeNet::Customer
4
- include AuthorizeNet::Model
5
-
6
- attr_accessor :customer_profile_id, :payment_profiles
7
-
8
- def to_hash
9
- hash = super
10
- hash.delete_if { |_k, v| v.nil? }
11
- hash[:payment_profiles] = handle_multivalue_hashing(@payment_profiles)
12
- hash
13
- end
14
- end
15
- end
@@ -1,35 +0,0 @@
1
- module AuthorizeNet::CIM
2
- # Models a payment profile.
3
- class PaymentProfile
4
- module CustomerType
5
- INDIVIDUAL = 'individual'.freeze
6
- BUSINESS = 'business'.freeze
7
- end
8
-
9
- include AuthorizeNet::Model
10
-
11
- attr_accessor :cust_type, :billing_address, :payment_method, :customer_payment_profile_id
12
-
13
- def cust_type=(type) #:nodoc:
14
- case type
15
- when :business
16
- @cust_type = CustomerType::BUSINESS
17
- when :individual
18
- @cust_type = CustomerType::INDIVIDUAL
19
- else
20
- @cust_type = type
21
- end
22
- end
23
-
24
- def to_hash
25
- hash = {
26
- cust_type: @cust_type,
27
- customer_payment_profile_id: @customer_payment_profile_id
28
- }
29
- hash.delete_if { |_k, v| v.nil? }
30
- hash.merge!(@billing_address.to_hash) unless @billing_address.nil?
31
- hash.merge!(@payment_method.to_hash) unless @payment_method.nil?
32
- hash
33
- end
34
- end
35
- end