paypal_nvp 0.1.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/Manifest +5 -0
- data/README.rdoc +36 -0
- data/Rakefile +14 -0
- data/init.rb +1 -0
- data/lib/paypal_nvp.rb +44 -0
- data/paypal_nvp.gemspec +31 -0
- metadata +64 -0
data/Manifest
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
= Paypal NVP
|
2
|
+
|
3
|
+
Paypal NVP allow to connect your Ruby on Rails application to the Paypal NVP API.
|
4
|
+
|
5
|
+
== Installation
|
6
|
+
|
7
|
+
The recommended way is that you get the gem:
|
8
|
+
|
9
|
+
sudo gem install paypal_nvp
|
10
|
+
|
11
|
+
PaypalNVP need a paypal.yml file in your config directory.
|
12
|
+
|
13
|
+
# All those fields are mandatory
|
14
|
+
|
15
|
+
sandbox:
|
16
|
+
url: "https://api-3t.sandbox.paypal.com/nvp"
|
17
|
+
user: "o.bonn_1237393081_biz_api1.solisoft.net"
|
18
|
+
pass: "1237393093"
|
19
|
+
cert: "AU2Yv5COwWPCfeYLv34Z766F-gfNAzX6LaQE6VZkHMRq35Gmite-bMXu"
|
20
|
+
|
21
|
+
live:
|
22
|
+
url: "https://api-3t.paypal.com/nvp"
|
23
|
+
user: "o.bonn_1237393081_biz_api1.solisoft.net"
|
24
|
+
pass: "1237393093"
|
25
|
+
cert: "AU2Yv5COwWPCfeYLv34Z766F-gfNAzX6LaQE6VZkHMRq35Gmite-bMXu"
|
26
|
+
|
27
|
+
== Example usage
|
28
|
+
|
29
|
+
p = PaypalNVP.new(true) # true mean "use sandbox"
|
30
|
+
data = {
|
31
|
+
:method => "MyPaypalMethod",
|
32
|
+
:amt => 55
|
33
|
+
# other params needed
|
34
|
+
}
|
35
|
+
result = p.call_paypal(data) # will return a hash
|
36
|
+
puts result["ACK"] # Success
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'echoe'
|
4
|
+
|
5
|
+
Echoe.new('paypal_nvp', '0.1.1') do |p|
|
6
|
+
p.description = "Paypal NVP API Class."
|
7
|
+
p.url = "http://github.com/solisoft/paypal_nvp"
|
8
|
+
p.author = "Olivier BONNAURE - Direct Interactive LLC"
|
9
|
+
p.email = "o.bonnaure@directinteractive.com"
|
10
|
+
p.ignore_pattern = ["tmp/*", "script/*"]
|
11
|
+
p.development_dependencies = []
|
12
|
+
end
|
13
|
+
|
14
|
+
Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
|
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'paypal_nvp'
|
data/lib/paypal_nvp.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
class PaypalNVP
|
2
|
+
def self.included(base)
|
3
|
+
base.extend ClassMethods
|
4
|
+
end
|
5
|
+
|
6
|
+
def initialize(sandbox = false)
|
7
|
+
config = YAML.load_file("#{RAILS_ROOT}/config/paypal.yml")
|
8
|
+
type = sandbox ? "sandbox" : "live"
|
9
|
+
@url = config[type]["url"]
|
10
|
+
@user = config[type]["user"]
|
11
|
+
@pass = config[type]["pass"]
|
12
|
+
@cert = config[type]["cert"]
|
13
|
+
end
|
14
|
+
|
15
|
+
def call_paypal(data)
|
16
|
+
data.merge!({ "USER" => @user, "PWD" => @pass, "SIGNATURE" => @cert, "VERSION" => "50.0" })
|
17
|
+
qs = []
|
18
|
+
data.each do |key, value|
|
19
|
+
qs << "#{key.to_s.upcase}=#{url_encode(value)}"
|
20
|
+
end
|
21
|
+
qs = "?#{qs * "&"}"
|
22
|
+
|
23
|
+
uri = URI.parse(@url)
|
24
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
25
|
+
http.use_ssl = true
|
26
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
27
|
+
|
28
|
+
response = http.start {
|
29
|
+
http.request_get(uri.path) {|res|
|
30
|
+
res
|
31
|
+
}
|
32
|
+
}
|
33
|
+
data = {}
|
34
|
+
if response.kind_of? Net::HTTPSuccess
|
35
|
+
response.body.split("&").each do |element|
|
36
|
+
a = element.split("=")
|
37
|
+
data[a[0]] = a[1] if a.size == 2
|
38
|
+
end
|
39
|
+
end
|
40
|
+
data
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
data/paypal_nvp.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{paypal_nvp}
|
5
|
+
s.version = "0.1.1"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Olivier BONNAURE - Direct Interactive LLC"]
|
9
|
+
s.date = %q{2009-03-31}
|
10
|
+
s.description = %q{Paypal NVP API Class.}
|
11
|
+
s.email = %q{o.bonnaure@directinteractive.com}
|
12
|
+
s.extra_rdoc_files = ["lib/paypal_nvp.rb", "README.rdoc"]
|
13
|
+
s.files = ["init.rb", "lib/paypal_nvp.rb", "Manifest", "Rakefile", "README.rdoc", "paypal_nvp.gemspec"]
|
14
|
+
s.has_rdoc = true
|
15
|
+
s.homepage = %q{http://github.com/solisoft/paypal_nvp}
|
16
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Paypal_nvp", "--main", "README.rdoc"]
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
s.rubyforge_project = %q{paypal_nvp}
|
19
|
+
s.rubygems_version = %q{1.3.1}
|
20
|
+
s.summary = %q{Paypal NVP API Class.}
|
21
|
+
|
22
|
+
if s.respond_to? :specification_version then
|
23
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
24
|
+
s.specification_version = 2
|
25
|
+
|
26
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
27
|
+
else
|
28
|
+
end
|
29
|
+
else
|
30
|
+
end
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: paypal_nvp
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Olivier BONNAURE - Direct Interactive LLC
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-03-31 00:00:00 +02:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Paypal NVP API Class.
|
17
|
+
email: o.bonnaure@directinteractive.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- lib/paypal_nvp.rb
|
24
|
+
- README.rdoc
|
25
|
+
files:
|
26
|
+
- init.rb
|
27
|
+
- lib/paypal_nvp.rb
|
28
|
+
- Manifest
|
29
|
+
- Rakefile
|
30
|
+
- README.rdoc
|
31
|
+
- paypal_nvp.gemspec
|
32
|
+
has_rdoc: true
|
33
|
+
homepage: http://github.com/solisoft/paypal_nvp
|
34
|
+
post_install_message:
|
35
|
+
rdoc_options:
|
36
|
+
- --line-numbers
|
37
|
+
- --inline-source
|
38
|
+
- --title
|
39
|
+
- Paypal_nvp
|
40
|
+
- --main
|
41
|
+
- README.rdoc
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: "0"
|
49
|
+
version:
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: "1.2"
|
55
|
+
version:
|
56
|
+
requirements: []
|
57
|
+
|
58
|
+
rubyforge_project: paypal_nvp
|
59
|
+
rubygems_version: 1.3.1
|
60
|
+
signing_key:
|
61
|
+
specification_version: 2
|
62
|
+
summary: Paypal NVP API Class.
|
63
|
+
test_files: []
|
64
|
+
|