paypal-permissions 0.1.0

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,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source :rubygems
2
+
3
+ gem 'httpclient'
4
+
5
+ group :development do
6
+ gem "jeweler", "~> 1.6.4"
7
+ end
8
+
9
+ group :test do
10
+ gem "rspec", ">= 2.0.0"
11
+
12
+ # testing help
13
+ gem "webmock"
14
+ gem "vcr"
15
+ end
@@ -0,0 +1,35 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ addressable (2.2.6)
5
+ crack (0.1.8)
6
+ diff-lcs (1.1.2)
7
+ git (1.2.5)
8
+ httpclient (2.2.1)
9
+ jeweler (1.6.4)
10
+ bundler (~> 1.0)
11
+ git (>= 1.2.5)
12
+ rake
13
+ rake (0.9.2)
14
+ rspec (2.6.0)
15
+ rspec-core (~> 2.6.0)
16
+ rspec-expectations (~> 2.6.0)
17
+ rspec-mocks (~> 2.6.0)
18
+ rspec-core (2.6.4)
19
+ rspec-expectations (2.6.0)
20
+ diff-lcs (~> 1.1.2)
21
+ rspec-mocks (2.6.0)
22
+ vcr (1.10.3)
23
+ webmock (1.6.4)
24
+ addressable (~> 2.2, > 2.2.5)
25
+ crack (>= 0.1.7)
26
+
27
+ PLATFORMS
28
+ ruby
29
+
30
+ DEPENDENCIES
31
+ httpclient
32
+ jeweler (~> 1.6.4)
33
+ rspec (>= 2.0.0)
34
+ vcr
35
+ webmock
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2011 Recurly, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,72 @@
1
+ # Paypal Permissions
2
+
3
+ Ruby implementation of the [PayPal Permissions API](https://www.x.com/community/ppx/permissions).
4
+
5
+ Please visit PayPal's [Permissions Service API developer forums](https://www.x.com/community/ppx/permissions?view=discussions) for questions about the Permissions API.
6
+
7
+ ## Example
8
+
9
+ ### Step 1: Direct the user to the "Grant Permissions" on PayPal
10
+
11
+ paypal = PaypalPermissions::Paypal.new( userid, password, signature, application_id, :production )
12
+ request_data = paypal.request_permissions(
13
+ [:express_checkout, :direct_payment, :auth_capture, :refund, :transaction_details],
14
+ 'http://localhost/callback_url'
15
+ )
16
+
17
+ # Send the browser to :permissions_url to grant permission to your application
18
+ redirect_to request_data[:permissions_url]
19
+
20
+ ### Step 2: Lookup result to get the final permission token
21
+
22
+ paypal = PaypalPermissions::Paypal.new( userid, password, signature, application_id, :production )
23
+ token_data = paypal.get_access_token( params['token'], params['verifier'] )
24
+
25
+ # Save token_data[:token] and token_data[:token_secret]
26
+
27
+ ### Step 3: Make API calls with the `X-PP-AUTHORIZATION` header
28
+
29
+ Use the `:token` and `:token_secret`, along with your own API credentials, to create the `X-PP-AUTHORIZATION` header.
30
+
31
+ signature = paypal.generate_signature(api_key, secret, token, token_secret, 'POST', 'https://api.paypal.com/nvp')
32
+ header = { 'X-PP-AUTHORIZATION' => signature }
33
+
34
+ ### Lookup granted permissions
35
+
36
+ scopes = paypal.lookup_permissions paypal_token
37
+
38
+ ### Cancel granted permissions
39
+
40
+ paypal.cancel_permissions paypal_token
41
+
42
+ ## Available Permissions
43
+
44
+ :express_checkout
45
+ :direct_payment
46
+ :settlement_consolidation
47
+ :settlement_reporting
48
+ :auth_capture
49
+ :mobile_checkout
50
+ :billing_agreement
51
+ :reference_transaction
52
+ :air_travel
53
+ :mass_pay
54
+ :transaction_details
55
+ :transaction_search
56
+ :recurring_payments
57
+ :account_balance
58
+ :encrypted_website_payments
59
+ :refund
60
+ :non_referenced_credit
61
+ :button_manager
62
+ :manage_pending_transaction_status
63
+ :recurring_payment_report
64
+ :extended_pro_processing_report
65
+ :exception_processing_report
66
+ :account_management_permission
67
+
68
+ ## Copyright
69
+
70
+ Copyright (c) 2011 Recurly. MIT License
71
+
72
+ Original version by Isaac Hall.
@@ -0,0 +1,44 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'bundler'
4
+ begin
5
+ Bundler.setup(:default, :test)
6
+ rescue Bundler::BundlerError => e
7
+ $stderr.puts e.message
8
+ $stderr.puts "Run `bundle install` to install missing gems"
9
+ exit e.status_code
10
+ end
11
+ require 'rake'
12
+
13
+ require 'jeweler'
14
+ Jeweler::Tasks.new do |gem|
15
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
16
+ gem.name = "paypal-permissions"
17
+ gem.homepage = "http://github.com/isaachall/paypal-permissions"
18
+ gem.license = "MIT"
19
+ gem.summary = %Q{Ruby implementation of the PayPal Permissions API.}
20
+ gem.description = %Q{Ruby implementation of the PayPal Permissions API.}
21
+ gem.email = "isaac@isaachall.com"
22
+ gem.authors = ["Isaac Hall"]
23
+ # Include your dependencies below. Runtime dependencies are required when using your gem,
24
+ # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
25
+ gem.add_runtime_dependency 'httpclient'
26
+ gem.add_development_dependency 'rspec', '> 2.0.0'
27
+ gem.add_development_dependency 'vcr'
28
+ gem.add_development_dependency 'webmock'
29
+ end
30
+ Jeweler::RubygemsDotOrgTasks.new
31
+
32
+ require 'rspec/core/rake_task'
33
+ RSpec::Core::RakeTask.new(:spec)
34
+ task :default => :spec
35
+
36
+ require 'rdoc/task'
37
+ Rake::RDocTask.new do |rdoc|
38
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
39
+
40
+ rdoc.rdoc_dir = 'rdoc'
41
+ rdoc.title = "paypal-permissions #{version}"
42
+ rdoc.rdoc_files.include('README*')
43
+ rdoc.rdoc_files.include('lib/**/*.rb')
44
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,9 @@
1
+ require 'paypal-permissions/version'
2
+ require 'paypal-permissions/fault_message'
3
+ require 'paypal-permissions/oauth'
4
+ require 'paypal-permissions/paypal'
5
+
6
+ # configuration
7
+ module PaypalPermissions
8
+
9
+ end
@@ -0,0 +1,58 @@
1
+ module PaypalPermissions
2
+ # Base error class
3
+ class Error < Exception; end
4
+
5
+ # PayPal returned a 500 Internal Server Error. Retry?
6
+ class InternalServerError < PaypalPermissions::Error; end
7
+
8
+ # PayPal returned an unexpected error message
9
+ class UnknownResponse < PaypalPermissions::Error
10
+ attr_accessor :response_code
11
+
12
+ def initialize(response_code, message)
13
+ @response_code = response_code
14
+ @message = message
15
+ end
16
+ end
17
+
18
+ # PayPal returned a well formatted error message
19
+ class FaultMessage < Error
20
+ attr_accessor :timestamp, :ack, :correlation_id, :build, :errors
21
+
22
+ class ErrorInformation
23
+ attr_accessor :category, :domain, :subdomain, :error_id, :message, :parameter, :severity
24
+
25
+ def initialize(options = {}, error_number = 0)
26
+ @category = options["error(#{error_number}).category"]
27
+ @domain = options["error(#{error_number}).domain"]
28
+ @subdomain = options["error(#{error_number}).subdomain"]
29
+ @error_id = options["error(#{error_number}).errorId"]
30
+ @message = options["error(#{error_number}).message"]
31
+ @parameter = options["error(#{error_number}).parameter"]
32
+ @severity = options["error(#{error_number}).severity"]
33
+ end
34
+ end
35
+
36
+ def initialize(options = {})
37
+ @timestamp = options['timestamp']
38
+ @ack = options['ack'].to_s.downcase.to_sym
39
+ @correlation_id = options['correlationId']
40
+ @build = options['build']
41
+ @errors = collect_errors(options)
42
+
43
+ @message = @ack
44
+ end
45
+
46
+ private
47
+ def collect_errors(options={})
48
+ errors = []
49
+ error_number = 0
50
+
51
+ while options["error(#{error_number}).errorId"]
52
+ errors << PaypalPermissions::FaultMessage::ErrorInformation.new(options, error_number)
53
+ error_number = error_number + 1
54
+ end
55
+ errors
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,174 @@
1
+ require 'net/http'
2
+ require 'net/https'
3
+ require 'uri'
4
+ require 'cgi'
5
+
6
+ module PaypalPermissions
7
+ class Paypal
8
+ include Oauth
9
+
10
+ attr_accessor :userid, :password, :signature, :application_id, :mode
11
+
12
+ SANDBOX_SERVER = 'https://svcs.sandbox.paypal.com/Permissions/'
13
+ PRODUCTION_SERVER = 'https://svcs.paypal.com/Permissions/'
14
+ API_VERSION = '74.0'
15
+
16
+ SANDBOX_GRANT_PERMISSION_URL = 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_grant-permission&request_token='
17
+ PRODUCTION_GRANT_PERMISSION_URL = 'https://www.paypal.com/cgi-bin/webscr?cmd=_grant-permission&request_token='
18
+
19
+ PERMISSIONS = {
20
+ :express_checkout => 'EXPRESS_CHECKOUT',
21
+ :direct_payment => 'DIRECT_PAYMENT',
22
+ :settlement_consolidation => 'SETTLEMENT_CONSOLIDATION',
23
+ :settlement_reporting => 'SETTLEMENT_REPORTING',
24
+ :auth_capture => 'AUTH_CAPTURE',
25
+ :mobile_checkout => 'MOBILE_CHECKOUT',
26
+ :billing_agreement => 'BILLING_AGREEMENT',
27
+ :reference_transaction => 'REFERENCE_TRANSACTION',
28
+ :air_travel => 'AIR_TRAVEL',
29
+ :mass_pay => 'MASS_PAY',
30
+ :transaction_details => 'TRANSACTION_DETAILS',
31
+ :transaction_search => 'TRANSACTION_SEARCH',
32
+ :recurring_payments => 'RECURRING_PAYMENTS',
33
+ :account_balance => 'ACCOUNT_BALANCE',
34
+ :encrypted_website_payments => 'ENCRYPTED_WEBSITE_PAYMENTS',
35
+ :refund => 'REFUND',
36
+ :non_referenced_credit => 'NON_REFERENCED_CREDIT',
37
+ :button_manager => 'BUTTON_MANAGER',
38
+ :manage_pending_transaction_status => 'MANAGE_PENDING_TRANSACTION_STATUS',
39
+ :recurring_payment_report => 'RECURRING_PAYMENT_REPORT',
40
+ :extended_pro_processing_report => 'EXTENDED_PRO_PROCESSING_REPORT',
41
+ :exception_processing_report => 'EXCEPTION_PROCESSING_REPORT',
42
+ :account_management_permission => 'ACCOUNT_MANAGEMENT_PERMISSION',
43
+ }
44
+
45
+ # Credentials: UserID, Password, Signature, Application ID
46
+ def initialize(userid, password, signature, application_id, mode = :production)
47
+ raise "Mode must be :sandbox or :production" unless [:sandbox, :production].include? mode
48
+ @userid = userid
49
+ @password = password
50
+ @signature = signature
51
+ @application_id = application_id
52
+ @mode = mode
53
+ end
54
+
55
+ # Create a "Request Permissions" URL. After requesting permissions, send the user to the URL
56
+ # so they can grant permissions. The user will be redirected back to the :callback_url.
57
+ def request_permissions(permissions_scopes, callback_url, language = 'en')
58
+ url = create_url('RequestPermissions')
59
+
60
+ request_data = {'callback' => callback_url, 'language' => language }
61
+ permissions_scopes.each_with_index { |ps,index| request_data["scope(#{index})"] = PERMISSIONS[ps] }
62
+ data = call(url, request_data)
63
+
64
+ raise PaypalPermissions::FaultMessage.new(data) unless data['token']
65
+
66
+ # Redirect URL:
67
+ # https://www.paypal.com/cgi-bin/webscr?cmd=_grant-permission&request_token= + token
68
+ {
69
+ permissions_url: (mode == :production ? PRODUCTION_GRANT_PERMISSION_URL : SANDBOX_GRANT_PERMISSION_URL) + data['token'],
70
+ token: data['token'],
71
+ }
72
+ end
73
+
74
+ # After a callback, lookup the access token and token secret using the :token and :verification from
75
+ # the callback URL.
76
+ def get_access_token(token, verifier)
77
+ url = create_url('GetAccessToken')
78
+ data = call(url, { 'token' => token, 'verifier' => verifier })
79
+
80
+ raise PaypalPermissions::FaultMessage.new(data) unless (data['token'] && data['tokenSecret'])
81
+
82
+ {
83
+ token: data['token'],
84
+ token_secret: data['tokenSecret'],
85
+ scopes: parse_scopes(data),
86
+ }
87
+ end
88
+
89
+ # Lookup the permissions granted to a given token.
90
+ def lookup_permissions(token)
91
+ url = create_url('GetPermissions')
92
+ data = call(url, { 'token' => token })
93
+
94
+ paypal_scopes = parse_scopes(data)
95
+ raise PaypalPermissions::FaultMessage.new(data) if paypal_scopes.empty?
96
+
97
+ { scopes: paypal_scopes }
98
+ end
99
+
100
+ # Cancel the permissions granted to the given token
101
+ def cancel_permissions(token)
102
+ url = create_url('CancelPermissions')
103
+ data = call(url, { 'token' => token })
104
+ true
105
+ end
106
+
107
+ protected
108
+
109
+ def create_url(endpoint)
110
+ (mode == :production ? PRODUCTION_SERVER : SANDBOX_SERVER) + endpoint
111
+ end
112
+
113
+ def call(url, params={})
114
+ headers = {
115
+ 'X-PAYPAL-SECURITY-USERID' => @userid,
116
+ 'X-PAYPAL-SECURITY-PASSWORD' => @password,
117
+ 'X-PAYPAL-SECURITY-SIGNATURE' => @signature,
118
+ 'X-PAYPAL-REQUEST-DATA-FORMAT' => 'NV',
119
+ 'X-PAYPAL-RESPONSE-DATA-FORMAT'=> 'NV',
120
+ 'X-PAYPAL-APPLICATION-ID' => @application_id,
121
+ 'Content-Type' => 'application/x-www-form-urlencoded',
122
+ }
123
+ params['requestEnvelope.errorLanguage'] = 'en_US'
124
+ data = params.map{ |k,v| "#{CGI.escape(k)}=#{CGI.escape(v)}" }.join('&')
125
+ data = URI.encode_www_form(params)
126
+
127
+ endpoint = URI(url)
128
+ timeout(30) do
129
+ http = Net::HTTP.new(endpoint.host, endpoint.port)
130
+ http.use_ssl = true
131
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE if mode == :sandbox
132
+ response = http.post(endpoint.request_uri, data, headers)
133
+ code = response.code
134
+
135
+ case code.to_i
136
+ when 200
137
+ data = get_hash(response.body)
138
+ raise PaypalPermissions::FaultMessage.new(data) if data['responseEnvelope.ack'] == 'Failure'
139
+ return data
140
+ when 500
141
+ raise PaypalPermissions::InternalServerError.new(response.body)
142
+ else
143
+ raise PaypalPermissions::UnknownResponse.new(code.to_i, response.body)
144
+ end
145
+ end
146
+ end
147
+
148
+ private
149
+
150
+ # Gets a hash from a string, with a set of name value pairs joined by '='
151
+ # and concatenated with '&'
152
+ def get_hash(string)
153
+ hash = {}
154
+ string.split('&').collect { |pair| pair.split('=') }.each { |a|
155
+ hash[a[0]] = URI.unescape(a[1])
156
+ }
157
+ return hash
158
+ end
159
+
160
+ # Parse out the scopes from the PayPal response
161
+ def parse_scopes(data)
162
+ scopes = []
163
+ scopes << data['scope'] if data['scope'] # If there is only one scope
164
+
165
+ i = 0
166
+ while (data["scope(#{i})"]) do
167
+ scopes << data["scope(#{i})"]; i = i + 1
168
+ end # For multiple scopes
169
+
170
+ # Convert to symbols
171
+ scopes.collect { |paypal_scope| PERMISSIONS.select { |k,val| val == paypal_scope }.keys.first }
172
+ end
173
+ end
174
+ end
@@ -0,0 +1,3 @@
1
+ module PaypalPermissions #:nodoc
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,63 @@
1
+ require 'spec_helper'
2
+
3
+ module PaypalPermissions
4
+ describe Paypal do
5
+ it "should request permissions with multiple scopes" do
6
+ VCR.use_cassette("request_permissions_multiple") do
7
+ permission_data = @paypal.request_permissions(
8
+ [:express_checkout, :direct_payment, :auth_capture, :refund, :transaction_details],
9
+ 'http://localhost/')
10
+
11
+ permission_data[:token].should == 'AAAAAAATmjdbA3ADelJ6'
12
+ permission_data[:permissions_url].should == 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_grant-permission&request_token=' + permission_data[:token]
13
+ end
14
+ end
15
+
16
+ it "should request permissions with a single scopes" do
17
+ VCR.use_cassette("request_permissions_single") do
18
+ permission_data = @paypal.request_permissions(
19
+ [:express_checkout],
20
+ 'http://localhost/')
21
+
22
+ permission_data[:token].should == 'AAAAAAATmnP2wcRCp7Mc'
23
+ permission_data[:permissions_url].should == 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_grant-permission&request_token=' + permission_data[:token]
24
+ end
25
+ end
26
+
27
+ it "should get an access token" do
28
+ VCR.use_cassette("get_access_token_valid") do
29
+ access_data = @paypal.get_access_token('AAAAAAATmjdbA3ADelJ6','KVTI4zbTe.QW07vOqPpqYg')
30
+ access_data[:token].should == 'M-RTGNyaZP5OMNIUxkH29I53eFvQhTJk3UfByH4pWfjSQHlj5csUVA'
31
+ access_data[:token_secret].should == 'l1.rjYM659iL92IwDmnPFeDWUnU'
32
+ access_data[:scopes].should == [:express_checkout, :refund, :direct_payment, :auth_capture, :transaction_details]
33
+ end
34
+ end
35
+
36
+ describe "#lookup_permissions" do
37
+ it "should lookup permissions" do
38
+ VCR.use_cassette("lookup_permissions_multiple") do
39
+ lookup_data = @paypal.lookup_permissions('M-RTGNyaZP5OMNIUxkH29I53eFvQhTJk3UfByH4pWfjSQHlj5csUVA')
40
+ lookup_data[:scopes].should == [:express_checkout, :refund, :direct_payment, :auth_capture, :transaction_details]
41
+ end
42
+ end
43
+ end
44
+
45
+ describe "#cancel_permission" do
46
+ it "should cancel permmission successfully" do
47
+ VCR.use_cassette("cancel_permission") do
48
+ cancel_data = @paypal.cancel_permissions('M-RTGNyaZP5OMNIUxkH29I53eFvQhTJk3UfByH4pWfjSQHlj5csUVA')
49
+ cancel_data.should be_true
50
+ end
51
+ end
52
+
53
+ it "should raise a FaultMessage when canceling an invalid permmission" do
54
+ lambda {
55
+ VCR.use_cassette("cancel_permission_invalid") do
56
+ @paypal.cancel_permissions('M-RTGNyaZP5OMNIUxkH29I53eFvQhTJk3UfByH4pWfjSQHlj5csUVA')
57
+ end
58
+ }.should raise_error(PaypalPermissions::FaultMessage)
59
+ end
60
+ end
61
+ end
62
+ end
63
+
@@ -0,0 +1,34 @@
1
+ require 'test/unit'
2
+ require 'rubygems'
3
+ require "bundler"
4
+ require 'yaml'
5
+ require 'vcr'
6
+ Bundler.setup
7
+
8
+ $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
9
+ require 'paypal-permissions'
10
+
11
+ module SpecHelper
12
+ # add helper methods here
13
+ end
14
+
15
+ RSpec.configure do |config|
16
+ config.include SpecHelper
17
+ config.extend VCR::RSpec::Macros
18
+ config.mock_with :rspec
19
+
20
+ config.before(:all) do
21
+ credentials = YAML.load(File.read(File.join(File.dirname(__FILE__), 'sandbox_credentials.yml')))
22
+ @paypal = PaypalPermissions::Paypal.new(
23
+ credentials['userid'], credentials['password'],credentials['signature'],credentials['application_id'],credentials['mode']
24
+ )
25
+ end
26
+ end
27
+
28
+ VCR.config do |c|
29
+ c.cassette_library_dir = 'spec/vcr'
30
+ c.stub_with :webmock
31
+
32
+ # Uncomment to allow VCR to record new cassettes
33
+ #c.default_cassette_options = { :record => :new_episodes }
34
+ end
@@ -0,0 +1,53 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :post
5
+ uri: https://svcs.sandbox.paypal.com:443/Permissions/CancelPermissions
6
+ body: token=M-RTGNyaZP5OMNIUxkH29I53eFvQhTJk3UfByH4pWfjSQHlj5csUVA&requestEnvelope.errorLanguage=en_US
7
+ headers:
8
+ x-paypal-security-userid:
9
+ - test_user_api1.recurly.com
10
+ x-paypal-security-password:
11
+ - '1234567890'
12
+ x-paypal-security-signature:
13
+ - AW123412341234123412341234123412341234123412341234123412
14
+ x-paypal-request-data-format:
15
+ - NV
16
+ x-paypal-response-data-format:
17
+ - NV
18
+ x-paypal-application-id:
19
+ - APP-80W284485P519543T
20
+ content-type:
21
+ - application/x-www-form-urlencoded
22
+ response: !ruby/struct:VCR::Response
23
+ status: !ruby/struct:VCR::ResponseStatus
24
+ code: 200
25
+ message: OK
26
+ headers:
27
+ date:
28
+ - Thu, 28 Jul 2011 03:07:42 GMT
29
+ server:
30
+ - Apache-Coyote/1.1
31
+ x-paypal-message-protocol:
32
+ - NONE
33
+ x-paypal-response-data-format:
34
+ - NV
35
+ x-ebay-soa-request-id:
36
+ - 1316eb62-ec10-a486-d666-6636ffffffba!Permissions!10.72.109.102![]
37
+ x-paypal-operation-name:
38
+ - CancelPermissions
39
+ x-paypal-service-name:
40
+ - ! '{http://svcs.paypal.com/types/perm}Permissions'
41
+ x-paypal-service-version:
42
+ - 1.0.0
43
+ content-type:
44
+ - text/plain;charset=UTF-8
45
+ set-cookie:
46
+ - Apache=10.72.109.11.1311822458368813; path=/; expires=Sat, 20-Jul-41 03:07:38
47
+ GMT
48
+ vary:
49
+ - Accept-Encoding
50
+ transfer-encoding:
51
+ - chunked
52
+ body: responseEnvelope.timestamp=2011-07-27T20%3A07%3A42.513-07%3A00&responseEnvelope.ack=Success&responseEnvelope.correlationId=ca9bd9ab62f06&responseEnvelope.build=1860631
53
+ http_version: '1.1'
@@ -0,0 +1,55 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :post
5
+ uri: https://svcs.sandbox.paypal.com:443/Permissions/CancelPermissions
6
+ body: token=M-RTGNyaZP5OMNIUxkH29I53eFvQhTJk3UfByH4pWfjSQHlj5csUVA&requestEnvelope.errorLanguage=en_US
7
+ headers:
8
+ x-paypal-security-userid:
9
+ - test_user_api1.recurly.com
10
+ x-paypal-security-password:
11
+ - '1234567890'
12
+ x-paypal-security-signature:
13
+ - AW123412341234123412341234123412341234123412341234123412
14
+ x-paypal-request-data-format:
15
+ - NV
16
+ x-paypal-response-data-format:
17
+ - NV
18
+ x-paypal-application-id:
19
+ - APP-80W284485P519543T
20
+ content-type:
21
+ - application/x-www-form-urlencoded
22
+ response: !ruby/struct:VCR::Response
23
+ status: !ruby/struct:VCR::ResponseStatus
24
+ code: 200
25
+ message: OK
26
+ headers:
27
+ date:
28
+ - Thu, 28 Jul 2011 03:08:17 GMT
29
+ server:
30
+ - Apache-Coyote/1.1
31
+ x-paypal-message-protocol:
32
+ - NONE
33
+ x-paypal-response-data-format:
34
+ - NV
35
+ x-ebay-soa-request-id:
36
+ - 1316eb6c-1390-a486-d647-d8d7ffffffb8!Permissions!10.72.109.100![]
37
+ x-paypal-operation-name:
38
+ - CancelPermissions
39
+ x-paypal-service-name:
40
+ - ! '{http://svcs.paypal.com/types/perm}Permissions'
41
+ x-paypal-service-version:
42
+ - 1.0.0
43
+ x-paypal-error-response:
44
+ - 'TRUE'
45
+ content-type:
46
+ - text/plain;charset=UTF-8
47
+ set-cookie:
48
+ - Apache=10.72.109.11.1311822495864392; path=/; expires=Sat, 20-Jul-41 03:08:15
49
+ GMT
50
+ vary:
51
+ - Accept-Encoding
52
+ transfer-encoding:
53
+ - chunked
54
+ body: responseEnvelope.timestamp=2011-07-27T20%3A08%3A17.026-07%3A00&responseEnvelope.ack=Failure&responseEnvelope.correlationId=c8981c666c180&responseEnvelope.build=1860631&error(0).errorId=520002&error(0).domain=PLATFORM&error(0).subdomain=Application&error(0).severity=Error&error(0).category=Application&error(0).message=Internal+Error
55
+ http_version: '1.1'
@@ -0,0 +1,53 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :post
5
+ uri: https://svcs.sandbox.paypal.com:443/Permissions/GetAccessToken
6
+ body: token=AAAAAAATmjdbA3ADelJ6&verifier=KVTI4zbTe.QW07vOqPpqYg&requestEnvelope.errorLanguage=en_US
7
+ headers:
8
+ x-paypal-security-userid:
9
+ - test_user_api1.recurly.com
10
+ x-paypal-security-password:
11
+ - '1234567890'
12
+ x-paypal-security-signature:
13
+ - AW123412341234123412341234123412341234123412341234123412
14
+ x-paypal-request-data-format:
15
+ - NV
16
+ x-paypal-response-data-format:
17
+ - NV
18
+ x-paypal-application-id:
19
+ - APP-80W284485P519543T
20
+ content-type:
21
+ - application/x-www-form-urlencoded
22
+ response: !ruby/struct:VCR::Response
23
+ status: !ruby/struct:VCR::ResponseStatus
24
+ code: 200
25
+ message: OK
26
+ headers:
27
+ date:
28
+ - Thu, 28 Jul 2011 03:05:56 GMT
29
+ server:
30
+ - Apache-Coyote/1.1
31
+ x-paypal-message-protocol:
32
+ - NONE
33
+ x-paypal-response-data-format:
34
+ - NV
35
+ x-ebay-soa-request-id:
36
+ - 1316eb49-a450-a486-d637-e8f7fffffd10!Permissions!10.72.109.99![]
37
+ x-paypal-operation-name:
38
+ - GetAccessToken
39
+ x-paypal-service-name:
40
+ - ! '{http://svcs.paypal.com/types/perm}Permissions'
41
+ x-paypal-service-version:
42
+ - 1.0.0
43
+ content-type:
44
+ - text/plain;charset=UTF-8
45
+ set-cookie:
46
+ - Apache=10.72.109.11.1311822354823084; path=/; expires=Sat, 20-Jul-41 03:05:54
47
+ GMT
48
+ vary:
49
+ - Accept-Encoding
50
+ transfer-encoding:
51
+ - chunked
52
+ body: responseEnvelope.timestamp=2011-07-27T20%3A05%3A56.696-07%3A00&responseEnvelope.ack=Success&responseEnvelope.correlationId=35d2810849d35&responseEnvelope.build=1860631&scope(0)=EXPRESS_CHECKOUT&scope(1)=REFUND&scope(2)=DIRECT_PAYMENT&scope(3)=AUTH_CAPTURE&scope(4)=TRANSACTION_DETAILS&token=M-RTGNyaZP5OMNIUxkH29I53eFvQhTJk3UfByH4pWfjSQHlj5csUVA&tokenSecret=l1.rjYM659iL92IwDmnPFeDWUnU
53
+ http_version: '1.1'
@@ -0,0 +1,53 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :post
5
+ uri: https://svcs.sandbox.paypal.com:443/Permissions/GetPermissions
6
+ body: token=M-RTGNyaZP5OMNIUxkH29I53eFvQhTJk3UfByH4pWfjSQHlj5csUVA&requestEnvelope.errorLanguage=en_US
7
+ headers:
8
+ x-paypal-security-userid:
9
+ - test_user_api1.recurly.com
10
+ x-paypal-security-password:
11
+ - '1234567890'
12
+ x-paypal-security-signature:
13
+ - AW123412341234123412341234123412341234123412341234123412
14
+ x-paypal-request-data-format:
15
+ - NV
16
+ x-paypal-response-data-format:
17
+ - NV
18
+ x-paypal-application-id:
19
+ - APP-80W284485P519543T
20
+ content-type:
21
+ - application/x-www-form-urlencoded
22
+ response: !ruby/struct:VCR::Response
23
+ status: !ruby/struct:VCR::ResponseStatus
24
+ code: 200
25
+ message: OK
26
+ headers:
27
+ date:
28
+ - Thu, 28 Jul 2011 03:06:49 GMT
29
+ server:
30
+ - Apache-Coyote/1.1
31
+ x-paypal-message-protocol:
32
+ - NONE
33
+ x-paypal-response-data-format:
34
+ - NV
35
+ x-ebay-soa-request-id:
36
+ - 1316eb56-55c0-a486-d647-d8d7ffffffb9!Permissions!10.72.109.100![]
37
+ x-paypal-operation-name:
38
+ - GetPermissions
39
+ x-paypal-service-name:
40
+ - ! '{http://svcs.paypal.com/types/perm}Permissions'
41
+ x-paypal-service-version:
42
+ - 1.0.0
43
+ content-type:
44
+ - text/plain;charset=UTF-8
45
+ set-cookie:
46
+ - Apache=10.72.109.11.1311822406811670; path=/; expires=Sat, 20-Jul-41 03:06:46
47
+ GMT
48
+ vary:
49
+ - Accept-Encoding
50
+ transfer-encoding:
51
+ - chunked
52
+ body: responseEnvelope.timestamp=2011-07-27T20%3A06%3A49.264-07%3A00&responseEnvelope.ack=Success&responseEnvelope.correlationId=783aab5a565a2&responseEnvelope.build=1860631&scope(0)=EXPRESS_CHECKOUT&scope(1)=REFUND&scope(2)=DIRECT_PAYMENT&scope(3)=AUTH_CAPTURE&scope(4)=TRANSACTION_DETAILS
53
+ http_version: '1.1'
@@ -0,0 +1,53 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :post
5
+ uri: https://svcs.sandbox.paypal.com:443/Permissions/RequestPermissions
6
+ body: callback=http%3A%2F%2Flocalhost%2F&language=en&scope%280%29=EXPRESS_CHECKOUT&scope%281%29=DIRECT_PAYMENT&scope%282%29=AUTH_CAPTURE&scope%283%29=REFUND&scope%284%29=TRANSACTION_DETAILS&requestEnvelope.errorLanguage=en_US
7
+ headers:
8
+ x-paypal-security-userid:
9
+ - test_user_api1.recurly.com
10
+ x-paypal-security-password:
11
+ - '1234567890'
12
+ x-paypal-security-signature:
13
+ - AW123412341234123412341234123412341234123412341234123412
14
+ x-paypal-request-data-format:
15
+ - NV
16
+ x-paypal-response-data-format:
17
+ - NV
18
+ x-paypal-application-id:
19
+ - APP-80W284485P519543T
20
+ content-type:
21
+ - application/x-www-form-urlencoded
22
+ response: !ruby/struct:VCR::Response
23
+ status: !ruby/struct:VCR::ResponseStatus
24
+ code: 200
25
+ message: OK
26
+ headers:
27
+ date:
28
+ - Thu, 28 Jul 2011 02:56:56 GMT
29
+ server:
30
+ - Apache-Coyote/1.1
31
+ x-paypal-message-protocol:
32
+ - NONE
33
+ x-paypal-response-data-format:
34
+ - NV
35
+ x-ebay-soa-request-id:
36
+ - 1316eac5-f8b0-a486-d637-e8f7fffffd11!Permissions!10.72.109.99![]
37
+ x-paypal-operation-name:
38
+ - RequestPermissions
39
+ x-paypal-service-name:
40
+ - ! '{http://svcs.paypal.com/types/perm}Permissions'
41
+ x-paypal-service-version:
42
+ - 1.0.0
43
+ content-type:
44
+ - text/plain;charset=UTF-8
45
+ set-cookie:
46
+ - Apache=10.72.109.11.1311821815501667; path=/; expires=Sat, 20-Jul-41 02:56:55
47
+ GMT
48
+ vary:
49
+ - Accept-Encoding
50
+ transfer-encoding:
51
+ - chunked
52
+ body: responseEnvelope.timestamp=2011-07-27T19%3A56%3A56.696-07%3A00&responseEnvelope.ack=Success&responseEnvelope.correlationId=5ddfdbf7c627a&responseEnvelope.build=1860631&token=AAAAAAATmjdbA3ADelJ6
53
+ http_version: '1.1'
@@ -0,0 +1,53 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :post
5
+ uri: https://svcs.sandbox.paypal.com:443/Permissions/RequestPermissions
6
+ body: callback=http%3A%2F%2Flocalhost%2F&language=en&scope%280%29=EXPRESS_CHECKOUT&requestEnvelope.errorLanguage=en_US
7
+ headers:
8
+ x-paypal-security-userid:
9
+ - test_user_api1.recurly.com
10
+ x-paypal-security-password:
11
+ - '1234567890'
12
+ x-paypal-security-signature:
13
+ - AW123412341234123412341234123412341234123412341234123412
14
+ x-paypal-request-data-format:
15
+ - NV
16
+ x-paypal-response-data-format:
17
+ - NV
18
+ x-paypal-application-id:
19
+ - APP-80W284485P519543T
20
+ content-type:
21
+ - application/x-www-form-urlencoded
22
+ response: !ruby/struct:VCR::Response
23
+ status: !ruby/struct:VCR::ResponseStatus
24
+ code: 200
25
+ message: OK
26
+ headers:
27
+ date:
28
+ - Thu, 28 Jul 2011 03:19:29 GMT
29
+ server:
30
+ - Apache-Coyote/1.1
31
+ x-paypal-message-protocol:
32
+ - NONE
33
+ x-paypal-response-data-format:
34
+ - NV
35
+ x-ebay-soa-request-id:
36
+ - 1316ec10-5a50-a486-d666-6636ffffffb9!Permissions!10.72.109.102![]
37
+ x-paypal-operation-name:
38
+ - RequestPermissions
39
+ x-paypal-service-name:
40
+ - ! '{http://svcs.paypal.com/types/perm}Permissions'
41
+ x-paypal-service-version:
42
+ - 1.0.0
43
+ content-type:
44
+ - text/plain;charset=UTF-8
45
+ set-cookie:
46
+ - Apache=10.72.109.11.1311823168735914; path=/; expires=Sat, 20-Jul-41 03:19:28
47
+ GMT
48
+ vary:
49
+ - Accept-Encoding
50
+ transfer-encoding:
51
+ - chunked
52
+ body: responseEnvelope.timestamp=2011-07-27T20%3A19%3A29.943-07%3A00&responseEnvelope.ack=Success&responseEnvelope.correlationId=eecf5f55105eb&responseEnvelope.build=1860631&token=AAAAAAATmnP2wcRCp7Mc
53
+ http_version: '1.1'
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: paypal-permissions
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Isaac Hall
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-07-30 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: httpclient
16
+ requirement: &70250705306740 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70250705306740
25
+ - !ruby/object:Gem::Dependency
26
+ name: jeweler
27
+ requirement: &70250705305760 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 1.6.4
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70250705305760
36
+ - !ruby/object:Gem::Dependency
37
+ name: httpclient
38
+ requirement: &70250705304580 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70250705304580
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec
49
+ requirement: &70250705302480 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>'
53
+ - !ruby/object:Gem::Version
54
+ version: 2.0.0
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70250705302480
58
+ - !ruby/object:Gem::Dependency
59
+ name: vcr
60
+ requirement: &70250705300380 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *70250705300380
69
+ - !ruby/object:Gem::Dependency
70
+ name: webmock
71
+ requirement: &70250705299180 !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: *70250705299180
80
+ description: Ruby implementation of the PayPal Permissions API.
81
+ email: isaac@isaachall.com
82
+ executables: []
83
+ extensions: []
84
+ extra_rdoc_files:
85
+ - LICENSE.txt
86
+ - README.rdoc
87
+ files:
88
+ - .document
89
+ - Gemfile
90
+ - Gemfile.lock
91
+ - LICENSE.txt
92
+ - README.rdoc
93
+ - Rakefile
94
+ - VERSION
95
+ - lib/paypal-permissions/fault_message.rb
96
+ - lib/paypal-permissions/paypal.rb
97
+ - lib/paypal-permissions/version.rb
98
+ - lib/paypal-permissions.rb
99
+ - spec/paypal_spec.rb
100
+ - spec/spec_helper.rb
101
+ - spec/vcr/cancel_permission.yml
102
+ - spec/vcr/cancel_permission_invalid.yml
103
+ - spec/vcr/get_access_token_valid.yml
104
+ - spec/vcr/lookup_permissions_multiple.yml
105
+ - spec/vcr/request_permissions_multiple.yml
106
+ - spec/vcr/request_permissions_single.yml
107
+ homepage: http://github.com/isaachall/paypal-permissions
108
+ licenses:
109
+ - MIT
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ none: false
116
+ requirements:
117
+ - - ! '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ requirements: []
127
+ rubyforge_project:
128
+ rubygems_version: 1.8.10
129
+ signing_key:
130
+ specification_version: 3
131
+ summary: Ruby implementation of the PayPal Permissions API.
132
+ test_files: []
133
+ has_rdoc: