authorizenet 1.9.6 → 1.9.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +5 -5
  2. data/lib/app/helpers/authorize_net_helper.rb +23 -23
  3. data/lib/authorize_net.rb +107 -107
  4. data/lib/authorize_net/addresses/address.rb +25 -25
  5. data/lib/authorize_net/addresses/shipping_address.rb +22 -22
  6. data/lib/authorize_net/aim/response.rb +120 -120
  7. data/lib/authorize_net/aim/transaction.rb +171 -171
  8. data/lib/authorize_net/api/LogHelper.rb +97 -0
  9. data/lib/authorize_net/api/SensitiveDataFilter.rb +92 -0
  10. data/lib/authorize_net/api/api_transaction.rb +129 -119
  11. data/lib/authorize_net/api/constants.yml +1 -1
  12. data/lib/authorize_net/api/schema.rb +5421 -5165
  13. data/lib/authorize_net/api/transaction.rb +265 -261
  14. data/lib/authorize_net/arb/fields.rb +24 -24
  15. data/lib/authorize_net/arb/paging.rb +29 -29
  16. data/lib/authorize_net/arb/response.rb +26 -26
  17. data/lib/authorize_net/arb/sorting.rb +39 -39
  18. data/lib/authorize_net/arb/subscription.rb +68 -68
  19. data/lib/authorize_net/arb/subscription_detail.rb +10 -10
  20. data/lib/authorize_net/arb/subscription_list_response.rb +36 -36
  21. data/lib/authorize_net/arb/transaction.rb +171 -171
  22. data/lib/authorize_net/authorize_net.rb +154 -154
  23. data/lib/authorize_net/cim/customer_profile.rb +15 -15
  24. data/lib/authorize_net/cim/payment_profile.rb +35 -35
  25. data/lib/authorize_net/cim/response.rb +111 -111
  26. data/lib/authorize_net/cim/transaction.rb +721 -721
  27. data/lib/authorize_net/customer.rb +24 -24
  28. data/lib/authorize_net/email_receipt.rb +20 -20
  29. data/lib/authorize_net/fields.rb +760 -760
  30. data/lib/authorize_net/key_value_response.rb +109 -109
  31. data/lib/authorize_net/key_value_transaction.rb +281 -281
  32. data/lib/authorize_net/line_item.rb +21 -21
  33. data/lib/authorize_net/order.rb +38 -38
  34. data/lib/authorize_net/payment_methods/credit_card.rb +61 -61
  35. data/lib/authorize_net/payment_methods/echeck.rb +70 -70
  36. data/lib/authorize_net/reporting/batch.rb +16 -16
  37. data/lib/authorize_net/reporting/batch_statistics.rb +15 -15
  38. data/lib/authorize_net/reporting/fds_filter.rb +8 -8
  39. data/lib/authorize_net/reporting/response.rb +157 -157
  40. data/lib/authorize_net/reporting/returned_item.rb +45 -45
  41. data/lib/authorize_net/reporting/transaction.rb +131 -131
  42. data/lib/authorize_net/reporting/transaction_details.rb +22 -22
  43. data/lib/authorize_net/response.rb +25 -25
  44. data/lib/authorize_net/sim/hosted_payment_form.rb +34 -34
  45. data/lib/authorize_net/sim/hosted_receipt_page.rb +32 -32
  46. data/lib/authorize_net/sim/response.rb +133 -133
  47. data/lib/authorize_net/sim/transaction.rb +128 -128
  48. data/lib/authorize_net/transaction.rb +66 -66
  49. data/lib/authorize_net/xml_response.rb +154 -154
  50. data/lib/authorize_net/xml_transaction.rb +279 -279
  51. data/lib/authorizenet.rb +4 -4
  52. data/lib/generators/authorize_net/direct_post/direct_post_generator.rb +52 -52
  53. data/lib/generators/authorize_net/direct_post/templates/README-AuthorizeNet +48 -48
  54. data/lib/generators/authorize_net/direct_post/templates/config.yml.erb +8 -8
  55. data/lib/generators/authorize_net/direct_post/templates/config.yml.rails3.erb +8 -8
  56. data/lib/generators/authorize_net/direct_post/templates/controller.rb.erb +30 -30
  57. data/lib/generators/authorize_net/direct_post/templates/initializer.rb +4 -4
  58. data/lib/generators/authorize_net/direct_post/templates/layout.erb +17 -17
  59. data/lib/generators/authorize_net/direct_post/templates/payment.erb +9 -9
  60. data/lib/generators/authorize_net/direct_post/templates/payment.rails3.erb +9 -9
  61. data/lib/generators/authorize_net/sim/sim_generator.rb +46 -46
  62. data/lib/generators/authorize_net/sim/templates/README-AuthorizeNet +51 -51
  63. data/lib/generators/authorize_net/sim/templates/config.yml.erb +8 -8
  64. data/lib/generators/authorize_net/sim/templates/config.yml.rails3.erb +8 -8
  65. data/lib/generators/authorize_net/sim/templates/controller.rb.erb +20 -20
  66. data/lib/generators/authorize_net/sim/templates/initializer.rb +4 -4
  67. data/lib/generators/authorize_net/sim/templates/layout.erb +17 -17
  68. data/lib/generators/authorize_net/sim/templates/payment.erb +5 -5
  69. data/lib/generators/authorize_net/sim/templates/payment.rails3.erb +5 -5
  70. data/lib/generators/generator_extensions.rb +73 -73
  71. metadata +5 -3
