paypal_permissions 0.0.5.4 → 0.0.5.5
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.
@@ -3,7 +3,6 @@ require 'active_merchant/billing'
|
|
3
3
|
require 'active_merchant/billing/gateway'
|
4
4
|
require 'paypal_permissions/parsers'
|
5
5
|
require 'paypal_permissions/x_pp_authorization'
|
6
|
-
require 'uri'
|
7
6
|
require 'cgi'
|
8
7
|
|
9
8
|
|
@@ -36,9 +35,9 @@ module ActiveMerchant #:nodoc:
|
|
36
35
|
get_access_token_headers = request_permissions_headers.dup
|
37
36
|
get_basic_personal_data_headers = lambda { |access_token, access_token_verifier|
|
38
37
|
{
|
39
|
-
'X-PAYPAL-SECURITY-USERID' => @login,
|
40
|
-
'X-PAYPAL-SECURITY-PASSWORD' => @password,
|
41
|
-
'X-PAYPAL-SECURITY-SIGNATURE' => @api_signature,
|
38
|
+
#'X-PAYPAL-SECURITY-USERID' => @login,
|
39
|
+
#'X-PAYPAL-SECURITY-PASSWORD' => @password,
|
40
|
+
#'X-PAYPAL-SECURITY-SIGNATURE' => @api_signature,
|
42
41
|
'X-PAYPAL-APPLICATION-ID' => @app_id,
|
43
42
|
'X-PAYPAL-REQUEST-DATA-FORMAT' => 'NV',
|
44
43
|
'X-PAYPAL-RESPONSE-DATA-FORMAT' => 'NV',
|
@@ -46,9 +45,9 @@ module ActiveMerchant #:nodoc:
|
|
46
45
|
}
|
47
46
|
get_advanced_personal_data_headers = lambda { |access_token, access_token_verifier|
|
48
47
|
{
|
49
|
-
'X-PAYPAL-SECURITY-USERID' => @login,
|
50
|
-
'X-PAYPAL-SECURITY-PASSWORD' => @password,
|
51
|
-
'X-PAYPAL-SECURITY-SIGNATURE' => @api_signature,
|
48
|
+
#'X-PAYPAL-SECURITY-USERID' => @login,
|
49
|
+
#'X-PAYPAL-SECURITY-PASSWORD' => @password,
|
50
|
+
#'X-PAYPAL-SECURITY-SIGNATURE' => @api_signature,
|
52
51
|
'X-PAYPAL-APPLICATION-ID' => @app_id,
|
53
52
|
'X-PAYPAL-REQUEST-DATA-FORMAT' => 'NV',
|
54
53
|
'X-PAYPAL-RESPONSE-DATA-FORMAT' => 'NV',
|
@@ -163,7 +162,7 @@ module ActiveMerchant #:nodoc:
|
|
163
162
|
private
|
164
163
|
def build_request_permissions_query_string(callback_url, scope)
|
165
164
|
scopes_query = build_scopes_query_string(scope)
|
166
|
-
"requestEnvelope.errorLanguage=en_US&#{scopes_query}&callback=#{
|
165
|
+
"requestEnvelope.errorLanguage=en_US&#{scopes_query}&callback=#{CGI.escape(callback_url)}"
|
167
166
|
end
|
168
167
|
|
169
168
|
private
|
@@ -175,7 +174,13 @@ module ActiveMerchant #:nodoc:
|
|
175
174
|
else
|
176
175
|
scopes = []
|
177
176
|
end
|
178
|
-
|
177
|
+
|
178
|
+
scopes_str = ""
|
179
|
+
(0...scopes.length).each { |idx|
|
180
|
+
s = scopes[idx]
|
181
|
+
scopes_str += "&scope(#{idx})=#{CGI.escape(s.to_s.strip.upcase)}"
|
182
|
+
}
|
183
|
+
scopes_str[1..-1]
|
179
184
|
end
|
180
185
|
|
181
186
|
private
|
@@ -191,14 +196,6 @@ module ActiveMerchant #:nodoc:
|
|
191
196
|
end
|
192
197
|
body += "requestEnvelope.errorLanguage=en_US"
|
193
198
|
end
|
194
|
-
|
195
|
-
|
196
|
-
=begin
|
197
|
-
private
|
198
|
-
def setup_purchase(options)
|
199
|
-
commit('Pay', build_adaptive_payment_pay_request(options))
|
200
|
-
end
|
201
|
-
=end
|
202
199
|
end
|
203
200
|
end
|
204
201
|
end
|
@@ -1,6 +1,16 @@
|
|
1
|
+
require 'cgi'
|
1
2
|
require 'openssl'
|
2
3
|
require 'base64'
|
3
4
|
|
5
|
+
|
6
|
+
class Hash
|
7
|
+
def to_paypal_permissions_query
|
8
|
+
collect do |key, value|
|
9
|
+
"#{key}=#{value}"
|
10
|
+
end.sort * '&'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
4
14
|
module ActiveMerchant #:nodoc:
|
5
15
|
module Billing #:nodoc:
|
6
16
|
module XPPAuthorization
|
@@ -8,7 +18,7 @@ module ActiveMerchant #:nodoc:
|
|
8
18
|
def x_pp_authorization_header url, api_user_id, api_password, access_token, access_token_verifier
|
9
19
|
timestamp = Time.now.to_i.to_s
|
10
20
|
signature = x_pp_authorization_signature url, api_user_id, api_password, timestamp, access_token, access_token_verifier
|
11
|
-
{ 'X-
|
21
|
+
{ 'X-PAYPAL-AUTHORIZATION' => "token=#{access_token},signature=#{signature},timestamp=#{timestamp}" }
|
12
22
|
end
|
13
23
|
|
14
24
|
public
|
@@ -16,8 +26,8 @@ module ActiveMerchant #:nodoc:
|
|
16
26
|
# no query params, but if there were, this is where they'd go
|
17
27
|
query_params = {}
|
18
28
|
key = [
|
19
|
-
|
20
|
-
|
29
|
+
paypal_encode(api_password),
|
30
|
+
paypal_encode(access_token_verifier),
|
21
31
|
].join("&")
|
22
32
|
|
23
33
|
params = query_params.dup.merge({
|
@@ -27,17 +37,29 @@ module ActiveMerchant #:nodoc:
|
|
27
37
|
"oauth_token" => access_token,
|
28
38
|
"oauth_timestamp" => timestamp,
|
29
39
|
})
|
30
|
-
|
31
|
-
sorted_query_string = sorted_params.to_query
|
40
|
+
sorted_query_string = params.to_paypal_permissions_query
|
32
41
|
|
33
42
|
base = [
|
34
43
|
"POST",
|
35
|
-
|
36
|
-
|
44
|
+
paypal_encode(url),
|
45
|
+
paypal_encode(sorted_query_string)
|
37
46
|
].join("&")
|
47
|
+
base = base.gsub /%([0-9A-F])([0-9A-F])/ do
|
48
|
+
"%#{$1.downcase}#{$2.downcase}" # hack to match PayPal Java SDK bit for bit
|
49
|
+
end
|
50
|
+
|
51
|
+
digest = OpenSSL::HMAC.digest('sha1', key, base)
|
52
|
+
Base64.encode64(digest).chomp
|
53
|
+
end
|
38
54
|
|
39
|
-
|
40
|
-
|
55
|
+
# The PayPalURLEncoder java class percent encodes everything other than 'a-zA-Z0-9 _'.
|
56
|
+
# Then it converts ' ' to '+'.
|
57
|
+
# Ruby's CGI.encode takes care of the ' ' and '*' to satisfy PayPal
|
58
|
+
# (but beware, URI.encode percent encodes spaces, and does nothing with '*').
|
59
|
+
# Finally, CGI.encode does not encode '.-', which we need to do here.
|
60
|
+
def paypal_encode str
|
61
|
+
s = str.dup
|
62
|
+
CGI.escape(s).gsub('.', '%2E').gsub('-', '%2D')
|
41
63
|
end
|
42
64
|
end
|
43
65
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paypal_permissions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.5.
|
4
|
+
version: 0.0.5.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-30 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
|
-
requirement: &
|
16
|
+
requirement: &2152576900 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2152576900
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: vcr
|
27
|
-
requirement: &
|
27
|
+
requirement: &2152564420 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '1.11'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2152564420
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: railties
|
38
|
-
requirement: &
|
38
|
+
requirement: &2152547180 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '3.0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2152547180
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: activesupport
|
49
|
-
requirement: &
|
49
|
+
requirement: &2152545360 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '3.0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2152545360
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: activemerchant
|
60
|
-
requirement: &
|
60
|
+
requirement: &2152544080 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *2152544080
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
|
-
requirement: &
|
71
|
+
requirement: &2152541360 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
version: '2.6'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *2152541360
|
80
80
|
description: ! '"A gem to support PayPal Permissions API for Rails applications using
|
81
81
|
ActiveMerchant."'
|
82
82
|
email:
|
@@ -188,7 +188,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
188
188
|
version: '0'
|
189
189
|
segments:
|
190
190
|
- 0
|
191
|
-
hash:
|
191
|
+
hash: -766692562047454680
|
192
192
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
193
193
|
none: false
|
194
194
|
requirements:
|
@@ -197,7 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
197
197
|
version: '0'
|
198
198
|
segments:
|
199
199
|
- 0
|
200
|
-
hash:
|
200
|
+
hash: -766692562047454680
|
201
201
|
requirements: []
|
202
202
|
rubyforge_project: paypal_permissions
|
203
203
|
rubygems_version: 1.8.10
|