activetiger 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
6
+ *.gemspec
7
+ *.gem
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.rdoc ADDED
@@ -0,0 +1,61 @@
1
+ =activetiger
2
+
3
+ ==Overview
4
+
5
+ activetiger is a ruby library that allows interaction with Tiger Payment Processing.
6
+ Using simple commands you can charge, authorize, capture, void, refund and update
7
+ credit card transactions. Some simple examples are below, see
8
+ http://inventables.github.com/activetiger for complete documentation.
9
+
10
+ ==Simple example
11
+
12
+ Authorize and capture a credit card:
13
+
14
+ # authorize the charge
15
+ gateway = ActiveTiger::Gateway.new :username => "user", :password => "password"
16
+ response = gateway.authorize(
17
+ :ccnumber => "4111111111111111",
18
+ :ccexp => "1010",
19
+ :amount => "1.00"
20
+ )
21
+
22
+ # capture
23
+ gateway.capture(:transactionid => response.transaction_id)
24
+
25
+ ==Rails Integration
26
+
27
+ activetiger works great with rails. When used in a rails project, active tiger looks
28
+ for a directory called config/activetiger. Within this directory, it expects to find
29
+ yaml configuration files for each environment in which you will be using activetiger.
30
+ Tiger Payment Processing provides a dummy account with the username of "demo" and the
31
+ password of "password". The standard configuration would normally be something like
32
+ the example below:
33
+
34
+ # config/activetiger/development.yml
35
+ username: demo
36
+ password: password
37
+
38
+ # config/activetiger/test.yml
39
+ username: demo
40
+ password: password
41
+
42
+ # config/activetiger/production.yml
43
+ username: realusername
44
+ password: realpassword
45
+
46
+ The above setup allows you to instantiate an ActiveTiger::Gateway without providing a
47
+ username or password. It will be instantiated with the credentials specified in the
48
+ yaml config files based on the environment. This allows you the test and develop against
49
+ the sandbox account while run production with your account. Very handy for testing.
50
+
51
+ ==Note on Patches/Pull Requests
52
+
53
+ * Fork the project.
54
+ * Make your feature addition or bug fix.
55
+ * Add tests for it. This is important so I don't break it in a future version unintentionally.
56
+ * 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)
57
+ * Send me a pull request. Bonus points for topic branches.
58
+
59
+ ==Copyright
60
+
61
+ Copyright (c) 2009 Inventables. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,47 @@
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{ruby 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/inventables/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
+ Spec::Rake::SpecTask.new(:rcov) do |t|
29
+ t.spec_files = FileList['spec/**/*_spec.rb']
30
+ t.rcov = true
31
+ t.rcov_opts = ['--exclude', 'spec']
32
+ end
33
+
34
+ require 'rake/rdoctask'
35
+ Rake::RDocTask.new do |rdoc|
36
+ if File.exist?('VERSION')
37
+ version = File.read('VERSION')
38
+ else
39
+ version = ""
40
+ end
41
+
42
+ rdoc.rdoc_dir = 'rdoc'
43
+ rdoc.title = "activetiger #{version}"
44
+ rdoc.template = '/opt/local/lib/ruby/gems/1.8/gems/allison-2.0.3/lib/allison'
45
+ rdoc.rdoc_files.include('README*')
46
+ rdoc.rdoc_files.include('lib/**/*.rb')
47
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,8 @@
1
+ $:.unshift File.dirname(__FILE__)
2
+
3
+ require 'rubygems'
4
+ require 'restclient'
5
+ require 'activetiger/configuration'
6
+ require 'activetiger/gateway'
7
+ require 'activetiger/response'
8
+
@@ -0,0 +1,25 @@
1
+ module ActiveTiger
2
+ # The Configuration class is responsible for determining your username/password
3
+ # based on your given RAILS_ENV and RAILS_ROOT. It looks for a yaml configuration
4
+ # file at:
5
+ # #{RAILS_ROOT}/config/activetiger/#{RAILS_ENV}.yml
6
+ #
7
+ # A sample test configuration would be:
8
+ # username: demo
9
+ # password: password
10
+ class Configuration
11
+ def initialize
12
+ config_path = File.join(RAILS_ROOT, "config", "activetiger", "#{RAILS_ENV}.yml")
13
+ @config = YAML.load(File.read(config_path))
14
+ end
15
+
16
+ def username
17
+ @config["username"]
18
+ end
19
+
20
+ def password
21
+ @config["password"]
22
+ end
23
+ end
24
+ end
25
+
@@ -0,0 +1,137 @@
1
+ module ActiveTiger
2
+ # =Overview
3
+ # The Gateway class alows you to interact with Tiger Payment Processing.
4
+ #
5
+ # First, we instantiate a gateway. If you're using ActiveTiger in a
6
+ # rails application, there's no need to provide username/password
7
+ # credentials on instantiation. ActiveTiger will look for a configuration
8
+ # file at:
9
+ # config/activetiger/#{RAILS_ENV}.yml
10
+ #
11
+ # =Creating a Gateway
12
+ #
13
+ # First we instantiate a gateway in a rails application:
14
+ # # create a gateway from a rails app
15
+ # gateway = ActiveTiger::Gateway.new
16
+ #
17
+ # # create a gateway in any ruby application
18
+ # gateway = ActiveTiger::Gateway.new(:username => "demo", :password => "password")
19
+ #
20
+ # =Gateway Actions
21
+ #
22
+ # Once a Gateway is created, we can take many actions. Let's look at each
23
+ # of these.
24
+ #
25
+ # ==Sale
26
+ #
27
+ # Charge a card immediately. You must provide a ccnumber, ccexp and amount
28
+ # as a minimum.
29
+ #
30
+ # response = gateway.sale(
31
+ # :ccnumber => "4111111111111111",
32
+ # :ccexp => "1010",
33
+ # :amount => "1.00"
34
+ # )
35
+ #
36
+ # puts "Success!" if response.approved?
37
+ #
38
+ # ==Authorize
39
+ #
40
+ # Authorize the card to be captured in the future. Again, provide a ccnumber,
41
+ # ccexp and amount at a minumum. Store the resulting transaction_id to capture
42
+ # at a later time.
43
+ #
44
+ # response = gateway.authorize(
45
+ # :ccnumber => "4111111111111111",
46
+ # :ccexp => "1010",
47
+ # :amount => "1.00"
48
+ # )
49
+ #
50
+ # # store transaction_id for capture later
51
+ # transaction_id = response.transaction_id
52
+ #
53
+ # ==Capture
54
+ #
55
+ # Capture a previously authorized transaction. All you need is the transactionid.
56
+ #
57
+ # response = gateway.capture(:transactionid => my_transaction_id)
58
+ # puts "Success!" if response.approved?
59
+ #
60
+ # ==Credit
61
+ #
62
+ # Credit the card with some amount. Provide the ccnumber, ccexp and amount.
63
+ #
64
+ # response = gateway.credit(
65
+ # :ccnumber => "4111111111111111",
66
+ # :ccexp => "1010",
67
+ # :amount => "1.00"
68
+ # )
69
+ #
70
+ # puts "you just gave them a buck" if response.approved?
71
+ #
72
+ # ==Void
73
+ #
74
+ # Void an uncaptured transaction. Just provide the transactionid.
75
+ #
76
+ # response = gateway.void(:transactionid => my_transaction_id)
77
+ # puts "voided ftw" if response.approved?
78
+ #
79
+ # ==Refund
80
+ #
81
+ # Refund a transaction that has already been sold or captured. Just give it
82
+ # that transactionid.
83
+ #
84
+ # response = gateway.refund(:transactionid => my_transaction_id)
85
+ # puts "refund-city" if response.approved?
86
+ #
87
+ # ==Update
88
+ #
89
+ # Update an uncaptured transaction. Just provide the transactionid.
90
+ #
91
+ # response = gateway.update(:transactionid => my_transaction_id)
92
+ # puts "updated" if response.approved?
93
+ #
94
+ # =Responses
95
+ #
96
+ # For more info on how to deal with responses from the Gateway, check out
97
+ # the Response class.
98
+ class Gateway
99
+ TIGER_GATEWAY_URL = "https://secure.tigergateway.net/api/transact.php"
100
+
101
+ def initialize(params = {})
102
+ if defined?(RAILS_ENV) && defined?(RAILS_ROOT)
103
+ config = ActiveTiger::Configuration.new
104
+ @username = config.username
105
+ @password = config.password
106
+ else
107
+ @username = params[:username]
108
+ @password = params[:password]
109
+ end
110
+ end
111
+
112
+ ["sale", "credit", "capture", "void", "refund", "update"].each do |operation|
113
+ define_method(operation) do |params|
114
+ params.merge! :type => operation
115
+ make_request(params)
116
+ end
117
+ end
118
+
119
+ def authorize(params)
120
+ params.merge! :type => "auth"
121
+ make_request(params)
122
+ end
123
+
124
+ private
125
+
126
+ def make_request(params)
127
+ params.merge! :username => @username, :password => @password
128
+ response_string = tiger_gateway.post(params)
129
+ ActiveTiger::Response.build_from_string(response_string)
130
+ end
131
+
132
+ def tiger_gateway
133
+ @tiger_gateway ||= RestClient::Resource.new(TIGER_GATEWAY_URL)
134
+ end
135
+ end
136
+ end
137
+
@@ -0,0 +1,117 @@
1
+ module ActiveTiger
2
+ # =Overview
3
+ #
4
+ # The Response object describes what happened to your Gateway request. Let's
5
+ # set up a response object.
6
+ #
7
+ # gateway = ActiveTiger::Gateway.new(:username => "foo", :password => "password")
8
+ # response = gateway.sale(
9
+ # :ccnumber => '4111111111111111',
10
+ # :ccexp => '1010',
11
+ # :amount => '1.00'
12
+ # )
13
+ #
14
+ # ==Status
15
+ #
16
+ # When you get your response back from the Gateway, you can quickly check
17
+ # the status using three methods; #approved?, #declined? and #has_errors?
18
+ # The status is completely dependent on the response code from the gateway.
19
+ #
20
+ # if response.approved?
21
+ # puts "awesome"
22
+ # elsif response.declined?
23
+ # puts "someone doesn't have the cash, or the wrong card info"
24
+ # elsif response.has_errors?
25
+ # puts "there was probably a problem with the gateway or something"
26
+ # end
27
+ #
28
+ # ==Messages
29
+ #
30
+ # There are three types of messages you can get from the response; the
31
+ # message, the response code, and the response_code_message.
32
+ #
33
+ # response.message
34
+ # response.response_code
35
+ # response.response_code_message
36
+
37
+ class Response
38
+ RESPONSE = {
39
+ :approved => "1",
40
+ :declined => "2",
41
+ :errors => "3"
42
+ }
43
+ DEFAULT_MESSAGE = "No Message Provided"
44
+ RESPONSE_CODE_MESSAGES = {
45
+ "100" => "Transaction was Approved",
46
+ "200" => "Transaction was Declined by Processor",
47
+ "200" => "Do Not Honor",
48
+ "201" => "Insufficient Funds",
49
+ "202" => "Over Limit",
50
+ "203" => "Transaction not allowed",
51
+ "220" => "Incorrect Payment Data",
52
+ "221" => "No Such card Issuer",
53
+ "222" => "No Card Number on file with Issuer",
54
+ "223" => "Expired Card",
55
+ "224" => "Invalid Expiration Date",
56
+ "225" => "Invalid Security Code",
57
+ "240" => "Call Issuer for Further Information",
58
+ "250" => "Pick Up Card",
59
+ "251" => "Lost Card",
60
+ "252" => "Stolen Card",
61
+ "253" => "Fraudulant Card",
62
+ "260" => "Declined with further Instructions Available (see response text)",
63
+ "261" => "Declined - Stop All Recurring Payments",
64
+ "262" => "Declined - Stop this Recurring Program",
65
+ "263" => "Declined - Update Cardholder Data Available",
66
+ "264" => "Declined - Retry in a few days",
67
+ "300" => "Transaction was Rejected by Gateway",
68
+ "400" => "Transaction Error Returned by Processor",
69
+ "410" => "Invalid Merchant Configuration",
70
+ "411" => "Merchant Account is Inactive",
71
+ "420" => "Communication Error",
72
+ "421" => "Communication Error with Issuer",
73
+ "430" => "Duplicate Transaction at Processor",
74
+ "440" => "Processor Format Error",
75
+ "441" => "Invalid Transaction Information",
76
+ "460" => "Processor Feature not Available",
77
+ "461" => "Unsupported Card Type"
78
+ }
79
+
80
+ class << self
81
+ def build_from_string(response_string)
82
+ params = response_string.split("&").inject({}) do |hash, string_pair|
83
+ key, val = string_pair.split("=")
84
+ hash.merge(key.to_sym => val)
85
+ end
86
+
87
+ self.new(params)
88
+ end
89
+ end
90
+
91
+ attr_reader :transaction_id, :message, :response_code
92
+
93
+ def initialize(params)
94
+ @response = params[:response]
95
+ @transaction_id = params[:transactionid]
96
+ @response_code = params[:response_code]
97
+ @message = params[:responsetext]
98
+ end
99
+
100
+ def approved?
101
+ @response == RESPONSE[:approved]
102
+ end
103
+
104
+ def declined?
105
+ @response == RESPONSE[:declined]
106
+ end
107
+
108
+ def has_errors?
109
+ @response == RESPONSE[:errors]
110
+ end
111
+
112
+ def response_code_message
113
+ RESPONSE_CODE_MESSAGES[@response_code] || DEFAULT_MESSAGE
114
+ end
115
+ end
116
+ end
117
+
@@ -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
+
@@ -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,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: 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-10-08 00:00:00 -05: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.rdoc
44
+ files:
45
+ - .document
46
+ - .gitignore
47
+ - LICENSE
48
+ - README.rdoc
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: true
60
+ homepage: http://github.com/inventables/activetiger
61
+ licenses: []
62
+
63
+ post_install_message:
64
+ rdoc_options:
65
+ - --charset=UTF-8
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: "0"
73
+ version:
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: "0"
79
+ version:
80
+ requirements: []
81
+
82
+ rubyforge_project:
83
+ rubygems_version: 1.3.4
84
+ signing_key:
85
+ specification_version: 3
86
+ summary: ruby integration with Tiger Payment Solutions
87
+ test_files:
88
+ - spec/activetiger/configuration_spec.rb
89
+ - spec/activetiger/gateway_spec.rb
90
+ - spec/activetiger/response_spec.rb
91
+ - spec/spec_helper.rb