samurai 0.2.18 → 0.2.19
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.
- data/Gemfile +2 -0
- data/Gemfile.lock +11 -2
- data/README.markdown +3 -163
- data/Rakefile +16 -0
- data/api_reference.markdown +303 -0
- data/lib/samurai.rb +16 -3
- data/lib/samurai/base.rb +7 -1
- data/lib/samurai/cacheable_by_token.rb +8 -2
- data/lib/samurai/message.rb +7 -1
- data/lib/samurai/payment_method.rb +14 -7
- data/lib/samurai/processor.rb +27 -16
- data/lib/samurai/processor_response.rb +5 -0
- data/lib/samurai/rails/helpers.rb +5 -0
- data/lib/samurai/rails/views.rb +14 -0
- data/lib/samurai/transaction.rb +14 -6
- data/lib/samurai/version.rb +1 -1
- data/samurai.gemspec +1 -1
- data/spec/lib/authorization_spec.rb +9 -9
- data/spec/lib/{generate_docs_spec.rb → generate_docs_spec.rb.bak} +3 -32
- data/spec/lib/processor_spec.rb +4 -4
- data/spec/lib/purchase_spec.rb +2 -2
- data/spec/spec_helper.rb +55 -11
- data/spec/support/response_logger.rb +2 -2
- data/spec/support/transaction_seed.rb +10 -0
- data/spec/support/transparent_redirect_helper.rb +19 -0
- metadata +68 -55
data/spec/lib/processor_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe "Processor actions" do
|
4
4
|
before :each do
|
5
|
-
@payment_method_token =
|
5
|
+
@payment_method_token = create_payment_method(default_payment_method_params)[:payment_method_token]
|
6
6
|
end
|
7
7
|
|
8
8
|
it "should return an empty processor" do
|
@@ -11,13 +11,13 @@ describe "Processor actions" do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should create a new purchase" do
|
14
|
-
purchase = Samurai::Processor.purchase(@payment_method_token,
|
14
|
+
purchase = Samurai::Processor.purchase(@payment_method_token, @seed)
|
15
15
|
purchase.processor_response.success.should be_true
|
16
16
|
# FakeWeb.last_request
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should create a new purchase with tracking data" do
|
20
|
-
purchase = Samurai::Processor.purchase(@payment_method_token,
|
20
|
+
purchase = Samurai::Processor.purchase(@payment_method_token, @seed, {
|
21
21
|
:descriptor => "A test purchase",
|
22
22
|
:custom => "some optional custom data",
|
23
23
|
:billing_reference => "ABC123",
|
@@ -28,7 +28,7 @@ describe "Processor actions" do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
it "should create a non-new authorization" do
|
31
|
-
authorization = Samurai::Processor.authorize(@payment_method_token,
|
31
|
+
authorization = Samurai::Processor.authorize(@payment_method_token, @seed)
|
32
32
|
authorization.processor_response.success.should be_true
|
33
33
|
end
|
34
34
|
|
data/spec/lib/purchase_spec.rb
CHANGED
@@ -3,8 +3,8 @@ require 'spec_helper'
|
|
3
3
|
describe "processing purchases" do
|
4
4
|
|
5
5
|
before :each do
|
6
|
-
payment_method_token =
|
7
|
-
@purchase = Samurai::Processor.purchase(payment_method_token,
|
6
|
+
payment_method_token = create_payment_method(default_payment_method_params)[:payment_method_token]
|
7
|
+
@purchase = Samurai::Processor.purchase(payment_method_token, 1.0, :billing_reference=>rand(1000))
|
8
8
|
end
|
9
9
|
|
10
10
|
it "should process successfully" do
|
data/spec/spec_helper.rb
CHANGED
@@ -11,24 +11,68 @@ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
|
11
11
|
SITE = ENV['site'] || 'https://api.samurai.feefighters.com/v1/'
|
12
12
|
USE_MOCK = !ENV['site']
|
13
13
|
|
14
|
-
PAYMENT_METHOD_TOKENS = {
|
15
|
-
:success => 'b7c966452702282b32a4c65d'
|
16
|
-
}
|
17
|
-
|
18
14
|
RSpec.configure do |c|
|
19
|
-
c.before :all do
|
20
|
-
@@seed = rand(1000).to_f / 100.0
|
21
|
-
end
|
22
15
|
c.before :each do
|
23
|
-
|
16
|
+
@seed = next_seed
|
17
|
+
ActiveResource::Base.logger.info "---------------------------------------------"
|
18
|
+
ActiveResource::Base.logger.info "--- " + self.example.description
|
19
|
+
ActiveResource::Base.logger.info "---------------------------------------------"
|
24
20
|
end
|
21
|
+
c.include TransparentRedirectHelper
|
22
|
+
c.include TransactionSeed
|
25
23
|
end
|
26
24
|
|
27
25
|
require 'samurai'
|
28
26
|
Samurai.options = {
|
29
27
|
:site => SITE,
|
30
|
-
:merchant_key => ENV['merchant_key'] || '
|
31
|
-
:merchant_password => ENV['merchant_password'] || '
|
32
|
-
:processor_token => ENV['processor_token'] || '
|
28
|
+
:merchant_key => ENV['merchant_key'] || 'a1ebafb6da5238fb8a3ac9f6',
|
29
|
+
:merchant_password => ENV['merchant_password'] || 'ae1aa640f6b735c4730fbb56',
|
30
|
+
:processor_token => ENV['processor_token'] || '69ac9c704329bb067d427bf0'
|
33
31
|
}
|
34
32
|
|
33
|
+
|
34
|
+
|
35
|
+
#
|
36
|
+
# Add more detailed response logging to ActiveResource
|
37
|
+
#
|
38
|
+
require 'logger'
|
39
|
+
ActiveResource::Base.logger = Logger.new(STDOUT)
|
40
|
+
|
41
|
+
module ActiveResource
|
42
|
+
class Connection
|
43
|
+
private
|
44
|
+
# Makes a request to the remote service.
|
45
|
+
def request(method, path, *arguments)
|
46
|
+
result = ActiveSupport::Notifications.instrument("request.active_resource") do |payload|
|
47
|
+
payload[:method] = method
|
48
|
+
payload[:request_uri] = "#{site.scheme}://#{site.host}:#{site.port}#{path}"
|
49
|
+
payload[:request_arguments] = arguments
|
50
|
+
payload[:result] = http.send(method, path, *arguments)
|
51
|
+
end
|
52
|
+
handle_response(result)
|
53
|
+
rescue Timeout::Error => e
|
54
|
+
raise TimeoutError.new(e.message)
|
55
|
+
rescue OpenSSL::SSL::SSLError => e
|
56
|
+
raise SSLError.new(e.message)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
module ActiveResource
|
62
|
+
class VerboseLogSubscriber < ActiveSupport::LogSubscriber
|
63
|
+
def request(event)
|
64
|
+
result = event.payload[:result]
|
65
|
+
info "#{event.payload[:method].to_s.upcase} #{event.payload[:request_uri]}"
|
66
|
+
event.payload[:request_arguments].each {|s| debug s }
|
67
|
+
info "--> %d %s %d (%.1fms)" % [result.code, result.message, result.body.to_s.length, event.duration]
|
68
|
+
debug result.body.to_s
|
69
|
+
end
|
70
|
+
|
71
|
+
def logger
|
72
|
+
ActiveResource::Base.logger
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
ActiveSupport::Notifications.unsubscribe "request.active_resource"
|
78
|
+
ActiveResource::VerboseLogSubscriber.attach_to :active_resource
|
@@ -48,8 +48,8 @@ end
|
|
48
48
|
|
49
49
|
module ResponseLoggerHelper
|
50
50
|
def log_http! options={}
|
51
|
-
@logger.log Samurai::Base.connection.http.request,
|
52
|
-
Samurai::Base.connection.http.response,
|
51
|
+
@logger.log Samurai::Base.connection.send(:http).request,
|
52
|
+
Samurai::Base.connection.send(:http).response,
|
53
53
|
options
|
54
54
|
end
|
55
55
|
|
@@ -23,4 +23,23 @@ module TransparentRedirectHelper
|
|
23
23
|
}
|
24
24
|
end
|
25
25
|
|
26
|
+
def default_payment_method_params
|
27
|
+
{
|
28
|
+
'redirect_url' => 'http://test.host',
|
29
|
+
'merchant_key' => Samurai.merchant_key,
|
30
|
+
'custom' => 'custom',
|
31
|
+
'credit_card[first_name]' => 'FirstName',
|
32
|
+
'credit_card[last_name]' => 'LastName',
|
33
|
+
'credit_card[address_1]' => '123 Main St',
|
34
|
+
'credit_card[address_2]' => '',
|
35
|
+
'credit_card[city]' => 'Chicago',
|
36
|
+
'credit_card[state]' => 'IL',
|
37
|
+
'credit_card[zip]' => '60610',
|
38
|
+
'credit_card[card_number]' => '4222222222222',
|
39
|
+
'credit_card[cvv]' => '123',
|
40
|
+
'credit_card[expiry_month]' => '05',
|
41
|
+
'credit_card[expiry_year]' => '2014',
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
26
45
|
end
|
metadata
CHANGED
@@ -1,88 +1,92 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: samurai
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.18
|
3
|
+
version: !ruby/object:Gem::Version
|
5
4
|
prerelease:
|
5
|
+
version: 0.2.19
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Graeme Rouse
|
9
9
|
- Derek Zak
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
|
14
|
+
date: 2011-10-21 00:00:00 -07:00
|
15
|
+
default_executable:
|
16
|
+
dependencies:
|
17
|
+
- !ruby/object:Gem::Dependency
|
16
18
|
name: activeresource
|
17
|
-
requirement: &
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
18
20
|
none: false
|
19
|
-
requirements:
|
20
|
-
- -
|
21
|
-
- !ruby/object:Gem::Version
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
22
24
|
version: 2.2.2
|
23
25
|
type: :runtime
|
24
26
|
prerelease: false
|
25
|
-
version_requirements: *
|
26
|
-
- !ruby/object:Gem::Dependency
|
27
|
+
version_requirements: *id001
|
28
|
+
- !ruby/object:Gem::Dependency
|
27
29
|
name: bundler
|
28
|
-
requirement: &
|
30
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
29
31
|
none: false
|
30
|
-
requirements:
|
31
|
-
- -
|
32
|
-
- !ruby/object:Gem::Version
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
33
35
|
version: 1.0.0
|
34
36
|
type: :development
|
35
37
|
prerelease: false
|
36
|
-
version_requirements: *
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
+
version_requirements: *id002
|
39
|
+
- !ruby/object:Gem::Dependency
|
38
40
|
name: rspec
|
39
|
-
requirement: &
|
41
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
40
42
|
none: false
|
41
|
-
requirements:
|
42
|
-
- -
|
43
|
-
- !ruby/object:Gem::Version
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
44
46
|
version: 2.6.0
|
45
47
|
type: :development
|
46
48
|
prerelease: false
|
47
|
-
version_requirements: *
|
48
|
-
- !ruby/object:Gem::Dependency
|
49
|
+
version_requirements: *id003
|
50
|
+
- !ruby/object:Gem::Dependency
|
49
51
|
name: fakeweb
|
50
|
-
requirement: &
|
52
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
51
53
|
none: false
|
52
|
-
requirements:
|
53
|
-
- -
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
version:
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: "0"
|
56
58
|
type: :development
|
57
59
|
prerelease: false
|
58
|
-
version_requirements: *
|
59
|
-
- !ruby/object:Gem::Dependency
|
60
|
+
version_requirements: *id004
|
61
|
+
- !ruby/object:Gem::Dependency
|
60
62
|
name: ruby-debug19
|
61
|
-
requirement: &
|
63
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
62
64
|
none: false
|
63
|
-
requirements:
|
64
|
-
- -
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
version:
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: "0"
|
67
69
|
type: :development
|
68
70
|
prerelease: false
|
69
|
-
version_requirements: *
|
70
|
-
description: If you are an online merchant and using samurai.feefighters.com, this
|
71
|
-
|
72
|
-
and process transaction.
|
73
|
-
email:
|
71
|
+
version_requirements: *id005
|
72
|
+
description: If you are an online merchant and using samurai.feefighters.com, this gem will make your life easy. Integrate with the samurai.feefighters.com portal and process transaction.
|
73
|
+
email:
|
74
74
|
- graeme@ubergateway.com
|
75
75
|
- derek@ubergateway.com
|
76
76
|
executables: []
|
77
|
+
|
77
78
|
extensions: []
|
79
|
+
|
78
80
|
extra_rdoc_files: []
|
79
|
-
|
81
|
+
|
82
|
+
files:
|
80
83
|
- .gitignore
|
81
84
|
- .rvmrc
|
82
85
|
- Gemfile
|
83
86
|
- Gemfile.lock
|
84
87
|
- README.markdown
|
85
88
|
- Rakefile
|
89
|
+
- api_reference.markdown
|
86
90
|
- app/assets/stylesheets/samurai.css
|
87
91
|
- app/views/application/_errors.html.erb
|
88
92
|
- app/views/application/_payment_form.html.erb
|
@@ -101,35 +105,44 @@ files:
|
|
101
105
|
- lib/samurai/version.rb
|
102
106
|
- samurai.gemspec
|
103
107
|
- spec/lib/authorization_spec.rb
|
104
|
-
- spec/lib/generate_docs_spec.rb
|
108
|
+
- spec/lib/generate_docs_spec.rb.bak
|
105
109
|
- spec/lib/processor_spec.rb
|
106
110
|
- spec/lib/purchase_spec.rb
|
107
111
|
- spec/spec_helper.rb
|
108
112
|
- spec/support/http_proxy.rb
|
109
113
|
- spec/support/response_logger.rb
|
114
|
+
- spec/support/transaction_seed.rb
|
110
115
|
- spec/support/transparent_redirect_helper.rb
|
116
|
+
has_rdoc: true
|
111
117
|
homepage: http://rubygems.org/gems/samurai
|
112
118
|
licenses: []
|
119
|
+
|
113
120
|
post_install_message:
|
114
121
|
rdoc_options: []
|
115
|
-
|
122
|
+
|
123
|
+
require_paths:
|
116
124
|
- lib
|
117
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
125
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
118
126
|
none: false
|
119
|
-
requirements:
|
120
|
-
- -
|
121
|
-
- !ruby/object:Gem::Version
|
122
|
-
|
123
|
-
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
hash: 2600934991802428395
|
131
|
+
segments:
|
132
|
+
- 0
|
133
|
+
version: "0"
|
134
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
135
|
none: false
|
125
|
-
requirements:
|
126
|
-
- -
|
127
|
-
- !ruby/object:Gem::Version
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
128
139
|
version: 1.3.5
|
129
140
|
requirements: []
|
141
|
+
|
130
142
|
rubyforge_project:
|
131
|
-
rubygems_version: 1.
|
143
|
+
rubygems_version: 1.6.2
|
132
144
|
signing_key:
|
133
145
|
specification_version: 3
|
134
146
|
summary: Integration gem for samurai.feefighters.com
|
135
147
|
test_files: []
|
148
|
+
|