auth_net_receiver 1.0.beta3 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6e3dca12b1bc018b4eb1ecfc51e31664411c0227
4
- data.tar.gz: 2369cdcaf0b5c59958a7aec631b3b28605d53bf9
3
+ metadata.gz: f6b991ce02ca5ee5c87b41c2d8f6003bebac79b6
4
+ data.tar.gz: 5c3df309a82146e1396a82c3f696d904aa83c510
5
5
  SHA512:
6
- metadata.gz: ba94aadeebd9fe13afd9ef763ab69153116327b013eb778fac0f54edd866ae740cbe19daf74cfe7c505d99698bbec014707f17cbd8ed8b5b5d4e4574f46e5ed2
7
- data.tar.gz: 4b306a5cea7d2b4cff9c30df4cde63a91dbf3961f9e196bf35240870dbd47c422d5c91775551ae386056e12fe60f45694ae437bc7243339f603ab407e648d2cc
6
+ metadata.gz: 765601d0f8b3223df8ddaa952b97d68bd9e3712ef8177f071852c82a3c746de9fdbf55b6097cdcc5bf261eb26bb1254e22491d5e57a9b39bb1984f63d79107b6
7
+ data.tar.gz: bc004e70ff8c799f2b1710cf1826202eca07ddac6a77209341fa9ef3da33fb05b1d1e379f8cfde4569b6b83e3e84497899fe50d33dde73f5d33e45fecd29a475
data/README.md CHANGED
@@ -48,7 +48,7 @@ The processing side will require some configuration before it works.
48
48
 
