authorize_net_reporting 0.0.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,52 +1,153 @@
1
- # WORK IN PROGRESS!!!!
2
- # AuhtorizeNetReporting
3
-
4
- AuthorizeNetReporting allows you to retrieve Authorize.net transaction details through the [Transaction Details API](http://developer.authorize.net/api/transaction_details/)
5
-
6
- # Sample Usage
7
- **Go to [Authorize.net](http://authorize.net) to obtain your key/login**
8
-
9
- ````ruby
10
- require 'rubygems'
11
-
12
- require 'authorize_net_reporting'
13
-
14
- report = AuthorizeNetReporting::Report.new({ :mode => ['test'|'live'], :key => 'your_api_key', :login => 'your_api_login' })
15
- ````
16
-
17
- **All settled batched with a date range**
18
-
19
-
20
- ````ruby
21
- #It will default to the last 12 hours if no date range is provided
22
- report.settled_batch_list({ :first_settlement_date => "2011/04/20", :last_settlement_date => "2011/05/20", :include_statistics => true })
23
- ````
24
-
25
- **Statistics for a specific batch**
26
-
27
- ````ruby
28
- report.batch_statistics(1049686)
29
- ````
30
-
31
- **Data for all transactions in a specified batch**
32
-
33
- ````ruby
34
- report.transaction_list(1049686)
35
- ````
36
-
37
- **Unsettled Transactions**
38
-
39
- ````ruby
40
- report.unsettled_transaction_list
41
- ````
42
-
43
- **Detailed information about one specific transaction**
44
-
45
- ````ruby
46
- report.transaction_details(2157585857)
47
- ````
48
-
49
- # LICENSE:
1
+ # Authorize.Net Transaction Details API
2
+
3
+ In order to use the Transaction Details API you must have enabled Transaction Details API in the Merchant Interface account settings where you will find
4
+ your developer and production credentials.
5
+
6
+ For more information about the API visit [Authorize.net Reporting API](http://developer.authorize.net/api/transaction_details/).
7
+
8
+ Note: You will be able to view test transactions at [https://sandbox.authorize.net](https://sandbox.authorize.net/).
9
+
10
+ # Installation
11
+ # Gemfile
12
+
13
+ gem 'authorize_net_reporting'
14
+
15
+
16
+ # Documentation
17
+ [Click here to view the Documentation](http://rubydoc.info/github/jazminschroeder/authorize_net_reporting/master/frames/)
18
+
19
+ # Usage example
20
+
21
+ Build a new AuthorizeNetReporting::Report object for test or production mode by passing your credentials as follows:
22
+
23
+ ~$ require 'rubygems'
24
+ ~$ require 'authorize_net_reporting'
25
+ ~$ report = AuthorizeNetReporting::Report.new({ :mode => 'test', :key => 'your_developer_api_key', :login => 'your_developer_api_login' })
26
+ => #<AuthorizeNetReporting::Report:0x007fd94b2dd7b0 @mode="test", @key="XXXXXXX", @login="XXXXX">
27
+
28
+ # In Production Mode
29
+ ~$ report = AuthorizeNetReporting::Report.new({ :mode => 'production', :key => 'your_production_api_key', :login => 'your_production_api_login' })
30
+ => #<AuthorizeNetReporting::Report:0x007fd94b2dd7b0 @mode="production", @key="XXXXXXX", @login="XXXXX">
31
+
32
+ **Retrieve Settled Batches within a date range**
33
+
34
+ *Note: If no dates are specified, then the default is the last 24 hours.*
35
+
36
+ ~$ batches = report.settled_batch_list({ :first_settlement_date => "2011/04/20", :last_settlement_date => "2011/05/20"})
37
+
38
+ # Result
39
+ [
40
+ [0] #<AuthorizeNetReporting::Batch:0x007fc099a08488 @batch_id="1033266", @settlement_time_utc="2011-04-21T05:17:52Z", @settlement_time_local="2011-04-21T00:17:52", @settlement_state="settledSuccessfully", @payment_method="creditCard">,
41
+ [1] #<AuthorizeNetReporting::Batch:0x007fc099a07010 @batch_id="1039515", @settlement_time_utc="2011-04-26T05:17:34Z", @settlement_time_local="2011-04-26T00:17:34", @settlement_state="settledSuccessfully", @payment_method="creditCard">,
42
+ [2] #<AuthorizeNetReporting::Batch:0x007fc099a061d8 @batch_id="1049686", @settlement_time_utc="2011-05-03T05:13:09Z", @settlement_time_local="2011-05-03T00:13:09", @settlement_state="settledSuccessfully", @payment_method="creditCard">,
43
+ [3] #<AuthorizeNetReporting::Batch:0x007fc099a05210 @batch_id="1075905", @settlement_time_utc="2011-05-20T05:13:57Z", @settlement_time_local="2011-05-20T00:13:57", @settlement_state="settledSuccessfully", @payment_method="creditCard">
44
+ ]
45
+
46
+
47
+ **Include statistics for each batch**
48
+
49
+ If you pass *:include_statistics => true* to the settled_batch_list resquest you will also receive batch statistics by payment type.
50
+
51
+ ~$ batches = report.settled_batch_list({ :first_settlement_date => "2011/04/20", :last_settlement_date => "2011/05/20", :include_statistics => true})
52
+
53
+ #Result
54
+ ~ $ batches.first
55
+ => #<AuthorizeNetReporting::Batch:0x007fd94b271f38
56
+ @batch_id="1033266",
57
+ @settlement_time_utc="2011-04-21T05:17:52Z",
58
+ @settlement_time_local="2011-04-21T00:17:52",
59
+ @settlement_state="settledSuccessfully",
60
+ @payment_method="creditCard",
61
+ @statistics=[ { :account_type=>"Visa",
62
+ :charge_amount=>"14526.00",
63
+ :charge_count=>"1",
64
+ :refund_amount=>"0.00",
65
+ :refund_count=>"0",
66
+ :void_count=>"0",
67
+ :decline_count=>"0",
68
+ :error_count=>"0" } ]>
69
+
70
+
71
+
72
+ **Retrieve information for a specified Batch ID**
73
+
74
+ ~$ batch = report.batch_statistics(1049686)
75
+
76
+ => #<AuthorizeNetReporting::Batch:0x007fdb83966048 @batch_id="1049686",
77
+ @settlement_time_utc="2011-05-03T05:13:09Z",
78
+ @settlement_time_local="2011-05-03T00:13:09",
79
+ @settlement_state="settledSuccessfully",
80
+ @payment_method="creditCard",
81
+ @statistics=[ { :account_type=>"AmericanExpress",
82
+ :charge_amount=>"1.00",
83
+ :charge_count=>"1",
84
+ :refund_amount=>"0.00",
85
+ :refund_count=>"0",
86
+ :void_count=>"0",
87
+ :decline_count=>"0",
88
+ :error_count=>"0" },
89
+ { :account_type=>"Visa",
90
+ :charge_amount=>"899.52",
91
+ :charge_count=>"3",
92
+ :refund_amount=>"0.00",
93
+ :refund_count=>"0",
94
+ :void_count=>"0",
95
+ :decline_count=>"0",
96
+ :error_count=>"0" } ] >
97
+
98
+ **Retrieve Transaction details for a specified Batch ID**
99
+
100
+ ~$ report.transaction_list(1049686)
101
+
102
+ # Result
103
+
104
+ [
105
+ [1] #<AuthorizeNetReporting::AuthorizeNetTransaction:0x007fc3c392f8e0 @trans_id="2159639081", @submit_time_utc="2011-05-02T18:11:50Z", @submit_time_local="2011-05-02T13:11:50", @transaction_status="settledSuccessfully", @first_name="Max", @last_name="Schroeder", @account_type="Visa", @account_number="XXXX8888", @settle_amount="299.84">,
106
+ [2] #<AuthorizeNetReporting::AuthorizeNetTransaction:0x007fc3c392bf10 @trans_id="2159639020", @submit_time_utc="2011-05-02T18:08:10Z", @submit_time_local="2011-05-02T13:08:10", @transaction_status="settledSuccessfully", @first_name="American", @last_name="Express", @account_type="AmericanExpress", @account_number="XXXX0002", @settle_amount="1.00">
107
+ ]
108
+
109
+ **Retrieve Transaction Details for Unsettled Transactions**
110
+
111
+ Retrieve up to 1000 of the most recent transactions
112
+
113
+ ~$ report.unsettled_transaction_list
114
+
115
+ => [#<AuthorizeNetReporting::AuthorizeNetTransaction:0x007fc3c38b9960 @trans_id="2157217187", @submit_time_utc="2011-01-28T16:30:57Z", @submit_time_local="2011-01-28T10:30:57", @transaction_status="authorizedPendingCapture", @account_type="Visa", @account_number="XXXX0027", @settle_amount="25.45">]
116
+
117
+
118
+ **Retrieve Detailed information about one specific transaction**
119
+
120
+ ~$ report.transaction_details(2157585857)
121
+
122
+ => #<AuthorizeNetReporting::AuthorizeNetTransaction:0x007fc3c2883668
123
+ @trans_id="2157585857",
124
+ @submit_time_utc="2011-02-16T21:51:10.953Z",
125
+ @submit_time_local="2011-02-16T15:51:10.953",
126
+ @transaction_status="settledSuccessfully",
127
+ @settle_amount="50.23",
128
+ @transaction_type="authCaptureTransaction",
129
+ @response_code="1",
130
+ @response_reason_code="1",
131
+ @response_reason_description="Approval",
132
+ @auth_code="S1ZRPA",
133
+ @avs_response="Y",
134
+ @auth_amount="50.23",
135
+ @tax_exempt="false",
136
+ @recurring_billing="false">
137
+
138
+ **Debug**
139
+
140
+ To view the response from the API directly set debug to true
141
+
142
+ ~$ report.debug = true
143
+ ~$ report.transaction_details(2157585857)
144
+
145
+
146
+ #Notes:
147
+
148
+ Tested with Ruby 1.8.7 and 1.9.2
149
+
150
+ # Copyright/License:
50
151
 
51
152
  (The MIT License)
52
153
 
@@ -54,21 +155,4 @@ Copyright (c) 2011:
54
155
 
55
156
  [Jazmin Schroeder](http://jazminschroeder.com)
56
157
 
57
- Permission is hereby granted, free of charge, to any person obtaining
58
- a copy of this software and associated documentation files (the
59
- 'Software'), to deal in the Software without restriction, including
60
- without limitation the rights to use, copy, modify, merge, publish,
61
- distribute, sub license, and/or sell copies of the Software, and to
62
- permit persons to whom the Software is furnished to do so, subject to
63
- the following conditions:
64
-
65
- The above copyright notice and this permission notice shall be
66
- included in all copies or substantial portions of the Software.
67
-
68
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
69
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
70
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
71
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
72
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
73
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
74
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
158
+
@@ -10,12 +10,12 @@ Gem::Specification.new do |s|
10
10
  s.email = ["jazminschroeder@gmail.com"]
11
11
  s.homepage = ""
12
12
  s.summary = %q{Authorize.net Transaction Details API }
13
- s.description = %q{Retrieve transaction details through the Authorize.net Transaction Details API }
13
+ s.description = %q{Ruby Library to interact with the Authorize.net Transaction Details API }
14
14
 
15
15
  s.rubyforge_project = "authorize_net_reporting"
16
- s.add_dependency 'httparty'
17
- s.add_dependency 'builder'
18
- s.add_development_dependency "rspec"
16
+ s.add_dependency 'httparty', '>= 0.6.1'
17
+ s.add_dependency 'builder', '>= 2.1.2'
18
+ s.add_development_dependency "rspec", '~> 2.0'
19
19
 
20
20
  s.files = `git ls-files`.split("\n")
21
21
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -1,6 +1,5 @@
1
1
  # @author: Jazmin Schroeder
2
2
  # July/20011
3
- require 'authorize_net_reporting/common'
4
3
  require 'authorize_net_reporting/gateway'
5
4
  require 'authorize_net_reporting/report'
6
5
  require 'authorize_net_reporting/response'
@@ -1,10 +1,12 @@
1
1
  # AuthorizeNetReporting::Report
2
2
  module AuthorizeNetReporting
3
+ #Handeling Errors
4
+ class Error < StandardError; end
3
5
  # Initialize AuthorizeNetReporting::Report class
4
6
  #
5
7
  # report = AuthorizeNetReporting::Report.new({ :mode => ['test'|'live'], :key => 'your api key', :login => 'your api_login' })
6
8
  class Report < Gateway
7
- include Common
9
+ attr_accessor :debug
8
10
  # Set API login, password and mode(live/test)
9
11
  #
10
12
  # AuthorizeNetReporting::Report.new({ :mode => ['test'|'live'], :key => 'your api key', :login => 'your api_login' })
@@ -62,8 +64,14 @@ module AuthorizeNetReporting
62
64
  # @param [Hash] options, options to be passed to API request, '{:batch_id => 12345}'
63
65
  def process_request(api_function, options = {})
64
66
  xml = build_request(api_function, options)
65
- response = send_xml(xml)
66
- handle_response(api_function,response)
67
+ api_response = send_xml(xml)
68
+ puts api_response if @debug
69
+ response = parse_response(api_response)
70
+ if success?(response["get_#{api_function.to_s}_response".to_sym])
71
+ AuthorizeNetReporting::Response.send("parse_#{api_function}", response)
72
+ else
73
+ raise AuthorizeNetReporting::Error, error_message(response["get_#{api_function.to_s}_response".to_sym])
74
+ end
67
75
  end
68
76
 
69
77
  # Validates that required parameters are present
@@ -71,7 +79,7 @@ module AuthorizeNetReporting
71
79
  # @param [Symbol] params required :mode, :key
72
80
  def requires!(hash, *params)
73
81
  params.each do |param|
74
- raise ArgumentError, "Missing Required Parameter #{param}" unless hash.has_key?(param)
82
+ raise AuthorizeNetReporting::Error, "Missing Required Parameter #{param}" unless hash.has_key?(param)
75
83
  end
76
84
  end
77
85
 
@@ -87,14 +95,14 @@ module AuthorizeNetReporting
87
95
  xml.tag!('name', @login)
88
96
  xml.tag!('transactionKey', @key)
89
97
  end
90
- send("build_#{underscore(api_request)}", xml, options)
98
+ send("build_#{underscorize(api_request)}", xml, options)
91
99
  end
92
100
  end
93
101
 
94
102
  def build_get_settled_batch_list_request(xml, options) #:nodoc:
95
103
  xml.tag!("includeStatistics", true) if options[:include_statistics]
96
104
  if options[:first_settlement_date] and options[:last_settlement_date]
97
- xml.tag!("firstSettlementDate", Date.parse(options[:first_settlement_date]).strftime("%Y-%m-%dT00:00:00Z"))
105
+ xml.tag!("firstSettlementDate", Date.parse(options[:first_settlement_date]).strftime("%Y-%m-%dT00:00:00Z"))
98
106
  xml.tag!("lastSettlementDate", Date.parse(options[:last_settlement_date]).strftime("%Y-%m-%dT00:00:00Z"))
99
107
  end
100
108
  xml.target!
@@ -119,27 +127,41 @@ module AuthorizeNetReporting
119
127
  xml.target!
120
128
  end
121
129
 
122
- # Call to Response.parse to handle response if transaction is successful, otherwise raise StandardError
123
- def handle_response(api_function, response)
124
- response_message = get_response_message(api_function, response)
125
- if response_message =~ /successful/
126
- eval("AuthorizeNetReporting::Response.parse_#{api_function}(#{response.parsed_response})")
127
- elsif response_message =~ /found/
128
- ["transaction_details", "batch_statistics"].include?(api_function.to_s) ? nil : []
130
+ # Extract response message from response for specified api_function
131
+ def success?(api_response_message)
132
+ !api_response_message.nil? and (!api_response_message[:messages][:result_code].match(/ok/i).nil? or api_response_message[:messages][:message][:text].match(/cannot be found/i))
133
+ end
134
+
135
+ # @returns error message from API if request is not successful
136
+ def error_message(api_response_message)
137
+ api_response_message[:messages][:message][:text] rescue "Unable to process request. Try with debug = true"
138
+ end
139
+
140
+ # Parse response, convert keys to underscore symbols
141
+ def parse_response(response)
142
+ response = sanitize_response_keys(response.parsed_response)
143
+ end
144
+
145
+ # Recursively sanitizes the response object by clenaing up any hash keys.
146
+ def sanitize_response_keys(response)
147
+ if response.is_a?(Hash)
148
+ response.inject({}) { |result, (key, value)| result[underscorize(key).to_sym] = sanitize_response_keys(value); result }
149
+ elsif response.is_a?(Array)
150
+ response.collect { |result| sanitize_response_keys(result) }
129
151
  else
130
- raise StandardError, response_message
152
+ response
131
153
  end
132
154
  end
133
-
134
- # Extract response message from response for specified api_function
135
- def get_response_message(api_function, response)
136
- api_response = "get#{camelize(api_function.to_s)}Response"
137
- if response.parsed_response[api_response]
138
- message = response.parsed_response[api_response]["messages"]["message"]["text"]
139
- else
140
- message = response.parsed_response["ErrorResponse"]["messages"]["message"]["text"] rescue "Unable to execute transaction"
141
- end
142
- message.downcase
155
+
156
+ #helper method
157
+ def underscorize(key) #:nodoc:
158
+ key.to_s.sub(/^(v[0-9]+|ns):/, "").gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').gsub(/([a-z\d])([A-Z])/,'\1_\2').downcase
159
+ end
160
+
161
+ #helper method
162
+ def camelize(str)
163
+ str.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
143
164
  end
165
+
144
166
  end
145
167
  end
@@ -2,99 +2,92 @@ module AuthorizeNetReporting
2
2
  # AuthorizeNetReporting::Response parses the response from Authorize.net API and turns results into objects setting attributes for easy integration
3
3
 
4
4
  class Response
5
- extend Common
6
5
  # Parse response for settled_batch_list
7
6
  def self.parse_settled_batch_list(response)
8
- batch_list = response["getSettledBatchListResponse"]["batchList"]["batch"]
9
7
  batches = []
10
- batch_list.each do |batch|
11
- statistics = extract_batch_statistics(batch)
12
- params = to_single_hash(batch)
13
- params.merge!("statistics" => statistics) unless statistics.blank?
14
- batches << create_class("Batch", params)
8
+ unless response[:get_settled_batch_list_response][:batch_list].nil?
9
+ batch_list = [response[:get_settled_batch_list_response][:batch_list][:batch]].flatten
10
+ batch_list.each do |batch|
11
+ batch.merge!(:statistics => [batch[:statistics][:statistic]].flatten) unless batch[:statistics].nil?
12
+ batches << create_class("Batch", batch)
13
+ end
15
14
  end
16
15
  batches
17
16
  end
18
17
 
19
18
  # Parse response for batch_statistics
20
19
  def self.parse_batch_statistics(response)
21
- batch = response["getBatchStatisticsResponse"]["batch"]
22
- statistics = extract_batch_statistics(batch)
23
- params = to_single_hash(batch)
24
- params.merge!("statistics" => statistics) unless statistics.blank?
25
- create_class("Batch", params)
20
+ return nil if response[:get_batch_statistics_response][:batch].nil?
21
+ batch = response[:get_batch_statistics_response][:batch]
22
+ batch.merge!(:statistics => [batch[:statistics][:statistic]].flatten) unless batch[:statistics].nil?
23
+ create_class("Batch", batch)
26
24
  end
27
25
 
28
26
  # Parse response for transaction_list
29
27
  def self.parse_transaction_list(response)
30
- transactions = [response["getTransactionListResponse"]["transactions"]["transaction"]].flatten
31
- transaction_list = []
32
- transactions.each do |transaction|
33
- transaction_list << create_class("AuthorizeNetTransaction", to_single_hash(transaction))
28
+ transactions = []
29
+ unless response[:get_transaction_list_response][:transactions].nil?
30
+ transaction_list = [response[:get_transaction_list_response][:transactions][:transaction]].flatten
31
+ transaction_list.each do |transaction|
32
+ transactions << create_class("AuthorizeNetTransaction", transaction)
33
+ end
34
34
  end
35
- transaction_list
35
+ transactions
36
36
  end
37
37
 
38
38
 
39
39
  # Parse response unsettled_transaction
40
40
  def self.parse_unsettled_transaction_list(response)
41
- unsettled_transactions = [response["getUnsettledTransactionListResponse"]["transactions"]["transaction"]]
42
41
  transactions = []
43
- unsettled_transactions.each do |transaction|
44
- transactions << create_class("AuthorizeNetTransaction", to_single_hash(transaction))
45
- end
46
- transactions
42
+ unless response[:get_unsettled_transaction_list_response][:transactions].nil?
43
+ unsettled_transactions = [response[:get_unsettled_transaction_list_response][:transactions][:transaction]].flatten
44
+ unsettled_transactions.each do |transaction|
45
+ transactions << create_class("AuthorizeNetTransaction", transaction)
46
+ end
47
+ end
48
+ transactions
47
49
  end
48
50
 
49
51
 
50
52
  # Parse response transaction_details
51
53
  def self.parse_transaction_details(response)
52
- params = response["getTransactionDetailsResponse"]["transaction"]
53
- create_class("AuthorizeNetTransaction", to_single_hash(params))
54
+ return nil if response[:get_transaction_details_response][:transaction].nil?
55
+ transaction = response[:get_transaction_details_response][:transaction]
56
+ create_class("AuthorizeNetTransaction", transaction)
54
57
  end
55
58
 
56
- # Handle batch statistics
57
- def self.extract_batch_statistics(batch)
58
- statistics = []
59
- if batch["statistics"]
60
- batch_statistics = [batch["statistics"]["statistic"]].flatten
61
- batch_statistics.each do |statistic|
62
- statistic = statistic.inject({}) {|h, (key,value)| h[underscore(key)] = value; h}
63
- statistics << statistic
64
- end
65
- end
66
- statistics
67
- end
68
-
69
59
  # Convert response nested hash into a single hash
70
60
  # param[Hash] hash
71
- def self.to_single_hash(hash)
61
+ def self.to_single_hash(hash, first_iteration = true)
62
+ temp_hash = {} if first_iteration == true
72
63
  hash.each do |key, value|
73
64
  case value
74
65
  when Hash then to_single_hash(value)
75
- when String, Integer then (@temp_hash||={})[underscore(key)] = value
66
+ when String, Integer, Array then temp_hash[key] = value
76
67
  end
77
68
  end
78
- @temp_hash
69
+ temp_hash
79
70
  end
80
71
 
81
- #Create objects dinamicaly
72
+ #Create objects dinamically
82
73
  def self.create_class(class_name, params)
83
- if AuthorizeNetReporting.const_defined?(class_name)
84
- klass = AuthorizeNetReporting.const_get(class_name)
85
- else
86
- klass = AuthorizeNetReporting.const_set(class_name, Class.new)
87
- klass.class_eval do
88
- define_method(:initialize) do |params|
89
- params.each do |key, value|
90
- self.class.__send__(:attr_accessor, key)
91
- instance_variable_set("@#{key}", value)
92
- end
74
+ params = to_single_hash(params)
75
+ if AuthorizeNetReporting.const_defined?(class_name)
76
+ klass = AuthorizeNetReporting.const_get(class_name)
77
+ else
78
+ klass = AuthorizeNetReporting.const_set(class_name, Class.new)
79
+ klass.class_eval do
80
+ define_method(:initialize) do |params|
81
+ params.each do |key, value|
82
+ self.class.__send__(:attr_accessor, key)
83
+ instance_variable_set("@#{key}", value)
93
84
  end
94
- end
95
- end
96
- klass.new(params)
85
+ end
86
+ end
87
+ end
88
+ klass.new(params)
97
89
  end
90
+
98
91
  end
99
92
  end
100
93
 
@@ -1,3 +1,3 @@
1
1
  module AuthorizeNetReporting
2
- VERSION = "0.0.1" #:nodoc:
2
+ VERSION = "1.0.0" #:nodoc:
3
3
  end
@@ -1,16 +1,15 @@
1
1
  require 'spec_helper'
2
2
  describe AuthorizeNetReporting::Report do
3
3
  let(:test_mode) do
4
- #TEST API LOGIN: 3vk59E5BgM - API KEY:4c8FeAW7ebq5U733
5
- { :mode => "test", :login=>"3vk59E5BgM", :key => "4c8FeAW7ebq5U733" }
4
+ { :mode => "test", :login=>"xxxx", :key => "xxxx" }
6
5
  end
7
6
 
8
7
  let(:live_mode) do
9
- { :mode => "live", :key=>"key", :login => "login" }
8
+ { :mode => "live", :key=>"xxxxx", :login => "xxxxx" }
10
9
  end
11
10
  context "missing requirements" do
12
11
  it "should raise exception" do
13
- lambda { AuthorizeNetReporting::Report.new }.should raise_error(ArgumentError)
12
+ lambda { AuthorizeNetReporting::Report.new }.should raise_error(AuthorizeNetReporting::Error)
14
13
  end
15
14
  end
16
15
  describe "API URL in live mode" do
@@ -33,7 +32,7 @@ describe AuthorizeNetReporting::Report do
33
32
  describe "settled_batch_list" do
34
33
  context "when there are not batches settled" do
35
34
  it "should return an empty array" do
36
- @authorize_net_reporting.settled_batch_list.should be_empty
35
+ @authorize_net_reporting.settled_batch_list({:first_settlement_date => "2011/11/16", :last_settlement_date => "2011/11/16"}).should be_empty
37
36
  end
38
37
  end
39
38
  context "when there are settled batches" do
@@ -54,29 +53,36 @@ describe AuthorizeNetReporting::Report do
54
53
  it "should return an array statistics for given batch" do
55
54
  @authorize_net_reporting.batch_statistics(1049686).statistics.should be_an_instance_of(Array)
56
55
  end
56
+ it "should return nil if batch is not found" do
57
+ @authorize_net_reporting.batch_statistics(11111).should eql(nil)
58
+ end
57
59
  end
58
-
60
+
59
61
  describe "transactions_list" do
62
+ it "should return empty array if no transactions are found" do
63
+ transactions = @authorize_net_reporting.transaction_list(10000)
64
+ transactions.should be_empty
65
+ end
60
66
  it "should return all transactions in a specified batch" do
61
67
  transactions = @authorize_net_reporting.transaction_list(1049686)
62
68
  transactions.size.should eql(4)
63
69
  end
64
70
  end
65
-
71
+
66
72
  describe "unsettled_transaction_list" do
67
73
  it "should return unsettled transactions" do
68
74
  transactions = @authorize_net_reporting.unsettled_transaction_list
69
75
  transactions.should be_an_instance_of(Array)
70
76
  end
71
77
  end
72
-
78
+
73
79
  describe "transaction_details" do
74
80
  it "should return transaction if transaction_exists" do
75
81
  transaction = @authorize_net_reporting.transaction_details(2157585857)
76
82
  transaction.should be_an_instance_of(AuthorizeNetReporting::AuthorizeNetTransaction)
77
83
  end
78
84
  it "should return nil if transaction doesn't exist" do
79
- @authorize_net_reporting.transaction_details(0).should be_nil
85
+ @authorize_net_reporting.transaction_details(0).should be_nil
80
86
  end
81
87
  end
82
88
  end
metadata CHANGED
@@ -1,61 +1,57 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: authorize_net_reporting
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
4
5
  prerelease:
5
- version: 0.0.1
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Jazmin Schroeder
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-07-04 00:00:00 -05:00
14
- default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
12
+ date: 2011-11-21 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
17
15
  name: httparty
18
- prerelease: false
19
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &70143284072100 !ruby/object:Gem::Requirement
20
17
  none: false
21
- requirements:
22
- - - ">="
23
- - !ruby/object:Gem::Version
24
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.6.1
25
22
  type: :runtime
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
28
- name: builder
29
23
  prerelease: false
30
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *70143284072100
25
+ - !ruby/object:Gem::Dependency
26
+ name: builder
27
+ requirement: &70143284071600 !ruby/object:Gem::Requirement
31
28
  none: false
32
- requirements:
33
- - - ">="
34
- - !ruby/object:Gem::Version
35
- version: "0"
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 2.1.2
36
33
  type: :runtime
37
- version_requirements: *id002
38
- - !ruby/object:Gem::Dependency
39
- name: rspec
40
34
  prerelease: false
41
- requirement: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *70143284071600
36
+ - !ruby/object:Gem::Dependency
37
+ name: rspec
38
+ requirement: &70143284071140 !ruby/object:Gem::Requirement
42
39
  none: false
43
- requirements:
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: "0"
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: '2.0'
47
44
  type: :development
48
- version_requirements: *id003
49
- description: "Retrieve transaction details through the Authorize.net Transaction Details API "
50
- email:
45
+ prerelease: false
46
+ version_requirements: *70143284071140
47
+ description: ! 'Ruby Library to interact with the Authorize.net Transaction Details
48
+ API '
49
+ email:
51
50
  - jazminschroeder@gmail.com
52
51
  executables: []
53
-
54
52
  extensions: []
55
-
56
53
  extra_rdoc_files: []
57
-
58
- files:
54
+ files:
59
55
  - .gitignore
60
56
  - .rspec
61
57
  - Gemfile
@@ -63,40 +59,36 @@ files:
63
59
  - Rakefile
64
60
  - authorize_net_reporting.gemspec
65
61
  - lib/authorize_net_reporting.rb
66
- - lib/authorize_net_reporting/common.rb
67
62
  - lib/authorize_net_reporting/gateway.rb
68
63
  - lib/authorize_net_reporting/report.rb
69
64
  - lib/authorize_net_reporting/response.rb
70
65
  - lib/authorize_net_reporting/version.rb
71
66
  - spec/authorize_net_reporting_spec.rb
72
67
  - spec/spec_helper.rb
73
- has_rdoc: true
74
- homepage: ""
68
+ homepage: ''
75
69
  licenses: []
76
-
77
70
  post_install_message:
78
71
  rdoc_options: []
79
-
80
- require_paths:
72
+ require_paths:
81
73
  - lib
82
- required_ruby_version: !ruby/object:Gem::Requirement
74
+ required_ruby_version: !ruby/object:Gem::Requirement
83
75
  none: false
84
- requirements:
85
- - - ">="
86
- - !ruby/object:Gem::Version
87
- version: "0"
88
- required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
81
  none: false
90
- requirements:
91
- - - ">="
92
- - !ruby/object:Gem::Version
93
- version: "0"
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
94
86
  requirements: []
95
-
96
87
  rubyforge_project: authorize_net_reporting
97
- rubygems_version: 1.5.0
88
+ rubygems_version: 1.8.6
98
89
  signing_key:
99
90
  specification_version: 3
100
91
  summary: Authorize.net Transaction Details API
101
- test_files: []
102
-
92
+ test_files:
93
+ - spec/authorize_net_reporting_spec.rb
94
+ - spec/spec_helper.rb
@@ -1,12 +0,0 @@
1
- # Helper methods
2
- module Common
3
- # Converts string to underscore
4
- def underscore(str)
5
- str.gsub(/(.)([A-Z])/,'\1_\2').downcase
6
- end
7
- # Converts string to camelCase format
8
- def camelize(str)
9
- str.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
10
- end
11
- end
12
-