adyen_jpiqueras 2.3.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8c9637788e33f4b5ea6358b481dd6b84fa21c893
4
- data.tar.gz: 0373397b8eea85370cff403d086d87f199075a4b
3
+ metadata.gz: 05bd483db66cada29259292de71f385a2c54345a
4
+ data.tar.gz: ac777c6f970f2b311ce3bd4d3798eace00b0d357
5
5
  SHA512:
6
- metadata.gz: d7c29df5296cfca388f24baf77d5bd5d9ef7445912de358b4fadbbea2aabfdd3c86f8e1755ae57e14e55fb684e7d86cfe51c91e23f13a605eeaa25a680792ae3
7
- data.tar.gz: e50f8976df8452af922a403fec63ffbc833d7a79c9fc6ea4531930da1760966b94e1abe12c8a80f2989f722dac02470d1340703b51002cb787837449ce8a1370
6
+ metadata.gz: c118178acf9a176f816c06fb831ba622656d0f99f611a62ada157422a76fcac23e2e16c6a6d5b78ebf0c0ebc737b450a4cf46076d2b1aa45903c1f055ce44b21
7
+ data.tar.gz: 5131df70714f73087622423e4cc206412e5ab49abc53e5f61f060b1df9462ea796c84d60c72a0d3d15282889c52c0bf9b5a8ac90e0cde522b4cf31214fe1b811
data/.gitignore CHANGED
@@ -4,7 +4,7 @@
4
4
  /tmp
5
5
  /pkg
6
6
  /doc
7
- adyen-*.gem
7
+ adyen_jpiqueras*.gem
8
8
  .yardoc
9
9
  *.swp
10
10
  *.swo
data/README.md CHANGED
@@ -1,31 +1,7 @@
1
- # Adyen [![Build Status](https://travis-ci.org/wvanbergen/adyen.svg?branch=master)](https://travis-ci.org/wvanbergen/adyen)
1
+ # Adyen_jpiqueras
2
2
 
3
- Package to simplify including Adyen payments services into a Ruby on Rails application.
3
+ ### This is a temporal fork of the [adyen gem](https://github.com/wvanbergen/adyen)
4
4
 
