adyen 1.6.0 → 2.0.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -0
  3. data/CHANGELOG.md +116 -0
  4. data/CONTRIBUTING.md +84 -0
  5. data/Gemfile +1 -1
  6. data/README.md +33 -0
  7. data/Rakefile +19 -4
  8. data/adyen.gemspec +7 -5
  9. data/config.ru +5 -0
  10. data/lib/adyen.rb +2 -2
  11. data/lib/adyen/configuration.rb +6 -0
  12. data/lib/adyen/form.rb +13 -48
  13. data/lib/adyen/matchers.rb +1 -1
  14. data/lib/adyen/rest.rb +53 -0
  15. data/lib/adyen/rest/authorise_payment.rb +148 -0
  16. data/lib/adyen/rest/client.rb +110 -0
  17. data/lib/adyen/rest/errors.rb +33 -0
  18. data/lib/adyen/rest/modify_payment.rb +97 -0
  19. data/lib/adyen/rest/request.rb +107 -0
  20. data/lib/adyen/rest/response.rb +59 -0
  21. data/lib/adyen/util.rb +147 -0
  22. data/lib/adyen/version.rb +1 -1
  23. data/test/form_test.rb +17 -10
  24. data/test/functional/payment_authorisation_api_test.rb +54 -0
  25. data/test/functional/payment_modification_api_test.rb +57 -0
  26. data/test/helpers/configure_adyen.rb +5 -0
  27. data/test/helpers/example_server.rb +105 -0
  28. data/test/helpers/public/adyen.encrypt.js +679 -0
  29. data/test/helpers/public/adyen.encrypt.min.js +14 -0
  30. data/test/helpers/test_cards.rb +20 -0
  31. data/test/helpers/views/authorized.erb +7 -0
  32. data/test/helpers/views/hpp.erb +19 -0
  33. data/test/helpers/views/index.erb +6 -0
  34. data/test/helpers/views/pay.erb +36 -0
  35. data/test/helpers/views/redirect_shopper.erb +18 -0
  36. data/test/integration/hpp_integration_test.rb +52 -0
  37. data/test/integration/payment_using_3d_secure_integration_test.rb +40 -0
  38. data/test/integration/payment_with_client_side_encryption_integration_test.rb +26 -0
  39. data/test/rest_request_test.rb +50 -0
  40. data/test/rest_response_test.rb +18 -0
  41. data/test/test_helper.rb +32 -0
  42. data/test/util_test.rb +77 -0
  43. metadata +89 -16
  44. data/README.rdoc +0 -50
  45. data/lib/adyen/encoding.rb +0 -21
  46. data/lib/adyen/formatter.rb +0 -33
  47. data/test/adyen_test.rb +0 -31
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 455a933ae555a5bdef76141cf1b8ff4d7e44b383
4
- data.tar.gz: a6f844a752ce6f69778bd9eba5bcfc86a935404c
3
+ metadata.gz: fd5a2022e170a6376459b9fa48062f85ac05ce97
4
+ data.tar.gz: dc37f35aa6a2265d467c5ae1dd3d6860cc959894
5
5
  SHA512:
6
- metadata.gz: 997202692973d0ab546fca1ee3c343a1e0c7e7809b2f4a8d6cf7636bc34ced06b3d31bcfeae77339472483888d5b0db10a56f70c47a6ddffed49eb6f7c6b0ed5
7
- data.tar.gz: b591907d17db7636db322d851c796c6ae6b2b247b3c8cac2fba8d4bee63aa940596469ff9946ce2f818467a4253c53572947381d2eb80994dcb9c61ba11ce399
6
+ metadata.gz: 6928bc0115a69ed05d2be6cd1deccce983bb3bcb53ff34a8e068505bc8d09b82930df245fc96c6e5bd058830e4a92f2f12df352724285b4bab5f7a3684bf11f2
7
+ data.tar.gz: bcc9cd8995fd9c299a71dcc20ec2415b87038bdf1b8d6eb05177303d1470e38f08ee1e72d54fb1dbbaa3813aa8839b67c3bbabd4f16f3eeba6bc5b73358378d7
@@ -1,4 +1,5 @@
1
1
  language: ruby
