paypal_adaptive 0.2.2 → 0.2.3

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.
@@ -0,0 +1,22 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
22
+ config
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1,20 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ paypal_adaptive (0.3)
5
+ json (~> 1.6.0)
6
+ jsonschema (~> 2.0.0)
7
+ rake (~> 0.8)
8
+
9
+ GEM
10
+ remote: http://rubygems.org/
11
+ specs:
12
+ json (1.6.1)
13
+ jsonschema (2.0.1)
14
+ rake (0.9.2)
15
+
16
+ PLATFORMS
17
+ ruby
18
+
19
+ DEPENDENCIES
20
+ paypal_adaptive!
@@ -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.3
96
+ Using bundler for gem creation. Moved all code to paypal_adaptive dir. Added ExecutePayment call to request. Thanks Roger Neel.
97
+
95
98
  0.2.2
96
99
  Added support for ERB in the config file. Thanks DanielVartanov.
97
100
 
data/Rakefile CHANGED
@@ -1,38 +1,8 @@
1
- require 'rubygems'
2
- require 'psych'
3
- require 'rake'
1
+ require 'bundler'
4
2
  require 'rake/testtask'
5
3
 
6
- begin
7
- require 'jeweler'
8
- Jeweler::Tasks.new do |gem|
9
- gem.name = "paypal_adaptive"
10
- gem.summary = %Q{initial import}
11
- gem.description = %Q{Lightweight wrapper for Paypal's Adaptive Payments API.}
12
- gem.email = "tommy.chheng@gmail.com"
13
- gem.homepage = "http://github.com/tc/paypal_adaptive"
14
- gem.authors = ["Tommy Chheng"]
15
- gem.add_development_dependency "json", ">= 0"
16
- gem.add_development_dependency "jsonschema", ">= 0"
17
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
18
- end
19
- Jeweler::GemcutterTasks.new
20
- rescue LoadError
21
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
22
- end
23
-
24
- begin
25
- require 'rcov/rcovtask'
26
- Rcov::RcovTask.new do |test|
27
- test.libs << 'test'
28
- test.pattern = 'test/**/test_*.rb'
29
- test.verbose = true
30
- end
31
- rescue LoadError
32
- task :rcov do
33
- abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
34
- end
35
- end
4
+ Bundler::GemHelper.install_tasks
5
+ Dir[File.join(File.dirname(__FILE__), "lib", "tasks", "**", "*.rake")].each { |ext| load ext }
36
6
 
37
7
  task :default => :test
38
8
 
@@ -44,13 +14,3 @@ namespace :test do
44
14
  test.test_files = FileList["test/unit/*_test.rb", "test/unit/*/*_test.rb"]
45
15
  end
46
16
  end
47
-
48
- require 'rake/rdoctask'
49
- Rake::RDocTask.new do |rdoc|
50
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
51
-
52
- rdoc.rdoc_dir = 'rdoc'
53
- rdoc.title = "paypal_adaptive #{version}"
54
- rdoc.rdoc_files.include('README*')
55
- rdoc.rdoc_files.include('lib/**/*.rb')
56
- end
@@ -1,4 +1,7 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), "config"))
2
- require File.expand_path(File.join(File.dirname(__FILE__), "request"))
3
- require File.expand_path(File.join(File.dirname(__FILE__), "response"))
4
- require File.expand_path(File.join(File.dirname(__FILE__), "ipn_notification"))
1
+ require 'paypal_adaptive/config'
2
+ require 'paypal_adaptive/request'
3
+ require 'paypal_adaptive/response'
4
+ require 'paypal_adaptive/ipn_notification'
5
+
6
+ module PaypalAdaptive
7
+ end
@@ -20,7 +20,7 @@ module PaypalAdaptive
20
20
  def initialize(env=nil, config_override=nil)
21
21
  if env
22
22
  #non-rails env
23
- @config_filepath = File.join(File.dirname(__FILE__), "..", "config", "paypal_adaptive.yml")
23
+ @config_filepath = File.join(File.dirname(__FILE__), "..", "..", "config", "paypal_adaptive.yml")
24
24
  load(env, config_override)
25
25
  else
26
26
  @config_filepath = File.join(Rails.root, "config", "paypal_adaptive.yml")
@@ -31,6 +31,7 @@ module PaypalAdaptive
31
31
  def load(environment, config_override)
32
32
  config = YAML.load(ERB.new(File.new(@config_filepath).read).result)[environment]
33
33
  config.merge!(config_override) unless config_override.nil?
34
+ raise "Could not load settings from config file" unless config
34
35
 
35
36
  if config["retain_requests_for_test"] == true
36
37
  @retain_requests_for_test = true
@@ -55,7 +56,7 @@ module PaypalAdaptive
55
56
  elsif File.exists?("/etc/ssl/certs")
56
57
  @ssl_cert_path = "/etc/ssl/certs"
57
58
  else
58
- @ssl_cert_file = File.join(File.dirname(__FILE__), "..", "cacert.pem")
59
+ @ssl_cert_file = File.join(File.dirname(__FILE__), "..", "..", "cacert.pem")
59
60
  end
