ActiveMerchant-FatZebra 1.0.1 → 1.0.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: fc33ce583ddfa981b7e773b974d53e79ed207415c4e16309cd7fe4cc466a166a
4
+ data.tar.gz: 5d23922b2503ff32c25bb87459d1b6e2e4481edc3a804764ccd018e3e2fc8a17
5
+ SHA512:
6
+ metadata.gz: 67fbb0383de1757aa030df4a4875757f3b7a84a185a5cd6c72c8dbd5a63671f6cedea07b71af772eff587afb9c7f5372dacf72ae4a2c8bd570b3d52735556162
7
+ data.tar.gz: 8c6899b50f5d4aac560ee3d48bc40f56c8043886ad3fdef2459212ec5c83cbe06b9508d1928f223c96a477fa4dcfc06465391edfeae899130cba98b3232c90b4
@@ -2,19 +2,14 @@
2
2
  $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
- s.name = "ActiveMerchant-FatZebra"
6
- s.version = "1.0.1"
7
- s.authors = ["Matthew Savage"]
8
- s.email = ["matthew.savage@fatzebra.com.au"]
9
- s.homepage = "https://www.fatzebra.com.au"
10
- s.summary = %q{Fat Zebra support for Active Merchant, as a gem}
11
- s.description = %q{Fat Zebra support for Active Merchant - temporary gem until support is combined into active_merchant core.}
12
-
13
- s.rubyforge_project = "ActiveMerchant-FatZebra"
14
-
15
- s.files = `git ls-files`.split("\n")
16
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
5
+ s.name = "ActiveMerchant-FatZebra"
6
+ s.version = "1.0.2"
7
+ s.authors = ['fatzebra']
8
+ s.email = ['operations@fatzebra.com.au']
9
+ s.homepage = "https://github.com/fatzebra/ActiveMerchant-FatZebra"
10
+ s.summary = "⚠️ DEPRECATED – Fat Zebra support for Active Merchant, as a gem"
11
+ s.description = "⚠️ DEPRECATED - This gem is no longer maintained."
12
+ s.files = Dir.glob('lib/**/*') + %w[README.md ActiveMerchant-FatZebra.gemspec]
18
13
  s.require_paths = ["lib"]
19
14
 
20
15
  s.add_runtime_dependency "activemerchant"
data/README.md CHANGED
@@ -1,3 +1,8 @@
1
+ ⚠️ **DEPRECATED** - this Gem is no longer maintained
2
+ ====================================================
3
+
4
+ _The following is left for archival/legacy purposes only - this Gem is no longer maintained or supported by Fat Zebra._
5
+
1
6
  FatZebra ActiveMerchant integration
2
7
  ===================================
3
8
 
@@ -6,7 +11,7 @@ The quick 30-second rundown
6
11
 
7
12
  1. Install the gem in your Gemfile
8
13
 
9
- gem "active_merchant_fat_zebra"
14
+ gem "ActiveMerchant-FatZebra"
10
15
 
11
16
  Then `bundle install`
12
17
 
@@ -15,8 +20,8 @@ Then `bundle install`
15
20
  ```ruby
16
21
 
17
22
  options = {
18
- :login => "test",
19
- :token => "test_token"
23
+ :username => "TEST",
24
+ :token => "TEST"
20
25
  }
21
26
  gateway = ActiveMerchant::Billing::FatZebraGateway.new(options)
22
27
 
@@ -27,27 +32,30 @@ gateway = ActiveMerchant::Billing::FatZebraGateway.new(options)
27
32
  3. Setup the transaction data and then... transact!
28
33
 
29
34
  ```ruby
30
- cc = ActiveMerchant::Billing::CreditCard.new(:first_name => "Joe",
31
- :last_name => "Smith",
32
- :number => "4444333322221111",
33
- :month => 12,
34
- :year => 2013,
35
- :verification_value => 123)
35
+ cc = ActiveMerchant::Billing::CreditCard.new(:first_name => "Joe",
36
+ :last_name => "Smith",
37
+ :number => "5123456789012346",
38
+ :month => 12,
39
+ :year => 2013,
40
+ :verification_value => 123)
36
41
 
