adyen 1.5.0 → 1.6.0
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 +4 -4
- data/.gitignore +3 -0
- data/.travis.yml +2 -2
- data/LICENSE +1 -1
- data/README.rdoc +4 -0
- data/Rakefile +7 -5
- data/adyen.gemspec +2 -0
- data/lib/adyen/api.rb +66 -6
- data/lib/adyen/api/payment_service.rb +69 -2
- data/lib/adyen/api/recurring_service.rb +1 -1
- data/lib/adyen/api/templates/payment_service.rb +31 -1
- data/lib/adyen/api/xml_querier.rb +1 -1
- data/lib/adyen/form.rb +3 -0
- data/lib/adyen/formatter.rb +10 -4
- data/lib/adyen/matchers.rb +3 -7
- data/lib/adyen/version.rb +1 -1
- data/spec/api/api_spec.rb +23 -10
- data/spec/api/payment_service_spec.rb +29 -1
- data/spec/api/response_spec.rb +2 -2
- data/spec/api/simple_soap_client_spec.rb +1 -1
- data/spec/api/spec_helper.rb +12 -0
- data/spec/functional/api_spec.rb +61 -55
- data/test/adyen_test.rb +31 -0
- data/test/form_test.rb +220 -0
- data/test/test_helper.rb +24 -0
- metadata +36 -8
- data/.kick +0 -35
- data/TODO +0 -16
- data/spec/adyen_spec.rb +0 -44
- data/spec/form_spec.rb +0 -318
data/test/test_helper.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'minitest/autorun'
|
3
|
+
require 'minitest/pride'
|
4
|
+
require 'mocha/setup'
|
5
|
+
|
6
|
+
require 'adyen'
|
7
|
+
require 'adyen/matchers'
|
8
|
+
|
9
|
+
module Adyen::Test
|
10
|
+
module EachXMLBackend
|
11
|
+
XML_BACKENDS = [Adyen::API::XMLQuerier::NokogiriBackend, Adyen::API::XMLQuerier::REXMLBackend]
|
12
|
+
|
13
|
+
def for_each_xml_backend(&block)
|
14
|
+
XML_BACKENDS.each do |xml_backend|
|
15
|
+
begin
|
16
|
+
Adyen::API::XMLQuerier.stubs(:default_backend).returns(xml_backend.new)
|
17
|
+
block.call(xml_backend)
|
18
|
+
ensure
|
19
|
+
Adyen::API::XMLQuerier.unstub(:default_backend)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: adyen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Willem van Bergen
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2014-
|
14
|
+
date: 2014-12-03 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rake
|
@@ -41,6 +41,34 @@ dependencies:
|
|
41
41
|
- - ~>
|
42
42
|
- !ruby/object:Gem::Version
|
43
43
|
version: '2.14'
|
44
|
+
- !ruby/object:Gem::Dependency
|
45
|
+
name: minitest
|
46
|
+
requirement: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ~>
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '5'
|
51
|
+
type: :development
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ~>
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '5'
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: mocha
|
60
|
+
requirement: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - '>='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
type: :development
|
66
|
+
prerelease: false
|
67
|
+
version_requirements: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - '>='
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
44
72
|
- !ruby/object:Gem::Dependency
|
45
73
|
name: rails
|
46
74
|
requirement: !ruby/object:Gem::Requirement
|
@@ -85,13 +113,11 @@ extra_rdoc_files:
|
|
85
113
|
- README.rdoc
|
86
114
|
files:
|
87
115
|
- .gitignore
|
88
|
-
- .kick
|
89
116
|
- .travis.yml
|
90
117
|
- Gemfile
|
91
118
|
- LICENSE
|
92
119
|
- README.rdoc
|
93
120
|
- Rakefile
|
94
|
-
- TODO
|
95
121
|
- adyen.gemspec
|
96
122
|
- lib/adyen.rb
|
97
123
|
- lib/adyen/api.rb
|
@@ -114,7 +140,6 @@ files:
|
|
114
140
|
- lib/adyen/templates/notification_migration.rb
|
115
141
|
- lib/adyen/templates/notification_model.rb
|
116
142
|
- lib/adyen/version.rb
|
117
|
-
- spec/adyen_spec.rb
|
118
143
|
- spec/api/api_spec.rb
|
119
144
|
- spec/api/payment_service_spec.rb
|
120
145
|
- spec/api/recurring_service_spec.rb
|
@@ -122,11 +147,13 @@ files:
|
|
122
147
|
- spec/api/simple_soap_client_spec.rb
|
123
148
|
- spec/api/spec_helper.rb
|
124
149
|
- spec/api/test_helpers_spec.rb
|
125
|
-
- spec/form_spec.rb
|
126
150
|
- spec/functional/api_spec.rb
|
127
151
|
- spec/functional/initializer.rb.ci
|
128
152
|
- spec/functional/initializer.rb.sample
|
129
153
|
- spec/spec_helper.rb
|
154
|
+
- test/adyen_test.rb
|
155
|
+
- test/form_test.rb
|
156
|
+
- test/test_helper.rb
|
130
157
|
- yard_extensions.rb
|
131
158
|
homepage: http://github.com/wvanbergen/adyen/wiki
|
132
159
|
licenses:
|
@@ -160,7 +187,6 @@ signing_key:
|
|
160
187
|
specification_version: 4
|
161
188
|
summary: Integrate Adyen payment services in your Ruby on Rails application.
|
162
189
|
test_files:
|
163
|
-
- spec/adyen_spec.rb
|
164
190
|
- spec/api/api_spec.rb
|
165
191
|
- spec/api/payment_service_spec.rb
|
166
192
|
- spec/api/recurring_service_spec.rb
|
@@ -168,8 +194,10 @@ test_files:
|
|
168
194
|
- spec/api/simple_soap_client_spec.rb
|
169
195
|
- spec/api/spec_helper.rb
|
170
196
|
- spec/api/test_helpers_spec.rb
|
171
|
-
- spec/form_spec.rb
|
172
197
|
- spec/functional/api_spec.rb
|
173
198
|
- spec/functional/initializer.rb.ci
|
174
199
|
- spec/functional/initializer.rb.sample
|
175
200
|
- spec/spec_helper.rb
|
201
|
+
- test/adyen_test.rb
|
202
|
+
- test/form_test.rb
|
203
|
+
- test/test_helper.rb
|
data/.kick
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
options.on('--doc', 'Also generate docs.') do
|
2
|
-
process do |files|
|
3
|
-
if files.any? { |f| f =~ /lib\/.+\.rb$/ }
|
4
|
-
execute "yardoc --no-private"
|
5
|
-
execute(%{osascript -e 'tell application "Safari"
|
6
|
-
do JavaScript "window.location.reload()" in first document
|
7
|
-
end tell'})
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
recipe :ruby
|
13
|
-
|
14
|
-
process do |files|
|
15
|
-
specs = files.take_and_map do |file|
|
16
|
-
case file
|
17
|
-
when "spec/spec_helper.rb"
|
18
|
-
Dir.glob("spec/**/*_spec.rb")
|
19
|
-
when "spec/api/spec_helper.rb"
|
20
|
-
Dir.glob("spec/api/*_spec.rb")
|
21
|
-
when "lib/adyen/api.rb"
|
22
|
-
"spec/api/api_spec.rb"
|
23
|
-
when "lib/adyen/api/xml_querier.rb"
|
24
|
-
["spec/api/payment_service_spec.rb", "spec/api/recurring_service_spec.rb"]
|
25
|
-
when "lib/adyen/api/simple_soap_client.rb"
|
26
|
-
["spec/api/simple_soap_client_spec.rb", "spec/api/payment_service_spec.rb", "spec/api/recurring_service_spec.rb"]
|
27
|
-
when "lib/adyen/api/response.rb"
|
28
|
-
["spec/api/response_spec.rb", "spec/api/payment_service_spec.rb", "spec/api/recurring_service_spec.rb"]
|
29
|
-
when %r{lib/adyen/api/templates/(.+)\.rb$}, %r{lib/adyen/api/(.+)\.rb$}
|
30
|
-
"spec/api/#{$1}_spec.rb"
|
31
|
-
end
|
32
|
-
end
|
33
|
-
Ruby.run_tests(specs)
|
34
|
-
end
|
35
|
-
|
data/TODO
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
* Add a capture! method to an authorisation response from the PaymentService.
|
2
|
-
|
3
|
-
* Add iDEAL API. To get started, see the `iDEAL' topic-branch which contains `ideal-scratchpad.rb' and a stub for a functional spec.
|
4
|
-
|
5
|
-
* Add the DirectDebit API.
|
6
|
-
|
7
|
-
* Add ActiveMerchant integration
|
8
|
-
|
9
|
-
* Split up gem to have more explicit dependency requirements, e.g.:
|
10
|
-
* adyen-soap
|
11
|
-
* adyen-railtie
|
12
|
-
* adyen-activemerchant
|
13
|
-
|
14
|
-
* Add mocks for notification requests in order to test your app
|
15
|
-
|
16
|
-
* Add more mock SOAP responses for testing your app.
|
data/spec/adyen_spec.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Adyen do
|
6
|
-
|
7
|
-
describe Adyen::Encoding do
|
8
|
-
it "should a hmac_base64 correcly" do
|
9
|
-
encoded_str = Adyen::Encoding.hmac_base64('bla', 'bla')
|
10
|
-
encoded_str.should == '6nItEkVpIYF+i1RwrEyQ7RHmrfU='
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should gzip_base64 correcly" do
|
14
|
-
encoded_str = Adyen::Encoding.gzip_base64('bla')
|
15
|
-
encoded_str.length.should == 32
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe Adyen::Formatter::DateTime do
|
20
|
-
it "should accept dates" do
|
21
|
-
Adyen::Formatter::DateTime.fmt_date(Date.today).should match(/^\d{4}-\d{2}-\d{2}$/)
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should accept times" do
|
25
|
-
Adyen::Formatter::DateTime.fmt_time(Time.now).should match(/^\d{4}-\d{2}-\d{2}T\d{2}\:\d{2}\:\d{2}Z$/)
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should accept valid time strings" do
|
29
|
-
Adyen::Formatter::DateTime.fmt_time('2009-01-01T11:11:11Z').should match(/^\d{4}-\d{2}-\d{2}T\d{2}\:\d{2}\:\d{2}Z$/)
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should accept valid time strings" do
|
33
|
-
Adyen::Formatter::DateTime.fmt_date('2009-01-01').should match(/^\d{4}-\d{2}-\d{2}$/)
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should raise on an invalid time string" do
|
37
|
-
lambda { Adyen::Formatter::DateTime.fmt_time('2009-01-01 11:11:11') }.should raise_error
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should raise on an invalid date string" do
|
41
|
-
lambda { Adyen::Formatter::DateTime.fmt_date('2009-1-1') }.should raise_error
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
data/spec/form_spec.rb
DELETED
@@ -1,318 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'date'
|
4
|
-
require 'spec_helper'
|
5
|
-
require 'adyen/form'
|
6
|
-
|
7
|
-
describe Adyen::Form do
|
8
|
-
|
9
|
-
before(:each) do
|
10
|
-
Adyen.configuration.register_form_skin(:testing, '4aD37dJA', 'Kah942*$7sdp0)')
|
11
|
-
Adyen.configuration.default_form_params[:merchant_account] = 'TestMerchant'
|
12
|
-
end
|
13
|
-
|
14
|
-
describe 'Action URLs' do
|
15
|
-
|
16
|
-
before(:each) do
|
17
|
-
# Use autodetection for the environment unless otherwise specified
|
18
|
-
Adyen.configuration.environment = nil
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should generate correct testing url" do
|
22
|
-
Adyen::Form.url.should == 'https://test.adyen.com/hpp/select.shtml'
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should generate a live url if the environment is set to live" do
|
26
|
-
Adyen.configuration.environment = :live
|
27
|
-
Adyen::Form.url.should == 'https://live.adyen.com/hpp/select.shtml'
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should generate correct live url in a production environment" do
|
31
|
-
Adyen.configuration.stub(:autodetect_environment).and_return('live')
|
32
|
-
Adyen::Form.url.should. == 'https://live.adyen.com/hpp/select.shtml'
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should generate correct live url if explicitely asked for" do
|
36
|
-
Adyen::Form.url(:live).should == 'https://live.adyen.com/hpp/select.shtml'
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should generate correct testing url if the payment flow selection is set to select" do
|
40
|
-
Adyen.configuration.payment_flow = :select
|
41
|
-
Adyen::Form.url.should == 'https://test.adyen.com/hpp/select.shtml'
|
42
|
-
end
|
43
|
-
|
44
|
-
it "should generate correct testing url if the payment flow selection is set to pay" do
|
45
|
-
Adyen.configuration.payment_flow = :pay
|
46
|
-
Adyen::Form.url.should == 'https://test.adyen.com/hpp/pay.shtml'
|
47
|
-
end
|
48
|
-
|
49
|
-
it "should generate correct testing url if the payment flow selection is set to details" do
|
50
|
-
Adyen.configuration.payment_flow = :details
|
51
|
-
Adyen::Form.url.should == 'https://test.adyen.com/hpp/details.shtml'
|
52
|
-
end
|
53
|
-
|
54
|
-
context "with custom domain" do
|
55
|
-
before(:each) do
|
56
|
-
Adyen.configuration.payment_flow = :select
|
57
|
-
Adyen.configuration.payment_flow_domain = "checkout.mydomain.com"
|
58
|
-
end
|
59
|
-
|
60
|
-
it "should generate correct testing url" do
|
61
|
-
Adyen::Form.url.should == 'https://checkout.mydomain.com/hpp/select.shtml'
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
describe 'redirect signature check' do
|
67
|
-
before(:each) do
|
68
|
-
# Example taken from integration manual
|
69
|
-
|
70
|
-
# Example get params sent back with redirect
|
71
|
-
@params = { :authResult => 'AUTHORISED', :pspReference => '1211992213193029',
|
72
|
-
:merchantReference => 'Internet Order 12345', :skinCode => '4aD37dJA',
|
73
|
-
:merchantSig => 'ytt3QxWoEhAskUzUne0P5VA9lPw='}
|
74
|
-
end
|
75
|
-
|
76
|
-
it "should calculate the signature string correctly" do
|
77
|
-
Adyen::Form.redirect_signature_string(@params).should == 'AUTHORISED1211992213193029Internet Order 123454aD37dJA'
|
78
|
-
params = @params.merge(:merchantReturnData => 'testing1234')
|
79
|
-
Adyen::Form.redirect_signature_string(params).should == 'AUTHORISED1211992213193029Internet Order 123454aD37dJAtesting1234'
|
80
|
-
end
|
81
|
-
|
82
|
-
it "should calculate the signature correctly" do
|
83
|
-
Adyen::Form.redirect_signature(@params).should == @params[:merchantSig]
|
84
|
-
end
|
85
|
-
|
86
|
-
it "should check the signature correctly with explicit shared signature" do
|
87
|
-
Adyen::Form.redirect_signature_check(@params, 'Kah942*$7sdp0)').should be_true
|
88
|
-
end
|
89
|
-
|
90
|
-
it "should check the signature correctly using the stored shared secret" do
|
91
|
-
Adyen::Form.redirect_signature_check(@params).should be_true
|
92
|
-
end
|
93
|
-
|
94
|
-
it "should raise ArgumentError on missing skinCode" do
|
95
|
-
expect do
|
96
|
-
@params.delete(:skinCode)
|
97
|
-
Adyen::Form.redirect_signature_check(@params).should be_false
|
98
|
-
end.to raise_error ArgumentError
|
99
|
-
end
|
100
|
-
|
101
|
-
it "should raise ArgumentError on empty input" do
|
102
|
-
expect do
|
103
|
-
Adyen::Form.redirect_signature_check({}).should be_false
|
104
|
-
end.to raise_error ArgumentError
|
105
|
-
end
|
106
|
-
|
107
|
-
it "should detect a tampered field" do
|
108
|
-
Adyen::Form.redirect_signature_check(@params.merge(:pspReference => 'tampered')).should be_false
|
109
|
-
end
|
110
|
-
|
111
|
-
it "should detect a tampered signature" do
|
112
|
-
Adyen::Form.redirect_signature_check(@params.merge(:merchantSig => 'tampered')).should be_false
|
113
|
-
end
|
114
|
-
|
115
|
-
end
|
116
|
-
|
117
|
-
describe 'redirect URL generation' do
|
118
|
-
before(:each) do
|
119
|
-
@attributes = { :currency_code => 'GBP', :payment_amount => 10000, :ship_before_date => Date.today,
|
120
|
-
:merchant_reference => 'Internet Order 12345', :skin => :testing,
|
121
|
-
:session_validity => Time.now + 3600 }
|
122
|
-
|
123
|
-
@redirect_url = Adyen::Form.redirect_url(@attributes)
|
124
|
-
end
|
125
|
-
|
126
|
-
it "should return an URL pointing to the adyen server" do
|
127
|
-
@redirect_url.should =~ %r[^#{Adyen::Form.url}]
|
128
|
-
end
|
129
|
-
|
130
|
-
it "should include all provided attributes" do
|
131
|
-
params = @redirect_url.split('?', 2).last.split('&').map { |param| param.split('=', 2).first }
|
132
|
-
params.should include(*(@attributes.keys.map { |k| Adyen::Form.camelize(k) }))
|
133
|
-
end
|
134
|
-
|
135
|
-
it "should include the merchant signature" do
|
136
|
-
params = @redirect_url.split('?', 2).last.split('&').map { |param| param.split('=', 2).first }
|
137
|
-
params.should include('merchantSig')
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
describe 'payment methods available URL' do
|
142
|
-
let(:payment_methods_url) do
|
143
|
-
@attributes = { :currency_code => 'GBP', :payment_amount => 10000, :ship_before_date => Date.today,
|
144
|
-
:merchant_reference => 'Internet Order 12345', :skin => :testing,
|
145
|
-
:session_validity => Time.now + 3600 }
|
146
|
-
|
147
|
-
Adyen::Form.payment_methods_url(@attributes)
|
148
|
-
end
|
149
|
-
|
150
|
-
it "should return an directory URL" do
|
151
|
-
payment_methods_url.should =~ %r[^#{Adyen::Form.url(nil, :directory)}]
|
152
|
-
end
|
153
|
-
|
154
|
-
it "should include all provided attributes" do
|
155
|
-
params = payment_methods_url.split('?', 2).last.split('&').map { |param| param.split('=', 2).first }
|
156
|
-
params.should include(*(@attributes.keys.map { |k| Adyen::Form.camelize(k) }))
|
157
|
-
end
|
158
|
-
|
159
|
-
it "should include the merchant signature" do
|
160
|
-
params = payment_methods_url.split('?', 2).last.split('&').map { |param| param.split('=', 2).first }
|
161
|
-
params.should include('merchantSig')
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
165
|
-
describe 'hidden fields generation' do
|
166
|
-
include APISpecHelper
|
167
|
-
subject { %Q'<form action="#{CGI.escapeHTML(Adyen::Form.url)}" method="post">#{Adyen::Form.hidden_fields(@attributes)}</form>' }
|
168
|
-
|
169
|
-
before(:each) do
|
170
|
-
@attributes = { :currency_code => 'GBP', :payment_amount => 10000, :ship_before_date => Date.today,
|
171
|
-
:merchant_reference => 'Internet Order 12345', :skin => :testing,
|
172
|
-
:session_validity => Time.now + 3600 }
|
173
|
-
end
|
174
|
-
|
175
|
-
for_each_xml_backend do
|
176
|
-
it { should have_adyen_payment_form }
|
177
|
-
end
|
178
|
-
|
179
|
-
it { should include('<input type="hidden" name="merchantAccount" value="TestMerchant" />') }
|
180
|
-
|
181
|
-
context "width default_form_params" do
|
182
|
-
before(:each) do
|
183
|
-
Adyen.configuration.register_form_skin(:testing, '4aD37dJA', 'Kah942*$7sdp0)', {
|
184
|
-
:merchant_account => 'OtherMerchant',
|
185
|
-
})
|
186
|
-
end
|
187
|
-
|
188
|
-
it { should include('<input type="hidden" name="merchantAccount" value="OtherMerchant" />') }
|
189
|
-
it { should_not include('<input type="hidden" name="merchantAccount" value="TestMerchant" />') }
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
|
-
describe 'signature calculation' do
|
194
|
-
|
195
|
-
# This example is taken from the Adyen integration manual
|
196
|
-
|
197
|
-
before(:each) do
|
198
|
-
|
199
|
-
@parameters = { :currency_code => 'GBP', :payment_amount => 10000,
|
200
|
-
:ship_before_date => '2007-10-20', :merchant_reference => 'Internet Order 12345',
|
201
|
-
:skin => :testing, :session_validity => '2007-10-11T11:00:00Z',
|
202
|
-
:billing_address => {
|
203
|
-
:street => 'Alexanderplatz',
|
204
|
-
:house_number_or_name => '0815',
|
205
|
-
:city => 'Berlin',
|
206
|
-
:postal_code => '10119',
|
207
|
-
:state_or_province => 'Berlin',
|
208
|
-
:country => 'Germany',
|
209
|
-
},
|
210
|
-
:shopper => {
|
211
|
-
:telephone_number => '1234512345',
|
212
|
-
:first_name => 'John',
|
213
|
-
:last_name => 'Doe',
|
214
|
-
:social_security_number => '123-45-1234'
|
215
|
-
}
|
216
|
-
}
|
217
|
-
|
218
|
-
Adyen::Form.do_parameter_transformations!(@parameters)
|
219
|
-
end
|
220
|
-
|
221
|
-
it "should construct the signature base string correctly" do
|
222
|
-
signature_string = Adyen::Form.calculate_signature_string(@parameters)
|
223
|
-
signature_string.should == "10000GBP2007-10-20Internet Order 123454aD37dJATestMerchant2007-10-11T11:00:00Z"
|
224
|
-
|
225
|
-
signature_string = Adyen::Form.calculate_signature_string(@parameters.merge(:merchant_return_data => 'testing123'))
|
226
|
-
signature_string.should == "10000GBP2007-10-20Internet Order 123454aD37dJATestMerchant2007-10-11T11:00:00Ztesting123"
|
227
|
-
end
|
228
|
-
|
229
|
-
it "should calculate the signature correctly" do
|
230
|
-
signature = Adyen::Form.calculate_signature(@parameters)
|
231
|
-
signature.should == 'x58ZcRVL1H6y+XSeBGrySJ9ACVo='
|
232
|
-
end
|
233
|
-
|
234
|
-
it "should raise ArgumentError on empty shared_secret" do
|
235
|
-
expect do
|
236
|
-
@parameters.delete(:shared_secret)
|
237
|
-
signature = Adyen::Form.calculate_signature(@parameters)
|
238
|
-
end.to raise_error ArgumentError
|
239
|
-
end
|
240
|
-
|
241
|
-
it "should calculate the signature base string correctly for a recurring payment" do
|
242
|
-
# Add the required recurrent payment attributes
|
243
|
-
@parameters.merge!(:recurring_contract => 'DEFAULT', :shopper_reference => 'grasshopper52', :shopper_email => 'gras.shopper@somewhere.org')
|
244
|
-
|
245
|
-
signature_string = Adyen::Form.calculate_signature_string(@parameters)
|
246
|
-
signature_string.should == "10000GBP2007-10-20Internet Order 123454aD37dJATestMerchant2007-10-11T11:00:00Zgras.shopper@somewhere.orggrasshopper52DEFAULT"
|
247
|
-
end
|
248
|
-
|
249
|
-
it "should calculate the signature correctly for a recurring payment" do
|
250
|
-
# Add the required recurrent payment attributes
|
251
|
-
@parameters.merge!(:recurring_contract => 'DEFAULT', :shopper_reference => 'grasshopper52', :shopper_email => 'gras.shopper@somewhere.org')
|
252
|
-
|
253
|
-
signature = Adyen::Form.calculate_signature(@parameters)
|
254
|
-
signature.should == 'F2BQEYbE+EUhiRGuPtcD16Gm7JY='
|
255
|
-
end
|
256
|
-
|
257
|
-
context 'billing address' do
|
258
|
-
|
259
|
-
it "should construct the signature base string correctly" do
|
260
|
-
signature_string = Adyen::Form.calculate_billing_address_signature_string(@parameters[:billing_address])
|
261
|
-
signature_string.should == "Alexanderplatz0815Berlin10119BerlinGermany"
|
262
|
-
end
|
263
|
-
|
264
|
-
it "should calculate the signature correctly" do
|
265
|
-
signature = Adyen::Form.calculate_billing_address_signature(@parameters)
|
266
|
-
signature.should == '5KQb7VJq4cz75cqp11JDajntCY4='
|
267
|
-
end
|
268
|
-
|
269
|
-
it "should raise ArgumentError on empty shared_secret" do
|
270
|
-
expect do
|
271
|
-
@parameters.delete(:shared_secret)
|
272
|
-
signature = Adyen::Form.calculate_billing_address_signature(@parameters)
|
273
|
-
end.to raise_error ArgumentError
|
274
|
-
end
|
275
|
-
|
276
|
-
end
|
277
|
-
|
278
|
-
context 'shopper' do
|
279
|
-
|
280
|
-
it "should construct the signature base string correctly" do
|
281
|
-
signature_string = Adyen::Form.calculate_shopper_signature_string(@parameters[:shopper])
|
282
|
-
signature_string.should == "JohnDoe1234512345"
|
283
|
-
end
|
284
|
-
|
285
|
-
it "should calculate the signature correctly" do
|
286
|
-
signature = Adyen::Form.calculate_shopper_signature(@parameters)
|
287
|
-
signature.should == 'rb2GEs1kGKuLh255a3QRPBYXmsQ='
|
288
|
-
end
|
289
|
-
|
290
|
-
it "should raise ArgumentError on empty shared_secret" do
|
291
|
-
expect do
|
292
|
-
@parameters.delete(:shared_secret)
|
293
|
-
signature = Adyen::Form.calculate_shopper_signature(@parameters)
|
294
|
-
end.to raise_error ArgumentError
|
295
|
-
end
|
296
|
-
|
297
|
-
end
|
298
|
-
|
299
|
-
end
|
300
|
-
|
301
|
-
describe "flatten" do
|
302
|
-
let(:parameters) do
|
303
|
-
{
|
304
|
-
:billing_address => { :street => 'My Street'}
|
305
|
-
}
|
306
|
-
end
|
307
|
-
|
308
|
-
it "returns empty hash for nil input" do
|
309
|
-
Adyen::Form.flatten(nil).should == {}
|
310
|
-
end
|
311
|
-
|
312
|
-
it "flattens hash and prefixes keys" do
|
313
|
-
Adyen::Form.flatten(parameters).should == {
|
314
|
-
'billingAddress.street' => 'My Street'
|
315
|
-
}
|
316
|
-
end
|
317
|
-
end
|
318
|
-
end
|