paypal_nvp 0.1.7 → 0.1.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.
Files changed (3) hide show
  1. data/lib/paypal_nvp.rb +15 -4
  2. data/paypal_nvp.gemspec +1 -1
  3. metadata +17 -4
data/lib/paypal_nvp.rb CHANGED
@@ -9,6 +9,7 @@ class PaypalNVP
9
9
  def initialize(sandbox = false, extras = {})
10
10
  type = sandbox ? "sandbox" : "live"
11
11
  config = YAML.load_file("#{RAILS_ROOT}/config/paypal.yml") rescue nil
12
+ @require_ssl_certs = (extras[:require_ssl_certs]!=nil)? extras[:require_ssl_certs] : true
12
13
  if config
13
14
  @url = config[type]["url"]
14
15
  @user = config[type]["user"]
@@ -30,15 +31,25 @@ class PaypalNVP
30
31
  data.each do |key, value|
31
32
  qs << "#{key.to_s.upcase}=#{URI.escape(value)}"
32
33
  end
33
- qs = "?#{qs * "&"}"
34
+ qs = "#{qs * "&"}"
34
35
 
35
36
  uri = URI.parse(@url)
36
37
  http = Net::HTTP.new(uri.host, uri.port)
37
38
  http.use_ssl = true
38
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
39
+ # http.verify_mode = OpenSSL::SSL::VERIFY_NONE
40
+ rootCA = '/etc/ssl/certs'
41
+ if File.directory? rootCA
42
+ http.ca_path = rootCA
43
+ http.verify_mode = OpenSSL::SSL::VERIFY_PEER
44
+ http.verify_depth = 5
45
+ else
46
+ raise "missing ssl certs. Cannot secure paypal communication" if (@require_ssl_certs == true)
47
+ puts "WARNING: no ssl certs found. Paypal communication will be insecure. DO NOT DEPLOY"
48
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
49
+ end
39
50
 
40
51
  response = http.start {
41
- http.request_get(uri.path + qs) {|res|
52
+ http.request_post(uri.path, qs) {|res|
42
53
  res
43
54
  }
44
55
  }
@@ -52,4 +63,4 @@ class PaypalNVP
52
63
  data
53
64
  end
54
65
 
55
- end
66
+ end
data/paypal_nvp.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{paypal_nvp}
5
- s.version = "0.1.7"
5
+ s.version = "0.1.8"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Olivier BONNAURE - Direct Interactive LLC"]
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paypal_nvp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ hash: 11
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 8
10
+ version: 0.1.8
5
11
  platform: ruby
6
12
  authors:
7
13
  - Olivier BONNAURE - Direct Interactive LLC
@@ -44,21 +50,28 @@ rdoc_options:
44
50
  require_paths:
45
51
  - lib
46
52
  required_ruby_version: !ruby/object:Gem::Requirement
53
+ none: false
47
54
  requirements:
48
55
  - - ">="
49
56
  - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
50
60
  version: "0"
51
- version:
52
61
  required_rubygems_version: !ruby/object:Gem::Requirement
62
+ none: false
53
63
  requirements:
54
64
  - - ">="
55
65
  - !ruby/object:Gem::Version
66
+ hash: 11
67
+ segments:
68
+ - 1
69
+ - 2
56
70
  version: "1.2"
57
- version:
58
71
  requirements: []
59
72
 
60
73
  rubyforge_project: paypal_nvp
61
- rubygems_version: 1.3.5
74
+ rubygems_version: 1.5.2
62
75
  signing_key:
63
76
  specification_version: 3
64
77
  summary: Paypal NVP API Class.