49
49
  The gateway login should be the same value you use when authenticating against Authorize.Net. MD5 Hash is a secret value you configure in the Authorize.Net dashboard. You can read more about the MD5 value [here](https://support.authorize.net/authkb/index?page=content&id=A588).
50
50
 
51
- As a final step, you should log in to your Authorize.Net account and enter the desired endpoint into Silent Post URL setting. Depending on how you mounted the engine in your routes.rb file, the URL will look something like this: `http://sample.com/auth_net/transactions/receiver`. It is strongly recommended that you try this in a [sandbox account](https://sandbox.authorize.net) first.
51
+ As a final step, you should log in to your Authorize.Net account and enter the desired endpoint into Silent Post URL setting. Depending on how you mounted the engine in your routes.rb file, the URL will look something like this: `https://sample.com/auth_net/transactions/receiver`. It is strongly recommended that you try this in a [sandbox account](https://sandbox.authorize.net) first.
52
52
 
53
53
  **NOTE:** Because Authorize.Net has to actually make an HTTP post to your endpoint, it is not possible to run this application on localhost without a bit of work on the networking side. I won't attempt to cover the entire topic here, but if you are comfortable with DNS and port forwards you can probably figure out the rest.
54
54
 
@@ -1,6 +1,8 @@
1
1
  module AuthNetReceiver
2
2
  class Transaction < ActiveRecord::Base
3
3
 
4
+ scope :approved, ->{ where(:response_reason_code => 1) }
5
+
4
6
  belongs_to :raw_transaction
5
7
  validates_presence_of :raw_transaction_id
6
8
 
@@ -10,5 +12,13 @@ module AuthNetReceiver
10
12
  return self.subscription_id.present?
11
13
  end
12
14
 
15
+ # Return true if the transaction was succesful
16
+ # This will be indicated by a Response Reason Code 1. All other codes indicate an error of some kind
17
+ # http://developer.authorize.net/tools/responsereasoncode/
18
+ #
19
+ def is_approved?
20
+ return response_reason_code == 1
21
+ end
22
+
13
23
  end
14
24
  end
@@ -1,4 +1,5 @@
1
1
  require "auth_net_receiver/configuration"
2
+ require "auth_net_receiver/active_job" if defined?(ActiveJob)
2
3
 
3
4
  module AuthNetReceiver
4
5
  class Engine < ::Rails::Engine
@@ -1,3 +1,3 @@
1
1
  module AuthNetReceiver
2
- VERSION = "1.0.beta3"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -3,11 +3,21 @@ require 'rails_helper'
3
3
  module AuthNetReceiver
4
4
  RSpec.describe RawTransactionsController, :type => :controller do
5
5
 
6
+ routes { AuthNetReceiver::Engine.routes }
7
+
6
8
  it "should create a new raw transaction" do
7
- post :create, {:use_route => :auth_net_receiver}
9
+ post :create
8
10
  expect(response).to be_success
9
11
  expect(AuthNetReceiver::RawTransaction.count).to eq(1)
10
12
  end
11
13
 
14
+ it "should schedule a job if ActiveJob is turned on" do
15
+ post :create
16
+ expect(response).to be_success
17
+ if AuthNetReceiver.config.active_job
18
+ expect(Delayed::Job.count).to eq(1)
19
+ end
20
+ end
21
+
12
22
  end
13
23
  end
@@ -20,7 +20,7 @@ Rails.application.configure do
20
20
  # config.action_dispatch.rack_cache = true
21
21
 
22
22
  # Disable Rails's static asset server (Apache or NGINX will already do this).
23
- config.serve_static_assets = false
23
+ config.serve_static_files = false
24
24
 
25
25
  # Compress JavaScripts and CSS.
26
26
  config.assets.js_compressor = :uglifier
@@ -10,10 +10,10 @@ Rails.application.configure do
10
10
  # Do not eager load code on boot. This avoids loading your whole application
11
11
  # just for the purpose of running a single test. If you are using a tool that
12
12
  # preloads Rails for running tests, you may have to set it to true.
13
- config.eager_load = false
13
+ config.eager_load = true
14
14
 
15
15
  # Configure static asset server for tests with Cache-Control for performance.
16
- config.serve_static_assets = true
16
+ config.serve_static_files = true
17
17
  config.static_cache_control = 'public, max-age=3600'
18
18
 
19
19
  # Show full error reports and disable caching.
@@ -37,5 +37,7 @@ Rails.application.configure do
37
37
  # Raises error for missing translations
38
38
  # config.action_view.raise_on_missing_translations = true
39
39
 
40
- config.active_job.queue_adapter = :delayed_job
40
+ if defined?(ActiveJob)
41
+ config.active_job.queue_adapter = :delayed_job
42
+ end
41
43
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  FactoryGirl.define do
4
4
  factory :transaction, :class => 'AuthNetReceiver::Transaction' do
5
- association :raw_transaction, :factory => :auth_net_receiver_raw_transaction
5
+ association :raw_transaction, :factory => :raw_transaction
6
6
  transaction_id 1
7
7
  subscription_id 1
8
8
  subscription_paynum 1
@@ -3,5 +3,19 @@ require 'rails_helper'
3
3
  module AuthNetReceiver
4
4
  RSpec.describe Transaction, :type => :model do
5
5
 
6
+ describe "#is_approved?" do
7
+
8
+ it "should return true if response_reason_code is 1" do
9
+ transaction = FactoryGirl.create(:transaction, {:response_reason_code => 1})
10
+ expect(transaction.is_approved?).to eq(true)
11
+ end
12
+
13
+ it "should return false if response_reason_code is not 1" do
14
+ transaction = FactoryGirl.create(:transaction, {:response_reason_code => 2})
15
+ expect(transaction.is_approved?).to eq(false)
16
+ end
17
+
18
+ end
19
+
6
20
  end
7
21
  end
@@ -37,6 +37,11 @@ RSpec.configure do |config|
37
37
  # instead of true.
38
38
  config.use_transactional_fixtures = true
39
39
 
40
+ # Skip ActiveJob if testing Rails 4.1 or lower
41
+ if Rails.version.to_f < 4.2
42
+ config.exclude_pattern = 'spec/jobs/auth_net_receiver/*'
43
+ end
44
+
40
45
  # RSpec Rails can automatically mix in different behaviours to your tests
41
46
  # based on their file location, for example enabling you to call `get` and
42
47
  # `post` in specs under `spec/controllers`.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auth_net_receiver
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.beta3
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Woods
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-15 00:00:00.000000000 Z
11
+ date: 2015-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -113,13 +113,13 @@ files:
113
113
  - Rakefile
114
114
  - app/controllers/auth_net_receiver/application_controller.rb
115
115
  - app/controllers/auth_net_receiver/raw_transactions_controller.rb
116
- - app/jobs/auth_net_receiver/process_transaction_job.rb
117
116
  - app/models/auth_net_receiver/raw_transaction.rb
118
117
  - app/models/auth_net_receiver/transaction.rb
119
118
  - config/routes.rb
120
119
  - db/migrate/20141106200527_create_auth_net_receiver_raw_transactions.rb
121
120
  - db/migrate/20141106200940_create_auth_net_receiver_transactions.rb
122
121
  - lib/auth_net_receiver.rb
122
+ - lib/auth_net_receiver/active_job.rb
123
123
  - lib/auth_net_receiver/configuration.rb
124
124
  - lib/auth_net_receiver/engine.rb
125
125
  - lib/auth_net_receiver/version.rb
@@ -166,7 +166,6 @@ files:
166
166
  - spec/dummy/public/favicon.ico
167
167
  - spec/factories/auth_net_receiver_raw_transactions.rb
168
168
  - spec/factories/auth_net_receiver_transactions.rb
169
- - spec/jobs/auth_net_receiver/process_transaction_job_spec.rb
170
169
  - spec/models/auth_net_receiver/raw_transaction_spec.rb
171
170
  - spec/models/auth_net_receiver/transaction_spec.rb
172
171
  - spec/rails_helper.rb
@@ -187,9 +186,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
187
186
  version: '0'
188
187
  required_rubygems_version: !ruby/object:Gem::Requirement
189
188
  requirements:
190
- - - ">"
189
+ - - ">="
191
190
  - !ruby/object:Gem::Version
192
- version: 1.3.1
191
+ version: '0'
193
192
  requirements: []
194
193
  rubyforge_project:
195
194
  rubygems_version: 2.4.2
@@ -239,7 +238,6 @@ test_files:
239
238
  - spec/dummy/README.rdoc
240
239
  - spec/factories/auth_net_receiver_raw_transactions.rb
241
240
  - spec/factories/auth_net_receiver_transactions.rb
242
- - spec/jobs/auth_net_receiver/process_transaction_job_spec.rb
243
241
  - spec/models/auth_net_receiver/raw_transaction_spec.rb
244
242
  - spec/models/auth_net_receiver/transaction_spec.rb
245
243
  - spec/rails_helper.rb
@@ -1,7 +0,0 @@
1
- require 'rails_helper'
2
-
3
- module AuthNetReceiver
4
- RSpec.describe ProcessTransactionJob, :type => :job do
5
- pending "add some examples to (or delete) #{__FILE__}"
6
- end
7
- end