paypal_adaptive 0.3.5 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.markdown +3 -0
- data/lib/paypal_adaptive/request.rb +11 -4
- data/lib/paypal_adaptive/version.rb +1 -1
- data/paypal_adaptive.gemspec +1 -0
- data/test/test_helper.rb +4 -1
- data/test/unit/request_test.rb +15 -4
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YWQ2Y2UzMTAzNWQzZmRjYWZjOGE0MTIwNjNlMzc0ZjYzNWVmMGU1MA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MzM5YTU4ZjMxMmVhYjYwMjk4NzUyYjJmMzdiYTM4MTc0YjRkYjY1Zg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OTRhZDRkN2FjOWJmNjY1YTAyMjk1Yzg3ZmY5ODljYjAwMWIzZDk1ZjQwMzkw
|
10
|
+
NDBiNWIxOTNhZTdkODcxZTJmNDllZTAxOTA2MTY3OTNmMWIzNDFmMzdjYTg0
|
11
|
+
NWRhZWU3N2U3OGYyMGJiNWQ0MTI5MGFiYzVjMWU0NzBmMjkxMzg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZDM3ODVmMmUzZjMxZmQ5NGIxOTllODI4MGY5MGI5MTEwM2EzYjVlZjk3NzVk
|
14
|
+
ZDBkOWUwZjA1NGQ1NzU5N2EyZjIwMWY5OWM0MWY3MWU3MDRmYjJhMzYwNWFm
|
15
|
+
MTc5ZDVmM2ViOWYyM2IzYzlmYjIwMmRkZjNhOTdkNjAyOTViYWE=
|
data/README.markdown
CHANGED
@@ -96,6 +96,9 @@ for each environment, e.g.:
|
|
96
96
|
The api_cert_file should point to your cert_key_pem.txt that is downloaded through the paypal developer interface. It will contain a section that specifies the RSA private key and another section that specifies a certificate. If this is left empty, paypal_adaptive will attempt to use the signature method of validation with PayPal, so your signature config must not be nil.
|
97
97
|
|
98
98
|
## Changelog
|
99
|
+
0.3.6
|
100
|
+
Include more details in error in case the HTTP request doesn't return. thanks mreinsch
|
101
|
+
|
99
102
|
0.3.5
|
100
103
|
SSL verify mode set to none for sandbox testing. thanks @mikong
|
101
104
|
|
@@ -81,8 +81,15 @@ module PaypalAdaptive
|
|
81
81
|
PaypalAdaptive::Response.new(post(data, path), @env)
|
82
82
|
end
|
83
83
|
|
84
|
-
def rescue_error_message(e, message = nil)
|
85
|
-
|
84
|
+
def rescue_error_message(e, message = nil, response_data = nil)
|
85
|
+
error = {"message" => message || e}
|
86
|
+
if response_data
|
87
|
+
error["details"] = {
|
88
|
+
"httpCode" => response_data.code,
|
89
|
+
"httpMessage" => response_data.message.to_s,
|
90
|
+
"httpBody" => response_data.body }
|
91
|
+
end
|
92
|
+
{"responseEnvelope" => {"ack" => "Failure"}, "error" => [error]}
|
86
93
|
end
|
87
94
|
|
88
95
|
def post(data, path)
|
@@ -107,13 +114,13 @@ module PaypalAdaptive
|
|
107
114
|
rescue Net::HTTPBadGateway => e
|
108
115
|
rescue_error_message(e, "Error reading from remote server.")
|
109
116
|
rescue JSON::ParserError => e
|
110
|
-
rescue_error_message(e, "Response is not in JSON format.")
|
117
|
+
rescue_error_message(e, "Response is not in JSON format.", response_data)
|
111
118
|
rescue Exception => e
|
112
119
|
case e
|
113
120
|
when Errno::ECONNRESET
|
114
121
|
rescue_error_message(e, "Connection Reset. Request invalid URL.")
|
115
122
|
else
|
116
|
-
rescue_error_message(e)
|
123
|
+
rescue_error_message(e, response_data)
|
117
124
|
end
|
118
125
|
end
|
119
126
|
|
data/paypal_adaptive.gemspec
CHANGED
@@ -16,6 +16,7 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.add_dependency("jsonschema", "~>2.0.0")
|
17
17
|
s.add_development_dependency("rake")
|
18
18
|
s.add_development_dependency("activesupport", "~> 3.2.0")
|
19
|
+
s.add_development_dependency("webmock")
|
19
20
|
|
20
21
|
s.rubyforge_project = "paypal_adaptive"
|
21
22
|
|
data/test/test_helper.rb
CHANGED
data/test/unit/request_test.rb
CHANGED
@@ -12,16 +12,27 @@ class RequestTest < Test::Unit::TestCase
|
|
12
12
|
assert_instance_of Hash, response
|
13
13
|
end
|
14
14
|
|
15
|
-
def
|
15
|
+
def test_post_should_return_error_message_when_request_is_invalid
|
16
16
|
request = PaypalAdaptive::Request.new('test')
|
17
17
|
response = request.post({:data => true}, '/some-random-url')
|
18
18
|
assert_instance_of Hash, response
|
19
|
+
assert_equal "Connection Reset. Request invalid URL.", response["error"][0]["message"]
|
19
20
|
end
|
20
21
|
|
21
|
-
def
|
22
|
+
def test_post_should_return_error_details_when_response_is_invalid
|
23
|
+
WebMock.disable_net_connect!
|
24
|
+
stub_request(:post, "https://svcs.sandbox.paypal.com/some-random-url").
|
25
|
+
to_return(:status => [500, "Internal Server Error"], :body => "Something went wrong")
|
22
26
|
request = PaypalAdaptive::Request.new('test')
|
23
27
|
response = request.post({:data => true}, '/some-random-url')
|
24
|
-
|
28
|
+
assert_instance_of Hash, response
|
29
|
+
error = response["error"].first
|
30
|
+
assert_instance_of Hash, error
|
31
|
+
assert_equal "Response is not in JSON format.", error["message"]
|
32
|
+
assert_equal "500", error["details"]["httpCode"]
|
33
|
+
assert_equal "Internal Server Error", error["details"]["httpMessage"]
|
34
|
+
assert_equal "Something went wrong", error["details"]["httpBody"]
|
35
|
+
ensure
|
36
|
+
WebMock.allow_net_connect!
|
25
37
|
end
|
26
|
-
|
27
38
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paypal_adaptive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tommy Chheng
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 3.2.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: webmock
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
description: Lightweight wrapper for Paypal's Adaptive Payments API
|
70
84
|
email:
|
71
85
|
- tommy.chheng@gmail.com
|
@@ -133,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
147
|
version: '0'
|
134
148
|
requirements: []
|
135
149
|
rubyforge_project: paypal_adaptive
|
136
|
-
rubygems_version: 2.0.
|
150
|
+
rubygems_version: 2.0.3
|
137
151
|
signing_key:
|
138
152
|
specification_version: 4
|
139
153
|
summary: Lightweight wrapper for Paypal's Adaptive Payments API
|