inventables-activetiger 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +5 -0
- data/LICENSE +20 -0
- data/README.textile +46 -0
- data/Rakefile +40 -0
- data/VERSION +1 -0
- data/lib/activetiger.rb +8 -0
- data/lib/activetiger/configuration.rb +17 -0
- data/lib/activetiger/gateway.rb +41 -0
- data/lib/activetiger/response.rb +82 -0
- data/spec/activetiger/configuration_spec.rb +37 -0
- data/spec/activetiger/gateway_spec.rb +152 -0
- data/spec/activetiger/response_spec.rb +93 -0
- data/spec/spec_helper.rb +14 -0
- metadata +89 -0
data/.document
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Inventables
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.textile
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
h1. activetiger
|
2
|
+
|
3
|
+
h2. Overview
|
4
|
+
|
5
|
+
activetiger is a ruby library that allows interaction with Tiger Payment Processing. Using simple commands you can charge, authorize, capture, void, refund and update credit card transactions. Some simple examples are below, see the "wiki":http://wiki.github.com/inventables/activetiger for a more complete guide.
|
6
|
+
|
7
|
+
h2. Simple example
|
8
|
+
|
9
|
+
Authorize and capture a credit card:
|
10
|
+
|
11
|
+
bc. # authorize the charge
|
12
|
+
gateway = ActiveTiger::Gateway.new :username => "user", :password => "password"
|
13
|
+
response = gateway.authorize :ccnumber => "4111111111111111", :ccexp => "1010", :amount => "1.00"
|
14
|
+
|
15
|
+
bc. # capture
|
16
|
+
gateway.charge(:transactionid => response.transaction_id)
|
17
|
+
|
18
|
+
h2. Rails Integration
|
19
|
+
|
20
|
+
activetiger works great with rails. When used in a rails project, active tiger looks for a directory called config/activetiger. Within this directory, it expects to find yaml configuration files for each environment in which you will be using activetiger. Tiger Payment Processing provides a dummy account with the username of "demo" and the password of "password". The standard configuration would normally be something like the example below:
|
21
|
+
|
22
|
+
bc. # config/activetiger/development.yml
|
23
|
+
username: demo
|
24
|
+
password: password
|
25
|
+
|
26
|
+
bc. # config/activetiger/test.yml
|
27
|
+
username: demo
|
28
|
+
password: password
|
29
|
+
|
30
|
+
bc. # config/activetiger/production.yml
|
31
|
+
username: realusername
|
32
|
+
password: realpassword
|
33
|
+
|
34
|
+
The above setup allows you to instantiate an ActiveTiger::Gateway without providing a username or password. It will be instantiated with the credentials specified in the yaml config files based on the environment. This allows you the test and develop against the sandbox account while run production with your account. Very handy for testing.
|
35
|
+
|
36
|
+
h2. Note on Patches/Pull Requests
|
37
|
+
|
38
|
+
* Fork the project.
|
39
|
+
* Make your feature addition or bug fix.
|
40
|
+
* Add tests for it. This is important so I don't break it in a future version unintentionally.
|
41
|
+
* Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
42
|
+
* Send me a pull request. Bonus points for topic branches.
|
43
|
+
|
44
|
+
h2. Copyright
|
45
|
+
|
46
|
+
Copyright (c) 2009 Inventables. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'spec/rake/spectask'
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'jeweler'
|
7
|
+
Jeweler::Tasks.new do |gem|
|
8
|
+
gem.name = "activetiger"
|
9
|
+
gem.summary = %Q{Easy integration with Tiger Payment Solutions}
|
10
|
+
gem.description = %Q{ActiveTiger allows you to simply add payment processing to your application using Tiger Payment Solutions}
|
11
|
+
gem.email = "development@inventables.com"
|
12
|
+
gem.homepage = "http://github.com/drewolson/activetiger"
|
13
|
+
gem.authors = ["Drew Olson"]
|
14
|
+
gem.add_development_dependency "rspec"
|
15
|
+
gem.add_dependency "adamwiggins-rest-client", ">=1.0.4"
|
16
|
+
end
|
17
|
+
rescue LoadError
|
18
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
19
|
+
end
|
20
|
+
|
21
|
+
task :spec => :check_dependencies
|
22
|
+
task :default => :spec
|
23
|
+
|
24
|
+
Spec::Rake::SpecTask.new do |t|
|
25
|
+
t.warning = true
|
26
|
+
end
|
27
|
+
|
28
|
+
require 'rake/rdoctask'
|
29
|
+
Rake::RDocTask.new do |rdoc|
|
30
|
+
if File.exist?('VERSION')
|
31
|
+
version = File.read('VERSION')
|
32
|
+
else
|
33
|
+
version = ""
|
34
|
+
end
|
35
|
+
|
36
|
+
rdoc.rdoc_dir = 'rdoc'
|
37
|
+
rdoc.title = "activetiger #{version}"
|
38
|
+
rdoc.rdoc_files.include('README*')
|
39
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
40
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/lib/activetiger.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
module ActiveTiger
|
2
|
+
class Configuration
|
3
|
+
def initialize
|
4
|
+
config_path = File.join(RAILS_ROOT, "config", "activetiger", "#{RAILS_ENV}.yml")
|
5
|
+
@config = YAML.load(File.read(config_path))
|
6
|
+
end
|
7
|
+
|
8
|
+
def username
|
9
|
+
@config["username"]
|
10
|
+
end
|
11
|
+
|
12
|
+
def password
|
13
|
+
@config["password"]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module ActiveTiger
|
2
|
+
class Gateway
|
3
|
+
TIGER_GATEWAY_URL = "https://secure.tigergateway.net/api/transact.php"
|
4
|
+
|
5
|
+
def initialize(params = {})
|
6
|
+
if defined?(RAILS_ENV) && defined?(RAILS_ROOT)
|
7
|
+
config = ActiveTiger::Configuration.new
|
8
|
+
@username = config.username
|
9
|
+
@password = config.password
|
10
|
+
else
|
11
|
+
@username = params[:username]
|
12
|
+
@password = params[:password]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
["sale", "credit", "capture", "void", "refund", "update"].each do |operation|
|
17
|
+
define_method(operation) do |params|
|
18
|
+
params.merge! :type => operation
|
19
|
+
make_request(params)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def authorize(params)
|
24
|
+
params.merge! :type => "auth"
|
25
|
+
make_request(params)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def make_request(params)
|
31
|
+
params.merge! :username => @username, :password => @password
|
32
|
+
response_string = tiger_gateway.post(params)
|
33
|
+
ActiveTiger::Response.build_from_string(response_string)
|
34
|
+
end
|
35
|
+
|
36
|
+
def tiger_gateway
|
37
|
+
@tiger_gateway ||= RestClient::Resource.new(TIGER_GATEWAY_URL)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
@@ -0,0 +1,82 @@
|
|
1
|
+
module ActiveTiger
|
2
|
+
class Response
|
3
|
+
RESPONSE = {
|
4
|
+
:approved => "1",
|
5
|
+
:declined => "2",
|
6
|
+
:errors => "3"
|
7
|
+
}
|
8
|
+
DEFAULT_MESSAGE = "No Message Provided"
|
9
|
+
RESPONSE_CODE_MESSAGES = {
|
10
|
+
"100" => "Transaction was Approved",
|
11
|
+
"200" => "Transaction was Declined by Processor",
|
12
|
+
"200" => "Do Not Honor",
|
13
|
+
"201" => "Insufficient Funds",
|
14
|
+
"202" => "Over Limit",
|
15
|
+
"203" => "Transaction not allowed",
|
16
|
+
"220" => "Incorrect Payment Data",
|
17
|
+
"221" => "No Such card Issuer",
|
18
|
+
"222" => "No Card Number on file with Issuer",
|
19
|
+
"223" => "Expired Card",
|
20
|
+
"224" => "Invalid Expiration Date",
|
21
|
+
"225" => "Invalid Security Code",
|
22
|
+
"240" => "Call Issuer for Further Information",
|
23
|
+
"250" => "Pick Up Card",
|
24
|
+
"251" => "Lost Card",
|
25
|
+
"252" => "Stolen Card",
|
26
|
+
"253" => "Fraudulant Card",
|
27
|
+
"260" => "Declined with further Instructions Available (see response text)",
|
28
|
+
"261" => "Declined - Stop All Recurring Payments",
|
29
|
+
"262" => "Declined - Stop this Recurring Program",
|
30
|
+
"263" => "Declined - Update Cardholder Data Available",
|
31
|
+
"264" => "Declined - Retry in a few days",
|
32
|
+
"300" => "Transaction was Rejected by Gateway",
|
33
|
+
"400" => "Transaction Error Returned by Processor",
|
34
|
+
"410" => "Invalid Merchant Configuration",
|
35
|
+
"411" => "Merchant Account is Inactive",
|
36
|
+
"420" => "Communication Error",
|
37
|
+
"421" => "Communication Error with Issuer",
|
38
|
+
"430" => "Duplicate Transaction at Processor",
|
39
|
+
"440" => "Processor Format Error",
|
40
|
+
"441" => "Invalid Transaction Information",
|
41
|
+
"460" => "Processor Feature not Available",
|
42
|
+
"461" => "Unsupported Card Type"
|
43
|
+
}
|
44
|
+
|
45
|
+
class << self
|
46
|
+
def build_from_string(response_string)
|
47
|
+
params = response_string.split("&").inject({}) do |hash, string_pair|
|
48
|
+
key, val = string_pair.split("=")
|
49
|
+
hash.merge(key.to_sym => val)
|
50
|
+
end
|
51
|
+
|
52
|
+
self.new(params)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
attr_reader :transaction_id, :message, :response_code
|
57
|
+
|
58
|
+
def initialize(params)
|
59
|
+
@response = params[:response]
|
60
|
+
@transaction_id = params[:transactionid]
|
61
|
+
@response_code = params[:response_code]
|
62
|
+
@message = params[:responsetext]
|
63
|
+
end
|
64
|
+
|
65
|
+
def approved?
|
66
|
+
@response == RESPONSE[:approved]
|
67
|
+
end
|
68
|
+
|
69
|
+
def declined?
|
70
|
+
@response == RESPONSE[:declined]
|
71
|
+
end
|
72
|
+
|
73
|
+
def has_errors?
|
74
|
+
@response == RESPONSE[:errors]
|
75
|
+
end
|
76
|
+
|
77
|
+
def response_code_message
|
78
|
+
RESPONSE_CODE_MESSAGES[@response_code] || DEFAULT_MESSAGE
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe ActiveTiger::Configuration do
|
4
|
+
it "loads the yaml configuration for the given environment" do
|
5
|
+
file_mock = mock("Config file")
|
6
|
+
File.should_receive(:read).with("foo/config/activetiger/test.yml").and_return(file_mock)
|
7
|
+
YAML.should_receive(:load).with(file_mock)
|
8
|
+
|
9
|
+
with_constants :RAILS_ENV => "test", :RAILS_ROOT => "foo" do
|
10
|
+
ActiveTiger::Configuration.new
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "with a loaded configuration" do
|
15
|
+
before(:each) do
|
16
|
+
yml = <<-YML
|
17
|
+
username: user
|
18
|
+
password: pass
|
19
|
+
YML
|
20
|
+
|
21
|
+
File.should_receive(:read).with("foo/config/activetiger/test.yml").and_return(yml)
|
22
|
+
|
23
|
+
with_constants :RAILS_ENV => "test", :RAILS_ROOT => "foo" do
|
24
|
+
@config = ActiveTiger::Configuration.new
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
it "gives the correct username" do
|
29
|
+
@config.username.should == "user"
|
30
|
+
end
|
31
|
+
|
32
|
+
it "gives the correct password" do
|
33
|
+
@config.password.should == "pass"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
@@ -0,0 +1,152 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe ActiveTiger::Gateway do
|
4
|
+
before(:each) do
|
5
|
+
@default_response = "response=1&responsetext=SUCCESS&authcode=123456&transactionid=1042256997&avsresponse=&cvvresponse=&orderid=&type=sale&response_code=100"
|
6
|
+
@mock_tiger_gateway = mock('Tiger ActiveTigers')
|
7
|
+
RestClient::Resource.stub!(:new).with("https://secure.tigergateway.net/api/transact.php").and_return(@mock_tiger_gateway)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "creates a payment response" do
|
11
|
+
@mock_tiger_gateway.stub!(:post).with(
|
12
|
+
:username => "drew",
|
13
|
+
:password => "foo",
|
14
|
+
:type => "sale",
|
15
|
+
:ccnumber => "4111111111111111",
|
16
|
+
:ccexp => "1010",
|
17
|
+
:amount => "1.00"
|
18
|
+
).and_return(@default_response)
|
19
|
+
|
20
|
+
ActiveTiger::Response.should_receive(:build_from_string).with(@default_response)
|
21
|
+
|
22
|
+
gateway = ActiveTiger::Gateway.new(:username => "drew", :password => "foo")
|
23
|
+
gateway.sale :ccnumber => "4111111111111111", :ccexp => "1010", :amount => "1.00"
|
24
|
+
end
|
25
|
+
|
26
|
+
context "if RAILS_ROOT and RAILS_ENV are defined" do
|
27
|
+
it "defaults to payment configuration values" do
|
28
|
+
with_constants :RAILS_ROOT => "bar", :RAILS_ENV => "test" do
|
29
|
+
config_mock = mock("ActiveTiger configuration")
|
30
|
+
config_mock.should_receive(:username).and_return("drew")
|
31
|
+
config_mock.should_receive(:password).and_return("pass")
|
32
|
+
ActiveTiger::Configuration.should_receive(:new).and_return(config_mock)
|
33
|
+
|
34
|
+
gateway = ActiveTiger::Gateway.new
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context "if RAILS_ROOT or RAILS_ENV are not defined" do
|
40
|
+
it "should not create an instance of the configuration class" do
|
41
|
+
ActiveTiger::Configuration.should_not_receive(:new)
|
42
|
+
gateway = ActiveTiger::Gateway.new
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "#sale" do
|
47
|
+
it "posts a hash of arguments the payment gateway" do
|
48
|
+
@mock_tiger_gateway.should_receive(:post).with(
|
49
|
+
:username => "drew",
|
50
|
+
:password => "foo",
|
51
|
+
:type => "sale",
|
52
|
+
:ccnumber => "4111111111111111",
|
53
|
+
:ccexp => "1010",
|
54
|
+
:amount => "1.00"
|
55
|
+
).and_return(@default_response)
|
56
|
+
|
57
|
+
gateway = ActiveTiger::Gateway.new(:username => "drew", :password => "foo")
|
58
|
+
gateway.sale :ccnumber => "4111111111111111", :ccexp => "1010", :amount => "1.00"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe "#authorize" do
|
63
|
+
it "posts a hash of arguments the payment gateway" do
|
64
|
+
@mock_tiger_gateway.should_receive(:post).with(
|
65
|
+
:username => "drew",
|
66
|
+
:password => "foo",
|
67
|
+
:type => "auth",
|
68
|
+
:ccnumber => "4111111111111111",
|
69
|
+
:ccexp => "1010",
|
70
|
+
:amount => "1.00"
|
71
|
+
).and_return(@default_response)
|
72
|
+
|
73
|
+
gateway = ActiveTiger::Gateway.new(:username => "drew", :password => "foo")
|
74
|
+
gateway.authorize :ccnumber => "4111111111111111", :ccexp => "1010", :amount => "1.00"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe "#credit" do
|
79
|
+
it "posts a hash of arguments the payment gateway" do
|
80
|
+
@mock_tiger_gateway.should_receive(:post).with(
|
81
|
+
:username => "drew",
|
82
|
+
:password => "foo",
|
83
|
+
:type => "credit",
|
84
|
+
:ccnumber => "4111111111111111",
|
85
|
+
:ccexp => "1010",
|
86
|
+
:amount => "1.00"
|
87
|
+
).and_return(@default_response)
|
88
|
+
|
89
|
+
gateway = ActiveTiger::Gateway.new(:username => "drew", :password => "foo")
|
90
|
+
gateway.credit :ccnumber => "4111111111111111", :ccexp => "1010", :amount => "1.00"
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
describe "#capture" do
|
95
|
+
it "posts a hash of arguments the payment gateway" do
|
96
|
+
@mock_tiger_gateway.should_receive(:post).with(
|
97
|
+
:username => "drew",
|
98
|
+
:password => "foo",
|
99
|
+
:type => "capture",
|
100
|
+
:transactionid => "12345",
|
101
|
+
:amount => "1.00"
|
102
|
+
).and_return(@default_response)
|
103
|
+
|
104
|
+
gateway = ActiveTiger::Gateway.new(:username => "drew", :password => "foo")
|
105
|
+
gateway.capture :transactionid => "12345", :amount => "1.00"
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe "#void" do
|
110
|
+
it "posts a hash of arguments the payment gateway" do
|
111
|
+
@mock_tiger_gateway.should_receive(:post).with(
|
112
|
+
:username => "drew",
|
113
|
+
:password => "foo",
|
114
|
+
:type => "void",
|
115
|
+
:transactionid => "12345"
|
116
|
+
).and_return(@default_response)
|
117
|
+
|
118
|
+
gateway = ActiveTiger::Gateway.new(:username => "drew", :password => "foo")
|
119
|
+
gateway.void :transactionid => "12345"
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
describe "#refund" do
|
124
|
+
it "posts a hash of arguments the payment gateway" do
|
125
|
+
@mock_tiger_gateway.should_receive(:post).with(
|
126
|
+
:username => "drew",
|
127
|
+
:password => "foo",
|
128
|
+
:type => "refund",
|
129
|
+
:transactionid => "12345",
|
130
|
+
:amount => "1.00"
|
131
|
+
).and_return(@default_response)
|
132
|
+
|
133
|
+
gateway = ActiveTiger::Gateway.new(:username => "drew", :password => "foo")
|
134
|
+
gateway.refund :transactionid => "12345", :amount => "1.00"
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
describe "#update" do
|
139
|
+
it "posts a hash of arguments the payment gateway" do
|
140
|
+
@mock_tiger_gateway.should_receive(:post).with(
|
141
|
+
:username => "drew",
|
142
|
+
:password => "foo",
|
143
|
+
:type => "update",
|
144
|
+
:transactionid => "12345"
|
145
|
+
).and_return(@default_response)
|
146
|
+
|
147
|
+
gateway = ActiveTiger::Gateway.new(:username => "drew", :password => "foo")
|
148
|
+
gateway.update :transactionid => "12345"
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe ActiveTiger::Response do
|
4
|
+
describe "#build_from_string" do
|
5
|
+
it "builds a response object from a url params string" do
|
6
|
+
ActiveTiger::Response.should_receive(:new).with(
|
7
|
+
:response => "1",
|
8
|
+
:responsetext => "SUCCESS",
|
9
|
+
:authcode => nil,
|
10
|
+
:transactionid => "1042369612",
|
11
|
+
:avsresponse => nil,
|
12
|
+
:cvvresponse => nil,
|
13
|
+
:orderid => nil,
|
14
|
+
:type => "refund",
|
15
|
+
:response_code => "100"
|
16
|
+
)
|
17
|
+
|
18
|
+
ActiveTiger::Response.build_from_string(
|
19
|
+
"response=1&responsetext=SUCCESS&authcode=&transactionid=1042369612&avsresponse=&cvvresponse=&orderid=&type=refund&response_code=100"
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#approved?" do
|
25
|
+
it "returns true if approved" do
|
26
|
+
response = ActiveTiger::Response.new(:response => "1")
|
27
|
+
response.should be_approved
|
28
|
+
end
|
29
|
+
|
30
|
+
it "returns false if not approved" do
|
31
|
+
response = ActiveTiger::Response.new(:response => "2")
|
32
|
+
response.should_not be_approved
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "#declined?" do
|
37
|
+
it "returns true if declined" do
|
38
|
+
response = ActiveTiger::Response.new(:response => "2")
|
39
|
+
response.should be_declined
|
40
|
+
end
|
41
|
+
|
42
|
+
it "returns false if not declined" do
|
43
|
+
response = ActiveTiger::Response.new(:response => "1")
|
44
|
+
response.should_not be_declined
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "#has_errors?" do
|
49
|
+
it "returns true if declined" do
|
50
|
+
response = ActiveTiger::Response.new(:response => "3")
|
51
|
+
response.should have_errors
|
52
|
+
end
|
53
|
+
|
54
|
+
it "returns false if not declined" do
|
55
|
+
response = ActiveTiger::Response.new(:response => "1")
|
56
|
+
response.should_not have_errors
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "#transaction_id" do
|
61
|
+
it "returns the transaction_id" do
|
62
|
+
response = ActiveTiger::Response.new(:transactionid => "12345")
|
63
|
+
response.transaction_id.should == "12345"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "#response_code_message" do
|
68
|
+
it "returns the response_code_message associated with the response code" do
|
69
|
+
response = ActiveTiger::Response.new(:response_code => "100")
|
70
|
+
response.response_code_message.should == "Transaction was Approved"
|
71
|
+
end
|
72
|
+
|
73
|
+
it "returns the default response_code_message for an unknow response code" do
|
74
|
+
response = ActiveTiger::Response.new(:response_code => "42")
|
75
|
+
response.response_code_message.should == ActiveTiger::Response::DEFAULT_MESSAGE
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe "#response_code" do
|
80
|
+
it "returns the response_code" do
|
81
|
+
response = ActiveTiger::Response.new(:response_code => "100")
|
82
|
+
response.response_code.should == "100"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe "#message" do
|
87
|
+
it "returns the response text" do
|
88
|
+
response = ActiveTiger::Response.new(:responsetext => "Sample Text")
|
89
|
+
response.message.should == "Sample Text"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__),'..','lib','activetiger')
|
2
|
+
|
3
|
+
def with_constants(constants, &block)
|
4
|
+
constants.each do |constant, val|
|
5
|
+
Object.const_set(constant, val)
|
6
|
+
end
|
7
|
+
|
8
|
+
block.call
|
9
|
+
|
10
|
+
constants.each do |constant, val|
|
11
|
+
Object.send(:remove_const, constant)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
metadata
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: inventables-activetiger
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Drew Olson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-08-27 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: adamwiggins-rest-client
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.0.4
|
34
|
+
version:
|
35
|
+
description: ActiveTiger allows you to simply add payment processing to your application using Tiger Payment Solutions
|
36
|
+
email: development@inventables.com
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- LICENSE
|
43
|
+
- README.textile
|
44
|
+
files:
|
45
|
+
- .document
|
46
|
+
- .gitignore
|
47
|
+
- LICENSE
|
48
|
+
- README.textile
|
49
|
+
- Rakefile
|
50
|
+
- VERSION
|
51
|
+
- lib/activetiger.rb
|
52
|
+
- lib/activetiger/configuration.rb
|
53
|
+
- lib/activetiger/gateway.rb
|
54
|
+
- lib/activetiger/response.rb
|
55
|
+
- spec/activetiger/configuration_spec.rb
|
56
|
+
- spec/activetiger/gateway_spec.rb
|
57
|
+
- spec/activetiger/response_spec.rb
|
58
|
+
- spec/spec_helper.rb
|
59
|
+
has_rdoc: false
|
60
|
+
homepage: http://github.com/drewolson/activetiger
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options:
|
63
|
+
- --charset=UTF-8
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: "0"
|
71
|
+
version:
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: "0"
|
77
|
+
version:
|
78
|
+
requirements: []
|
79
|
+
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 1.2.0
|
82
|
+
signing_key:
|
83
|
+
specification_version: 3
|
84
|
+
summary: Easy integration with Tiger Payment Solutions
|
85
|
+
test_files:
|
86
|
+
- spec/activetiger/configuration_spec.rb
|
87
|
+
- spec/activetiger/gateway_spec.rb
|
88
|
+
- spec/activetiger/response_spec.rb
|
89
|
+
- spec/spec_helper.rb
|