paypal_permissions 0.0.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.
@@ -0,0 +1,2 @@
1
+ ActiveMerchant::Billing::PaypalPermissionsGateway.setup do |config|
2
+ end
@@ -0,0 +1,6 @@
1
+ require "paypal_permissions/version"
2
+ require "active_merchant/billing/gateways/paypal_permissions"
3
+
4
+ module PaypalPermissions
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,3 @@
1
+ module PaypalPermissions
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,31 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "paypal_permissions/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "paypal_permissions"
7
+ s.version = PaypalPermissions::VERSION
8
+ s.authors = ["Mark Paine"]
9
+ s.email = ["mark@mailbiter.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{"Rails gem for PayPal Permissions API support."}
12
+ s.description = %q{"A gem to support PayPal Permissions API for Rails applications using ActiveMerchant."}
13
+
14
+ s.rubyforge_project = "paypal_permissions"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_development_dependency "rake"
22
+ s.add_development_dependency "activesupport", "~> 3.0"
23
+ s.add_development_dependency "activemerchant"
24
+ s.add_development_dependency "rspec", "~> 2.6"
25
+ s.add_development_dependency "vcr", "~> 1.11"
26
+ s.add_development_dependency "ammeter"
27
+
28
+ s.add_runtime_dependency 'railties', '~> 3.0'
29
+ s.add_runtime_dependency "activesupport", "~> 3.0"
30
+ s.add_runtime_dependency "activemerchant"
31
+ end
@@ -0,0 +1,147 @@
1
+ require 'spec_helper'
2
+
3
+ describe ActiveMerchant::Billing::PaypalPermissionsGateway do
4
+ let(:required_params) do
5
+ {
6
+ :login => "caller_1327459669_biz_api1.moshbit.com",
7
+ :password => "1327459694",
8
+ :signature => "AkzCUa2Iv085jJrg3I3gi7lOC61mAp59Sx7.lboUrlIi9ovIdVHk9PCr",
9
+ :app_id => "APP-80W284485P519543T",
10
+ }
11
+ end
12
+
13
+ let (:valid_gateway) do
14
+ ActiveMerchant::Billing::Base.mode = :test
15
+ ActiveMerchant::Billing::PaypalPermissionsGateway.new required_params
16
+ end
17
+
18
+ let (:invalid_login_gateway) do
19
+ ActiveMerchant::Billing::Base.mode = :test
20
+ ActiveMerchant::Billing::PaypalPermissionsGateway.new required_params.dup.merge(:login => 'invalid_login')
21
+ end
22
+
23
+ let (:invalid_password_gateway) do
24
+ ActiveMerchant::Billing::Base.mode = :test
25
+ ActiveMerchant::Billing::PaypalPermissionsGateway.new required_params.dup.merge(:password => 'invalid_password')
26
+ end
27
+
28
+ let (:invalid_app_id_gateway) do
29
+ ActiveMerchant::Billing::Base.mode = :test
30
+ ActiveMerchant::Billing::PaypalPermissionsGateway.new required_params.dup.merge(:app_id => 'invalid_app_id')
31
+ end
32
+
33
+ let (:callback_url) do
34
+ 'http://www.example.com/paypal_permissions_callback'
35
+ end
36
+
37
+ it "can be initialized with all required options" do
38
+ lambda {
39
+ ActiveMerchant::Billing::PaypalPermissionsGateway.new required_params
40
+ }.should_not raise_error
41
+ end
42
+
43
+ it "can't be initialized without a login option" do
44
+ lambda {
45
+ ActiveMerchant::Billing::PaypalPermissionsGateway.new required_params.except(:login)
46
+ }.should raise_error(ArgumentError, "Missing required parameter: login")
47
+ end
48
+
49
+ it "can't be initialized without a password option" do
50
+ lambda {
51
+ ActiveMerchant::Billing::PaypalPermissionsGateway.new required_params.except(:password)
52
+ }.should raise_error(ArgumentError, "Missing required parameter: password")
53
+ end
54
+
55
+ it "can't be initialized without a signature option" do
56
+ lambda {
57
+ ActiveMerchant::Billing::PaypalPermissionsGateway.new required_params.except(:signature)
58
+ }.should raise_error(ArgumentError, "Missing required parameter: signature")
59
+ end
60
+
61
+ it "can't be initialized without an app_id option" do
62
+ lambda {
63
+ ActiveMerchant::Billing::PaypalPermissionsGateway.new required_params.except(:app_id)
64
+ }.should raise_error(ArgumentError, "Missing required parameter: app_id")
65
+ end
66
+
67
+ it "rejects a request with no permissions" do
68
+ lambda {
69
+ # response = valid_gateway.request_permissions callback_url, nil
70
+ }.should_not raise_error
71
+ end
72
+
73
+ it "accepts a request for a single permission" do
74
+ response = valid_gateway.request_permissions callback_url, "DIRECT_PAYMENT"
75
+ response[:ack].should == 'Success'
76
+ end
77
+
78
+ it "strips leading and trailing whitespace from permissions" do
79
+ response = valid_gateway.request_permissions callback_url, " DIRECT_PAYMENT "
80
+ response[:ack].should == 'Success'
81
+ end
82
+
83
+ it "accepts permissions requests which aren't all upper case" do
84
+ response = valid_gateway.request_permissions callback_url, "express_checkout, direct_payment"
85
+ response[:ack].should == 'Success'
86
+ end
87
+
88
+ it "accepts a request for multiple permissions as a comma-separated string" do
89
+ response = valid_gateway.request_permissions callback_url, "EXPRESS_CHECKOUT, DIRECT_PAYMENT"
90
+ response[:ack].should == 'Success'
91
+ end
92
+
93
+ it "accepts a request for multiple permissions as an array" do
94
+ response = valid_gateway.request_permissions callback_url, [ "EXPRESS_CHECKOUT", "DIRECT_PAYMENT" ]
95
+ response[:ack].should == 'Success'
96
+ end
97
+
98
+ it "reports an error when the login is invalid" do
99
+ response = invalid_login_gateway.request_permissions callback_url, "DIRECT_PAYMENT"
100
+ response[:errors][0][:message].should == "Authentication failed. API credentials are incorrect."
101
+ end
102
+
103
+ it "reports the severity of the error when the login is invalid" do
104
+ response = invalid_login_gateway.request_permissions callback_url, "DIRECT_PAYMENT"
105
+ response[:errors][0][:severity].should == "Error"
106
+ end
107
+
108
+ it "reports an error when the password is invalid" do
109
+ response = invalid_password_gateway.request_permissions callback_url, "DIRECT_PAYMENT"
110
+ response[:errors][0][:message].should == "Authentication failed. API credentials are incorrect."
111
+ end
112
+
113
+ it "reports the severity of the error when the password is invalid" do
114
+ response = invalid_password_gateway.request_permissions callback_url, "DIRECT_PAYMENT"
115
+ response[:errors][0][:severity].should == "Error"
116
+ end
117
+
118
+ it "reports an error when the app id is invalid" do
119
+ response = invalid_app_id_gateway.request_permissions callback_url, "DIRECT_PAYMENT"
120
+ response[:errors][0][:message].should == "The X-PAYPAL-APPLICATION-ID header contains an invalid value"
121
+ end
122
+
123
+ it "reports the parameter that caused the error when the app id is invalid" do
124
+ response = invalid_app_id_gateway.request_permissions callback_url, "DIRECT_PAYMENT"
125
+ response[:errors][0][:parameters][0].should == "X-PAYPAL-APPLICATION-ID"
126
+ end
127
+
128
+ it "reports the severity of the error when the app id is invalid" do
129
+ response = invalid_app_id_gateway.request_permissions callback_url, "DIRECT_PAYMENT"
130
+ response[:errors][0][:severity].should == "Error"
131
+ end
132
+
133
+ it "reports an error when a requested permission is invalid" do
134
+ response = valid_gateway.request_permissions callback_url, "I_AM_NOT_VALID"
135
+ response[:errors][0][:message].should == "Invalid request parameter: scope with value I_AM_NOT_VALID"
136
+ end
137
+
138
+ it "reports the parameter that caused the error when a requested permission is invalid" do
139
+ response = valid_gateway.request_permissions callback_url, "I_AM_NOT_VALID"
140
+ response[:errors][0][:parameters][0].should == "I_AM_NOT_VALID"
141
+ end
142
+
143
+ it "reports the severity of the error when a requested permission is invalid" do
144
+ response = valid_gateway.request_permissions callback_url, "I_AM_NOT_VALID"
145
+ response[:errors][0][:severity].should == "Error"
146
+ end
147
+ end
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+
3
+ # Generators are not automatically loaded by Rails
4
+ require 'generators/paypal_permissions/install_generator'
5
+
6
+ describe PaypalPermissions::Generators::InstallGenerator do
7
+ snippet =<<-SNIPPET
8
+ Agentfriday::Application.configure do
9
+ end
10
+ SNIPPET
11
+
12
+ tmpdir = File.expand_path("../../../../tmp", __FILE__)
13
+ destination tmpdir
14
+ before { prepare_destination }
15
+
16
+ describe 'no arguments' do
17
+ before {
18
+ `mkdir -p "#{tmpdir}/config/environments"`
19
+ ["development", "test", "production"].each do |env|
20
+ File::open("#{tmpdir}/config/environments/#{env}.rb", "w") do |f|
21
+ f << snippet
22
+ end
23
+ end
24
+ run_generator
25
+ }
26
+
27
+ describe 'config/environments/development.rb' do
28
+ subject { file('config/environments/development.rb') }
29
+ it { should exist }
30
+ it { should contain "TODO: your PayPal" }
31
+ end
32
+
33
+ describe 'config/environments/test.rb' do
34
+ subject { file('config/environments/test.rb') }
35
+ it { should exist }
36
+ it { should contain "TODO: your PayPal" }
37
+ end
38
+
39
+ describe 'config/environments/production.rb' do
40
+ subject { file('config/environments/development.rb') }
41
+ it { should exist }
42
+ it { should contain "TODO: your PayPal" }
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,13 @@
1
+ require 'active_support/core_ext/hash/except'
2
+ require 'active_merchant/billing/gateways/paypal_permissions'
3
+ require 'ammeter/init'
4
+
5
+ class Rails::Application; end
6
+ module Agentfriday
7
+ class Application < Rails::Application; end
8
+ end
9
+ module Rails
10
+ def self.application
11
+ Agentfriday::Application.new
12
+ end
13
+ end
metadata ADDED
@@ -0,0 +1,205 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: paypal_permissions
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Mark Paine
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-02-11 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: &2160410120 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *2160410120
25
+ - !ruby/object:Gem::Dependency
26
+ name: activesupport
27
+ requirement: &2160408500 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '3.0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *2160408500
36
+ - !ruby/object:Gem::Dependency
37
+ name: activemerchant
38
+ requirement: &2160407380 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *2160407380
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec
49
+ requirement: &2160405460 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '2.6'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *2160405460
58
+ - !ruby/object:Gem::Dependency
59
+ name: vcr
60
+ requirement: &2160404180 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ version: '1.11'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *2160404180
69
+ - !ruby/object:Gem::Dependency
70
+ name: ammeter
71
+ requirement: &2160402960 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *2160402960
80
+ - !ruby/object:Gem::Dependency
81
+ name: railties
82
+ requirement: &2160401320 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ~>
86
+ - !ruby/object:Gem::Version
87
+ version: '3.0'
88
+ type: :runtime
89
+ prerelease: false
90
+ version_requirements: *2160401320
91
+ - !ruby/object:Gem::Dependency
92
+ name: activesupport
93
+ requirement: &2160399800 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ~>
97
+ - !ruby/object:Gem::Version
98
+ version: '3.0'
99
+ type: :runtime
100
+ prerelease: false
101
+ version_requirements: *2160399800
102
+ - !ruby/object:Gem::Dependency
103
+ name: activemerchant
104
+ requirement: &2160393460 !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ type: :runtime
111
+ prerelease: false
112
+ version_requirements: *2160393460
113
+ description: ! '"A gem to support PayPal Permissions API for Rails applications using
114
+ ActiveMerchant."'
115
+ email:
116
+ - mark@mailbiter.com
117
+ executables:
118
+ - autospec
119
+ - erubis
120
+ - htmldiff
121
+ - ldiff
122
+ - rackup
123
+ - rails
124
+ - rake
125
+ - rake2thor
126
+ - rdoc
127
+ - ri
128
+ - rspec
129
+ - thor
130
+ - tilt
131
+ - tt
132
+ extensions: []
133
+ extra_rdoc_files: []
134
+ files:
135
+ - .gitignore
136
+ - Gemfile
137
+ - Rakefile
138
+ - bin/autospec
139
+ - bin/erubis
140
+ - bin/htmldiff
141
+ - bin/ldiff
142
+ - bin/rackup
143
+ - bin/rails
144
+ - bin/rake
145
+ - bin/rake2thor
146
+ - bin/rdoc
147
+ - bin/ri
148
+ - bin/rspec
149
+ - bin/thor
150
+ - bin/tilt
151
+ - bin/tt
152
+ - config/locales/en.yml
153
+ - lib/active_merchant.rb
154
+ - lib/active_merchant/billing.rb
155
+ - lib/active_merchant/billing/gateways.rb
156
+ - lib/active_merchant/billing/gateways/paypal_permissions.rb
157
+ - lib/generators/active_record/paypal_permissions_generator.rb
158
+ - lib/generators/active_record/templates/migration.rb
159
+ - lib/generators/active_record/templates/migration_existing.rb
160
+ - lib/generators/paypal_permissions/install_generator.rb
161
+ - lib/generators/paypal_permissions/orm_helpers.rb
162
+ - lib/generators/paypal_permissions/paypal_permissions_generator.rb
163
+ - lib/generators/templates/README
164
+ - lib/generators/templates/README.rdoc
165
+ - lib/generators/templates/paypal_permissions.rb
166
+ - lib/paypal_permissions.rb
167
+ - lib/paypal_permissions/version.rb
168
+ - paypal_permissions.gemspec
169
+ - spec/gateway_spec.rb
170
+ - spec/generators/paypal_permissions/install_generator_spec.rb
171
+ - spec/spec_helper.rb
172
+ homepage: ''
173
+ licenses: []
174
+ post_install_message:
175
+ rdoc_options: []
176
+ require_paths:
177
+ - lib
178
+ required_ruby_version: !ruby/object:Gem::Requirement
179
+ none: false
180
+ requirements:
181
+ - - ! '>='
182
+ - !ruby/object:Gem::Version
183
+ version: '0'
184
+ segments:
185
+ - 0
186
+ hash: -2869217312495989041
187
+ required_rubygems_version: !ruby/object:Gem::Requirement
188
+ none: false
189
+ requirements:
190
+ - - ! '>='
191
+ - !ruby/object:Gem::Version
192
+ version: '0'
193
+ segments:
194
+ - 0
195
+ hash: -2869217312495989041
196
+ requirements: []
197
+ rubyforge_project: paypal_permissions
198
+ rubygems_version: 1.8.10
199
+ signing_key:
200
+ specification_version: 3
201
+ summary: ! '"Rails gem for PayPal Permissions API support."'
202
+ test_files:
203
+ - spec/gateway_spec.rb
204
+ - spec/generators/paypal_permissions/install_generator_spec.rb
205
+ - spec/spec_helper.rb