@@ -1,4 +1,4 @@
1
- # This file is just here to avoid obnoxious gem name/require name issues. All this
2
- # file does is require authorize_net.rb, the real initialization file.
3
-
4
- require 'authorize_net'
1
+ # This file is just here to avoid obnoxious gem name/require name issues. All this
2
+ # file does is require authorize_net.rb, the real initialization file.
3
+
4
+ require 'authorize_net'
@@ -1,52 +1,52 @@
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', __dir__)
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
- end
51
- end
52
- end
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', __dir__)
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
+ end
51
+ end
52
+ end
@@ -1,49 +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
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
49
  Diners Club/ Carte Blanche:: 38000000000006
@@ -1,8 +1,8 @@
1
- default:
2
- api_login_id: <%= args[0] %>
3
- api_transaction_key: <%= args[1] %>
4
- merchant_hash_value: <%= args[2] %>
5
-
6
- development:
7
- test:
8
- production:
1
+ default:
2
+ api_login_id: <%= args[0] %>
3
+ api_transaction_key: <%= args[1] %>
4
+ merchant_hash_value: <%= args[2] %>
5
+
6
+ development:
7
+ test:
8
+ production:
@@ -1,8 +1,8 @@
1
- default:
2
- api_login_id: <%= self.api_login_id %>
3
- api_transaction_key: <%= self.api_transaction_key %>
4
- merchant_hash_value: <%= self.merchant_hash_value %>
5
-
6
- development:
7
- test:
8
- production:
1
+ default:
2
+ api_login_id: <%= self.api_login_id %>
3
+ api_transaction_key: <%= self.api_transaction_key %>
4
+ merchant_hash_value: <%= self.merchant_hash_value %>
5
+
6
+ development:
7
+ test:
8
+ production:
@@ -1,31 +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
-
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
31
  end
@@ -1,4 +1,4 @@
1
- yml = YAML.load_file("#{Rails.root}/config/authorize_net.yml")
2
- AUTHORIZE_NET_CONFIG = yml['default']
3
- AUTHORIZE_NET_CONFIG.merge!(yml[Rails.env]) unless yml[Rails.env].nil?
4
- AUTHORIZE_NET_CONFIG.freeze
1
+ yml = YAML.load_file("#{Rails.root}/config/authorize_net.yml")
2
+ AUTHORIZE_NET_CONFIG = yml['default']
3
+ AUTHORIZE_NET_CONFIG.merge!(yml[Rails.env]) unless yml[Rails.env].nil?
4
+ AUTHORIZE_NET_CONFIG.freeze
@@ -1,18 +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>
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
18
  </html>
@@ -1,10 +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'%>
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
10
  <% end %>
@@ -1,10 +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'%>
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
10
  <% end %>
