paylane 0.0.2 → 0.0.3

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.
@@ -2,7 +2,6 @@ require "savon"
2
2
  require "paylane/version"
3
3
  require "paylane/gateway"
4
4
  require "paylane/api"
5
- require "paylane/response"
6
5
  require "paylane/payment"
7
6
  require "paylane/recurring_payment"
8
7
  require "paylane/railtie" if defined?(Rails)
@@ -1,3 +1,6 @@
1
+ require "paylane/response"
2
+ require "paylane/connection_error"
3
+
1
4
  module PayLane
2
5
  class API
3
6
  def initialize(client)
@@ -49,9 +52,15 @@ module PayLane
49
52
  private
50
53
 
51
54
  def request(method, params, params_prefix = nil)
52
- body = params_prefix ? {params_prefix => params} : params
53
- soap_response = @client.request(method) { soap.body = body }
54
- soap_response.to_hash
55
+ begin
56
+ body = params_prefix ? {params_prefix => params} : params
57
+ soap_response = @client.request(method) { soap.body = body }
58
+ soap_response.to_hash
59
+ rescue Savon::Error => e
60
+ err = PayLane::ConnectionError.new(e)
61
+ PayLane.logger.error("[PayLane][Savon] #{err}")
62
+ raise err
63
+ end
55
64
  end
56
65
  end
57
66
  end
@@ -0,0 +1,13 @@
1
+ module PayLane
2
+ class ConnectionError < StandardError
3
+ attr_reader :soap_error
4
+
5
+ def initialize(soap_error)
6
+ @soap_error = soap_error
7
+ end
8
+
9
+ def to_s
10
+ @soap_error.to_s
11
+ end
12
+ end
13
+ end
@@ -1,3 +1,3 @@
1
1
  module PayLane
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -187,5 +187,19 @@ describe PayLane::API do
187
187
  sales.should include({id_sale: "2772323", status: "PERFORMED", is_refund: false, is_chargeback: false, is_reversal: false})
188
188
  end
189
189
  end
190
+
191
+ describe 'handle savon error' do
192
+ let(:savon_http_error) {
193
+ Savon::HTTP::Error.new(double(error?: true, code: 404, body: 'Not Found'))
194
+ }
195
+
196
+ it 'logs and raise PayLane::ConnectionError' do
197
+ connection.stub(:request).and_raise(savon_http_error)
198
+ PayLane.logger.should_receive(:error).with("[PayLane][Savon] HTTP error (404): Not Found")
199
+ expect {
200
+ api.multi_sale({})
201
+ }.to raise_error(PayLane::ConnectionError)
202
+ end
203
+ end
190
204
  end
191
205
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paylane
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-09 00:00:00.000000000 Z
12
+ date: 2012-08-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: savon
@@ -91,6 +91,7 @@ files:
91
91
  - Rakefile
92
92
  - lib/paylane.rb
93
93
  - lib/paylane/api.rb
94
+ - lib/paylane/connection_error.rb
94
95
  - lib/paylane/gateway.rb
95
96
  - lib/paylane/payment.rb
96
97
  - lib/paylane/railtie.rb