authorize-net 1.5.2
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.
- 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
data/License.pdf
ADDED
Binary file
|
data/README.rdoc
ADDED
@@ -0,0 +1,124 @@
|
|
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
|
+
* Nokogiri 1.4.3 or higher
|
15
|
+
* RubyGem 1.3.7 or higher (to build the gem)
|
16
|
+
* RDoc 1.0 or higher (to build documentation)
|
17
|
+
* Rake 0.8.7 or higher (to use the rake tasks)
|
18
|
+
|
19
|
+
== Installation
|
20
|
+
|
21
|
+
Goto the Authorize.Net SDK download page and download the Ruby gem. Then
|
22
|
+
|
23
|
+
> gem install authorize-net-1.5.1.gem
|
24
|
+
|
25
|
+
== Usage
|
26
|
+
|
27
|
+
=== Advanced Merchant Integration (AIM)
|
28
|
+
|
29
|
+
require 'rubygems'
|
30
|
+
require 'authorize_net'
|
31
|
+
|
32
|
+
transaction = AuthorizeNet::AIM::Transaction.new('API_LOGIN', 'API_KEY', :gateway => :sandbox)
|
33
|
+
credit_card = AuthorizeNet::CreditCard.new('4111111111111111', '1120')
|
34
|
+
response = transaction.purchase('10.00', credit_card)
|
35
|
+
|
36
|
+
if response.success?
|
37
|
+
puts "Successfully made a purchase (authorization code: #{response.authorization_code})"
|
38
|
+
else
|
39
|
+
raise "Failed to make purchase."
|
40
|
+
end
|
41
|
+
|
42
|
+
=== Direct Post Method (DPM)
|
43
|
+
|
44
|
+
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.
|
45
|
+
|
46
|
+
> sudo gem install rails -v '~> 2.1'
|
47
|
+
> rails my_direct_post_app
|
48
|
+
> cd my_direct_post_app
|
49
|
+
> script/generate authorize_net_direct_post payments YOUR_API_LOGIN_ID YOUR_TRANSACTION_KEY MERCH_HASH_KEY
|
50
|
+
> script/server
|
51
|
+
|
52
|
+
After running the generator you will probably want to customize the payment form found in <tt>app/views/payments/payment.erb</tt> and the receipt found in <tt>app/views/payments/receipt.erb</tt>.
|
53
|
+
|
54
|
+
There is also a default layout generated, <tt>app/views/layouts/authorize_net.erb</tt>. If you already have your own layout, you can delete that file and the reference to it in the controller (<tt>app/controllers/payments_controller.rb</tt>).
|
55
|
+
|
56
|
+
=== Server Integration Method (SIM)
|
57
|
+
|
58
|
+
A generator is provided to aid in setting up a Server Integration Method application. In the example below +payments+ is the name of the controller to generate.
|
59
|
+
|
60
|
+
> sudo gem install rails -v '~> 2.1'
|
61
|
+
> rails my_sim_app
|
62
|
+
> cd my_sim_app
|
63
|
+
> script/generate authorize_net_sim payments YOUR_API_LOGIN_ID YOUR_TRANSACTION_KEY MERCH_HASH_KEY
|
64
|
+
> script/server
|
65
|
+
|
66
|
+
After running the generator you will probably want to customize the payment page found in <tt>app/views/payments/payment.erb</tt> and the thank you page found in <tt>app/views/payments/thank_you.erb</tt>.
|
67
|
+
|
68
|
+
You may also want to customize the actual payment form and receipt pages. That can be done by making the necessary changes to the AuthorizeNet::SIM::Transaction object (<tt>@sim_transaction</tt>) found in the +payment+ action in <tt>app/controllers/payments_controller.rb</tt>. The styling of those hosted pages are controlled by the AuthorizeNet::SIM::HostedReceiptPage and AuthorizeNet::SIM::HostedPaymentForm objects (which are passed to the AuthorizeNet::SIM::Transaction).
|
69
|
+
|
70
|
+
There is also a default layout generated, <tt>app/views/layouts/authorize_net.erb</tt>. If you already have your own layout, you can delete that file and the reference to it in the controller (<tt>app/controllers/payments_controller.rb</tt>).
|
71
|
+
|
72
|
+
=== Automated Recurring Billing (ARB)
|
73
|
+
|
74
|
+
require 'rubygems'
|
75
|
+
require 'authorize_net'
|
76
|
+
|
77
|
+
transaction = AuthorizeNet::ARB::Transaction.new('API_LOGIN', 'API_KEY', :gateway => :sandbox)
|
78
|
+
subscription = AuthorizeNet::ARB::Subscription.new(
|
79
|
+
:name => "Monthly Gift Basket",
|
80
|
+
:length => 1,
|
81
|
+
:unit => :month,
|
82
|
+
:start_date => Date.today,
|
83
|
+
:total_occurrences => :unlimited,
|
84
|
+
:amount => 100.00,
|
85
|
+
:invoice_number => '1234567',
|
86
|
+
:description => "John Doe's Monthly Gift Basket",
|
87
|
+
:credit_card => AuthorizeNet::CreditCard.new('4111111111111111', '1120'),
|
88
|
+
:billing_address => AuthorizeNet::Address.new(:first_name => 'John', :last_name => 'Doe')
|
89
|
+
)
|
90
|
+
response = transaction.create(subscription)
|
91
|
+
|
92
|
+
if response.success?
|
93
|
+
puts "Successfully created a subscription (subscription id: #{response.subscription_id})"
|
94
|
+
else
|
95
|
+
raise "Failed to create a subscription."
|
96
|
+
end
|
97
|
+
|
98
|
+
=== Card Present (CP)
|
99
|
+
|
100
|
+
require 'rubygems'
|
101
|
+
require 'authorize_net'
|
102
|
+
|
103
|
+
transaction = AuthorizeNet::AIM::Transaction.new('API_LOGIN', 'API_KEY', :gateway => :card_present_sandbox)
|
104
|
+
credit_card = AuthorizeNet::CreditCard.new(nil, nil, :track_1 => '%B4111111111111111^DOE/JOHN^1803101000000000020000831000000?')
|
105
|
+
response = transaction.purchase('10.00', credit_card)
|
106
|
+
|
107
|
+
if response.success?
|
108
|
+
puts "Successfully made a purchase (authorization code: #{response.authorization_code})"
|
109
|
+
else
|
110
|
+
raise "Failed to make purchase."
|
111
|
+
end
|
112
|
+
|
113
|
+
== Credit Card Test Numbers
|
114
|
+
|
115
|
+
For your reference, you can use the following test credit card numbers.
|
116
|
+
The expiration date must be set to the present date or later. Use 123 for
|
117
|
+
the CCV code.
|
118
|
+
|
119
|
+
American Express:: 370000000000002
|
120
|
+
Discover:: 6011000000000012
|
121
|
+
Visa:: 4007000000027
|
122
|
+
JCB:: 3088000000000017
|
123
|
+
Diners Club/ Carte Blanche:: 38000000000006
|
124
|
+
Visa (Card Present Track 1):: %B4111111111111111^DOE/JOHN^1803101000000000020000831000000?
|
data/Rakefile
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
require "rake"
|
2
|
+
require "spec/rake/spectask"
|
3
|
+
|
4
|
+
task :default => :spec
|
5
|
+
desc "Run all specs"
|
6
|
+
Spec::Rake::SpecTask.new('spec') do |t|
|
7
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
8
|
+
t.spec_opts = ['--options', 'spec/spec.opts']
|
9
|
+
end
|
10
|
+
|
11
|
+
namespace "spec" do
|
12
|
+
desc "Run the CIM spec"
|
13
|
+
Spec::Rake::SpecTask.new('cim') do |t|
|
14
|
+
t.spec_files = FileList['spec/cim_spec.rb']
|
15
|
+
t.spec_opts = ['--options', 'spec/spec.opts']
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "Run the ARB spec"
|
19
|
+
Spec::Rake::SpecTask.new('arb') do |t|
|
20
|
+
t.spec_files = FileList['spec/arb_spec.rb']
|
21
|
+
t.spec_opts = ['--options', 'spec/spec.opts']
|
22
|
+
end
|
23
|
+
|
24
|
+
desc "Run the AIM spec"
|
25
|
+
Spec::Rake::SpecTask.new('aim') do |t|
|
26
|
+
t.spec_files = FileList['spec/aim_spec.rb']
|
27
|
+
t.spec_opts = ['--options', 'spec/spec.opts']
|
28
|
+
end
|
29
|
+
|
30
|
+
desc "Run the SIM spec"
|
31
|
+
Spec::Rake::SpecTask.new('sim') do |t|
|
32
|
+
t.spec_files = FileList['spec/sim_spec.rb']
|
33
|
+
t.spec_opts = ['--options', 'spec/spec.opts']
|
34
|
+
end
|
35
|
+
|
36
|
+
desc "Run the Reporting spec"
|
37
|
+
Spec::Rake::SpecTask.new('reporting') do |t|
|
38
|
+
t.spec_files = FileList['spec/reporting_spec.rb']
|
39
|
+
t.spec_opts = ['--options', 'spec/spec.opts']
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
desc "Builds the gem"
|
44
|
+
task :gem do
|
45
|
+
%x"gem build authorize-net.gemspec"
|
46
|
+
end
|
47
|
+
|
48
|
+
desc "Builds the documentation"
|
49
|
+
task :doc do
|
50
|
+
%x"rdoc -U -S --main=README.rdoc -A documented_accessor=RW README.rdoc lib/"
|
51
|
+
end
|
52
|
+
|
53
|
+
namespace "doc" do
|
54
|
+
desc "Builds the documentation with graphical class hierarchy"
|
55
|
+
task :graph do
|
56
|
+
%x"rdoc -U -d -S --main=README.rdoc -A documented_accessor=RW README.rdoc lib/"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
desc "Builds the documentation (alias of :doc)"
|
61
|
+
task :rdoc do
|
62
|
+
Rake::Task[:doc].execute
|
63
|
+
end
|
64
|
+
|
65
|
+
desc "Bundles the sample app."
|
66
|
+
task :samples do
|
67
|
+
%x". sample_app_version && zip -r anet_ruby_samples-$VERSION.zip sample_app -x '*/.*' -x '*/Icon' -x '*/__MACOSX'"
|
68
|
+
end
|
69
|
+
|
70
|
+
desc "Bundles the sample app and gem."
|
71
|
+
task :bundle do
|
72
|
+
Rake::Task[:samples].execute
|
73
|
+
Rake::Task[:gem].execute
|
74
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Description:
|
2
|
+
Generates a simple implementation of Authorize.Net's Direct Post Method integration method.
|
3
|
+
|
4
|
+
Example:
|
5
|
+
./script/generate authorize_net_direct_post payments API_LOGIN_ID API_TRANSACTION_KEY MERCHANT_HASH_VALUE
|
6
|
+
|
7
|
+
This will create:
|
8
|
+
README-AuthorizeNet
|
9
|
+
app/views/payments
|
10
|
+
app/views/payments/payment.erb
|
11
|
+
app/views/payments/receipt.erb
|
12
|
+
app/views/payments/relay_response.erb
|
13
|
+
app/views/layouts/authorize_net.erb
|
14
|
+
config/authorize_net.yml
|
15
|
+
config/initializers/authorize_net.rb
|
16
|
+
app/controller/payments_controller.rb
|
17
|
+
route payment_payment
|
18
|
+
route payment_receipt
|
19
|
+
route payment_relay_response
|
20
|
+
gem authorize-net
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'generator_extensions.rb')
|
2
|
+
|
3
|
+
class AuthorizeNetDirectPostGenerator < Rails::Generator::NamedBase
|
4
|
+
def manifest
|
5
|
+
record do |m|
|
6
|
+
m.file "README-AuthorizeNet", "README-AuthorizeNet"
|
7
|
+
m.directory "app/views/#{file_name}"
|
8
|
+
m.file "payment.erb", "app/views/#{file_name}/payment.erb"
|
9
|
+
m.file "receipt.erb", "app/views/#{file_name}/receipt.erb"
|
10
|
+
m.file "relay_response.erb", "app/views/#{file_name}/relay_response.erb"
|
11
|
+
m.file "layout.erb", "app/views/layouts/authorize_net.erb"
|
12
|
+
m.template "config.yml.erb", "config/authorize_net.yml"
|
13
|
+
m.file "initializer.rb", "config/initializers/authorize_net.rb"
|
14
|
+
m.template "controller.rb.erb", "app/controllers/#{file_name}_controller.rb"
|
15
|
+
m.route :name => "#{singular_name}_receipt", :path => "/#{plural_name}/receipt", :controller => file_name, :action => 'receipt', :conditions => "{:method => :get}"
|
16
|
+
m.route :name => "#{singular_name}_relay_response", :path => "/#{plural_name}/relay_response", :controller => file_name, :action => 'relay_response', :conditions => "{:method => :post}"
|
17
|
+
m.route :name => "#{singular_name}_payment", :path => "/#{plural_name}/payment", :controller => file_name, :action => 'payment', :conditions => "{:method => :get}"
|
18
|
+
m.gem :name => 'authorize-net'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,49 @@
|
|
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
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class <%= class_name %>Controller < ApplicationController
|
2
|
+
|
3
|
+
layout 'authorize_net'
|
4
|
+
helper :authorize_net
|
5
|
+
protect_from_forgery :except => :relay_response
|
6
|
+
|
7
|
+
# GET
|
8
|
+
# Displays a payment form.
|
9
|
+
def payment
|
10
|
+
@amount = 10.00
|
11
|
+
@sim_transaction = AuthorizeNet::SIM::Transaction.new(AUTHORIZE_NET_CONFIG['api_login_id'], AUTHORIZE_NET_CONFIG['api_transaction_key'], @amount, :relay_url => <%= singular_name %>_relay_response_url(:only_path => false))
|
12
|
+
end
|
13
|
+
|
14
|
+
# POST
|
15
|
+
# Returns relay response when Authorize.Net POSTs to us.
|
16
|
+
def relay_response
|
17
|
+
sim_response = AuthorizeNet::SIM::Response.new(params)
|
18
|
+
if sim_response.success?(AUTHORIZE_NET_CONFIG['api_login_id'], AUTHORIZE_NET_CONFIG['merchant_hash_value'])
|
19
|
+
render :text => sim_response.direct_post_reply(<%= singular_name %>_receipt_url(:only_path => false), :include => true)
|
20
|
+
else
|
21
|
+
render
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# GET
|
26
|
+
# Displays a receipt.
|
27
|
+
def receipt
|
28
|
+
@auth_code = params[:x_auth_code]
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Direct Post Sample App</title>
|
5
|
+
<style>
|
6
|
+
body {
|
7
|
+
text-align: center;
|
8
|
+
font-family: Helvetica;
|
9
|
+
}
|
10
|
+
label {
|
11
|
+
display: block;
|
12
|
+
}
|
13
|
+
</style>
|
14
|
+
</head>
|
15
|
+
<body>
|
16
|
+
<%= yield %>
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<% form_for :sim_transaction, :url => AuthorizeNet::SIM::Transaction::Gateway::TEST do |f| %>
|
2
|
+
<%= sim_fields(@sim_transaction) %>
|
3
|
+
<%= label_tag 'x_amount', "Total: #{number_to_currency(@amount)}" %>
|
4
|
+
<%= label_tag 'x_card_num', 'Credit Card Number'%>
|
5
|
+
<%= text_field_tag 'x_card_num' %>
|
6
|
+
<%= label_tag 'x_exp_date', 'Expiration Date (MMYY)'%>
|
7
|
+
<%= text_field_tag 'x_exp_date' %>
|
8
|
+
<br />
|
9
|
+
<%= f.submit 'Purchase'%>
|
10
|
+
<% end %>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<%= form_for :sim_transaction, :url => AuthorizeNet::SIM::Transaction::Gateway::TEST do |f| %>
|
2
|
+
<%= sim_fields(@sim_transaction) %>
|
3
|
+
<%= label_tag 'x_amount', "Total: #{number_to_currency(@amount)}" %>
|
4
|
+
<%= label_tag 'x_card_num', 'Credit Card Number'%>
|
5
|
+
<%= text_field_tag 'x_card_num' %>
|
6
|
+
<%= label_tag 'x_exp_date', 'Expiration Date (MMYY)'%>
|
7
|
+
<%= text_field_tag 'x_exp_date' %>
|
8
|
+
<br />
|
9
|
+
<%= f.submit 'Purchase'%>
|
10
|
+
<% end %>
|
@@ -0,0 +1 @@
|
|
1
|
+
Thanks for your purchase! Your authorization code is <%=h @auth_code %>.
|
@@ -0,0 +1 @@
|
|
1
|
+
Sorry, something went wrong, please try your transaction again.
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Description:
|
2
|
+
Generates a simple implementation of Authorize.Net's SIM integration method.
|
3
|
+
|
4
|
+
Example:
|
5
|
+
./script/generate authorize_net_sim payments API_LOGIN_ID API_TRANSACTION_KEY MERCHANT_HASH_VALUE
|
6
|
+
|
7
|
+
This will create:
|
8
|
+
README-AuthorizeNet
|
9
|
+
app/views/payments
|
10
|
+
app/views/payments/payment.erb
|
11
|
+
app/views/payments/receipt.erb
|
12
|
+
app/views/payments/relay_response.erb
|
13
|
+
app/views/layouts/authorize_net.erb
|
14
|
+
config/authorize_net.yml
|
15
|
+
config/initializers/authorize_net.rb
|
16
|
+
app/controller/payments_controller.rb
|
17
|
+
route payment_payment
|
18
|
+
route payment_receipt
|
19
|
+
route payment_relay_response
|
20
|
+
gem authorize-net
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'generator_extensions.rb')
|
2
|
+
|
3
|
+
class AuthorizeNetSimGenerator < Rails::Generator::NamedBase
|
4
|
+
def manifest
|
5
|
+
record do |m|
|
6
|
+
m.file "README-AuthorizeNet", "README-AuthorizeNet"
|
7
|
+
m.directory "app/views/#{file_name}"
|
8
|
+
m.file "payment.erb", "app/views/#{file_name}/payment.erb"
|
9
|
+
m.file "thank_you.erb", "app/views/#{file_name}/thank_you.erb"
|
10
|
+
m.file "layout.erb", "app/views/layouts/authorize_net.erb"
|
11
|
+
m.template "config.yml.erb", "config/authorize_net.yml"
|
12
|
+
m.file "initializer.rb", "config/initializers/authorize_net.rb"
|
13
|
+
m.template "controller.rb.erb", "app/controllers/#{file_name}_controller.rb"
|
14
|
+
m.route :name => "#{singular_name}_thank_you", :path => "/#{plural_name}/thank_you", :controller => file_name, :action => 'thank_you', :conditions => "{:method => :get}"
|
15
|
+
m.route :name => "#{singular_name}_payment", :path => "/#{plural_name}/payment", :controller => file_name, :action => 'payment', :conditions => "{:method => :get}"
|
16
|
+
m.gem :name => 'authorize-net'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,52 @@
|
|
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
|
+
=== Server Integration Method (SIM)
|
27
|
+
|
28
|
+
A generator is provided to aid in setting up a Server Integration Method application. In the example below 'payments' is the name of the controller to generate.
|
29
|
+
|
30
|
+
> sudo gem install rails -v '~> 2.1'
|
31
|
+
> rails my_sim_app
|
32
|
+
> cd my_sim_app
|
33
|
+
> script/generate authorize_net_sim payments YOUR_API_LOGIN_ID YOUR_TRANSACTION_KEY MERCH_HASH_KEY
|
34
|
+
> script/server
|
35
|
+
|
36
|
+
After running the generator you will probably want to customize the payment page found in 'app/views/payments/payment.erb' and the thank you page found in 'app/views/payments/thank_you.erb'.
|
37
|
+
|
38
|
+
You may also want to customize the actual payment form and receipt pages. That can be done by making the necessary changes to the AuthorizeNet::SIM::Transaction object ('@sim_transaction') found in the +payment+ action in 'app/controllers/payments_controller.rb'. The styling of those hosted pages are controlled by the AuthorizeNet::SIM::HostedReceiptPage and AuthorizeNet::SIM::HostedPaymentForm objects (which are passed to the AuthorizeNet::SIM::Transaction).
|
39
|
+
|
40
|
+
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').
|
41
|
+
|
42
|
+
== Credit Card Test Numbers
|
43
|
+
|
44
|
+
For your reference, you can use the following test credit card numbers.
|
45
|
+
The expiration date must be set to the present date or later. Use 123 for
|
46
|
+
the CCV code.
|
47
|
+
|
48
|
+
American Express:: 370000000000002
|
49
|
+
Discover:: 6011000000000012
|
50
|
+
Visa:: 4007000000027
|
51
|
+
JCB:: 3088000000000017
|
52
|
+
Diners Club/ Carte Blanche:: 38000000000006
|