wepay-rails 0.1.39 → 0.1.40
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/helpers/controller_helpers.rb +2 -14
- data/lib/wepay-rails.rb +14 -5
- data/wepay-rails.gemspec +2 -2
- metadata +13 -13
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.40
|
@@ -6,12 +6,8 @@ module WepayRails
|
|
6
6
|
redirect_to gateway.auth_code_url(scope)
|
7
7
|
end
|
8
8
|
|
9
|
-
def redirect_to_wepay_for_token
|
10
|
-
redirect_to gateway.token_url
|
11
|
-
end
|
12
|
-
|
13
9
|
def gateway
|
14
|
-
@gateway ||= WepayRails::Payments::Gateway.new
|
10
|
+
@gateway ||= WepayRails::Payments::Gateway.new(wepay_access_token)
|
15
11
|
end
|
16
12
|
|
17
13
|
# From https://stage.wepay.com/developer/tutorial/authorization
|
@@ -25,11 +21,9 @@ module WepayRails
|
|
25
21
|
# Response
|
26
22
|
# {"user_id":"123456","access_token":"1337h4x0rzabcd12345","token_type":"BEARER"} Example
|
27
23
|
def initialize_wepay_access_token(auth_code)
|
28
|
-
|
29
|
-
File.open('/tmp/redirect_loop.log','a') {|f| f.write(wepay_access_token)}
|
24
|
+
session[unique_wepay_access_token_key] = gateway.access_token(auth_code)
|
30
25
|
return
|
31
26
|
rescue WepayRails::Exceptions::ExpiredTokenError => e
|
32
|
-
File.open('/tmp/redirect_loop.log','a') {|f| f.write(e.message)}
|
33
27
|
redirect_to_wepay_for_auth(gateway.scope) and return
|
34
28
|
end
|
35
29
|
|
@@ -40,12 +34,6 @@ module WepayRails
|
|
40
34
|
:IODDR8856UUFG6788
|
41
35
|
end
|
42
36
|
|
43
|
-
# Access token is the OAUTH access token that is used for future
|
44
|
-
# comunique
|
45
|
-
def wepay_access_token=(value)
|
46
|
-
session[unique_wepay_access_token_key] = value
|
47
|
-
end
|
48
|
-
|
49
37
|
# Access token is the OAUTH access token that is used for future
|
50
38
|
# comunique
|
51
39
|
def wepay_access_token
|
data/lib/wepay-rails.rb
CHANGED
@@ -17,15 +17,24 @@ module WepayRails
|
|
17
17
|
attr_accessor :wepay_access_token, :wepay_auth_code, :scope
|
18
18
|
|
19
19
|
def initialize(*args)
|
20
|
+
@wepay_access_token = args.first
|
21
|
+
|
20
22
|
yml = Rails.root.join('config', 'wepay.yml').to_s
|
21
23
|
@config = YAML.load_file(yml)[Rails.env].symbolize_keys
|
24
|
+
|
22
25
|
@scope = @config.delete(:scope)
|
23
|
-
|
26
|
+
|
27
|
+
# Build the base uri
|
28
|
+
# Default if there isn't a setting for version and/or api uri
|
29
|
+
version = @config[:wepay_api_version].present? ? @config[:wepay_api_version] : "v2"
|
30
|
+
api_uri = @config[:wepay_api_uri].present? ? @config[:wepay_api_uri] : "https://wepayapi.com"
|
31
|
+
|
32
|
+
@base_uri = "#{api_uri}/#{version}"
|
24
33
|
end
|
25
34
|
|
26
35
|
def access_token(auth_code)
|
27
36
|
@wepay_auth_code = auth_code
|
28
|
-
response = self.class.get("#{@base_uri}/
|
37
|
+
response = self.class.get("#{@base_uri}/oauth2/token", :query => @config.merge(:code => auth_code))
|
29
38
|
json = JSON.parse(response.body)
|
30
39
|
|
31
40
|
if json.has_key?("error")
|
@@ -50,7 +59,7 @@ module WepayRails
|
|
50
59
|
"#{k.to_s}=#{v}"
|
51
60
|
end.join('&')
|
52
61
|
|
53
|
-
"#{@base_uri}/
|
62
|
+
"#{@base_uri}/oauth2/authorize?#{query}"
|
54
63
|
end
|
55
64
|
|
56
65
|
def token_url
|
@@ -58,7 +67,7 @@ module WepayRails
|
|
58
67
|
"#{k.to_s}=#{v}"
|
59
68
|
end.join('&')
|
60
69
|
|
61
|
-
"#{@base_uri}/
|
70
|
+
"#{@base_uri}/oauth2/authorize?#{query}"
|
62
71
|
end
|
63
72
|
|
64
73
|
def wepay_auth_header
|
@@ -66,7 +75,7 @@ module WepayRails
|
|
66
75
|
end
|
67
76
|
|
68
77
|
def wepay_user
|
69
|
-
response = self.class.get("#{@base_uri}/
|
78
|
+
response = self.class.get("#{@base_uri}/user", {:headers => wepay_auth_header})
|
70
79
|
JSON.parse(response.body)
|
71
80
|
end
|
72
81
|
end
|
data/wepay-rails.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{wepay-rails}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.40"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Adam Medeiros"]
|
12
|
-
s.date = %q{2011-07-
|
12
|
+
s.date = %q{2011-07-21}
|
13
13
|
s.description = %q{Rails gem that interfaces with the WePay API}
|
14
14
|
s.email = %q{adammede@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wepay-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.40
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,12 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-07-
|
12
|
+
date: 2011-07-21 00:00:00.000000000 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: httparty
|
17
|
-
requirement: &
|
17
|
+
requirement: &2151870980 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2151870980
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: shoulda
|
28
|
-
requirement: &
|
28
|
+
requirement: &2151868920 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *2151868920
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: bundler
|
39
|
-
requirement: &
|
39
|
+
requirement: &2151866540 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ~>
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: 1.0.0
|
45
45
|
type: :development
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *2151866540
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: jeweler
|
50
|
-
requirement: &
|
50
|
+
requirement: &2151864920 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ~>
|
@@ -55,10 +55,10 @@ dependencies:
|
|
55
55
|
version: 1.6.4
|
56
56
|
type: :development
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *2151864920
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: rcov
|
61
|
-
requirement: &
|
61
|
+
requirement: &2151863760 !ruby/object:Gem::Requirement
|
62
62
|
none: false
|
63
63
|
requirements:
|
64
64
|
- - ! '>='
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
version: '0'
|
67
67
|
type: :development
|
68
68
|
prerelease: false
|
69
|
-
version_requirements: *
|
69
|
+
version_requirements: *2151863760
|
70
70
|
description: Rails gem that interfaces with the WePay API
|
71
71
|
email: adammede@gmail.com
|
72
72
|
executables: []
|
@@ -106,7 +106,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
106
106
|
version: '0'
|
107
107
|
segments:
|
108
108
|
- 0
|
109
|
-
hash: -
|
109
|
+
hash: -3827481191935128799
|
110
110
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
111
|
none: false
|
112
112
|
requirements:
|