2
+ cache: bundler
2
3
  script: bundle exec rake
3
4
  rvm:
4
5
  - 1.9.3
@@ -20,3 +21,4 @@ env:
20
21
  - ADYEN_MERCHANT_ACCOUNT: "VanBergenORG"
21
22
  - ADYEN_API_USERNAME: "ws@Company.VanBergen"
22
23
  - ADYEN_API_PASSWORD: "7phtHzbfnzsp"
24
+ sudo: false
@@ -0,0 +1,116 @@
1
+ # Changelog
2
+
3
+ The following changes have been made to the library over the years. Pleae add an entry to this file as part of your pull requests.
4
+
5
+ #### Unrelease changes
6
+
7
+ - Add `Adyen::REST` to intereact with Adyen's webservices.
8
+ - Add `Adyen::HPP` to integrate with Adyen's Hosted Payment Pages.
9
+ - Make client-side encryption a first class citizen.
10
+ - Add integration test suite that uses a functional example app.
11
+ - Deprecate `Adyen::API` and `Adyen::Form`.
12
+ - DOcumentation updates and improvements.
13
+
14
+ #### Version 1.6.0
15
+
16
+ - Make the credit card's CVC not required for authorise calls.
17
+ - Add support for instant payments: authorise & capture in one call.
18
+ - Add support for Billet payments.
19
+ - Fix functional tests in CI, and move to Minitest for unit tests.
20
+
21
+ #### Version 1.5.0
22
+
23
+ - Drop support for Ruby 1.8.
24
+ - Add support for SEPA Direct Debit payments
25
+ - Add support for payment in installments.
26
+ - Enable client-side encryption support to one click payments.
27
+ - Add `Adyen::Form.payments_method_url`.
28
+ - Parse additional data in authorisation responses.
29
+ - Add support sending for shopper details as part of `Adyen::Form`.
30
+ - Fixed some XML encoding issues on different Ruby versions.
31
+
32
+ #### Version 1.4.1
33
+
34
+ - Improve form matchers for testing
35
+ - Fix some deprecation warnings
36
+
37
+ #### Version 1.4.0
38
+
39
+ - Add support for client-side encryption
40
+ - Add support for `fraud_offset`.
41
+
42
+ #### Version 1.3.2
43
+
44
+ - Add support sending for billing details as part of `Adyen::Form`.
45
+ - Allow setting a custom domain for the HPP payment flow.
46
+ - Allow setting default parameters on a `Adyen::Form` skin.
47
+ - Fix: recurring contracts without references.
48
+ - Several improvement sin the notification handler template.
49
+
50
+ #### Version 1.3.1
51
+
52
+ - Allow sending a shipper's statement as part of the API.
53
+
54
+ #### Version 1.3.0
55
+
56
+ - Add support for ELV direct debit payments.
57
+ - Improved error handling on SOAP errors.
58
+
59
+ #### Version 1.2.0
60
+
61
+ - Implemented the `RecurringService#store_token` API call to store credit cards for recurring billing.
62
+ - Other fixes in recurring API dure to changes in Adyen backend.
63
+ - Added some new parameters to the signature string calculations.
64
+ - Add support for storing the HTTP basic authentication credentials Adyen uses for notifications in the configuration object. Note that this gem will currently never use these, but you can refer to them when building your integration, and store your configuration in one location.
65
+
66
+ #### Version 1.1.0
67
+
68
+ - Add support for different payment flows in the form-based mode.
69
+ - Fixed some encoding issues.
70
+
71
+ #### Version 1.0.0
72
+
73
+ - Complete rewrite of the SOAP client.
74
+ - Rails 3 integration for configuration and generators.
75
+ - Removed all dependencies; Nokogiri and Rails 3 are optional.
76
+ - Configuration variables are now integrated in `Adyen.configuration`.
77
+ - Better documentation and improved testsuite.
78
+
79
+ #### Version 0.3.2
80
+
81
+ - Fixed Rails 3 ActiveRecord deprecation notice.
82
+ - Implemented the `cancelOrRefund` call for the payment SOAP service as `Adyen::SOAP::PaymentService.cancel_or_refund`
83
+
84
+ Thanks to [tibastral](https://github.com/tibastral) for implementing this SOAP call.
85
+
86
+ #### Version 0.3.1
87
+
88
+ - Implemented the `authorise` call for the payment SOAP service as `Adyen::SOAP::PaymentService.authorise`
89
+ - Implemented the `disable` call for the recurring payment SOAP service as `Adyen::SOAP::RecurringService.disable`
90
+
91
+ Thanks again to [Stefan Borsje](http://github.com/sborsje) for implementing the SOAP calls.
92
+
93
+ #### Version 0.3.0
94
+
95
+ - Switched to Yard for code documentation, which is served on [rdoc.info](http://rdoc.info/projects/wvanbergen/adyen)
96
+ - Authentication now compatible with the latest *handsoap* version 1.1.4. Please update handsoap to this version.
97
+ - Implemented the `listRecurringDetails` call for the recurring payment SOAP service as `Adyen::SOAP::RecurringService.list`
98
+
99
+ Thanks to [Stefan Borsje](http://github.com/sborsje) for fixing handsoap authentication and implementing the SOAP call.
100
+
101
+ #### Version 0.2.3
102
+
103
+ - Implemented `Adyen.load_config` to load configuration values from a Hash or YAML file.
104
+
105
+ #### Version 0.2.2
106
+
107
+ - Fixed Curb HTTP backend to handle "101 Continue" responses correctly
108
+
109
+ #### Version 0.2.1
110
+
111
+ - Added `Adyen::Form.default_arguments` to store arguments that should be used in every payment form or redirect.
112
+
113
+ #### Version 0.2.0
114
+
115
+ - Switched to gemcutter.org for gem releases.
116
+ - Added support for automatically handling skins and their shared secrets by registering them using `Adyen::Form.register_skin`
@@ -0,0 +1,84 @@
1
+ # Contributing
2
+
3
+ This projects welcomes outside contributions from anyone.
4
+
5
+ ## Reporting issues
6
+
7
+ Please report bugs as a [Github issue](https://github.com/wvanbergen/adyen/issues/new).
8
+
9
+ - We are not associated with Adyen. Please contact Adyen youself if you are having
10
+ trouble with your integration.
11
+ - This library supports several features that are not supported by default on a new
12
+ Adyen account. You may have to contact Adyen if you are receiving a
13
+ "010 Not allowed" response.
14
+ - Feature request issues will be closed. This is a scratch your own itch project,
15
+ so implement it yourself and open a pull request to get it included.
16
+
17
+ ## Pull requests
18
+
19
+ Pull requests are welcomed; this is very much a scratch your own itch project.
20
+ Fork the project, implement your stuff and issue a pull request.
21
+
22
+ Some notes:
23
+
24
+ - Try to follow the coding style of the surrounding code.
25
+ - We prefer to keep the number of dependencies of this library to 0. So we will
26
+ not accept new runtime dependencies.
27
+ - All changes should be unit tested using Minitest. (Rspec is used only for some
28
+ of the deprecated functionality)
29
+ - All changes should be documented using
30
+ [Yardoc](http://www.rubydoc.info/gems/yard/file/docs/GettingStarted.md) notation.
31
+ - All new functionality that requires interfacing with Adyen should either come with
32
+ a functional or integration test to prevent regressions.
33
+ - It is possible that something that works with your own account, does not work with
34
+ the account we are using for CI (e.g. failure with "010 Not allowed". We may have
35
+ to ask Adyem to enable the functionality on our test account. Please let me know in
36
+ a PR comment.
37
+ - `Adyen::API` and `Adyen::Form` are deprecated. Only bugfixes to these components
38
+ will be accepted. Use and improve `Adyen::REST` and `Adyen::HPP` instead, respectively.
39
+ - **DO** add amn entry to [CHANGELOG.md](./CHANGELOG.md).
40
+ - **DO NOT** update `Adyen::VERSION`. This will be done as part of the release process.
41
+
42
+ ### Become contributor
43
+
44
+ If one of your pull request gets accepted, I will add you as a contributor if you wish.
45
+ Once accepted, please be mindful that this project is used in production in several apps.
46
+ So follow good engineering practices:
47
+
48
+ - No backwards incompatible changes.
49
+ - No pushing directly to master.
50
+ - Ask for code reviews on larger changes.
51
+
52
+ ### Contributors
53
+
54
+ - Willem van Bergen
55
+ - Michel Barbosa
56
+ - Stefan Borsje
57
+ - Eloy Durán
58
+ - Tobias Bielohlawek
59
+ - Dimitri Sinitsa
60
+ - Rinaldi Fonseca
61
+ - Joost Hietbrink
62
+ - Daryl Yeo
63
+ - Washington Luiz
64
+ - Lucas Húngaro
65
+ - Richard Bone
66
+ - Benjamin Waldher
67
+ - Martin Beck
68
+ - Paweł Gościcki
69
+ - Priit Hamer
70
+ - Eugene Pimenov
71
+ - Michael Grosser
72
+ - Lukasz Lazewski
73
+ - Thibaut Assus
74
+ - Vinicius Ferriani
75
+ - Timo Rößner
76
+
77
+ ## Release process
78
+
79
+ Use the following steps to release a new version of this gem.
80
+
81
+ - Run `git co master && git pull origin master`
82
+ - Update `Adyen::VERSION`
83
+ - Move CHANGELOG items from "Unreleased" section to a new section for the chosen version number.
84
+ - Run `bundle exec rake release`
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source 'https://rubygems.org'
2
2
  gemspec
3
3
 
4
- platform :rbx do
4
+ platform :rbx do
5
5
  gem 'rubysl'
6
6
  gem 'racc'
7
7
  end
@@ -0,0 +1,33 @@
1
+ # Adyen [![Build Status](https://travis-ci.org/wvanbergen/adyen.svg?branch=master)](https://travis-ci.org/wvanbergen/adyen)
2
+
3
+ Package to simplify including Adyen payments services into a Ruby on Rails application.
4
+
5
+ > Note: this library is corrently undergoing a major rewrite. Information in this README is about the still unreleased version of this library. If you want information about the last released version, check out version [1.6.0](https://github.com/wvanbergen/adyen/tree/v1.6.0).
6
+
7
+ Adyen integration relies on three modes of communication between Adyen, your server and your client/customer:
8
+
9
+ - Client-to-Adyen communication using Hosted Payment Pages (HPP).
10
+ - Server-to-Adyen communication using their REST webservice.
11
+ - Adyen-to-server communications using notifications.
12
+
13
+ This library aims to ease the implementation of all these modes into your Rack application. Moreover, it provides matchers, assertions and mocks to make it easier to implement an automated test suite to assert the integration is working correctly.
14
+
15
+ ### Usage
16
+
17
+ - See the [project wiki](https://github.com/wvanbergen/adyen/wiki) to get started.
18
+ - Check out [the example server](https://github.com/wvanbergen/adyen/blob/master/test/helpers/example_server.rb) for an example implementation of the HPP payment flow, and an implementation of self-hosted a payment flow that uses the REST webservice. To start the example server, run `bundle exec rackup` in the root of this project.
19
+ - Complete RDoc documentation can be found on [rubydoc.info](http://www.rubydoc.info/gems/adyen).
20
+ - For more information about Adyen, see http://www.adyen.com
21
+ - For more information about integrating Adyen, see [their manuals](https://www.adyen.com/home/support/manuals.html). Of primary interest are the HPP integration manual for `Adyen::Form`, and the API integration manual for `Adyen::REST`.
22
+
23
+ The library doesn't have any dependencies, but making Nokogiri available in your environment will greatly improve the speed of any XML and HTML processing.
24
+
25
+ ### About
26
+
27
+ This package is written by Michel Barbosa and Willem van Bergen for Floorplanner.com, and
28
+ made public under the MIT license (see LICENSE). It is currently maintained by Willem van
29
+ Bergen, with help from several contributors. We are not affiliated with Adyen B.V. The software
30
+ comes without warranty of any kind, so use at your own risk.
31
+
32
+ - `CHANGELOG.md` documents the changes between releases.
33
+ - Check out `CONTRIBUTING.md` if you want to help out with this project.
data/Rakefile CHANGED
@@ -7,6 +7,21 @@ Rake::TestTask.new do |t|
7
7
  t.test_files = FileList['test/**/*_test.rb']
8
8
  end
9
9
 
10
+ Rake::TestTask.new('test:unit') do |t|
11
+ t.libs << "test"
12
+ t.test_files = FileList['test/*_test.rb']
13
+ end
14
+
15
+ Rake::TestTask.new('test:functional') do |t|
16
+ t.libs << "test"
17
+ t.test_files = FileList['test/functional/**/*_test.rb']
18
+ end
19
+
20
+ Rake::TestTask.new('test:integration') do |t|
21
+ t.libs << "test"
22
+ t.test_files = FileList['test/integration/**/*_test.rb']
23
+ end
24
+
10
25
  RSpec::Core::RakeTask.new(:spec) do |task|
11
26
  task.pattern = "./spec/**/*_spec.rb"
12
27
  task.rspec_opts = ['--color']
@@ -22,10 +37,10 @@ task :update_cacert do
22
37
  cp tmp, CACERT_PATH
23
38
  end
24
39
 
25
- # Update the cacert.pem file before each release.
26
- task :build => :update_cacert do
27
- sh "git diff-index --quiet HEAD #{CACERT_PATH} || (git add #{CACERT_PATH} && git commit -m '[API] Update CA root certificates file.')"
28
- end
40
+ # # Update the cacert.pem file before each release.
41
+ # task :build => :update_cacert do
42
+ # sh "git diff-index --quiet HEAD #{CACERT_PATH} || (git add #{CACERT_PATH} && git commit -m '[API] Update CA root certificates file.')"
43
+ # end
29
44
 
30
45
  begin
31
46
  require 'rubygems'
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
13
13
  s.summary = "Integrate Adyen payment services in your Ruby on Rails application."
14
14
  s.description = <<-EOS
15
15
  Package to simplify including the Adyen payments services into a Ruby on Rails application.
16
- The package provides functionality to create payment forms, handling and storing notifications
16
+ The package provides functionality to create payment forms, handling and storing notifications
17
17
  sent by Adyen and consuming the SOAP services provided by Adyen. Moreover, it contains helper
18
18
  methods, mocks and matchers to simpify writing tests/specs for your code.
19
19
  EOS
@@ -27,14 +27,16 @@ Gem::Specification.new do |s|
27
27
  s.add_development_dependency('rspec', '~> 2.14')
28
28
  s.add_development_dependency('minitest', '~> 5')
29
29
  s.add_development_dependency('mocha')
30
-
30
+ s.add_development_dependency('sinatra')
31
+ s.add_development_dependency('poltergeist')
32
+
31
33
  s.add_development_dependency('rails', '>= 3.2')
32
34
  s.add_development_dependency('nokogiri', '>= 1.6.1')
33
-
35
+
34
36
  s.requirements << 'Having Nokogiri installed will speed up XML handling when using the SOAP API.'
35
37
 
36
- s.rdoc_options << '--title' << s.name << '--main' << 'README.rdoc' << '--line-numbers' << '--inline-source'
37
- s.extra_rdoc_files = ['README.rdoc']
38
+ s.rdoc_options << '--title' << s.name << '--main' << 'README.md' << '--line-numbers' << '--inline-source'
39
+ s.extra_rdoc_files = ['README.md', 'CHANGELOG.md', 'CONTRIBUTING.md']
38
40
 
39
41
  s.files = `git ls-files`.split($/)
40
42
  s.test_files = s.files.grep(%r{^(test|spec|features)/})
@@ -0,0 +1,5 @@
1
+ $LOAD_PATH.unshift(File.expand_path('../lib', __FILE__))
2
+ $LOAD_PATH.unshift(File.expand_path('../test', __FILE__))
3
+
4
+ require 'helpers/example_server'
5
+ run Adyen::ExampleServer.new
@@ -21,9 +21,9 @@ end
21
21
 
22
22
  require 'adyen/version'
23
23
  require 'adyen/configuration'
24
- require 'adyen/encoding'
25
- require 'adyen/formatter'
24
+ require 'adyen/util'
26
25
  require 'adyen/form'
27
26
  require 'adyen/api'
27
+ require 'adyen/rest'
28
28
 
29
29
  require 'adyen/railtie' if defined?(::Rails) && ::Rails::VERSION::MAJOR >= 3
@@ -79,6 +79,12 @@ class Adyen::Configuration
79
79
  # @return [Hash]
80
80
  attr_accessor :default_api_params
81
81
 
82
+ # The client-side encryption public key that is used to encrypt payment forms.
83
+ # You can find the key on the webservice user page in the Adyen settings.
84
+ #
85
+ # @return [String]
86
+ attr_accessor :cse_public_key
87
+
82
88
  # Default arguments that will be used for in every HTML form.
83
89
  #
84
90
  # @example
@@ -86,9 +86,9 @@ module Adyen
86
86
  end
87
87
 
88
88
  parameters[:recurring_contract] = 'RECURRING' if parameters.delete(:recurring) == true
89
- parameters[:order_data] = Adyen::Encoding.gzip_base64(parameters.delete(:order_data_raw)) if parameters[:order_data_raw]
90
- parameters[:ship_before_date] = Adyen::Formatter::DateTime.fmt_date(parameters[:ship_before_date])
91
- parameters[:session_validity] = Adyen::Formatter::DateTime.fmt_time(parameters[:session_validity])
89
+ parameters[:order_data] = Adyen::Util.gzip_base64(parameters.delete(:order_data_raw)) if parameters[:order_data_raw]
90
+ parameters[:ship_before_date] = Adyen::Util.format_date(parameters[:ship_before_date])
91
+ parameters[:session_validity] = Adyen::Util.format_timestamp(parameters[:session_validity])
92
92
  end
93
93
 
94
94
  # Transforms the payment parameters to be in the correct format and calculates the merchant
@@ -133,7 +133,7 @@ module Adyen
133
133
  # {Adyen::Configuration#default_form_params} hash will be included automatically.
134
134
  # @return [Hash] The payment parameters flatten, with camelized and prefixed key, stringified value
135
135
  def flat_payment_parameters(parameters = {})
136
- flatten(payment_parameters(parameters))
136
+ Adyen::Util.flatten(payment_parameters(parameters))
137
137
  end
138
138
 
139
139
  # Returns an absolute URL to the Adyen payment system, with the payment parameters included
@@ -252,7 +252,7 @@ module Adyen
252
252
  def calculate_signature(parameters, shared_secret = nil)
253
253
  shared_secret ||= parameters.delete(:shared_secret)
254
254
  raise ArgumentError, "Cannot calculate payment request signature with empty shared_secret" if shared_secret.to_s.empty?
255
- Adyen::Encoding.hmac_base64(shared_secret, calculate_signature_string(parameters))
255
+ Adyen::Util.hmac_base64(shared_secret, calculate_signature_string(parameters))
256
256
  end
257
257
 
258
258
  # Generates the string that is used to calculate the request signature. This signature
@@ -282,7 +282,7 @@ module Adyen
282
282
  def calculate_billing_address_signature(parameters, shared_secret = nil)
283
283
  shared_secret ||= parameters.delete(:shared_secret)
284
284
  raise ArgumentError, "Cannot calculate billing address request signature with empty shared_secret" if shared_secret.to_s.empty?
285
- Adyen::Encoding.hmac_base64(shared_secret, calculate_billing_address_signature_string(parameters[:billing_address]))
285
+ Adyen::Util.hmac_base64(shared_secret, calculate_billing_address_signature_string(parameters[:billing_address]))
286
286
  end
287
287
 
288
288
  # shopperSig: shopper.firstName + shopper.infix + shopper.lastName + shopper.gender + shopper.dateOfBirthDayOfMonth + shopper.dateOfBirthMonth + shopper.dateOfBirthYear + shopper.telephoneNumber
@@ -296,7 +296,7 @@ module Adyen
296
296
  def calculate_shopper_signature(parameters, shared_secret = nil)
297
297
  shared_secret ||= parameters.delete(:shared_secret)
298
298
  raise ArgumentError, "Cannot calculate shopper request signature with empty shared_secret" if shared_secret.to_s.empty?
299
- Adyen::Encoding.hmac_base64(shared_secret, calculate_shopper_signature_string(parameters[:shopper]))
299
+ Adyen::Util.hmac_base64(shared_secret, calculate_shopper_signature_string(parameters[:shopper]))
300
300
  end
301
301
 
302
302
  ######################################################
@@ -307,8 +307,8 @@ module Adyen
307
307
  # @param [Hash] params A hash of HTTP GET parameters for the redirect request.
308
308
  # @return [String] The signature string.
309
309
  def redirect_signature_string(params)
310
- params[:authResult].to_s + params[:pspReference].to_s + params[:merchantReference].to_s +
311
- params[:skinCode].to_s + params[:merchantReturnData].to_s
310
+ params['authResult'].to_s + params['pspReference'].to_s + params['merchantReference'].to_s +
311
+ params['skinCode'].to_s + params['merchantReturnData'].to_s
312
312
  end
313
313
 
314
314
  # Computes the redirect signature using the request parameters, so that the
@@ -321,9 +321,9 @@ module Adyen
321
321
  # @return [String] The redirect signature
322
322
  # @raise [ArgumentError] Thrown if shared_secret is empty
323
323
  def redirect_signature(params, shared_secret = nil)
324
- shared_secret ||= Adyen.configuration.form_skin_shared_secret_by_code(params[:skinCode])
324
+ shared_secret ||= Adyen.configuration.form_skin_shared_secret_by_code(params['skinCode'])
325
325
  raise ArgumentError, "Cannot compute redirect signature with empty shared_secret" if shared_secret.to_s.empty?
326
- Adyen::Encoding.hmac_base64(shared_secret, redirect_signature_string(params))
326
+ Adyen::Util.hmac_base64(shared_secret, redirect_signature_string(params))
327
327
  end
328
328
 
329
329
  # Checks the redirect signature for this request by calcultating the signature from
@@ -358,43 +358,8 @@ module Adyen
358
358
  # @return [true, false] Returns true only if the signature in the parameters is correct.
359
359
  def redirect_signature_check(params, shared_secret = nil)
360
360
  raise ArgumentError, "params should be a Hash" unless params.is_a?(Hash)
361
- raise ArgumentError, "params should contain :merchantSig" unless params.key?(:merchantSig)
362
- params[:merchantSig] == redirect_signature(params, shared_secret)
363
- end
364
-
365
- # Returns the camelized version of a string.
366
- # @param [:to_s] identifier The identifier to turn to camelcase
367
- # @return [String] The camelcase version of the identifier provided.
368
- def camelize(identifier)
369
- identifier.to_s.gsub(/_(.)/) { $1.upcase }
370
- end
371
-
372
- # Transforms the nested parameters Hash into a 'flat' Hash which is understood by adyen. This is:
373
- # * all keys are camelized
374
- # * all keys are stringified
375
- # * nested hash is flattened, keys are prefixed with root key
376
- #
377
- # @example
378
- # flatten {:billing_address => { :street => 'My Street'}}
379
- #
380
- # # resolves in:
381
- # {'billingAddress.street' => 'My Street'}
382
- #
383
- # @param [Hash] parameters The payment parameters which to transform
384
- # @param [String] prefix The prefix to add to the key
385
- # @param [Hash] return_hash The new hash which is retruned (needed for recursive calls)
386
- # @return [Hash] The return_hash filled with camelized and prefixed key, stringified value
387
- def flatten(parameters, prefix = "", return_hash = {})
388
- parameters ||= {}
389
- parameters.inject(return_hash) do |hash, (key, value)|
390
- key = "#{prefix}#{camelize(key)}"
391
- if value.is_a?(Hash)
392
- flatten(value, "#{key}.", return_hash)
393
- else
394
- hash[key] = value.to_s
395
- end
396
- hash
397
- end
361
+ raise ArgumentError, "params should contain :merchantSig" unless params.key?('merchantSig')
362
+ params['merchantSig'] == redirect_signature(params, shared_secret)
398
363
  end
399
364
  end
400
365
  end