60
61
  end
61
62
  end
@@ -1,7 +1,6 @@
1
1
  require 'net/http'
2
2
  require 'net/https'
3
3
  require 'json'
4
- require 'config'
5
4
 
6
5
  module PaypalAdaptive
7
6
  class IpnNotification
@@ -34,4 +33,4 @@ module PaypalAdaptive
34
33
  end
35
34
 
36
35
  end
37
- end
36
+ end
@@ -1,8 +1,6 @@
1
1
  require 'json'
2
- require 'config'
3
2
  require 'net/http'
4
3
  require 'net/https'
5
- require 'response'
6
4
 
7
5
  module PaypalAdaptive
8
6
  class NoDataError < Exception
@@ -78,6 +76,12 @@ module PaypalAdaptive
78
76
  call_api(data, "/AdaptivePayments/Refund")
79
77
  end
80
78
 
79
+ def execute_payment(data)
80
+ raise NoDataError unless data
81
+
82
+ call_api(data, "/AdaptivePayments/ExecutePayment")
83
+ end
84
+
81
85
  def call_api(data, path)
82
86
  #hack fix: JSON.unparse doesn't work in Rails 2.3.5; only {}.to_json does..
83
87
  api_request_data = JSON.unparse(data) rescue data.to_json
@@ -0,0 +1,4 @@
1
+ module PaypalAdaptive
2
+ VERSION = "0.2.3"
3
+ end
4
+
@@ -1,77 +1,25 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
1
  # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "paypal_adaptive/version"
5
4
 
6
5
  Gem::Specification.new do |s|
