paypal_nvp 0.2.0 → 0.2.1
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.rdoc +5 -0
- data/lib/paypal_nvp.rb +20 -15
- data/paypal_nvp.gemspec +1 -1
- metadata +5 -7
data/README.rdoc
CHANGED
@@ -31,9 +31,14 @@ Or you can specify parameter within the constructor
|
|
31
31
|
# Or you can specify paramaters directly
|
32
32
|
# p = PaypalNVP.new(true, { :user => "o.bonn_1237393081_biz_api1.solisoft.net", :pass => "1237393093", :cert => "AU2Yv5COwWPCfeYLv34Z766F-gfNAzX6LaQE6VZkHMRq35Gmite-bMXu", :url => "https://api-3t.sandbox.paypal.com/nvp" })
|
33
33
|
data = {
|
34
|
+
:version => "50.0", # Default is 50.0 as well... but now you can specify it
|
34
35
|
:method => "MyPaypalMethod",
|
35
36
|
:amt => "55"
|
36
37
|
# other params needed
|
37
38
|
}
|
38
39
|
result = p.call_paypal(data) # will return a hash
|
39
40
|
puts result["ACK"] # Success
|
41
|
+
|
42
|
+
== PAYPAL API Documentation
|
43
|
+
|
44
|
+
https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/howto_api_reference
|
data/lib/paypal_nvp.rb
CHANGED
@@ -1,19 +1,21 @@
|
|
1
1
|
require "net/https"
|
2
2
|
require "cgi"
|
3
|
+
require "logger"
|
3
4
|
|
4
5
|
class PaypalNVP
|
5
6
|
def self.included(base)
|
6
7
|
base.extend ClassMethods
|
7
8
|
end
|
8
|
-
|
9
|
-
def initialize(sandbox = false, extras = {})
|
9
|
+
|
10
|
+
def initialize(sandbox = false, extras = {}, rootCA = '/etc/ssl/certs')
|
10
11
|
type = sandbox ? "sandbox" : "live"
|
11
|
-
config = YAML.load_file("#{
|
12
|
-
@
|
13
|
-
|
14
|
-
#
|
12
|
+
config = YAML.load_file("#{Rails.root}/config/paypal.yml") rescue nil
|
13
|
+
@logger = defined?(Rails.logger) && Rails.logger || Logger.new(STDOUT)
|
14
|
+
|
15
|
+
# By default we use the 50.0 API version.
|
16
|
+
# At 30 Apr 2012, version 87.0 and provides additional shipping information.
|
15
17
|
extras[:version] ||= "50.0"
|
16
|
-
|
18
|
+
|
17
19
|
if config
|
18
20
|
@url = config[type]["url"]
|
19
21
|
@user = config[type]["user"]
|
@@ -26,6 +28,7 @@ class PaypalNVP
|
|
26
28
|
@cert = extras[:cert]
|
27
29
|
end
|
28
30
|
@extras = extras
|
31
|
+
@rootCA = rootCA
|
29
32
|
end
|
30
33
|
|
31
34
|
def call_paypal(data)
|
@@ -35,18 +38,21 @@ class PaypalNVP
|
|
35
38
|
data.each do |key, value|
|
36
39
|
qs << "#{key.to_s.upcase}=#{URI.escape(value.to_s)}"
|
37
40
|
end
|
38
|
-
qs = "#{qs * "&"}"
|
39
|
-
|
41
|
+
qs = "#{qs * "&"}"
|
42
|
+
|
40
43
|
uri = URI.parse(@url)
|
41
44
|
http = Net::HTTP.new(uri.host, uri.port)
|
42
45
|
http.use_ssl = true
|
43
|
-
|
44
|
-
|
45
|
-
http.
|
46
|
+
if File.directory? @rootCA
|
47
|
+
http.ca_path = @rootCA
|
48
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
49
|
+
http.verify_depth = 5
|
50
|
+
elsif File.exists?(@rootCA)
|
51
|
+
http.ca_file = @rootCA
|
46
52
|
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
47
53
|
http.verify_depth = 5
|
48
54
|
else
|
49
|
-
|
55
|
+
logger.warn "[PaypalNVP] No ssl certs found. Paypal communication will be insecure. DO NOT DEPLOY"
|
50
56
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
51
57
|
end
|
52
58
|
|
@@ -61,8 +67,7 @@ class PaypalNVP
|
|
61
67
|
a = element.split("=")
|
62
68
|
data[a[0]] = CGI.unescape(a[1]) if a.size == 2
|
63
69
|
end
|
64
|
-
end
|
70
|
+
end
|
65
71
|
data
|
66
72
|
end
|
67
|
-
|
68
73
|
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.2.
|
5
|
+
s.version = "0.2.1"
|
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,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paypal_nvp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 1
|
10
|
+
version: 0.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Olivier BONNAURE - Direct Interactive LLC
|
@@ -15,8 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-05-28 00:00:00
|
19
|
-
default_executable:
|
18
|
+
date: 2010-05-28 00:00:00 Z
|
20
19
|
dependencies: []
|
21
20
|
|
22
21
|
description: Paypal NVP API Class.
|
@@ -35,7 +34,6 @@ files:
|
|
35
34
|
- Rakefile
|
36
35
|
- README.rdoc
|
37
36
|
- paypal_nvp.gemspec
|
38
|
-
has_rdoc: true
|
39
37
|
homepage: http://github.com/solisoft/paypal_nvp
|
40
38
|
licenses: []
|
41
39
|
|
@@ -71,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
69
|
requirements: []
|
72
70
|
|
73
71
|
rubyforge_project: paypal_nvp
|
74
|
-
rubygems_version: 1.
|
72
|
+
rubygems_version: 1.8.24
|
75
73
|
signing_key:
|
76
74
|
specification_version: 3
|
77
75
|
summary: Paypal NVP API Class.
|