sisow 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +7 -0
- data/Gemfile +4 -0
- data/README.rdoc +116 -0
- data/Rakefile +2 -0
- data/lib/sisow.rb +40 -0
- data/lib/sisow/api/callback.rb +51 -0
- data/lib/sisow/api/request.rb +67 -0
- data/lib/sisow/api/request/check_merchant_request.rb +40 -0
- data/lib/sisow/api/request/directory_request.rb +25 -0
- data/lib/sisow/api/request/ping_request.rb +25 -0
- data/lib/sisow/api/request/transaction_request.rb +86 -0
- data/lib/sisow/configuration.rb +33 -0
- data/lib/sisow/error_response.rb +14 -0
- data/lib/sisow/exception.rb +4 -0
- data/lib/sisow/issuer.rb +24 -0
- data/lib/sisow/merchant.rb +10 -0
- data/lib/sisow/payment.rb +40 -0
- data/lib/sisow/payment/bancontact_payment.rb +9 -0
- data/lib/sisow/payment/ideal_payment.rb +9 -0
- data/lib/sisow/payment/sofort_payment.rb +9 -0
- data/lib/sisow/ping.rb +9 -0
- data/lib/sisow/version.rb +3 -0
- data/sisow.gemspec +29 -0
- data/spec/models/bancontact_payment_spec.rb +29 -0
- data/spec/models/callback_spec.rb +72 -0
- data/spec/models/configuration_spec.rb +25 -0
- data/spec/models/error_response_spec.rb +15 -0
- data/spec/models/ideal_payment_spec.rb +29 -0
- data/spec/models/issuer_spec.rb +14 -0
- data/spec/models/merchant_spec.rb +11 -0
- data/spec/models/payment_spec.rb +57 -0
- data/spec/models/ping_spec.rb +11 -0
- data/spec/models/request_spec.rb +40 -0
- data/spec/models/sisow_spec.rb +28 -0
- data/spec/models/sofort_payment_spec.rb +29 -0
- data/spec/models/transaction_request_spec.rb +24 -0
- data/spec/sisow.yml +2 -0
- data/spec/sisow.yml.example +2 -0
- data/spec/spec_helper.rb +26 -0
- data/spec/vcr_setup.rb +6 -0
- metadata +177 -0
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sisow::Api::Request do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
@request = Sisow::Api::Request.new
|
7
|
+
@request.stub!(:params).and_return(@request.default_params)
|
8
|
+
@request.stub!(:method).and_return("CheckMerchantRequest")
|
9
|
+
@request.stub!(:clean).and_return(['ideal'])
|
10
|
+
@request.stub!(:validate!).and_return(true)
|
11
|
+
Sisow::Api::Request.stub!(:new).and_return(@request)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should point to the base URI of the Sisow API" do
|
15
|
+
Sisow::Api::Request.base_uri.should == "http://www.sisow.nl/Sisow/iDeal/RestHandler.ashx"
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should perform properly" do
|
19
|
+
sha1 = Digest::SHA1.hexdigest(
|
20
|
+
[
|
21
|
+
Sisow.configuration.merchant_id,
|
22
|
+
Sisow.configuration.merchant_key
|
23
|
+
].join
|
24
|
+
)
|
25
|
+
|
26
|
+
params = @request.params.merge!(:sha1 => sha1)
|
27
|
+
@request.stub!(:params).and_return(params)
|
28
|
+
|
29
|
+
VCR.use_cassette('request') do
|
30
|
+
@request.perform
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should raise an exception if the API returns an error" do
|
35
|
+
VCR.use_cassette('failed_request') do
|
36
|
+
lambda{ @request.perform }.should raise_error(Sisow::Exception, "An error occurred: TA3130. No SHA1")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sisow do
|
4
|
+
|
5
|
+
it "should set the configuration" do
|
6
|
+
Sisow.configure do |c|
|
7
|
+
c.merchant_id = "789"
|
8
|
+
c.merchant_key = "foobar"
|
9
|
+
c.debug_mode = false
|
10
|
+
c.test_mode = true
|
11
|
+
c.shop_id = "myshop"
|
12
|
+
end
|
13
|
+
|
14
|
+
Sisow.configuration.merchant_id.should == "789"
|
15
|
+
Sisow.configuration.merchant_key.should == "foobar"
|
16
|
+
Sisow.configuration.debug_mode.should == false
|
17
|
+
Sisow.configuration.test_mode.should == true
|
18
|
+
Sisow.configuration.shop_id.should == "myshop"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should verify the Sisow API is reachable" do
|
22
|
+
VCR.use_cassette('ping') do
|
23
|
+
Sisow::Ping.should_receive(:send)
|
24
|
+
Sisow.service_reachable?
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sisow::SofortPayment do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
@payment = Sisow::SofortPayment.new(
|
7
|
+
:purchase_id => 'purchase-123',
|
8
|
+
:issuer_id => '99',
|
9
|
+
:description => 'Payment description',
|
10
|
+
:entrance_code => 'entrancecode',
|
11
|
+
:return_url => 'http://example.com/return',
|
12
|
+
:cancel_url => 'http://example.com/cancel',
|
13
|
+
:callback_url => 'http://example.com/callback',
|
14
|
+
:notify_url => 'http://example.com/notify',
|
15
|
+
:amount => 1299
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should have the 'sofort' payment method" do
|
20
|
+
@payment.payment_method.should == 'sofort'
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should request a payment URL with the Sisow API" do
|
24
|
+
VCR.use_cassette("sofort_payment") do
|
25
|
+
@payment.payment_url.should =~ /https:\/\/www\.sisow\.nl\/Sisow\/iDeal\/Simulator\.aspx/
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sisow::Api::TransactionRequest do
|
4
|
+
|
5
|
+
it "should raise an error if API response has been forged" do
|
6
|
+
response = Hashie::Mash.new
|
7
|
+
response.transactionrequest = {
|
8
|
+
:signature => {
|
9
|
+
:sha1 => 'this_is_not_a_correct_sha1_hash'
|
10
|
+
},
|
11
|
+
:transaction => {
|
12
|
+
:trxid => '123',
|
13
|
+
:issuerurl => 'http://example.com'
|
14
|
+
}
|
15
|
+
}
|
16
|
+
|
17
|
+
payment = Sisow::IdealPayment.new
|
18
|
+
request = Sisow::Api::TransactionRequest.new(payment)
|
19
|
+
|
20
|
+
lambda{ request.clean(response) }.should raise_error(Sisow::Exception, "This response has been forged")
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
data/spec/sisow.yml
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'simplecov'
|
3
|
+
SimpleCov.start
|
4
|
+
|
5
|
+
require 'vcr_setup'
|
6
|
+
|
7
|
+
require 'rspec/autorun'
|
8
|
+
require 'sisow'
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
config.mock_with :rspec
|
12
|
+
config.color_enabled = true
|
13
|
+
config.tty = true
|
14
|
+
config.formatter = :progress
|
15
|
+
|
16
|
+
config.before(:each) do
|
17
|
+
hash = YAML.load(File.open('./spec/sisow.yml'))
|
18
|
+
|
19
|
+
Sisow.configure do |config|
|
20
|
+
config.merchant_id = hash['merchant_id']
|
21
|
+
config.merchant_key = hash['merchant_key']
|
22
|
+
config.test_mode = true
|
23
|
+
config.debug_mode = false
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/spec/vcr_setup.rb
ADDED
metadata
ADDED
@@ -0,0 +1,177 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sisow
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.9.0
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Marcel de Graaf
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2012-03-10 00:00:00 +01:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: httparty
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: "0"
|
25
|
+
type: :runtime
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: hashie
|
29
|
+
prerelease: false
|
30
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: "0"
|
36
|
+
type: :runtime
|
37
|
+
version_requirements: *id002
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: rspec
|
40
|
+
prerelease: false
|
41
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: "0"
|
47
|
+
type: :development
|
48
|
+
version_requirements: *id003
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: vcr
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: "0"
|
58
|
+
type: :development
|
59
|
+
version_requirements: *id004
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: fakeweb
|
62
|
+
prerelease: false
|
63
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: "0"
|
69
|
+
type: :development
|
70
|
+
version_requirements: *id005
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: simplecov
|
73
|
+
prerelease: false
|
74
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: "0"
|
80
|
+
type: :development
|
81
|
+
version_requirements: *id006
|
82
|
+
description: This gem implements the REST API of the Sisow payment provider.
|
83
|
+
email:
|
84
|
+
- mail@marceldegraaf.net
|
85
|
+
executables: []
|
86
|
+
|
87
|
+
extensions: []
|
88
|
+
|
89
|
+
extra_rdoc_files: []
|
90
|
+
|
91
|
+
files:
|
92
|
+
- .gitignore
|
93
|
+
- Gemfile
|
94
|
+
- README.rdoc
|
95
|
+
- Rakefile
|
96
|
+
- lib/sisow.rb
|
97
|
+
- lib/sisow/api/callback.rb
|
98
|
+
- lib/sisow/api/request.rb
|
99
|
+
- lib/sisow/api/request/check_merchant_request.rb
|
100
|
+
- lib/sisow/api/request/directory_request.rb
|
101
|
+
- lib/sisow/api/request/ping_request.rb
|
102
|
+
- lib/sisow/api/request/transaction_request.rb
|
103
|
+
- lib/sisow/configuration.rb
|
104
|
+
- lib/sisow/error_response.rb
|
105
|
+
- lib/sisow/exception.rb
|
106
|
+
- lib/sisow/issuer.rb
|
107
|
+
- lib/sisow/merchant.rb
|
108
|
+
- lib/sisow/payment.rb
|
109
|
+
- lib/sisow/payment/bancontact_payment.rb
|
110
|
+
- lib/sisow/payment/ideal_payment.rb
|
111
|
+
- lib/sisow/payment/sofort_payment.rb
|
112
|
+
- lib/sisow/ping.rb
|
113
|
+
- lib/sisow/version.rb
|
114
|
+
- sisow.gemspec
|
115
|
+
- spec/models/bancontact_payment_spec.rb
|
116
|
+
- spec/models/callback_spec.rb
|
117
|
+
- spec/models/configuration_spec.rb
|
118
|
+
- spec/models/error_response_spec.rb
|
119
|
+
- spec/models/ideal_payment_spec.rb
|
120
|
+
- spec/models/issuer_spec.rb
|
121
|
+
- spec/models/merchant_spec.rb
|
122
|
+
- spec/models/payment_spec.rb
|
123
|
+
- spec/models/ping_spec.rb
|
124
|
+
- spec/models/request_spec.rb
|
125
|
+
- spec/models/sisow_spec.rb
|
126
|
+
- spec/models/sofort_payment_spec.rb
|
127
|
+
- spec/models/transaction_request_spec.rb
|
128
|
+
- spec/sisow.yml
|
129
|
+
- spec/sisow.yml.example
|
130
|
+
- spec/spec_helper.rb
|
131
|
+
- spec/vcr_setup.rb
|
132
|
+
has_rdoc: true
|
133
|
+
homepage: http://github.com/marceldegraaf/sisow
|
134
|
+
licenses: []
|
135
|
+
|
136
|
+
post_install_message:
|
137
|
+
rdoc_options: []
|
138
|
+
|
139
|
+
require_paths:
|
140
|
+
- lib
|
141
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
142
|
+
none: false
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: "0"
|
147
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
|
+
none: false
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: "0"
|
153
|
+
requirements: []
|
154
|
+
|
155
|
+
rubyforge_project: sisow
|
156
|
+
rubygems_version: 1.5.0
|
157
|
+
signing_key:
|
158
|
+
specification_version: 3
|
159
|
+
summary: Rails gem for payments through Sisow.
|
160
|
+
test_files:
|
161
|
+
- spec/models/bancontact_payment_spec.rb
|
162
|
+
- spec/models/callback_spec.rb
|
163
|
+
- spec/models/configuration_spec.rb
|
164
|
+
- spec/models/error_response_spec.rb
|
165
|
+
- spec/models/ideal_payment_spec.rb
|
166
|
+
- spec/models/issuer_spec.rb
|
167
|
+
- spec/models/merchant_spec.rb
|
168
|
+
- spec/models/payment_spec.rb
|
169
|
+
- spec/models/ping_spec.rb
|
170
|
+
- spec/models/request_spec.rb
|
171
|
+
- spec/models/sisow_spec.rb
|
172
|
+
- spec/models/sofort_payment_spec.rb
|
173
|
+
- spec/models/transaction_request_spec.rb
|
174
|
+
- spec/sisow.yml
|
175
|
+
- spec/sisow.yml.example
|
176
|
+
- spec/spec_helper.rb
|
177
|
+
- spec/vcr_setup.rb
|