7
- s.name = %q{paypal_adaptive}
8
- s.version = "0.2.2"
6
+ s.name = "paypal_adaptive"
7
+ s.version = PaypalAdaptive::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Tommy Chheng"]
10
+ s.email = ["tommy.chheng@gmail.com"]
11
+ s.homepage = "http://github.com/tc/paypal_adaptive"
12
+ s.summary = "Lightweight wrapper for Paypal's Adaptive Payments API"
13
+ s.description = "Lightweight wrapper for Paypal's Adaptive Payments API"
9
14
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Tommy Chheng"]
12
- s.date = %q{2011-07-22}
13
- s.description = %q{Lightweight wrapper for Paypal's Adaptive Payments API.}
14
- s.email = %q{tommy.chheng@gmail.com}
15
- s.extra_rdoc_files = [
16
- "LICENSE",
17
- "README.markdown"
18
- ]
19
- s.files = [
20
- "LICENSE",
21
- "README.markdown",
22
- "Rakefile",
23
- "VERSION",
24
- "cacert.pem",
25
- "config/paypal_adaptive.yml",
26
- "lib/config.rb",
27
- "lib/ipn_notification.rb",
28
- "lib/pay_request_schema.json",
29
- "lib/paypal_adaptive.rb",
30
- "lib/request.rb",
31
- "lib/response.rb",
32
- "paypal_adaptive.gemspec",
33
- "templates/paypal_ipn.rb",
34
- "test/data/invalid_chain_pay_request.json",
35
- "test/data/invalid_parallel_pay_request.json",
36
- "test/data/invalid_preapproval.json",
37
- "test/data/invalid_simple_pay_request_1.json",
38
- "test/data/valid_chain_pay_request.json",
39
- "test/data/valid_parallel_pay_request.json",
40
- "test/data/valid_preapproval.json",
41
- "test/data/valid_simple_pay_request_1.json",
42
- "test/test_helper.rb",
43
- "test/unit/config_test.rb",
44
- "test/unit/pay_request_schema_test.rb",
45
- "test/unit/pay_request_test.rb",
46
- "test/unit/payment_details_test.rb",
47
- "test/unit/preapproval_test.rb"
48
- ]
49
- s.homepage = %q{http://github.com/tc/paypal_adaptive}
50
- s.require_paths = ["lib"]
51
- s.rubygems_version = %q{1.6.2}
52
- s.summary = %q{initial import}
53
- s.test_files = [
54
- "test/test_helper.rb",
55
- "test/unit/config_test.rb",
56
- "test/unit/pay_request_schema_test.rb",
57
- "test/unit/pay_request_test.rb",
58
- "test/unit/payment_details_test.rb",
59
- "test/unit/preapproval_test.rb"
60
- ]
15
+ s.add_dependency("json", "~>1.6.0")
16
+ s.add_dependency("jsonschema", "~>2.0.0")
17
+ s.add_dependency("rake", "~>0.8")
61
18
 
62
- if s.respond_to? :specification_version then
63
- s.specification_version = 3
19
+ s.rubyforge_project = "paypal_adaptive"
64
20
 
65
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
66
- s.add_development_dependency(%q<json>, [">= 0"])
67
- s.add_development_dependency(%q<jsonschema>, [">= 0"])
68
- else
69
- s.add_dependency(%q<json>, [">= 0"])
70
- s.add_dependency(%q<jsonschema>, [">= 0"])
71
- end
72
- else
73
- s.add_dependency(%q<json>, [">= 0"])
74
- s.add_dependency(%q<jsonschema>, [">= 0"])
75
- end
21
+ s.files = `git ls-files`.split("\n")
22
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
23
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
24
+ s.require_paths = ["lib"]
76
25
  end
77
-
@@ -1,7 +1,8 @@
1
- require 'rubygems'
2
- require 'JSON'
3
- require 'test/unit'
4
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
5
1
  $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
6
3
 
4
+ require "rubygems"
5
+ require "test/unit"
6
+ require "json"
7
+ require "jsonschema"
7
8
  require 'paypal_adaptive'
@@ -1,6 +1,4 @@
1
1
  require 'test_helper'
2
- require 'json'
3
- require 'jsonschema'
4
2
 
5
3
  class PayRequestSchemaTest < Test::Unit::TestCase
6
4
  def setup
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.2
4
+ version: 0.2.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,51 +9,63 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-07-22 00:00:00.000000000 -07:00
13
- default_executable:
12
+ date: 2011-10-10 00:00:00.000000000Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: json
17
- requirement: &2153062760 !ruby/object:Gem::Requirement
16
+ requirement: &70366761922980 !ruby/object:Gem::Requirement
18
17
  none: false
19
18
  requirements:
20
- - - ! '>='
19
+ - - ~>
21
20
  - !ruby/object:Gem::Version
22
- version: '0'
23
- type: :development
21
+ version: 1.6.0
22
+ type: :runtime
24
23
  prerelease: false
25
- version_requirements: *2153062760
24
+ version_requirements: *70366761922980
26
25
  - !ruby/object:Gem::Dependency
27
26
  name: jsonschema
28
- requirement: &2153062160 !ruby/object:Gem::Requirement
27
+ requirement: &70366761921940 !ruby/object:Gem::Requirement
29
28
  none: false
30
29
  requirements:
31
- - - ! '>='
30
+ - - ~>
32
31
  - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
32
+ version: 2.0.0
33
+ type: :runtime
35
34
  prerelease: false
36
- version_requirements: *2153062160
37
- description: Lightweight wrapper for Paypal's Adaptive Payments API.
38
- email: tommy.chheng@gmail.com
35
+ version_requirements: *70366761921940
36
+ - !ruby/object:Gem::Dependency
37
+ name: rake
38
+ requirement: &70366761920820 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: '0.8'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70366761920820
47
+ description: Lightweight wrapper for Paypal's Adaptive Payments API
48
+ email:
49
+ - tommy.chheng@gmail.com
39
50
  executables: []
40
51
  extensions: []
41
- extra_rdoc_files:
42
- - LICENSE
43
- - README.markdown
52
+ extra_rdoc_files: []
44
53
  files:
54
+ - .gitignore
55
+ - Gemfile
56
+ - Gemfile.lock
45
57
  - LICENSE
46
58
  - README.markdown
47
59
  - Rakefile
48
- - VERSION
49
60
  - cacert.pem
50
61
  - config/paypal_adaptive.yml
51
- - lib/config.rb
52
- - lib/ipn_notification.rb
53
62
  - lib/pay_request_schema.json
54
63
  - lib/paypal_adaptive.rb
55
- - lib/request.rb
56
- - lib/response.rb
64
+ - lib/paypal_adaptive/config.rb
65
+ - lib/paypal_adaptive/ipn_notification.rb
66
+ - lib/paypal_adaptive/request.rb
67
+ - lib/paypal_adaptive/response.rb
68
+ - lib/paypal_adaptive/version.rb
57
69
  - paypal_adaptive.gemspec
58
70
  - templates/paypal_ipn.rb
59
71
  - test/data/invalid_chain_pay_request.json
@@ -70,7 +82,6 @@ files:
70
82
  - test/unit/pay_request_test.rb
71
83
  - test/unit/payment_details_test.rb
72
84
  - test/unit/preapproval_test.rb
73
- has_rdoc: true
74
85
  homepage: http://github.com/tc/paypal_adaptive
75
86
  licenses: []
76
87
  post_install_message:
@@ -90,12 +101,20 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
101
  - !ruby/object:Gem::Version
91
102
  version: '0'
92
103
  requirements: []
93
- rubyforge_project:
94
- rubygems_version: 1.6.2
104
+ rubyforge_project: paypal_adaptive
105
+ rubygems_version: 1.8.10
95
106
  signing_key:
96
107
  specification_version: 3
97
- summary: initial import
108
+ summary: Lightweight wrapper for Paypal's Adaptive Payments API
98
109
  test_files:
110
+ - test/data/invalid_chain_pay_request.json
111
+ - test/data/invalid_parallel_pay_request.json
112
+ - test/data/invalid_preapproval.json
113
+ - test/data/invalid_simple_pay_request_1.json
114
+ - test/data/valid_chain_pay_request.json
115
+ - test/data/valid_parallel_pay_request.json
116
+ - test/data/valid_preapproval.json
117
+ - test/data/valid_simple_pay_request_1.json
99
118
  - test/test_helper.rb
100
119
  - test/unit/config_test.rb
101
120
  - test/unit/pay_request_schema_test.rb
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.2.2