authorize-net 1.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data/License.pdf +0 -0
- data/README.rdoc +124 -0
- data/Rakefile +74 -0
- data/generators/authorize_net_direct_post/USAGE +20 -0
- data/generators/authorize_net_direct_post/authorize_net_direct_post_generator.rb +21 -0
- data/generators/authorize_net_direct_post/templates/README-AuthorizeNet +49 -0
- data/generators/authorize_net_direct_post/templates/config.yml.erb +8 -0
- data/generators/authorize_net_direct_post/templates/config.yml.rails3.erb +8 -0
- data/generators/authorize_net_direct_post/templates/controller.rb.erb +31 -0
- data/generators/authorize_net_direct_post/templates/initializer.rb +4 -0
- data/generators/authorize_net_direct_post/templates/layout.erb +18 -0
- data/generators/authorize_net_direct_post/templates/payment.erb +10 -0
- data/generators/authorize_net_direct_post/templates/payment.rails3.erb +10 -0
- data/generators/authorize_net_direct_post/templates/receipt.erb +1 -0
- data/generators/authorize_net_direct_post/templates/relay_response.erb +1 -0
- data/generators/authorize_net_sim/USAGE +20 -0
- data/generators/authorize_net_sim/authorize_net_sim_generator.rb +19 -0
- data/generators/authorize_net_sim/templates/README-AuthorizeNet +52 -0
- data/generators/authorize_net_sim/templates/config.yml.erb +8 -0
- data/generators/authorize_net_sim/templates/config.yml.rails3.erb +8 -0
- data/generators/authorize_net_sim/templates/controller.rb.erb +21 -0
- data/generators/authorize_net_sim/templates/initializer.rb +4 -0
- data/generators/authorize_net_sim/templates/layout.erb +18 -0
- data/generators/authorize_net_sim/templates/payment.erb +6 -0
- data/generators/authorize_net_sim/templates/payment.rails3.erb +6 -0
- data/generators/authorize_net_sim/templates/thank_you.erb +1 -0
- data/generators/generator_extensions.rb +75 -0
- data/init.rb +2 -0
- data/install.rb +1 -0
- data/lib/app/helpers/authorize_net_helper.rb +24 -0
- data/lib/authorize-net.rb +4 -0
- data/lib/authorize_net.rb +92 -0
- data/lib/authorize_net/addresses/address.rb +29 -0
- data/lib/authorize_net/addresses/shipping_address.rb +26 -0
- data/lib/authorize_net/aim/response.rb +131 -0
- data/lib/authorize_net/aim/transaction.rb +184 -0
- data/lib/authorize_net/arb/response.rb +34 -0
- data/lib/authorize_net/arb/subscription.rb +72 -0
- data/lib/authorize_net/arb/transaction.rb +146 -0
- data/lib/authorize_net/authorize_net.rb +154 -0
- data/lib/authorize_net/cim/customer_profile.rb +19 -0
- data/lib/authorize_net/cim/payment_profile.rb +37 -0
- data/lib/authorize_net/cim/response.rb +110 -0
- data/lib/authorize_net/cim/transaction.rb +678 -0
- data/lib/authorize_net/customer.rb +27 -0
- data/lib/authorize_net/email_receipt.rb +24 -0
- data/lib/authorize_net/fields.rb +736 -0
- data/lib/authorize_net/key_value_response.rb +117 -0
- data/lib/authorize_net/key_value_transaction.rb +291 -0
- data/lib/authorize_net/line_item.rb +25 -0
- data/lib/authorize_net/order.rb +42 -0
- data/lib/authorize_net/payment_methods/credit_card.rb +74 -0
- data/lib/authorize_net/payment_methods/echeck.rb +72 -0
- data/lib/authorize_net/reporting/batch.rb +19 -0
- data/lib/authorize_net/reporting/batch_statistics.rb +19 -0
- data/lib/authorize_net/reporting/fds_filter.rb +11 -0
- data/lib/authorize_net/reporting/response.rb +127 -0
- data/lib/authorize_net/reporting/transaction.rb +116 -0
- data/lib/authorize_net/reporting/transaction_details.rb +25 -0
- data/lib/authorize_net/response.rb +27 -0
- data/lib/authorize_net/sim/hosted_payment_form.rb +38 -0
- data/lib/authorize_net/sim/hosted_receipt_page.rb +37 -0
- data/lib/authorize_net/sim/response.rb +142 -0
- data/lib/authorize_net/sim/transaction.rb +138 -0
- data/lib/authorize_net/transaction.rb +66 -0
- data/lib/authorize_net/xml_response.rb +172 -0
- data/lib/authorize_net/xml_transaction.rb +275 -0
- data/lib/generators/authorize_net/direct_post_generator.rb +51 -0
- data/lib/generators/authorize_net/sim_generator.rb +47 -0
- data/spec/aim_spec.rb +310 -0
- data/spec/arb_spec.rb +191 -0
- data/spec/authorize_net_spec.rb +200 -0
- data/spec/cim_spec.rb +450 -0
- data/spec/reporting_spec.rb +431 -0
- data/spec/sim_spec.rb +97 -0
- data/spec/spec.opts +5 -0
- data/spec/spec_helper.rb +2 -0
- data/uninstall.rb +1 -0
- metadata +223 -0
@@ -0,0 +1,74 @@
|
|
1
|
+
module AuthorizeNet
|
2
|
+
|
3
|
+
# Defines constants for each payment method type.
|
4
|
+
module PaymentMethodType
|
5
|
+
CREDIT_CARD = 'CC'
|
6
|
+
end
|
7
|
+
|
8
|
+
# Models a credit card.
|
9
|
+
class CreditCard
|
10
|
+
PAYMENT_METHOD_CODE = AuthorizeNet::PaymentMethodType::CREDIT_CARD
|
11
|
+
|
12
|
+
# The option defaults for the constructor.
|
13
|
+
@@option_defaults = {
|
14
|
+
:card_code => nil,
|
15
|
+
:card_type => nil
|
16
|
+
}
|
17
|
+
|
18
|
+
attr_accessor :card_number, :expiration, :card_code, :card_type, :track_1, :track_2
|
19
|
+
|
20
|
+
# Constructs a new credit card object. Takes a credit card number
|
21
|
+
# and an expiration date. The CCV code can be passed as an option. So can
|
22
|
+
# the data tracks (1 & 2). When passing in data tracks, please pass the
|
23
|
+
# whole track. Sentinels and the LRC will be removed by the SDK. Track data
|
24
|
+
# must be passed along as ASCII. The raw bit stream from the card is not acceptable.
|
25
|
+
#
|
26
|
+
# Field separators on
|
27
|
+
#
|
28
|
+
# +card_number+:: The credit card number as a string.
|
29
|
+
# +expiration+:: The credit card expiration date as a string with format MMYY.
|
30
|
+
# +options+:: A hash of options.
|
31
|
+
#
|
32
|
+
# Options
|
33
|
+
# +card_code+:: Sets the CCV code for the credit card.
|
34
|
+
# +card_type+:: Sets the type of card (Visa, MasterCard, Dinners Club, etc.)
|
35
|
+
# +track_1+:: Sets the track 1 data. Either track 1 or track 2 data needs to be included for card present transactions (otherwise fee structure will change).
|
36
|
+
# +track_2+:: Sets the track 2 data. Either track 1 or track 2 data needs to be included for card present transactions (otherwise fee structure will change).
|
37
|
+
#
|
38
|
+
#
|
39
|
+
def initialize(card_number, expiration, options = {})
|
40
|
+
@card_number = card_number
|
41
|
+
@expiration = expiration
|
42
|
+
options = @@option_defaults.merge(options)
|
43
|
+
@card_code = options[:card_code]
|
44
|
+
@card_type = options[:card_type]
|
45
|
+
@track_1 = options[:track_1]
|
46
|
+
@track_2 = options[:track_2]
|
47
|
+
end
|
48
|
+
|
49
|
+
def to_hash
|
50
|
+
hash = {
|
51
|
+
:method => PAYMENT_METHOD_CODE,
|
52
|
+
:card_num => @card_number,
|
53
|
+
:exp_date => @expiration
|
54
|
+
}
|
55
|
+
hash[:card_code] = @card_code unless @card_code.nil?
|
56
|
+
unless @track_1.nil?
|
57
|
+
track_1 = @track_1
|
58
|
+
if track_1[0..0] == '%'
|
59
|
+
track_1 = track_1[1..(@track_1.rindex('?') - 1)]
|
60
|
+
end
|
61
|
+
hash[:track1] = track_1
|
62
|
+
end
|
63
|
+
unless @track_2.nil?
|
64
|
+
track_2 = @track_2
|
65
|
+
if track_2[0..0] == ';'
|
66
|
+
track_2 = track_2[1..(@track_2.rindex('?') - 1)]
|
67
|
+
end
|
68
|
+
hash[:track2] = track_2
|
69
|
+
end
|
70
|
+
hash
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module AuthorizeNet
|
2
|
+
|
3
|
+
# Defines constants for each payment method type.
|
4
|
+
module PaymentMethodType
|
5
|
+
ECHECK = 'ECHECK'
|
6
|
+
end
|
7
|
+
|
8
|
+
# Models an eCheck.
|
9
|
+
class ECheck
|
10
|
+
PAYMENT_METHOD_CODE = AuthorizeNet::PaymentMethodType::ECHECK
|
11
|
+
|
12
|
+
# Defines constants for each bank account type.
|
13
|
+
module AccountType
|
14
|
+
CHECKING = 'CHECKING'
|
15
|
+
SAVINGS = 'SAVINGS'
|
16
|
+
BUSINESS_CHECKING = 'BUSINESSCHECKING'
|
17
|
+
end
|
18
|
+
|
19
|
+
# Defines constants for each check type.
|
20
|
+
module CheckType
|
21
|
+
ACCOUNTS_RECEIVABLE_CONVERSION = 'ARC'
|
22
|
+
BACK_OFFICE_CONVERSION = 'BOC'
|
23
|
+
CASH_CONCENTRATION_DISBURSEMENT = 'CCD'
|
24
|
+
PREARRANGED_PAYMENT_DEPOSIT = 'PPD'
|
25
|
+
TELEPHONE_INITIATED = 'TEL'
|
26
|
+
INTERNET_INITIATED = 'WEB'
|
27
|
+
end
|
28
|
+
|
29
|
+
# The option defaults for the constructor.
|
30
|
+
@@option_defaults = {
|
31
|
+
:echeck_type => CheckType::INTERNET_INITIATED,
|
32
|
+
:check_number => nil,
|
33
|
+
:account_type => AccountType::CHECKING
|
34
|
+
}
|
35
|
+
|
36
|
+
attr_accessor :routing_number, :account_number, :bank_name, :account_holder_name, :echeck_type, :check_number, :account_type
|
37
|
+
|
38
|
+
# Constructs a new eCheck object.
|
39
|
+
#
|
40
|
+
# +routing_number+:: The bank routing number as a string.
|
41
|
+
# +account_number+:: The bank account number as a string.
|
42
|
+
# +bank_name+:: The legal name of the bank. This should match the name associated with the +routing_number+.
|
43
|
+
# +account_holder_name+:: The full name on the bank account represented by +account_number+.
|
44
|
+
# +options+:: A hash of options. Accepts +echeck_type+ (the type of check, can usually be ignored), +check_number+ (the number on the check, only needed for some check types), and +account_type+ (the type of bank account the check draws from). All values should be passed as strings.
|
45
|
+
#
|
46
|
+
def initialize(routing_number, account_number, bank_name, account_holder_name, options = {})
|
47
|
+
@routing_number = routing_number
|
48
|
+
@account_number = account_number
|
49
|
+
@bank_name = bank_name
|
50
|
+
@account_holder_name = account_holder_name
|
51
|
+
options = @@option_defaults.merge(options)
|
52
|
+
@echeck_type = options[:echeck_type]
|
53
|
+
@check_number = options[:check_number]
|
54
|
+
@account_type = options[:account_type]
|
55
|
+
end
|
56
|
+
|
57
|
+
def to_hash
|
58
|
+
hash = {
|
59
|
+
:method => PAYMENT_METHOD_CODE,
|
60
|
+
:bank_aba_code => @routing_number,
|
61
|
+
:bank_acct_num => @account_number,
|
62
|
+
:bank_acct_type => @account_type,
|
63
|
+
:bank_name => @bank_name,
|
64
|
+
:bank_acct_name => @account_holder_name,
|
65
|
+
:echeck_type => @echeck_type
|
66
|
+
}
|
67
|
+
hash[:bank_check_number] = @check_number unless @check_number.nil?
|
68
|
+
hash
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module AuthorizeNet::Reporting
|
2
|
+
|
3
|
+
# Models a batch of credit cards.
|
4
|
+
class Batch
|
5
|
+
|
6
|
+
include AuthorizeNet::Model
|
7
|
+
|
8
|
+
attr_accessor :id, :settled_at, :state, :statistics, :payment_method
|
9
|
+
|
10
|
+
def settled_at=(time)
|
11
|
+
if time.kind_of?(DateTime)
|
12
|
+
@settled_at = time
|
13
|
+
else
|
14
|
+
@settled_at = DateTime.parse(time.to_s)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module AuthorizeNet::Reporting
|
2
|
+
|
3
|
+
# Models a batch of credit cards.
|
4
|
+
class BatchStatistics
|
5
|
+
|
6
|
+
include AuthorizeNet::Model
|
7
|
+
|
8
|
+
attr_accessor :account_type, :charge_count, :charge_amount, :refund_count,
|
9
|
+
:refund_amount, :void_count, :decline_count, :error_count,
|
10
|
+
:returned_item_amount, :returned_item_count, :chargeback_count,
|
11
|
+
:chargeback_amount, :correction_notice_count, :charge_chageback_count,
|
12
|
+
:charge_chargeback_amount, :refund_chargeback_amount,
|
13
|
+
:refund_chargeback_count, :charge_returned_items_amount,
|
14
|
+
:charge_returned_items_count, :refund_returned_items_amount,
|
15
|
+
:refund_returned_items_count
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
module AuthorizeNet::Reporting
|
2
|
+
|
3
|
+
# The CIM response class.
|
4
|
+
class Response < AuthorizeNet::XmlResponse
|
5
|
+
|
6
|
+
include AuthorizeNet::CIM::Fields
|
7
|
+
|
8
|
+
# Constructs a new response object from raw_response in the context of transaction.
|
9
|
+
# You don‘t typically construct this object yourself, as AuthorizeNet::Reeporting::Transaction
|
10
|
+
# will build one for you when it makes the request to the gateway.
|
11
|
+
def initialize(raw_response, transaction)
|
12
|
+
super
|
13
|
+
unless connection_failure?
|
14
|
+
begin
|
15
|
+
@batch_list = @root.at_css('batchList')
|
16
|
+
@transactions = @root.at_css('transactions')
|
17
|
+
@transaction = @root.at_css('transaction')
|
18
|
+
rescue
|
19
|
+
@raw_response = $!
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
# Returns an Array of Batch objects built from the entities returned in the response. Returns nil if no batchList was returned.
|
26
|
+
def batch_list
|
27
|
+
unless @batch_list.nil?
|
28
|
+
batches = []
|
29
|
+
@batch_list.element_children.each do |child|
|
30
|
+
batches <<= build_entity(child, Fields::BATCH_ENTITY_DESCRIPTION) unless child.nil?
|
31
|
+
end
|
32
|
+
return batches unless batches.length == 0
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# Returns an Array of TransactionDetail objects built from the entities returned in the response. Returns nil if no transactions were returned.
|
37
|
+
def transactions
|
38
|
+
unless @transactions.nil?
|
39
|
+
transactions = []
|
40
|
+
@transactions.element_children.each do |child|
|
41
|
+
unless child.nil?
|
42
|
+
transaction = build_entity(child, Fields::TRANSACTION_DETAILS_ENTITY_DESCRIPTION)
|
43
|
+
|
44
|
+
# handle some stuff thats too tricky for EntityDecription to handle
|
45
|
+
first_name = node_content_unless_nil(child.at_css('firstName'))
|
46
|
+
last_name = node_content_unless_nil(child.at_css('lastName'))
|
47
|
+
unless first_name.nil? && last_name.nil?
|
48
|
+
address = AuthorizeNet::Address.new(:first_name => first_name, :last_name => last_name)
|
49
|
+
transaction.customer = AuthorizeNet::Customer.new(:address => address)
|
50
|
+
end
|
51
|
+
invoice_number = node_content_unless_nil(child.at_css('invoiceNumber'))
|
52
|
+
unless invoice_number.nil?
|
53
|
+
transaction.order = AuthorizeNet::Order.new(:invoice_num => invoice_number)
|
54
|
+
end
|
55
|
+
transactions <<= transaction
|
56
|
+
end
|
57
|
+
end
|
58
|
+
return transactions unless transactions.length == 0
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# Builds and returns a TransactionDetail entity built from the response. If no transaction was found, returns nil.
|
63
|
+
def transaction
|
64
|
+
unless @transaction.nil?
|
65
|
+
transaction = build_entity(@transaction, Fields::TRANSACTION_DETAILS_ENTITY_DESCRIPTION)
|
66
|
+
|
67
|
+
ip = node_content_unless_nil(@transaction.at_css('customerIP'))
|
68
|
+
unless ip.nil?
|
69
|
+
transaction.customer ||= AuthorizeNet::CIM::CustomerProfile.new()
|
70
|
+
transaction.customer.ip = ip
|
71
|
+
end
|
72
|
+
|
73
|
+
tax_exempt = node_content_unless_nil(@transaction.at_css('taxExempt'))
|
74
|
+
unless tax_exempt.nil?
|
75
|
+
transaction.order ||= AuthorizeNet::Order.new()
|
76
|
+
transaction.order.tax_exempt = value_to_boolean(tax_exempt)
|
77
|
+
end
|
78
|
+
|
79
|
+
tax = @transaction.at_css('tax')
|
80
|
+
unless tax.nil?
|
81
|
+
transaction.order ||= AuthorizeNet::Order.new()
|
82
|
+
tax_amount = node_content_unless_nil(tax.at_css('amount'))
|
83
|
+
transaction.order.tax_amount = value_to_decimal(tax_amount) unless tax_amount.nil?
|
84
|
+
transaction.order.tax_name = node_content_unless_nil(tax.at_css('name'))
|
85
|
+
transaction.order.tax_description = node_content_unless_nil(tax.at_css('description'))
|
86
|
+
end
|
87
|
+
|
88
|
+
shipping = @transaction.at_css('shipping')
|
89
|
+
unless shipping.nil?
|
90
|
+
transaction.order ||= AuthorizeNet::Order.new()
|
91
|
+
shipping_amount = node_content_unless_nil(shipping.at_css('amount'))
|
92
|
+
transaction.order.shipping_amount = value_to_decimal(shipping_amount) unless shipping_amount.nil?
|
93
|
+
transaction.order.shipping_name = node_content_unless_nil(shipping.at_css('name'))
|
94
|
+
transaction.order.shipping_description = node_content_unless_nil(shipping.at_css('description'))
|
95
|
+
end
|
96
|
+
|
97
|
+
duty = @transaction.at_css('duty')
|
98
|
+
unless duty.nil?
|
99
|
+
transaction.order ||= AuthorizeNet::Order.new()
|
100
|
+
duty_amount = node_content_unless_nil(duty.at_css('amount'))
|
101
|
+
transaction.order.duty_amount = value_to_decimal(duty_amount) unless duty_amount.nil?
|
102
|
+
transaction.order.duty_name = node_content_unless_nil(duty.at_css('name'))
|
103
|
+
transaction.order.duty_description = node_content_unless_nil(duty.at_css('description'))
|
104
|
+
end
|
105
|
+
|
106
|
+
line_items = @transaction.at_css('lineItems')
|
107
|
+
unless line_items.nil?
|
108
|
+
transaction.order ||= AuthorizeNet::Order.new()
|
109
|
+
line_items.element_children.each do |child|
|
110
|
+
line_item = build_entity(child, Fields::LINE_ITEM_ENTITY_DESCRIPTION)
|
111
|
+
transaction.order.add_line_item(line_item)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
# Really not sure what to do with customer type here. It should go on a payment
|
116
|
+
customer_type = node_content_unless_nil(@transaction.at_css('customer type'))
|
117
|
+
unless customer_type.nil?
|
118
|
+
transaction.customer ||= AuthorizeNet::CIM::CustomerProfile.new()
|
119
|
+
transaction.customer.payment_profiles = [AuthorizeNet::CIM::PaymentProfile.new(:cust_type => customer_type)]
|
120
|
+
end
|
121
|
+
|
122
|
+
return transaction
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
127
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
module AuthorizeNet::Reporting
|
2
|
+
|
3
|
+
# The Reporting API transaction class.
|
4
|
+
class Transaction < AuthorizeNet::XmlTransaction
|
5
|
+
|
6
|
+
include AuthorizeNet::Reporting::Fields
|
7
|
+
|
8
|
+
# The class to wrap our response in.
|
9
|
+
@response_class = AuthorizeNet::Reporting::Response
|
10
|
+
|
11
|
+
# Fields to convert to/from Date.
|
12
|
+
@@datetime_fields = [:first_settlement_date, :last_settlement_date]
|
13
|
+
|
14
|
+
# Constructs a Reporting transaction. You can use the new Reporting transaction object
|
15
|
+
# to issue a request to the payment gateway and parse the response into a new
|
16
|
+
# AuthorizeNet::Reporting::Response object.
|
17
|
+
#
|
18
|
+
# +api_login_id+:: Your API login ID, as a string.
|
19
|
+
# +api_transaction_key+:: Your API transaction key, as a string.
|
20
|
+
# +options+:: A hash of options. See below for values.
|
21
|
+
#
|
22
|
+
# Options
|
23
|
+
# +gateway+:: The gateway to submit the transaction to. Can be a URL string, an AuthorizeNet::Reporting::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).
|
24
|
+
# +verify_ssl+:: A boolean indicating if the SSL certificate of the +gateway+ should be verified. Defaults to false.
|
25
|
+
# +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.
|
26
|
+
#
|
27
|
+
def initialize(api_login_id, api_transaction_key, options = {})
|
28
|
+
super
|
29
|
+
end
|
30
|
+
|
31
|
+
# Sets up and submits a getSettledBatchListRequest transaction. If this transaction has already been
|
32
|
+
# run, this method will return nil. Otherwise it will return an AuthorizeNet::Reporting::Response object. The
|
33
|
+
# response object will have an array of Batch objects available via its batch_list method if
|
34
|
+
# the request was successful.
|
35
|
+
#
|
36
|
+
#
|
37
|
+
# +from_date+:: Takes either a DateTime or a String representing a date and time. Only settled batches >= this value will be returned. Defaults to nil (which returns >= 24hrs ago). A to_date must be specified if a from_date is.
|
38
|
+
# +to_date+:: Takes either a DateTime or a String representing a date and time. Only settled batches <= this value will be returned. Defaults to nil. The maximum date range is 31 days, and a from_date must be supplied if a to_date is.
|
39
|
+
# +include_stats+:: Takes a Boolean. Determines if BatchStatistics should be returned with the Batch objects. Defaults to false.
|
40
|
+
#
|
41
|
+
# Typical usage:
|
42
|
+
#
|
43
|
+
# response = transaction.get_settled_batch_list(DateTime.now() - (1 * 3600 * 48), DateTime.now(), true)
|
44
|
+
# batches = response.batch_list if response.success?
|
45
|
+
#
|
46
|
+
def get_settled_batch_list(from_date = nil, to_date = nil, include_stats = false)
|
47
|
+
@type = Type::REPORT_GET_BATCH_LIST
|
48
|
+
set_fields({:first_settlement_date => from_date, :last_settlement_date => to_date, :include_statistics => include_stats})
|
49
|
+
make_request
|
50
|
+
end
|
51
|
+
|
52
|
+
# Sets up and submits a getTransactionListRequest transaction. If this transaction has already been
|
53
|
+
# run, this method will return nil. Otherwise it will return an AuthorizeNet::Reporting::Response object. The
|
54
|
+
# response object will have an array of TransactionDetail objects available via its transactions method if
|
55
|
+
# the request was successful. These TransactionDetail objects will not be fully populated. Use get_transaction_details
|
56
|
+
# to get all the details.
|
57
|
+
#
|
58
|
+
#
|
59
|
+
# +batch_id+:: Takes either a Batch object with its id attribute populated, or a String representing the ID of the batch to retrieve the transaction list from.
|
60
|
+
#
|
61
|
+
# Typical usage:
|
62
|
+
#
|
63
|
+
# response = transaction.get_transaction_list('123456')
|
64
|
+
# transactions = response.transactions if response.success?
|
65
|
+
#
|
66
|
+
def get_transaction_list(batch_id)
|
67
|
+
@type = Type::REPORT_GET_TRANSACTION_LIST
|
68
|
+
handle_batch_id(batch_id)
|
69
|
+
make_request
|
70
|
+
end
|
71
|
+
|
72
|
+
# Sets up and submits a getTransactionDetailsRequest transaction. If this transaction has already been
|
73
|
+
# run, this method will return nil. Otherwise it will return an AuthorizeNet::Reporting::Response object. The
|
74
|
+
# response object will have a TransactionDetail object available via its transactions method if
|
75
|
+
# the request was successful. This TransactionDetail object will have more data than the limited version
|
76
|
+
# returned by get_transaction_list.
|
77
|
+
#
|
78
|
+
#
|
79
|
+
# +transaction_id+:: Takes either a TransactionDetail object with its id attribute populated, or a String representing the ID of the transaction to retrieve the details from.
|
80
|
+
#
|
81
|
+
# Typical usage:
|
82
|
+
#
|
83
|
+
# response = transaction.get_transaction_details('123456789')
|
84
|
+
# transactions = response.transactions if response.success?
|
85
|
+
#
|
86
|
+
def get_transaction_details(transaction_id)
|
87
|
+
@type = Type::REPORT_GET_TRANSACTION_DETAILS
|
88
|
+
handle_transaction_id(transaction_id)
|
89
|
+
make_request
|
90
|
+
end
|
91
|
+
|
92
|
+
#:enddoc:
|
93
|
+
protected
|
94
|
+
|
95
|
+
# Handles batch id type massaging.
|
96
|
+
def handle_batch_id(id)
|
97
|
+
case id
|
98
|
+
when Batch
|
99
|
+
set_fields(:batch_id => id.id.to_s)
|
100
|
+
else
|
101
|
+
set_fields(:batch_id => id.to_s)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
# Handles transaction id type massaging.
|
106
|
+
def handle_transaction_id(id)
|
107
|
+
case id
|
108
|
+
when TransactionDetails
|
109
|
+
set_fields(:transaction_id => id.id.to_s)
|
110
|
+
else
|
111
|
+
set_fields(:transaction_id => id.to_s)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module AuthorizeNet::Reporting
|
2
|
+
|
3
|
+
# Models the details of a transaction.
|
4
|
+
class TransactionDetails
|
5
|
+
|
6
|
+
include AuthorizeNet::Model
|
7
|
+
|
8
|
+
attr_accessor :id, :submitted_at, :status, :order, :customer, :account_type,
|
9
|
+
:account_number, :settle_amount, :reference_id, :split_tender_id,
|
10
|
+
:type, :response_code, :response_reason_code, :response_reason_description,
|
11
|
+
:auth_code, :avs_response, :card_code_response, :cavv_response,
|
12
|
+
:fds_filter_action, :fds_filters, :batch, :prepaid_balance_remaining,
|
13
|
+
:payment_method, :recurring_billing, :bill_to, :ship_to, :auth_amount
|
14
|
+
|
15
|
+
def submitted_at=(time)
|
16
|
+
if time.kind_of?(DateTime)
|
17
|
+
@submitted_at = time
|
18
|
+
else
|
19
|
+
@submitted_at = DateTime.parse(time.to_s)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|