37
42
  amount = 10000 # 100.00 in cents
38
43
 
39
- result = gateway.purchase(amount, cc, { :order_id => "ORD18239", :ip => request.ip }) # If you are using rails you would use request.remote_ip
44
+ result = gateway.purchase(amount, cc, { :order_id => "ORD18239", :ip => request.ip })
40
45
  ```
41
46
 
47
+ A list of test credit card numbers can be found at [https://www.fatzebra.com.au/help/testing#card-numbers](https://www.fatzebra.com.au/help/testing#card-numbers).
48
+
42
49
  4. Handle the response - the data you get back is:
43
50
 
44
51
  ```ruby
45
52
  result.success? # True or False depending on if the txn was successful
46
53
  result.message # e.g. "Approved" or "Declined"
47
- result.id # The transaction ID
54
+ result.authorization # The transaction ID
48
55
  result.test? # Indicates if this was a test transaction
49
56
  result.params # Parameters passed by the gateway (e.g. may be additional info like fraud review score.)
50
57
  result.params["result"]["id"] # The transaction ID
58
+ result.params["result"]["authorization"] # The acquirer authorization ID
51
59
  result.params["result"]["token"] # The card token (when storing a card)
52
60
  ```
53
61
 
@@ -1,2 +1,4 @@
1
1
  require 'active_merchant'
2
- require "active_merchant/billing/gateways/fat_zebra"
2
+ require "active_merchant/billing/gateways/fat_zebra"
3
+
4
+ warn "[DEPRECATION] ActiveMerchant-FatZebra is no longer maintained."
metadata CHANGED
@@ -1,113 +1,99 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ActiveMerchant-FatZebra
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
5
- prerelease:
4
+ version: 1.0.2
6
5
  platform: ruby
7
6
  authors:
8
- - Matthew Savage
9
- autorequire:
7
+ - fatzebra
10
8
  bindir: bin
11
9
  cert_chain: []
12
- date: 2012-06-18 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
13
11
  dependencies:
14
12
  - !ruby/object:Gem::Dependency
15
13
  name: activemerchant
16
- requirement: &70156374511060 !ruby/object:Gem::Requirement
17
- none: false
14
+ requirement: !ruby/object:Gem::Requirement
18
15
  requirements:
19
- - - ! '>='
16
+ - - ">="
20
17
  - !ruby/object:Gem::Version
21
18
  version: '0'
22
19
  type: :runtime
23
20
  prerelease: false
24
- version_requirements: *70156374511060
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '0'
25
26
  - !ruby/object:Gem::Dependency
26
27
  name: rake
27
- requirement: &70156374510460 !ruby/object:Gem::Requirement
28
- none: false
28
+ requirement: !ruby/object:Gem::Requirement
29
29
  requirements:
30
- - - ! '>='
30
+ - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70156374510460
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
36
40
  - !ruby/object:Gem::Dependency
37
41
  name: mocha
38
- requirement: &70156374509640 !ruby/object:Gem::Requirement
39
- none: false
42
+ requirement: !ruby/object:Gem::Requirement
40
43
  requirements:
41
- - - ~>
44
+ - - "~>"
42
45
  - !ruby/object:Gem::Version
43
46
  version: 0.11.3
44
47
  type: :development
45
48
  prerelease: false
46
- version_requirements: *70156374509640
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: 0.11.3
47
54
  - !ruby/object:Gem::Dependency
48
55
  name: rails
49
- requirement: &70156374508320 !ruby/object:Gem::Requirement
50
- none: false
56
+ requirement: !ruby/object:Gem::Requirement
51
57
  requirements:
52
- - - ! '>='
58
+ - - ">="
53
59
  - !ruby/object:Gem::Version
54
60
  version: 2.3.11
55
61
  type: :development
56
62
  prerelease: false
57
- version_requirements: *70156374508320
58
- description: Fat Zebra support for Active Merchant - temporary gem until support is
59
- combined into active_merchant core.
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: 2.3.11
68
+ description: "⚠️ DEPRECATED - This gem is no longer maintained."
60
69
  email:
61
- - matthew.savage@fatzebra.com.au
70
+ - operations@fatzebra.com.au
62
71
  executables: []
63
72
  extensions: []
64
73
  extra_rdoc_files: []
65
74
  files:
66
- - .gitignore
67
75
  - ActiveMerchant-FatZebra.gemspec
68
- - Gemfile
69
76
  - README.md
70
- - Rakefile
71
77
  - lib/ActiveMerchant-FatZebra.rb
72
78
  - lib/active_merchant/billing/gateways/fat_zebra.rb
73
- - test/comm_stub.rb
74
- - test/fixtures.yml
75
- - test/remote/gateways/remote_fat_zebra_test.rb
76
- - test/test_helper.rb
77
- - test/unit/gateways/fat_zebra_test.rb
78
- homepage: https://www.fatzebra.com.au
79
+ homepage: https://github.com/fatzebra/ActiveMerchant-FatZebra
79
80
  licenses: []
80
- post_install_message:
81
+ metadata: {}
81
82
  rdoc_options: []
82
83
  require_paths:
83
84
  - lib
84
85
  required_ruby_version: !ruby/object:Gem::Requirement
85
- none: false
86
86
  requirements:
87
- - - ! '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
- segments:
91
- - 0
92
- hash: 4098293208701406375
93
90
  required_rubygems_version: !ruby/object:Gem::Requirement
94
- none: false
95
91
  requirements:
96
- - - ! '>='
92
+ - - ">="
97
93
  - !ruby/object:Gem::Version
98
94
  version: '0'
99
- segments:
100
- - 0
101
- hash: 4098293208701406375
102
95
  requirements: []
103
- rubyforge_project: ActiveMerchant-FatZebra
104
- rubygems_version: 1.8.10
105
- signing_key:
106
- specification_version: 3
107
- summary: Fat Zebra support for Active Merchant, as a gem
108
- test_files:
109
- - test/comm_stub.rb
110
- - test/fixtures.yml
111
- - test/remote/gateways/remote_fat_zebra_test.rb
112
- - test/test_helper.rb
113
- - test/unit/gateways/fat_zebra_test.rb
96
+ rubygems_version: 3.6.9
97
+ specification_version: 4
98
+ summary: "⚠️ DEPRECATED – Fat Zebra support for Active Merchant, as a gem"
99
+ test_files: []
data/.gitignore DELETED
@@ -1,4 +0,0 @@
1
- *.gem
2
- .bundle
3
- Gemfile.lock
4
- pkg/*
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source "http://rubygems.org"
2
-
3
- # Specify your gem's dependencies in ActiveMerchant-FatZebra.gemspec
4
- gemspec
data/Rakefile DELETED
@@ -1,37 +0,0 @@
1
- require "bundler/gem_tasks"
2
-
3
- $:.unshift File.expand_path('../lib', __FILE__)
4
-
5
- begin
6
- require 'bundler'
7
- Bundler.setup
8
- rescue LoadError => e
9
- puts "Error loading bundler (#{e.message}): \"gem install bundler\" for bundler support."
10
- require 'rubygems'
11
- end
12
-
13
- require 'rake'
14
- require 'rake/testtask'
15
-
16
- desc "Run the unit test suite"
17
- task :default => 'test:all'
18
-
19
- namespace :test do
20
-
21
- Rake::TestTask.new(:units) do |t|
22
- t.pattern = 'test/unit/**/*_test.rb'
23
- t.ruby_opts << '-rubygems'
24
- t.libs << 'test'
25
- t.verbose = true
26
- end
27
-
28
- Rake::TestTask.new(:remote) do |t|
29
- t.pattern = 'test/remote/**/*_test.rb'
30
- t.ruby_opts << '-rubygems'
31
- t.libs << 'test'
32
- t.verbose = true
33
- end
34
-
35
- desc "Test all"
36
- task :all => [:units, :remote]
37
- end
data/test/comm_stub.rb DELETED
@@ -1,39 +0,0 @@
1
- module CommStub
2
- class Stub
3
- def initialize(gateway, action)
4
- @gateway = gateway
5
- @action = action
6
- @complete = false
7
- end
8
-
9
- def check_request(&block)
10
- @check = block
11
- self
12
- end
13
-
14
- def respond_with(*responses)
15
- @complete = true
16
- check = @check
17
- (class << @gateway; self; end).send(:define_method, :ssl_post) do |*args|
18
- check.call(*args) if check
19
- (responses.size == 1 ? responses.last : responses.shift)
20
- end
21
- @action.call
22
- end
23
-
24
- def complete?
25
- @complete
26
- end
27
- end
28
-
29
- def stub_comms(gateway=@gateway, &action)
30
- if @last_comm_stub
31
- assert @last_comm_stub.complete?, "Tried to stub communications when there's a stub already in progress."
32
- end
33
- @last_comm_stub = Stub.new(gateway, action)
34
- end
35
-
36
- def teardown
37
- assert(@last_comm_stub.complete?) if @last_comm_stub
38
- end
39
- end
data/test/fixtures.yml DELETED
@@ -1,3 +0,0 @@
1
- fat_zebra:
2
- username: TEST
3
- token: TEST
@@ -1,76 +0,0 @@
1
- require 'test_helper'
2
-
3
- class RemoteFatZebraTest < Test::Unit::TestCase
4
-
5
-
6
- def setup
7
- @gateway = FatZebraGateway.new(fixtures(:fat_zebra))
8
-
9
- @amount = 100
10
- @credit_card = credit_card('5123456789012346')
11
- @declined_card = credit_card('4557012345678902')
12
-
13
- @options = {
14
- :order_id => rand(100000).to_s,
15
- :ip => "123.1.2.3"
16
- }
17
- end
18
-
19
- def test_successful_purchase
20
- assert response = @gateway.purchase(@amount, @credit_card, @options)
21
- assert_success response
22
- assert_equal 'Approved', response.message
23
- end
24
-
25
- def test_unsuccessful_purchase
26
- assert response = @gateway.purchase(@amount, @declined_card, @options)
27
- assert_failure response
28
- assert_equal 'Declined', response.message
29
- end
30
-
31
- def test_invalid_data
32
- @options.delete(:ip)
33
- assert response = @gateway.purchase(@amount, @declined_card, @options)
34
- assert_failure response
35
- assert_equal "Customer ip can't be blank", response.message
36
- end
37
-
38
- def test_refund
39
- purchase = @gateway.purchase(@amount, @credit_card, @options)
40
-
41
- assert response = @gateway.refund(@amount, purchase.authorization, rand(1000000).to_s)
42
- assert_success response
43
- assert_match /Approved/, response.message
44
- end
45
-
46
- def test_invalid_refund
47
- purchase = @gateway.purchase(@amount, @credit_card, @options)
48
-
49
- assert response = @gateway.refund(@amount, nil, rand(1000000).to_s)
50
- assert_failure response
51
- assert_match /Original transaction is required/, response.message
52
- end
53
-
54
- def test_store
55
- assert card = @gateway.store(@credit_card)
56
-
57
- assert_success card
58
- assert_false card.params["response"]["token"].nil?
59
- end
60
-
61
- def test_purchase_with_token
62
- assert card = @gateway.store(@credit_card)
63
- assert purchase = @gateway.purchase(@amount, {:cvv => 123, :token => card.params["response"]["token"]}, @options)
64
- assert_success purchase
65
- end
66
-
67
- def test_invalid_login
68
- gateway = FatZebraGateway.new(
69
- :username => 'invalid',
70
- :token => 'wrongtoken'
71
- )
72
- assert response = gateway.purchase(@amount, @credit_card, @options)
73
- assert_failure response
74
- assert_equal 'Invalid Login', response.message
75
- end
76
- end
data/test/test_helper.rb DELETED
@@ -1,252 +0,0 @@
1
- #!/usr/bin/env ruby
2
- $:.unshift File.expand_path('../../lib', __FILE__)
3
-
4
- begin
5
- require 'rubygems'
6
- require 'bundler'
7
- Bundler.setup
8
- rescue LoadError => e
9
- puts "Error loading bundler (#{e.message}): \"gem install bundler\" for bundler support."
10
- end
11
-
12
- require 'test/unit'
13
- require 'money'
14
- require 'mocha'
15
- require 'yaml'
16
- require 'active_merchant'
17
- require 'active_merchant/billing/gateways/fat_zebra'
18
- require 'comm_stub'
19
-
20
- require 'active_support/core_ext/integer/time'
21
- require 'active_support/core_ext/numeric/time'
22
-
23
-
24
-
25
- begin
26
- require 'active_support/core_ext/time/acts_like'
27
- rescue LoadError
28
- end
29
-
30
- begin
31
- gem 'actionpack'
32
- rescue LoadError
33
- raise StandardError, "The view tests need ActionPack installed as gem to run"
34
- end
35
-
36
- require 'action_controller'
37
- require "action_view/template"
38
- begin
39
- require 'active_support/core_ext/module/deprecation'
40
- require 'action_dispatch/testing/test_process'
41
- rescue LoadError
42
- require 'action_controller/test_process'
43
- end
44
- require 'active_merchant/billing/integrations/action_view_helper'
45
-
46
- ActiveMerchant::Billing::Base.mode = :test
47
-
48
- if ENV['DEBUG_ACTIVE_MERCHANT'] == 'true'
49
- require 'logger'
50
- ActiveMerchant::Billing::Gateway.logger = Logger.new(STDOUT)
51
- ActiveMerchant::Billing::Gateway.wiredump_device = STDOUT
52
- end
53
-
54
- # Test gateways
55
- class SimpleTestGateway < ActiveMerchant::Billing::Gateway
56
- end
57
-
58
- class SubclassGateway < SimpleTestGateway
59
- end
60
-
61
-
62
- module ActiveMerchant
63
- module Assertions
64
- AssertionClass = RUBY_VERSION > '1.9' ? MiniTest::Assertion : Test::Unit::AssertionFailedError
65
-
66
- def assert_field(field, value)
67
- clean_backtrace do
68
- assert_equal value, @helper.fields[field]
69
- end
70
- end
71
-
72
- # Allows the testing of you to check for negative assertions:
73
- #
74
- # # Instead of
75
- # assert !something_that_is_false
76
- #
77
- # # Do this
78
- # assert_false something_that_should_be_false
79
- #
80
- # An optional +msg+ parameter is available to help you debug.
81
- def assert_false(boolean, message = nil)
82
- message = build_message message, '<?> is not false or nil.', boolean
83
-
84
- clean_backtrace do
85
- assert_block message do
86
- not boolean
87
- end
88
- end
89
- end
90
-
91
- # A handy little assertion to check for a successful response:
92
- #
93
- # # Instead of
94
- # assert_success response
95
- #
96
- # # DRY that up with
97
- # assert_success response
98
- #
99
- # A message will automatically show the inspection of the response
100
- # object if things go afoul.
101
- def assert_success(response)
102
- clean_backtrace do
103
- assert response.success?, "Response failed: #{response.inspect}"
104
- end
105
- end
106
-
107
- # The negative of +assert_success+
108
- def assert_failure(response)
109
- clean_backtrace do
110
- assert_false response.success?, "Response expected to fail: #{response.inspect}"
111
- end
112
- end
113
-
114
- def assert_valid(validateable)
115
- clean_backtrace do
116
- assert validateable.valid?, "Expected to be valid"
117
- end
118
- end
119
-
120
- def assert_not_valid(validateable)
121
- clean_backtrace do
122
- assert_false validateable.valid?, "Expected to not be valid"
123
- end
124
- end
125
-
126
- def assert_deprecation_warning(message, target)
127
- target.expects(:deprecated).with(message)
128
- yield
129
- end
130
-
131
- private
132
- def clean_backtrace(&block)
133
- yield
134
- rescue AssertionClass => e
135
- path = File.expand_path(__FILE__)
136
- raise AssertionClass, e.message, e.backtrace.reject { |line| File.expand_path(line) =~ /#{path}/ }
137
- end
138
- end
139
-
140
- module Fixtures
141
- HOME_DIR = RUBY_PLATFORM =~ /mswin32/ ? ENV['HOMEPATH'] : ENV['HOME'] unless defined?(HOME_DIR)
142
- LOCAL_CREDENTIALS = File.join(HOME_DIR.to_s, '.active_merchant/fixtures.yml') unless defined?(LOCAL_CREDENTIALS)
143
- DEFAULT_CREDENTIALS = File.join(File.dirname(__FILE__), 'fixtures.yml') unless defined?(DEFAULT_CREDENTIALS)
144
-
145
- private
146
- def credit_card(number = '4242424242424242', options = {})
147
- defaults = {
148
- :number => number,
149
- :month => 9,
150
- :year => Time.now.year + 1,
151
- :first_name => 'Longbob',
152
- :last_name => 'Longsen',
153
- :verification_value => '123',
154
- :brand => 'visa'
155
- }.update(options)
156
-
157
- Billing::CreditCard.new(defaults)
158
- end
159
-
160
- def check(options = {})
161
- defaults = {
162
- :name => 'Jim Smith',
163
- :routing_number => '244183602',
164
- :account_number => '15378535',
165
- :account_holder_type => 'personal',
166
- :account_type => 'checking',
167
- :number => '1'
168
- }.update(options)
169
-
170
- Billing::Check.new(defaults)
171
- end
172
-
173
- def address(options = {})
174
- {
175
- :name => 'Jim Smith',
176
- :address1 => '1234 My Street',
177
- :address2 => 'Apt 1',
178
- :company => 'Widgets Inc',
179
- :city => 'Ottawa',
180
- :state => 'ON',
181
- :zip => 'K1C2N6',
182
- :country => 'CA',
183
- :phone => '(555)555-5555',
184
- :fax => '(555)555-6666'
185
- }.update(options)
186
- end
187
-
188
- def all_fixtures
189
- @@fixtures ||= load_fixtures
190
- end
191
-
192
- def fixtures(key)
193
- data = all_fixtures[key] || raise(StandardError, "No fixture data was found for '#{key}'")
194
-
195
- data.dup
196
- end
197
-
198
- def load_fixtures
199
- [DEFAULT_CREDENTIALS, LOCAL_CREDENTIALS].inject({}) do |credentials, file_name|
200
- if File.exists?(file_name)
201
- yaml_data = YAML.load(File.read(file_name))
202
- credentials.merge!(symbolize_keys(yaml_data))
203
- end
204
- credentials
205
- end
206
- end
207
-
208
- def symbolize_keys(hash)
209
- return unless hash.is_a?(Hash)
210
-
211
- hash.symbolize_keys!
212
- hash.each{|k,v| symbolize_keys(v)}
213
- end
214
- end
215
- end
216
-
217
- Test::Unit::TestCase.class_eval do
218
- include ActiveMerchant::Billing
219
- include ActiveMerchant::Assertions
220
- include ActiveMerchant::Utils
221
- include ActiveMerchant::Fixtures
222
- end
223
-
224
- module ActionViewHelperTestHelper
225
-
226
- def self.included(base)
227
- base.send(:include, ActiveMerchant::Billing::Integrations::ActionViewHelper)
228
- base.send(:include, ActionView::Helpers::FormHelper)
229
- base.send(:include, ActionView::Helpers::FormTagHelper)
230
- base.send(:include, ActionView::Helpers::UrlHelper)
231
- base.send(:include, ActionView::Helpers::TagHelper)
232
- base.send(:include, ActionView::Helpers::CaptureHelper)
233
- base.send(:include, ActionView::Helpers::TextHelper)
234
- base.send(:attr_accessor, :output_buffer)
235
- end
236
-
237
- def setup
238
- @controller = Class.new do
239
- attr_reader :url_for_options
240
- def url_for(options, *parameters_for_method_reference)
241
- @url_for_options = options
242
- end
243
- end
244
- @controller = @controller.new
245
- @output_buffer = ''
246
- end
247
-
248
- protected
249
- def protect_against_forgery?
250
- false
251
- end
252
- end
@@ -1,234 +0,0 @@
1
- require 'test_helper'
2
-
3
- class FatZebraTest < Test::Unit::TestCase
4
- def setup
5
- @gateway = FatZebraGateway.new(
6
- :username => 'TEST',
7
- :token => 'TEST'
8
- )
9
-
10
- @credit_card = credit_card
11
- @amount = 100
12
-
13
- @options = {
14
- :order_id => rand(10000),
15
- :billing_address => address,
16
- :description => 'Store Purchase'
17
- }
18
- end
19
-
20
- def test_successful_purchase
21
- @gateway.expects(:ssl_request).returns(successful_purchase_response)
22
-
23
- assert response = @gateway.purchase(@amount, @credit_card, @options)
24
- assert_success response
25
-
26
- assert_equal '001-P-12345AA', response.authorization
27
- assert response.test?
28
- end
29
-
30
- def test_unsuccessful_request
31
- @gateway.expects(:ssl_request).returns(failed_purchase_response)
32
-
33
- assert response = @gateway.purchase(@amount, @credit_card, @options)
34
- assert_failure response
35
- assert response.test?
36
- assert_match /Invalid Card Number/, response.message
37
- end
38
-
39
- def test_declined_purchase
40
- @gateway.expects(:ssl_request).returns(declined_purchase_response)
41
-
42
- assert response = @gateway.purchase(@amount, @credit_card, @options)
43
- assert_failure response
44
- assert response.test?
45
- assert_match /Card Declined/, response.message
46
- end
47
-
48
- def test_parse_error
49
- @gateway.expects(:ssl_request).returns("{") # Some invalid JSON
50
- assert response = @gateway.purchase(@amount, @credit_card, @options)
51
- assert_failure response
52
- assert_match /Invalid JSON response/, response.message
53
- end
54
-
55
- def test_request_error
56
- @gateway.expects(:ssl_request).returns(missing_data_response)
57
-
58
- assert response = @gateway.purchase(@amount, @credit_card, @options)
59
- assert_failure response
60
- assert_match /Card Number is required/, response.message
61
- end
62
-
63
- def test_successful_tokenization
64
- @gateway.expects(:ssl_request).returns(successful_tokenize_response)
65
-
66
- assert response = @gateway.store(@credit_card)
67
- assert_success response
68
- end
69
-
70
- def test_unsuccessful_tokenization
71
- @gateway.expects(:ssl_request).returns(failed_tokenize_response)
72
-
73
- assert response = @gateway.store(@credit_card)
74
- assert_failure response
75
- end
76
-
77
- def test_successful_refund
78
- @gateway.expects(:ssl_request).returns(successful_refund_response)
79
-
80
- assert response = @gateway.refund(100, "TEST", "Test refund")
81
- assert_success response
82
- assert_equal '003-R-7MNIUMY6', response.authorization
83
- assert response.test?
84
- end
85
-
86
- def test_unsuccessful_refund
87
- @gateway.expects(:ssl_request).returns(unsuccessful_refund_response)
88
-
89
- assert response = @gateway.refund(100, "TEST", "Test refund")
90
- assert_failure response
91
- assert response.test?
92
- end
93
-
94
- private
95
-
96
- # Place raw successful response from gateway here
97
- def successful_purchase_response
98
- {
99
- :successful => true,
100
- :response => {
101
- :authorization => "55355",
102
- :id => "001-P-12345AA",
103
- :card_number => "XXXXXXXXXXXX1111",
104
- :card_holder => "John Smith",
105
- :card_expiry => "10/2011",
106
- :card_token => "a1bhj98j",
107
- :amount => 349,
108
- :successful => true,
109
- :reference => "ABC123",
110
- :message => "Approved",
111
- },
112
- :test => true,
113
- :errors => []
114
- }.to_json
115
- end
116
-
117
- def declined_purchase_response
118
- {
119
- :successful => true,
120
- :response => {
121
- :authorization_id => nil,
122
- :id => nil,
123
- :card_number => "XXXXXXXXXXXX1111",
124
- :card_holder => "John Smith",
125
- :card_expiry => "10/2011",
126
- :amount => 100,
127
- :authorized => false,
128
- :reference => "ABC123",
129
- :message => "Card Declined - check with issuer",
130
- },
131
- :test => true,
132
- :errors => []
133
- }.to_json
134
- end
135
-
136
- def successful_refund_response
137
- {
138
- :successful => true,
139
- :response => {
140
- :authorization => "1339973263",
141
- :id => "003-R-7MNIUMY6",
142
- :amount => -10,
143
- :refunded => "Approved",
144
- :message => "08 Approved",
145
- :card_holder => "Harry Smith",
146
- :card_number => "XXXXXXXXXXXX4444",
147
- :card_expiry => "2013-05-31",
148
- :card_type => "MasterCard",
149
- :transaction_id => "003-R-7MNIUMY6",
150
- :successful => true
151
- },
152
- :errors => [
153
-
154
- ],
155
- :test => true
156
- }.to_json
157
- end
158
-
159
- def unsuccessful_refund_response
160
- {
161
- :successful => false,
162
- :response => {
163
- :authorization => nil,
164
- :id => nil,
165
- :amount => nil,
166
- :refunded => nil,
167
- :message => nil,
168
- :card_holder => "Matthew Savage",
169
- :card_number => "XXXXXXXXXXXX4444",
170
- :card_expiry => "2013-05-31",
171
- :card_type => "MasterCard",
172
- :transaction_id => nil,
173
- :successful => false
174
- },
175
- :errors => [
176
- "Reference can't be blank"
177
- ],
178
- :test => true
179
- }.to_json
180
- end
181
-
182
- def successful_tokenize_response
183
- {
184
- :successful => true,
185
- :response => {
186
- :token => "e1q7dbj2",
187
- :card_holder => "Bob Smith",
188
- :card_number => "XXXXXXXXXXXX2346",
189
- :card_expiry => "2013-05-31T23:59:59+10:00",
190
- :authorized => true,
191
- :transaction_count => 0
192
- },
193
- :errors => [],
194
- :test => true
195
- }.to_json
196
- end
197
-
198
- def failed_tokenize_response
199
- {
200
- :successful => false,
201
- :response => {
202
- :token => nil,
203
- :card_holder => "Bob ",
204
- :card_number => "512345XXXXXX2346",
205
- :card_expiry => nil,
206
- :authorized => false,
207
- :transaction_count => 10
208
- },
209
- :errors => [
210
- "Expiry date can't be blank"
211
- ],
212
- :test => false
213
- }.to_json
214
- end
215
-
216
- # Place raw failed response from gateway here
217
- def failed_purchase_response
218
- {
219
- :successful => false,
220
- :response => {},
221
- :test => true,
222
- :errors => ["Invalid Card Number"]
223
- }.to_json
224
- end
225
-
226
- def missing_data_response
227
- {
228
- :successful => false,
229
- :response => {},
230
- :test => true,
231
- :errors => ["Card Number is required"]
232
- }.to_json
233
- end
234
- end