paypal_adaptive 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -20,3 +20,4 @@ pkg
20
20
 
21
21
  ## PROJECT::SPECIFIC
22
22
  config
23
+ Gemfile.lock
@@ -92,6 +92,9 @@ If you don't set ssl_cert_file then paypal_adaptive will check for certificates
92
92
  this location exists, otherwise falling back to the cacert.pem file included with paypal_adaptive.
93
93
 
94
94
  ## Changelog
95
+ 0.2.6
96
+ Fix for using correct status field in pre-approval, thanks nbibler. Fix for ruby 1.9.3, thanks deepj.
97
+
95
98
  0.2.5
96
99
  Fix for embedded payments, thanks rafaelivan. Fix for Rails 3.1.1, thanks synth.
97
100
 
@@ -23,7 +23,7 @@ module PaypalAdaptive
23
23
  http.ca_file = @@ssl_cert_file unless @@ssl_cert_file.nil?
24
24
 
25
25
  path = "#{@@paypal_base_url}/cgi-bin/webscr"
26
- resp, response_data = http.post(path, data)
26
+ response_data = http.post(path, data).body
27
27
 
28
28
  @verified = response_data == "VERIFIED"
29
29
  end
@@ -85,7 +85,7 @@ module PaypalAdaptive
85
85
  http.ca_path = @@ssl_cert_path unless @@ssl_cert_path.nil?
86
86
  http.ca_file = @@ssl_cert_file unless @@ssl_cert_file.nil?
87
87
 
88
- resp, response_data = http.post(path, api_request_data, @@headers)
88
+ response_data = http.post(path, api_request_data, @@headers).body
89
89
 
90
90
  JSON.parse(response_data)
91
91
  end
@@ -8,7 +8,8 @@ module PaypalAdaptive
8
8
  end
9
9
 
10
10
  def success?
11
- self['responseEnvelope']['ack'] == 'Success'
11
+ self['responseEnvelope']['ack'].to_s =~ /^Success$/i &&
12
+ !(self['paymentExecStatus'].to_s =~ /^ERROR$/i)
12
13
  end
13
14
 
14
15
  def errors
@@ -1,4 +1,4 @@
1
1
  module PaypalAdaptive
2
- VERSION = "0.2.5"
2
+ VERSION = "0.2.6"
3
3
  end
4
4
 
@@ -0,0 +1,22 @@
1
+ {
2
+ "responseEnvelope":{
3
+ "timestamp":"2011-11-20T09:33:51.178-08:00",
4
+ "ack":"Success",
5
+ "correlationId":"XXXXX",
6
+ "build":"2279004"
7
+ },
8
+ "payKey":"AP-XXXXXXXXXXXXXXXXX",
9
+ "paymentExecStatus":"ERROR",
10
+ "payErrorList":{
11
+ "payError":[{
12
+ "receiver":{"amount":"25.0","email":"email@email.com"},
13
+ "error":{
14
+ "errorId":"580036",
15
+ "domain":"PLATFORM",
16
+ "severity":"Error",
17
+ "category":"Application",
18
+ "message":"This transaction cannot be processed. Please enter a valid credit card number and type"
19
+ }
20
+ }]
21
+ }
22
+ }
@@ -36,6 +36,18 @@ class PreapprovalTest < Test::Unit::TestCase
36
36
  assert_nil pp_response['preapprovalKey']
37
37
  end
38
38
 
39
+ def test_invalid_preapproval_with_bad_credit_information
40
+ puts "-------"
41
+ puts "invalid"
42
+ data_filepath = File.join(File.dirname(__FILE__),"..", "data","invalid_preapproval_error_execstatus.json")
43
+
44
+ data = read_json_file(data_filepath)
45
+ pp_response = @preapproval_request.preapproval(data)
46
+ puts "error message is #{pp_response.error_message}"
47
+
48
+ assert pp_response.success? == false
49
+ end
50
+
39
51
  def read_json_file(filepath)
40
52
  File.open(filepath, "rb"){|f| JSON.parse(f.read)}
41
53
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paypal_adaptive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-16 00:00:00.000000000 Z
12
+ date: 2011-11-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
16
- requirement: &70129552049880 !ruby/object:Gem::Requirement
16
+ requirement: &70119519086160 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.6.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70129552049880
24
+ version_requirements: *70119519086160
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: jsonschema
27
- requirement: &70129552049300 !ruby/object:Gem::Requirement
27
+ requirement: &70119519085000 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 2.0.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70129552049300
35
+ version_requirements: *70119519085000
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &70129552048840 !ruby/object:Gem::Requirement
38
+ requirement: &70119519084120 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0.8'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70129552048840
46
+ version_requirements: *70119519084120
47
47
  description: Lightweight wrapper for Paypal's Adaptive Payments API
48
48
  email:
49
49
  - tommy.chheng@gmail.com
@@ -53,7 +53,6 @@ extra_rdoc_files: []
53
53
  files:
54
54
  - .gitignore
55
55
  - Gemfile
56
- - Gemfile.lock
57
56
  - LICENSE
58
57
  - README.markdown
59
58
  - Rakefile
@@ -71,6 +70,7 @@ files:
71
70
  - test/data/invalid_chain_pay_request.json
72
71
  - test/data/invalid_parallel_pay_request.json
73
72
  - test/data/invalid_preapproval.json
73
+ - test/data/invalid_preapproval_error_execstatus.json
74
74
  - test/data/invalid_simple_pay_request_1.json
75
75
  - test/data/valid_chain_pay_request.json
76
76
  - test/data/valid_get_payment_options_request.json
@@ -116,6 +116,7 @@ test_files:
116
116
  - test/data/invalid_chain_pay_request.json
117
117
  - test/data/invalid_parallel_pay_request.json
118
118
  - test/data/invalid_preapproval.json
119
+ - test/data/invalid_preapproval_error_execstatus.json
119
120
  - test/data/invalid_simple_pay_request_1.json
120
121
  - test/data/valid_chain_pay_request.json
121
122
  - test/data/valid_get_payment_options_request.json
@@ -1,20 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- paypal_adaptive (0.3)
5
- json (~> 1.6.0)
6
- jsonschema (~> 2.0.0)
7
- rake (~> 0.8)
8
-
9
- GEM
10
- remote: http://rubygems.org/
11
- specs:
12
- json (1.6.1)
13
- jsonschema (2.0.1)
14
- rake (0.9.2)
15
-
16
- PLATFORMS
17
- ruby
18
-
19
- DEPENDENCIES
20
- paypal_adaptive!