paypal_nvp 0.1.6 → 0.1.7
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 -2
- data/lib/paypal_nvp.rb +17 -10
- data/paypal_nvp.gemspec +1 -1
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -8,7 +8,8 @@ The recommended way is that you get the gem:
|
|
8
8
|
|
9
9
|
$ sudo gem install paypal_nvp
|
10
10
|
|
11
|
-
PaypalNVP need
|
11
|
+
PaypalNVP need an optional paypal.yml file in your config directory (Rails App).
|
12
|
+
Or you can specify parameter within the constructor
|
12
13
|
|
13
14
|
# All those fields are mandatory
|
14
15
|
|
@@ -27,9 +28,11 @@ PaypalNVP need a paypal.yml file in your config directory.
|
|
27
28
|
== Example usage
|
28
29
|
|
29
30
|
p = PaypalNVP.new(true) # true mean "use sandbox"
|
31
|
+
# Or you can specify paramaters directly
|
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" })
|
30
33
|
data = {
|
31
34
|
:method => "MyPaypalMethod",
|
32
|
-
:amt => 55
|
35
|
+
:amt => "55"
|
33
36
|
# other params needed
|
34
37
|
}
|
35
38
|
result = p.call_paypal(data) # will return a hash
|
data/lib/paypal_nvp.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
require
|
1
|
+
require "net/https"
|
2
|
+
require "cgi"
|
2
3
|
|
3
4
|
class PaypalNVP
|
4
5
|
def self.included(base)
|
@@ -6,12 +7,19 @@ class PaypalNVP
|
|
6
7
|
end
|
7
8
|
|
8
9
|
def initialize(sandbox = false, extras = {})
|
9
|
-
config = YAML.load_file("#{RAILS_ROOT}/config/paypal.yml")
|
10
10
|
type = sandbox ? "sandbox" : "live"
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
config = YAML.load_file("#{RAILS_ROOT}/config/paypal.yml") rescue nil
|
12
|
+
if config
|
13
|
+
@url = config[type]["url"]
|
14
|
+
@user = config[type]["user"]
|
15
|
+
@pass = config[type]["pass"]
|
16
|
+
@cert = config[type]["cert"]
|
17
|
+
else
|
18
|
+
@url = extras[:url]
|
19
|
+
@user = extras[:user]
|
20
|
+
@pass = extras[:pass]
|
21
|
+
@cert = extras[:cert]
|
22
|
+
end
|
15
23
|
@extras = extras
|
16
24
|
end
|
17
25
|
|
@@ -20,7 +28,7 @@ class PaypalNVP
|
|
20
28
|
data.merge!(@extras)
|
21
29
|
qs = []
|
22
30
|
data.each do |key, value|
|
23
|
-
qs << "#{key.to_s.upcase}=#{
|
31
|
+
qs << "#{key.to_s.upcase}=#{URI.escape(value)}"
|
24
32
|
end
|
25
33
|
qs = "?#{qs * "&"}"
|
26
34
|
|
@@ -34,7 +42,7 @@ class PaypalNVP
|
|
34
42
|
res
|
35
43
|
}
|
36
44
|
}
|
37
|
-
data = {}
|
45
|
+
data = { :response => response }
|
38
46
|
if response.kind_of? Net::HTTPSuccess
|
39
47
|
response.body.split("&").each do |element|
|
40
48
|
a = element.split("=")
|
@@ -44,5 +52,4 @@ class PaypalNVP
|
|
44
52
|
data
|
45
53
|
end
|
46
54
|
|
47
|
-
end
|
48
|
-
|
55
|
+
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.
|
5
|
+
s.version = "0.1.7"
|
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"]
|