authorizenet 1.9.4 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/lib/app/helpers/authorize_net_helper.rb +2 -3
- data/lib/authorize_net.rb +11 -56
- data/lib/authorize_net/api/LogHelper.rb +97 -0
- data/lib/authorize_net/api/SensitiveDataFilter.rb +92 -0
- data/lib/authorize_net/api/api_transaction.rb +95 -90
- data/lib/authorize_net/api/constants.yml +1 -1
- data/lib/authorize_net/api/schema.rb +1353 -994
- data/lib/authorize_net/api/transaction.rb +104 -102
- data/lib/authorize_net/authorize_net.rb +20 -27
- data/lib/authorize_net/response.rb +9 -15
- data/lib/authorize_net/transaction.rb +18 -26
- data/lib/authorize_net/xml_response.rb +36 -54
- data/lib/authorize_net/xml_transaction.rb +115 -134
- metadata +59 -73
- data/lib/authorize_net/addresses/address.rb +0 -29
- data/lib/authorize_net/addresses/shipping_address.rb +0 -26
- data/lib/authorize_net/aim/response.rb +0 -131
- data/lib/authorize_net/aim/transaction.rb +0 -190
- data/lib/authorize_net/arb/fields.rb +0 -24
- data/lib/authorize_net/arb/paging.rb +0 -33
- data/lib/authorize_net/arb/response.rb +0 -34
- data/lib/authorize_net/arb/sorting.rb +0 -43
- data/lib/authorize_net/arb/subscription.rb +0 -72
- data/lib/authorize_net/arb/subscription_detail.rb +0 -14
- data/lib/authorize_net/arb/subscription_list_response.rb +0 -43
- data/lib/authorize_net/arb/transaction.rb +0 -177
- data/lib/authorize_net/cim/customer_profile.rb +0 -19
- data/lib/authorize_net/cim/payment_profile.rb +0 -37
- data/lib/authorize_net/cim/response.rb +0 -116
- data/lib/authorize_net/cim/transaction.rb +0 -727
- data/lib/authorize_net/customer.rb +0 -27
- data/lib/authorize_net/email_receipt.rb +0 -24
- data/lib/authorize_net/fields.rb +0 -779
- data/lib/authorize_net/key_value_response.rb +0 -117
- data/lib/authorize_net/key_value_transaction.rb +0 -291
- data/lib/authorize_net/line_item.rb +0 -25
- data/lib/authorize_net/order.rb +0 -42
- data/lib/authorize_net/payment_methods/credit_card.rb +0 -62
- data/lib/authorize_net/payment_methods/echeck.rb +0 -72
- data/lib/authorize_net/reporting/batch.rb +0 -19
- data/lib/authorize_net/reporting/batch_statistics.rb +0 -19
- data/lib/authorize_net/reporting/fds_filter.rb +0 -11
- data/lib/authorize_net/reporting/response.rb +0 -163
- data/lib/authorize_net/reporting/returned_item.rb +0 -46
- data/lib/authorize_net/reporting/transaction.rb +0 -133
- data/lib/authorize_net/reporting/transaction_details.rb +0 -25
- data/lib/authorize_net/sim/hosted_payment_form.rb +0 -38
- data/lib/authorize_net/sim/hosted_receipt_page.rb +0 -37
- data/lib/authorize_net/sim/response.rb +0 -142
- data/lib/authorize_net/sim/transaction.rb +0 -138
- data/lib/generators/authorize_net/direct_post/direct_post_generator.rb +0 -53
- data/lib/generators/authorize_net/direct_post/templates/README-AuthorizeNet +0 -49
- data/lib/generators/authorize_net/direct_post/templates/config.yml.erb +0 -8
- data/lib/generators/authorize_net/direct_post/templates/config.yml.rails3.erb +0 -8
- data/lib/generators/authorize_net/direct_post/templates/controller.rb.erb +0 -31
- data/lib/generators/authorize_net/direct_post/templates/initializer.rb +0 -4
- data/lib/generators/authorize_net/direct_post/templates/layout.erb +0 -18
- data/lib/generators/authorize_net/direct_post/templates/payment.erb +0 -10
- data/lib/generators/authorize_net/direct_post/templates/payment.rails3.erb +0 -10
- data/lib/generators/authorize_net/direct_post/templates/receipt.erb +0 -1
- data/lib/generators/authorize_net/direct_post/templates/relay_response.erb +0 -1
- data/lib/generators/authorize_net/sim/sim_generator.rb +0 -47
- data/lib/generators/authorize_net/sim/templates/README-AuthorizeNet +0 -52
- data/lib/generators/authorize_net/sim/templates/config.yml.erb +0 -8
- data/lib/generators/authorize_net/sim/templates/config.yml.rails3.erb +0 -8
- data/lib/generators/authorize_net/sim/templates/controller.rb.erb +0 -21
- data/lib/generators/authorize_net/sim/templates/initializer.rb +0 -4
- data/lib/generators/authorize_net/sim/templates/layout.erb +0 -18
- data/lib/generators/authorize_net/sim/templates/payment.erb +0 -6
- data/lib/generators/authorize_net/sim/templates/payment.rails3.erb +0 -6
- data/lib/generators/authorize_net/sim/templates/thank_you.erb +0 -1
- data/lib/generators/generator_extensions.rb +0 -75
@@ -1,25 +0,0 @@
|
|
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
|
-
:subscription_id, :subscription_paynum, :solution_id, :solution_name, :returns
|
15
|
-
|
16
|
-
def submitted_at=(time)
|
17
|
-
if time.kind_of?(DateTime)
|
18
|
-
@submitted_at = time
|
19
|
-
else
|
20
|
-
@submitted_at = DateTime.parse(time.to_s)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
25
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
module AuthorizeNet::SIM
|
2
|
-
|
3
|
-
# Models a hosted payment form.
|
4
|
-
class HostedPaymentForm
|
5
|
-
|
6
|
-
include AuthorizeNet::Model
|
7
|
-
|
8
|
-
attr_accessor :header_html, :footer_html, :color_background, :color_link, :color_text, :logo_url, :background_url, :rename
|
9
|
-
|
10
|
-
# Convenience method for adding field rename requests to the transaction. This renames a field shown on
|
11
|
-
# the hosted payment form.
|
12
|
-
def add_rename(field, name)
|
13
|
-
rename = "#{field},#{name}"
|
14
|
-
unless @rename.nil?
|
15
|
-
@rename = @rename.to_a << rename
|
16
|
-
else
|
17
|
-
@rename = [rename]
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def to_hash
|
22
|
-
hash = {
|
23
|
-
:header_html_payment_form => @header_html,
|
24
|
-
:footer_html_payment_form => @footer_html,
|
25
|
-
:color_background => @color_background,
|
26
|
-
:color_link => @color_link,
|
27
|
-
:color_text => @color_text,
|
28
|
-
:logo_url => @logo_url,
|
29
|
-
:background_url => @background_url,
|
30
|
-
:rename => @rename
|
31
|
-
}
|
32
|
-
hash.delete_if {|k, v| v.nil?}
|
33
|
-
hash
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
module AuthorizeNet::SIM
|
2
|
-
|
3
|
-
# Models a hosted receipt page.
|
4
|
-
class HostedReceiptPage
|
5
|
-
|
6
|
-
# Defines constants for each of the link methods used by the hosted receipt page.
|
7
|
-
module LinkMethod
|
8
|
-
LINK = 'LINK'
|
9
|
-
POST = 'POST'
|
10
|
-
GET = 'GET'
|
11
|
-
end
|
12
|
-
|
13
|
-
include AuthorizeNet::Model
|
14
|
-
|
15
|
-
attr_accessor :header_html, :footer_html, :color_background, :color_link, :color_text, :logo_url, :background_url, :link_method, :link_text, :link_url
|
16
|
-
|
17
|
-
|
18
|
-
def to_hash
|
19
|
-
hash = {
|
20
|
-
:header_html_receipt => @header_html,
|
21
|
-
:footer_html_receipt => @footer_html,
|
22
|
-
:color_background => @color_background,
|
23
|
-
:color_link => @color_link,
|
24
|
-
:color_text => @color_text,
|
25
|
-
:logo_url => @logo_url,
|
26
|
-
:background_url => @background_url,
|
27
|
-
:receipt_link_method => @link_method,
|
28
|
-
:receipt_link_text => @link_text,
|
29
|
-
:receipt_link_url => @link_url
|
30
|
-
}
|
31
|
-
hash.delete_if {|k, v| v.nil?}
|
32
|
-
hash
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
@@ -1,142 +0,0 @@
|
|
1
|
-
module AuthorizeNet::SIM
|
2
|
-
|
3
|
-
# The SIM response class. Handles parsing the response from the gateway. Also
|
4
|
-
# provides a few relay response helpers used to implement Direct Post Method.
|
5
|
-
class Response < AuthorizeNet::KeyValueResponse
|
6
|
-
|
7
|
-
# Our MD5 digest generator.
|
8
|
-
@@digest = OpenSSL::Digest.new('md5')
|
9
|
-
|
10
|
-
include AuthorizeNet::SIM::Fields
|
11
|
-
|
12
|
-
# Constructs a new response object from a +raw_response+. Provides utility methods
|
13
|
-
# for validating the response as authentic, and for handling the Direct Post Method
|
14
|
-
# relay response.
|
15
|
-
#
|
16
|
-
# +raw_response+:: The raw response, either a string in POST body or GET query string format, or a hash of key/value pairs.
|
17
|
-
#
|
18
|
-
# Typical usage:
|
19
|
-
# response = AuthorizeNet::SIM::Response("x_first_name=John&x_last_name=Doe")
|
20
|
-
def initialize(raw_response)
|
21
|
-
@raw_response = raw_response
|
22
|
-
@custom_fields = {}
|
23
|
-
@fields = {}
|
24
|
-
parse_response(@raw_response)
|
25
|
-
end
|
26
|
-
|
27
|
-
|
28
|
-
# Returns True if the MD5 hash found in the response payload validates using
|
29
|
-
# the supplied api_login and secret merchant_value (THIS IS NOT YOUR API KEY).
|
30
|
-
def valid_md5?(api_login, merchant_value)
|
31
|
-
if @fields[:MD5_Hash].nil?
|
32
|
-
return false
|
33
|
-
end
|
34
|
-
@@digest.hexdigest("#{merchant_value}#{api_login}#{@fields[:trans_id]}#{@fields[:amount]}").downcase == @fields[:MD5_Hash].downcase
|
35
|
-
end
|
36
|
-
|
37
|
-
# Returns an HTML string that can be returned to the gateway during the Relay Response,
|
38
|
-
# and will send the user on to URL you specify. Takes a hash of options, currently the
|
39
|
-
# only option is :include, which can be True to include all fields returned in the response
|
40
|
-
# as query string parameters, or it can be an array of fields to include.
|
41
|
-
def direct_post_reply(url, options = {})
|
42
|
-
url = direct_post_url(url, options[:include]) if options.has_key?(:include)
|
43
|
-
js_url = url.gsub("'", '\'')
|
44
|
-
html_url = url.gsub('&', '&').gsub('"', "\"")
|
45
|
-
html = <<-HTML
|
46
|
-
<html><head><script type="text/javascript" charset="utf-8">window.location='#{js_url}';</script><noscript><meta http-equiv="refresh" content="1;url=#{html_url}"></noscript></head><body></body></html>
|
47
|
-
HTML
|
48
|
-
end
|
49
|
-
|
50
|
-
# Returns an URL with the fields found in the response and specified in include_fields attached as
|
51
|
-
# part of the URL's query string. If you pass true instead of an array of fields, all fields will be
|
52
|
-
# attached.
|
53
|
-
def direct_post_url(base_url, include_fields = true)
|
54
|
-
url = base_url
|
55
|
-
if include_fields
|
56
|
-
fields = []
|
57
|
-
case include_fields
|
58
|
-
when TrueClass
|
59
|
-
fields = FIELDS.collect do |k|
|
60
|
-
k_str = k.to_s
|
61
|
-
k_str[2..k_str.length].to_sym
|
62
|
-
end
|
63
|
-
when Array
|
64
|
-
fields = include_fields
|
65
|
-
else
|
66
|
-
fields = include_fields.to_a
|
67
|
-
end
|
68
|
-
parsed_url = URI.parse(url)
|
69
|
-
if parsed_url.query.nil?
|
70
|
-
parsed_url.query = ''
|
71
|
-
elsif parsed_url.query.length != 0
|
72
|
-
parsed_url.query = parsed_url.query.chomp('&') + '&'
|
73
|
-
end
|
74
|
-
parsed_url.query += ((fields.select { |k| @fields.has_key?(k) }).collect { |k| self.to_param(k, @fields[k]) }).join('&')
|
75
|
-
parsed_url.query.chomp('&')
|
76
|
-
url = parsed_url.to_s
|
77
|
-
end
|
78
|
-
url
|
79
|
-
end
|
80
|
-
|
81
|
-
# Check to see if the response indicated success. Success is defined as a valid MD5 hash
|
82
|
-
# and an response code of AuthorizeNet::Response::ResponseCode::APPROVED.
|
83
|
-
def success?(api_login, merchant_value)
|
84
|
-
valid_md5?(api_login, merchant_value) && approved?
|
85
|
-
end
|
86
|
-
|
87
|
-
# Returns the transaction's authorization code. This should be shown to the
|
88
|
-
# end user.
|
89
|
-
def authorization_code
|
90
|
-
@fields[:auth_code]
|
91
|
-
end
|
92
|
-
|
93
|
-
# Returns the transaction's authorization id. You will need this for future void, refund
|
94
|
-
# and prior authorization capture requests.
|
95
|
-
def transaction_id
|
96
|
-
@fields[:trans_id]
|
97
|
-
end
|
98
|
-
|
99
|
-
# Returns the customer id from the response.
|
100
|
-
def customer_id
|
101
|
-
@fields[:cust_id]
|
102
|
-
end
|
103
|
-
|
104
|
-
# Returns a response code (from AVSResponseCode) indicating the result of any Address Verification
|
105
|
-
# Service checks.
|
106
|
-
def avs_response
|
107
|
-
@fields[:avs_code]
|
108
|
-
end
|
109
|
-
|
110
|
-
#:enddoc:
|
111
|
-
protected
|
112
|
-
|
113
|
-
# Internal helper to parse the raw response object. It handles both raw POST bodies and
|
114
|
-
# hashes.
|
115
|
-
def parse_response(raw_response)
|
116
|
-
case raw_response
|
117
|
-
when Hash
|
118
|
-
raw_response.each do |k, v|
|
119
|
-
k = k.to_sym
|
120
|
-
if FIELDS.include?(k)
|
121
|
-
@fields[to_internal_field(k)] = v # remove x_ from sym and stick in @fields
|
122
|
-
else
|
123
|
-
@custom_fields[k] = v
|
124
|
-
end
|
125
|
-
end
|
126
|
-
when String
|
127
|
-
# convert to hash and re-parse
|
128
|
-
hash = CGI::parse(raw_response)
|
129
|
-
hash.each do |k, v|
|
130
|
-
if v.kind_of?(Array) && v.length == 1
|
131
|
-
hash[k] = v[0]
|
132
|
-
end
|
133
|
-
end
|
134
|
-
parse_response(hash)
|
135
|
-
else
|
136
|
-
parse_response(@raw_response.to_s)
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
end
|
141
|
-
|
142
|
-
end
|
@@ -1,138 +0,0 @@
|
|
1
|
-
module AuthorizeNet::SIM
|
2
|
-
|
3
|
-
# The SIM transaction class. Handles building the transaction payload and
|
4
|
-
# generating a set of hidden form fields to be POSTed to the gateway.
|
5
|
-
class Transaction < AuthorizeNet::KeyValueTransaction
|
6
|
-
|
7
|
-
RANDOM_SEQUENCE_MAX = (1 << 32) - 1
|
8
|
-
|
9
|
-
# Our MD5 digest generator.
|
10
|
-
@@digest = OpenSSL::Digest.new('md5')
|
11
|
-
|
12
|
-
# The default options for the constructor.
|
13
|
-
@@option_defaults = {
|
14
|
-
:sequence => nil,
|
15
|
-
:timestamp => nil,
|
16
|
-
:test => false,
|
17
|
-
:hosted_payment_form => false,
|
18
|
-
:relay_response => true,
|
19
|
-
:relay_url => nil,
|
20
|
-
:transaction_type => Type::AUTHORIZE_AND_CAPTURE
|
21
|
-
}
|
22
|
-
|
23
|
-
# Constructs a SIM transaction. You can use the new SIM transaction object
|
24
|
-
# to build the hidden field payload needed to process a SIM transaction with
|
25
|
-
# the gateway. In particular, this class handles generating the MD5 fingerprint
|
26
|
-
# used to authenticate transactions at the gateway. Since the fingerprint includes
|
27
|
-
# the amount to charge, you should not construct this object until you know EXACTLY
|
28
|
-
# how much you want to charge (or authorize).
|
29
|
-
#
|
30
|
-
# +api_login_id+:: Your API login ID, as a string.
|
31
|
-
# +api_transaction_key+:: Your API transaction key, as a string.
|
32
|
-
# +amount+:: The amount of the transaction, as a string, Float or BigDecimal.
|
33
|
-
# +options+:: A hash of options. See below for values.
|
34
|
-
#
|
35
|
-
# Options
|
36
|
-
# +sequence+:: The sequence number of the transaction as a string or Integer. This is usually something like an invoice number. If none is provided, the SDK generates one at random.
|
37
|
-
# +timestamp+:: The time the transaction was initiated as a string or Integer. This needs to be within 15 minutes of when the gateway receives the transaction. If no value is provided, the SDK defaults it to Time.now().
|
38
|
-
# +test+:: A boolean indicating if the transaction should be run in test mode or not (defaults to false).
|
39
|
-
# +hosted_payment_form+:: A boolean indicating if the transaction should use a hosted payment form (defaults to false).
|
40
|
-
# +relay_response+:: A boolean indicating if the transaction should use the relay response feature to return a receipt to the customer (defaults to true). Direct Post Method requires using a relay response.
|
41
|
-
# +relay_url+:: A string of the URL that the gateway should hit to get the relay response (defaults to nil).
|
42
|
-
# +transaction_type+:: The type of transaction to perform. Defaults to AuthorizeNet::Type::AUTHORIZE_AND_CAPTURE. This value is only used if run is called directly.
|
43
|
-
#
|
44
|
-
def initialize(api_login_id, api_transaction_key, amount, options = {})
|
45
|
-
super()
|
46
|
-
@api_transaction_key = api_transaction_key
|
47
|
-
@api_login_id = api_login_id
|
48
|
-
@amount = decimal_to_value(amount)
|
49
|
-
options = @@option_defaults.merge(options)
|
50
|
-
@sequence = options[:sequence]
|
51
|
-
@timestamp = options[:timestamp]
|
52
|
-
@test_mode = options[:test]
|
53
|
-
@hosted_payment_form = options[:hosted_payment_form]
|
54
|
-
@relay_url = options[:relay_url]
|
55
|
-
@type = options[:transaction_type]
|
56
|
-
unless @relay_url.nil?
|
57
|
-
@relay_response = true
|
58
|
-
else
|
59
|
-
@relay_response = !!options[:relay_response]
|
60
|
-
end
|
61
|
-
@delim_data = !@relay_response
|
62
|
-
end
|
63
|
-
|
64
|
-
# Calculates and returns the HMAC-MD5 fingerprint needed to authenticate the transaction
|
65
|
-
# with the SIM gateway.
|
66
|
-
def fingerprint
|
67
|
-
if @timestamp.nil?
|
68
|
-
@timestamp = Time.now.to_i
|
69
|
-
end
|
70
|
-
|
71
|
-
if @sequence.nil?
|
72
|
-
@sequence = rand(RANDOM_SEQUENCE_MAX)
|
73
|
-
end
|
74
|
-
OpenSSL::HMAC.hexdigest(@@digest, @api_transaction_key, "#{@api_login_id.to_s.rstrip}^#{@sequence.to_s.rstrip}^#{@timestamp.to_s.rstrip}^#{@amount.to_s.rstrip}^")
|
75
|
-
end
|
76
|
-
|
77
|
-
# Returns all the fields needed for the fingerprint. These must all be passed to the SIM
|
78
|
-
# exactly as returned. And these values are time sensitive.
|
79
|
-
def fingerprint_fields
|
80
|
-
{
|
81
|
-
:login => @api_login_id,
|
82
|
-
:fp_hash => fingerprint,
|
83
|
-
:fp_sequence => @sequence,
|
84
|
-
:fp_timestamp => @timestamp,
|
85
|
-
:amount => @amount
|
86
|
-
}
|
87
|
-
end
|
88
|
-
|
89
|
-
# Returns all the fields (including custom) exactly as they should be named
|
90
|
-
# in the SIM form. Fields with multiple values are returned with an array
|
91
|
-
# for the key's value.
|
92
|
-
def form_fields
|
93
|
-
form_fields = {}
|
94
|
-
form_fields[:x_test_request] = boolean_to_value(@test_mode)
|
95
|
-
if @hosted_payment_form
|
96
|
-
form_fields[:x_show_form] = 'PAYMENT_FORM'
|
97
|
-
end
|
98
|
-
if @relay_response && !@relay_url.nil?
|
99
|
-
form_fields[:x_relay_url] = @relay_url
|
100
|
-
end
|
101
|
-
fields.merge(:type => @type, :version => @version, :delim_data => boolean_to_value(@delim_data), :relay_response => boolean_to_value(@relay_response)).each do |k, v|
|
102
|
-
form_fields[to_external_field(k)] = v
|
103
|
-
end
|
104
|
-
fingerprint_fields.each do |k, v|
|
105
|
-
form_fields[to_external_field(k)] = v
|
106
|
-
end
|
107
|
-
form_fields.merge(custom_fields)
|
108
|
-
end
|
109
|
-
|
110
|
-
|
111
|
-
# Takes an instance of AuthorizeNet::SIM::HostedPaymentForm and adds it to the transaction. Note that
|
112
|
-
# many of the fields in AuthorizeNet::SIM::HostedPaymentForm are shared with those in
|
113
|
-
# AuthorizeNet::SIM::HostedReceiptPage. For the duplicate fields, which ever value
|
114
|
-
# is added to the transaction last will be the one used.
|
115
|
-
def set_hosted_payment_form(form)
|
116
|
-
@fields.merge!(form.to_hash)
|
117
|
-
@hosted_payment_form = true
|
118
|
-
end
|
119
|
-
|
120
|
-
# Takes an instance of AuthorizeNet::SIM::HostedReceiptPage and adds it to the transaction. Note that
|
121
|
-
# many of the fields in AuthorizeNet::SIM::HostedReceiptPage are shared with those in
|
122
|
-
# AuthorizeNet::SIM::HostedPaymentForm. For the duplicate fields, which ever value
|
123
|
-
# is added to the transaction last will be the one used. If you set a hosted payment receipt,
|
124
|
-
# the relay response will be disabled.
|
125
|
-
def set_hosted_payment_receipt(form)
|
126
|
-
@fields.merge!(form.to_hash)
|
127
|
-
@relay_response = false
|
128
|
-
@delim_data = true
|
129
|
-
end
|
130
|
-
|
131
|
-
# An alias for form_fields.
|
132
|
-
def run
|
133
|
-
form_fields
|
134
|
-
end
|
135
|
-
|
136
|
-
end
|
137
|
-
|
138
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
require 'rails/generators'
|
2
|
-
require 'rails/generators/named_base'
|
3
|
-
|
4
|
-
module AuthorizeNet
|
5
|
-
module Generators
|
6
|
-
class DirectPostGenerator < Rails::Generators::NamedBase
|
7
|
-
source_root File.expand_path("../templates", __FILE__)
|
8
|
-
p '__FILE__:' + __FILE__
|
9
|
-
p 'source_root:' + source_root
|
10
|
-
argument :api_login_id, :type => :string, :desc => 'Your Authorize.Net API login ID.', :optional => true
|
11
|
-
argument :api_transaction_key, :type => :string, :desc => 'Your Authorize.Net API transaction key.', :optional => true
|
12
|
-
argument :merchant_hash_value, :type => :string, :desc => 'Your Authorize.Net merchant hash value.', :optional => true
|
13
|
-
desc <<-DESC
|
14
|
-
Description
|
15
|
-
Generates a simple implementation of Authorize.Net's Direct Post Method integration method.
|
16
|
-
|
17
|
-
Example:
|
18
|
-
rails generate authorize_net:direct_post payments API_LOGIN_ID API_TRANSACTION_KEY MERCHANT_HASH_VALUE
|
19
|
-
|
20
|
-
This will create:
|
21
|
-
create README-AuthorizeNet
|
22
|
-
create app/views/payments
|
23
|
-
create app/views/payments/payment.erb
|
24
|
-
create app/views/payments/receipt.erb
|
25
|
-
create app/views/payments/relay_response.erb
|
26
|
-
create app/views/layouts/authorize_net.erb
|
27
|
-
create config/authorize_net.yml
|
28
|
-
create config/initializers/authorize_net.rb
|
29
|
-
create app/controllers/payments_controller.rb
|
30
|
-
route match '/payments/receipt', :to => 'payments#receipt', :as => 'payments_receipt', :via => [:get]
|
31
|
-
route match '/payments/relay_response', :to => 'payments#relay_response', :as => 'payments_relay_response', :via => [:post]
|
32
|
-
route match '/payments/payment', :to => 'payments#payment', :as => 'paymentspayment', :via => [:get]
|
33
|
-
|
34
|
-
DESC
|
35
|
-
|
36
|
-
def manifest
|
37
|
-
copy_file "README-AuthorizeNet", "README-AuthorizeNet"
|
38
|
-
empty_directory "app/views/#{file_name}"
|
39
|
-
copy_file "payment.rails3.erb", "app/views/#{file_name}/payment.erb"
|
40
|
-
copy_file "receipt.erb", "app/views/#{file_name}/receipt.erb"
|
41
|
-
copy_file "relay_response.erb", "app/views/#{file_name}/relay_response.erb"
|
42
|
-
copy_file "layout.erb", "app/views/layouts/authorize_net.erb"
|
43
|
-
template "config.yml.rails3.erb", "config/authorize_net.yml"
|
44
|
-
copy_file "initializer.rb", "config/initializers/authorize_net.rb"
|
45
|
-
template "controller.rb.erb", "app/controllers/#{file_name}_controller.rb"
|
46
|
-
route "match '/#{plural_name}/receipt', :to => '#{file_name}#receipt', :as => '#{singular_name}_receipt', :via => [:get]"
|
47
|
-
route "match '/#{plural_name}/relay_response', :to => '#{file_name}#relay_response', :as => '#{singular_name}_relay_response', :via => [:post]"
|
48
|
-
route "match '/#{plural_name}/payment', :to => '#{file_name}#payment', :as => '#{singular_name}payment', :via => [:get]"
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
= Authorize.Net Ruby SDK
|
2
|
-
|
3
|
-
The Authorize.Net Ruby SDK is meant to offer an alternate object-oriented
|
4
|
-
model of development with the Authorize.net APIs (Version 3.1). The SDK is
|
5
|
-
based entirely off the name-value pair API, but performs the core payment
|
6
|
-
activities (such as error handling/parsing, network communication, and data
|
7
|
-
encoding) behind the scenes. Providing the end developer with this allows the
|
8
|
-
developer to start integrating immediately without having to write out a mass
|
9
|
-
of boiler plate code.
|
10
|
-
|
11
|
-
== Prerequisites
|
12
|
-
|
13
|
-
* Ruby 1.8.7 or higher
|
14
|
-
* RubyGem 1.3.7 or higher (to build the gem)
|
15
|
-
* RDoc 1.0 or higher (to build documentation)
|
16
|
-
* Rake 0.8.7 or higher (to use the rake tasks)
|
17
|
-
|
18
|
-
== Installation
|
19
|
-
|
20
|
-
Goto the Authorize.Net SDK download page and download the Ruby gem. Then
|
21
|
-
|
22
|
-
> gem install authorize-net-1.0.0.gem
|
23
|
-
|
24
|
-
== Usage
|
25
|
-
|
26
|
-
A generator is provided to aid in setting up a Direct Post Method application. In the example below 'payments' is the name of the controller to generate.
|
27
|
-
|
28
|
-
> sudo gem install rails -v '~> 2.1'
|
29
|
-
> rails my_direct_post_app
|
30
|
-
> cd my_direct_post_app
|
31
|
-
> script/generate authorize_net_direct_post payments YOUR_API_LOGIN_ID YOUR_TRANSACTION_KEY MERCH_HASH_KEY
|
32
|
-
> script/server
|
33
|
-
|
34
|
-
After running the generator you will probably want to customize the payment form found in 'app/views/payments/payment.erb' and the receipt found in 'app/views/payments/receipt.erb'.
|
35
|
-
|
36
|
-
There is also a default layout generated, 'app/views/layouts/authorize_net.erb'. If you already have your own layout, you can delete that file and the reference to it in the controller ('app/controllers/payments_controller.rb').
|
37
|
-
|
38
|
-
|
39
|
-
== Credit Card Test Numbers
|
40
|
-
|
41
|
-
For your reference, you can use the following test credit card numbers.
|
42
|
-
The expiration date must be set to the present date or later. Use 123 for
|
43
|
-
the CCV code.
|
44
|
-
|
45
|
-
American Express:: 370000000000002
|
46
|
-
Discover:: 6011000000000012
|
47
|
-
Visa:: 4007000000027
|
48
|
-
JCB:: 3088000000000017
|
49
|
-
Diners Club/ Carte Blanche:: 38000000000006
|