paypal_adaptive 0.2.7 → 0.2.8

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.
data/README.markdown CHANGED
@@ -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.8
96
+ Cert fixes and ruby 1.9.3 files. Thanks tonyla.
97
+
95
98
  0.2.7
96
99
  Refactored config file handling for better non-Rails support, thanks mreinsch and dave-thompson.
97
100
 
@@ -16,7 +16,7 @@ module PaypalAdaptive
16
16
  } unless defined? API_BASE_URL_MAPPING
17
17
 
18
18
  attr_accessor :paypal_base_url, :api_base_url, :headers, :ssl_cert_path, :ssl_cert_file
19
-
19
+
20
20
  def initialize(env=nil, config_override={})
21
21
  config = YAML.load(ERB.new(File.new(config_filepath).read).result)[env]
22
22
  raise "Could not load settings from config file" unless config
@@ -31,17 +31,17 @@ module PaypalAdaptive
31
31
  @ssl_cert_file = nil
32
32
  @paypal_base_url = PAYPAL_BASE_URL_MAPPING[pp_env]
33
33
  @api_base_url = API_BASE_URL_MAPPING[pp_env]
34
-
34
+
35
35
  # http.rb requires headers to be strings. Protect against ints in paypal_adaptive.yml
36
36
  config.update(config){ |key,v| v.to_s }
37
37
  @headers = {
38
38
  "X-PAYPAL-SECURITY-USERID" => config['username'],
39
39
  "X-PAYPAL-SECURITY-PASSWORD" => config['password'],
40
- "X-PAYPAL-SECURITY-SIGNATURE" => config['signature'],
41
40
  "X-PAYPAL-APPLICATION-ID" => config['application_id'],
42
41
  "X-PAYPAL-REQUEST-DATA-FORMAT" => "JSON",
43
42
  "X-PAYPAL-RESPONSE-DATA-FORMAT" => "JSON"
44
43
  }
44
+ @headers.merge!({"X-PAYPAL-SECURITY-SIGNATURE" => config['signature']}) if config['signature']
45
45
 
46
46
  if config['ssl_cert_file'] && config['ssl_cert_file'].length > 0
47
47
  @ssl_cert_file = config['ssl_cert_file']
@@ -4,14 +4,14 @@ require 'json'
4
4
 
5
5
  module PaypalAdaptive
6
6
  class IpnNotification
7
-
7
+
8
8
  def initialize(env=nil)
9
9
  config = PaypalAdaptive.config(env)
10
10
  @paypal_base_url = config.paypal_base_url
11
11
  @ssl_cert_path = config.ssl_cert_path
12
12
  @ssl_cert_file = config.ssl_cert_file
13
13
  end
14
-
14
+
15
15
  def send_back(data)
16
16
  data = "cmd=_notify-validate&#{data}"
17
17
  url = URI.parse @paypal_base_url
@@ -19,17 +19,22 @@ module PaypalAdaptive
19
19
  http.use_ssl = true
20
20
  http.verify_mode = OpenSSL::SSL::VERIFY_PEER
21
21
  http.ca_path = @ssl_cert_path unless @ssl_cert_path.nil?
22
- http.ca_file = @ssl_cert_file unless @ssl_cert_file.nil?
23
-
22
+
23
+ if @ssl_cert_file
24
+ cert = File.read(@ssl_cert_file)
25
+ http.cert = OpenSSL::X509::Certificate.new(cert)
26
+ http.key = OpenSSL::PKey::RSA.new(cert)
27
+ end
28
+
24
29
  path = "#{@paypal_base_url}/cgi-bin/webscr"
25
30
  response_data = http.post(path, data).body
26
-
31
+
27
32
  @verified = response_data == "VERIFIED"
28
33
  end
29
-
34
+
30
35
  def verified?
31
36
  @verified
32
37
  end
33
-
38
+
34
39
  end
35
40
  end
@@ -82,8 +82,13 @@ module PaypalAdaptive
82
82
  http = Net::HTTP.new(url.host, 443)
83
83
  http.use_ssl = true
84
84
  http.verify_mode = OpenSSL::SSL::VERIFY_PEER
85
+
86
+ if @ssl_cert_file
87
+ cert = File.read(@ssl_cert_file)
88
+ http.cert = OpenSSL::X509::Certificate.new(cert)
89
+ http.key = OpenSSL::PKey::RSA.new(cert)
90
+ end
85
91
  http.ca_path = @ssl_cert_path unless @ssl_cert_path.nil?
86
- http.ca_file = @ssl_cert_file unless @ssl_cert_file.nil?
87
92
 
88
93
  response_data = http.post(path, api_request_data, @headers).body
89
94
 
@@ -1,4 +1,4 @@
1
1
  module PaypalAdaptive
2
- VERSION = "0.2.7"
2
+ VERSION = "0.2.8"
3
3
  end
4
4
 
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.7
4
+ version: 0.2.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,12 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-09 00:00:00.000000000 Z
12
+ date: 2012-02-10 00:00:00.000000000 -08:00
13
+ default_executable:
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: json
16
- requirement: &70239312828620 !ruby/object:Gem::Requirement
17
+ requirement: &2157775420 !ruby/object:Gem::Requirement
17
18
  none: false
18
19
  requirements:
19
20
  - - ~>
@@ -21,10 +22,10 @@ dependencies:
21
22
  version: 1.6.0
22
23
  type: :runtime
23
24
  prerelease: false
24
- version_requirements: *70239312828620
25
+ version_requirements: *2157775420
25
26
  - !ruby/object:Gem::Dependency
26
27
  name: jsonschema
27
- requirement: &70239312840100 !ruby/object:Gem::Requirement
28
+ requirement: &2157774920 !ruby/object:Gem::Requirement
28
29
  none: false
29
30
  requirements:
30
31
  - - ~>
@@ -32,10 +33,10 @@ dependencies:
32
33
  version: 2.0.0
33
34
  type: :runtime
34
35
  prerelease: false
35
- version_requirements: *70239312840100
36
+ version_requirements: *2157774920
36
37
  - !ruby/object:Gem::Dependency
37
38
  name: rake
38
- requirement: &70239312838340 !ruby/object:Gem::Requirement
39
+ requirement: &2157774440 !ruby/object:Gem::Requirement
39
40
  none: false
40
41
  requirements:
41
42
  - - ~>
@@ -43,7 +44,7 @@ dependencies:
43
44
  version: '0.8'
44
45
  type: :runtime
45
46
  prerelease: false
46
- version_requirements: *70239312838340
47
+ version_requirements: *2157774440
47
48
  description: Lightweight wrapper for Paypal's Adaptive Payments API
48
49
  email:
49
50
  - tommy.chheng@gmail.com
@@ -89,6 +90,7 @@ files:
89
90
  - test/unit/payment_details_test.rb
90
91
  - test/unit/payment_options_test.rb
91
92
  - test/unit/preapproval_test.rb
93
+ has_rdoc: true
92
94
  homepage: http://github.com/tc/paypal_adaptive
93
95
  licenses: []
94
96
  post_install_message:
@@ -109,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
111
  version: '0'
110
112
  requirements: []
111
113
  rubyforge_project: paypal_adaptive
112
- rubygems_version: 1.8.10
114
+ rubygems_version: 1.6.2
113
115
  signing_key:
114
116
  specification_version: 3
115
117
  summary: Lightweight wrapper for Paypal's Adaptive Payments API