@@ -1,46 +1,46 @@
1
- require 'rails/generators'
2
- require 'rails/generators/named_base'
3
-
4
- module AuthorizeNet
5
- module Generators
6
- class SimGenerator < Rails::Generators::NamedBase
7
- source_root File.expand_path('templates', __dir__)
8
- argument :api_login_id, type: :string, desc: 'Your Authorize.Net API login ID.', optional: true
9
- argument :api_transaction_key, type: :string, desc: 'Your Authorize.Net API transaction key.', optional: true
10
- argument :merchant_hash_value, type: :string, desc: 'Your Authorize.Net merchant hash value.', optional: true
11
- desc <<-DESC
12
- Description
13
- Generates a simple implementation of Authorize.Net's SIM integration method.
14
-
15
- Example:
16
- rails generate authorize_net:sim payments API_LOGIN_ID API_TRANSACTION_KEY MERCHANT_HASH_VALUE
17
-
18
- This will create:
19
- create README-AuthorizeNet
20
- create app/views/payments
21
- create app/views/payments/payment.erb
22
- create app/views/payments/thank_you.erb
23
- create app/views/layouts/authorize_net.erb
24
- create config/authorize_net.yml
25
- create config/initializers/authorize_net.rb
26
- create app/controllers/payments_controller.rb
27
- route match '/payments/thank_you', :to => 'payments#thank_you', :as => 'payments_thank_you', :via => [:get]
28
- route match '/payments/payment', :to => 'payments#payment', :as => 'paymentspayment', :via => [:get]
29
-
30
- DESC
31
-
32
- def manifest
33
- copy_file "README-AuthorizeNet", "README-AuthorizeNet"
34
- empty_directory "app/views/#{file_name}"
35
- copy_file "payment.rails3.erb", "app/views/#{file_name}/payment.erb"
36
- copy_file "thank_you.erb", "app/views/#{file_name}/thank_you.erb"
37
- copy_file "layout.erb", "app/views/layouts/authorize_net.erb"
38
- template "config.yml.rails3.erb", "config/authorize_net.yml"
39
- copy_file "initializer.rb", "config/initializers/authorize_net.rb"
40
- template "controller.rb.erb", "app/controllers/#{file_name}_controller.rb"
41
- route "match '/#{plural_name}/thank_you', :to => '#{file_name}#thank_you', :as => '#{singular_name}_thank_you', :via => [:get]"
42
- route "match '/#{plural_name}/payment', :to => '#{file_name}#payment', :as => '#{singular_name}payment', :via => [:get]"
43
- end
44
- end
45
- end
46
- end
1
+ require 'rails/generators'
2
+ require 'rails/generators/named_base'
3
+
4
+ module AuthorizeNet
5
+ module Generators
6
+ class SimGenerator < Rails::Generators::NamedBase
7
+ source_root File.expand_path('templates', __dir__)
8
+ argument :api_login_id, type: :string, desc: 'Your Authorize.Net API login ID.', optional: true
9
+ argument :api_transaction_key, type: :string, desc: 'Your Authorize.Net API transaction key.', optional: true
10
+ argument :merchant_hash_value, type: :string, desc: 'Your Authorize.Net merchant hash value.', optional: true
11
+ desc <<-DESC
12
+ Description
13
+ Generates a simple implementation of Authorize.Net's SIM integration method.
14
+
15
+ Example:
16
+ rails generate authorize_net:sim payments API_LOGIN_ID API_TRANSACTION_KEY MERCHANT_HASH_VALUE
17
+
18
+ This will create:
19
+ create README-AuthorizeNet
20
+ create app/views/payments
21
+ create app/views/payments/payment.erb
22
+ create app/views/payments/thank_you.erb
23
+ create app/views/layouts/authorize_net.erb
24
+ create config/authorize_net.yml
25
+ create config/initializers/authorize_net.rb
26
+ create app/controllers/payments_controller.rb
27
+ route match '/payments/thank_you', :to => 'payments#thank_you', :as => 'payments_thank_you', :via => [:get]
28
+ route match '/payments/payment', :to => 'payments#payment', :as => 'paymentspayment', :via => [:get]
29
+
30
+ DESC
31
+
32
+ def manifest
33
+ copy_file "README-AuthorizeNet", "README-AuthorizeNet"
34
+ empty_directory "app/views/#{file_name}"
35
+ copy_file "payment.rails3.erb", "app/views/#{file_name}/payment.erb"
36
+ copy_file "thank_you.erb", "app/views/#{file_name}/thank_you.erb"
37
+ copy_file "layout.erb", "app/views/layouts/authorize_net.erb"
38
+ template "config.yml.rails3.erb", "config/authorize_net.yml"
39
+ copy_file "initializer.rb", "config/initializers/authorize_net.rb"
40
+ template "controller.rb.erb", "app/controllers/#{file_name}_controller.rb"
41
+ route "match '/#{plural_name}/thank_you', :to => '#{file_name}#thank_you', :as => '#{singular_name}_thank_you', :via => [:get]"
42
+ route "match '/#{plural_name}/payment', :to => '#{file_name}#payment', :as => '#{singular_name}payment', :via => [:get]"
43
+ end
44
+ end
45
+ end
46
+ end