5
- Adyen integration relies on three modes of communication between Adyen, your server and your client/customer:
5
+ The main difference is that implements the payout support by [AlexGaspar](https://github.com/AlexGaspar)
6
6
 
7
- - Client-to-Adyen communication using Hosted Payment Pages (HPP).
8
- - Server-to-Adyen communication using their REST webservice.
9
- - Adyen-to-server communications using notifications.
10
-
11
- 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.
12
-
13
- ### Usage
14
-
15
- - See the [project wiki](https://github.com/wvanbergen/adyen/wiki) to get started.
16
- - 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.
17
- - Complete RDoc documentation can be found on [rubydoc.info](http://www.rubydoc.info/gems/adyen).
18
- - For more information about Adyen, see http://www.adyen.com
19
- - 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`.
20
-
21
- 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.
22
-
23
- ### About
24
-
25
- This package is written by Michel Barbosa and Willem van Bergen for Floorplanner.com, and
26
- made public under the MIT license (see LICENSE). It is currently maintained by Willem van
27
- Bergen, with help from several contributors. We are not affiliated with Adyen B.V. The software
28
- comes without warranty of any kind, so use at your own risk.
29
-
30
- - `CHANGELOG.md` documents the changes between releases.
31
- - Check out `CONTRIBUTING.md` if you want to help out with this project.
7
+ I also modified the ResponseError class to implement the new response error format (https://docs.adyen.com/developers/api-manual)
@@ -104,7 +104,7 @@ module Adyen
104
104
  case response = http.request(http_request)
105
105
  when Net::HTTPOK
106
106
  return response
107
- when Net::HTTPInternalServerError
107
+ when Net::HTTPUnprocessableEntity, Net::HTTPInternalServerError
108
108
  raise Adyen::REST::ResponseError.new(response.body)
109
109
  when Net::HTTPUnauthorized
110
110
  raise Adyen::REST::Error.new("Webservice credentials are incorrect")
@@ -11,23 +11,38 @@ module Adyen
11
11
 
12
12
  # Exception class for error responses from the Adyen API.
13
13
  #
14
- # @!attribute category
14
+ # @!attribute status
15
15
  # @return [String, nil]
16
- # @!attribute code
16
+ # @!attribute error_code
17
17
  # @return [Integer, nil]
18
- # @!attribute description
18
+ # @!attribute message
19
+ # @return [String, nil]
20
+ # @!attribute error_type
21
+ # @return [String, nil]
22
+ # @!attribute psp_reference
19
23
  # @return [String, nil]
20
24
  class ResponseError < Adyen::REST::Error
21
- attr_accessor :category, :code, :description
25
+ attr_reader :status, :error_code, :message, :error_type, :psp_reference
22
26
 
23
27
  def initialize(response_body)
24
- if match = /\A(\w+)\s(\d+)\s(.*)\z/.match(response_body)
25
- @category, @code, @description = match[1], match[2].to_i, match[3]
26
- super("API request error: #{description} (code: #{code}/#{category})")
28
+ parse_params(response_body)
29
+ if error_code && message && error_type
30
+ super("API request error: #{message} (code: #{error_type}/#{error_code})")
27
31
  else
28
32
  super("API request error: #{response_body}")
29
33
  end
30
34
  end
35
+
36
+ private
37
+
38
+ def parse_params(response_body)
39
+ params = Hash[CGI.parse(response_body).map {|key,values| [key.to_sym, values[0] || true]}]
40
+ @status = params[:status]
41
+ @error_code = params[:errorCode]
42
+ @message = params[:message]
43
+ @error_type = params[:errorType]
44
+ @psp_reference = params[:pspReference] if params[:pspReference]
45
+ end
31
46
  end
32
47
  end
33
48
  end
data/lib/adyen/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Adyen
2
2
  # Version constant for the Adyen plugin.
3
3
  # Set it & commit the change before running rake release.
4
- VERSION = "2.3.0"
4
+ VERSION = "2.4.0"
5
5
  end
@@ -0,0 +1,26 @@
1
+ require 'test_helper'
2
+ require 'adyen/rest/errors'
3
+
4
+ class RESTResponseErrorTest < Minitest::Test
5
+
6
+ def test_parsing_attributes
7
+ response_body = 'errorType=validation&errorCode=800&message=Contract+not+found&pspReference=1234512345&status=422'
8
+ response_error = Adyen::REST::ResponseError.new(response_body)
9
+ common_checks(response_error)
10
+ assert_equal '1234512345', response_error.psp_reference
11
+ end
12
+
13
+ def test_parsing_attributes_without_psp_reference
14
+ response_body = 'errorType=validation&errorCode=800&message=Contract+not+found&status=422'
15
+ response_error = Adyen::REST::ResponseError.new(response_body)
16
+ common_checks(response_error)
17
+ assert_nil response_error.psp_reference
18
+ end
19
+
20
+ def common_checks(response_error)
21
+ assert_equal '422', response_error.status
22
+ assert_equal 'validation', response_error.error_type
23
+ assert_equal '800', response_error.error_code
24
+ assert_equal 'Contract not found', response_error.message
25
+ end
26
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adyen_jpiqueras
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Willem van Bergen
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2016-08-29 00:00:00.000000000 Z
15
+ date: 2016-09-05 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: rake
@@ -231,6 +231,7 @@ files:
231
231
  - test/rest/signature_test.rb
232
232
  - test/rest_list_recurring_details_response_test.rb
233
233
  - test/rest_request_test.rb
234
+ - test/rest_response_error_test.rb
234
235
  - test/rest_response_test.rb
235
236
  - test/signature_test.rb
236
237
  - test/test_helper.rb
@@ -302,6 +303,7 @@ test_files:
302
303
  - test/rest/signature_test.rb
303
304
  - test/rest_list_recurring_details_response_test.rb
304
305
  - test/rest_request_test.rb
306
+ - test/rest_response_error_test.rb
305
307
  - test/rest_response_test.rb
306
308
  - test/signature_test.rb
307
309
  - test/test_helper.rb