wepay-rails 0.1.33 → 0.1.34
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/exceptions.rb +6 -0
- data/lib/helpers/controller_helpers.rb +4 -2
- data/lib/wepay-rails.rb +12 -5
- data/wepay-rails.gemspec +2 -1
- metadata +13 -12
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.34
|
data/lib/exceptions.rb
ADDED
@@ -2,7 +2,7 @@ module WepayRails
|
|
2
2
|
module Helpers
|
3
3
|
module ControllerHelpers
|
4
4
|
|
5
|
-
def redirect_to_wepay_for_auth(scope)
|
5
|
+
def redirect_to_wepay_for_auth(scope=gateway.scope)
|
6
6
|
redirect_to gateway.auth_code_url(scope)
|
7
7
|
end
|
8
8
|
|
@@ -26,7 +26,9 @@ module WepayRails
|
|
26
26
|
# {"user_id":"123456","access_token":"1337h4x0rzabcd12345","token_type":"BEARER"} Example
|
27
27
|
def initialize_wepay_access_token(auth_code)
|
28
28
|
wepay_access_token = gateway.access_token(auth_code)
|
29
|
-
|
29
|
+
rescue WepayRails::Exceptions::ExpiredTokenError => e
|
30
|
+
redirect_to_wepay_for_auth gateway.scope
|
31
|
+
return
|
30
32
|
end
|
31
33
|
|
32
34
|
# Since we are saving the access token in the session,
|
data/lib/wepay-rails.rb
CHANGED
@@ -7,22 +7,29 @@ module WepayRails
|
|
7
7
|
|
8
8
|
base_uri @base_uri
|
9
9
|
|
10
|
-
attr_accessor :wepay_access_token, :wepay_auth_code
|
10
|
+
attr_accessor :wepay_access_token, :wepay_auth_code, :scope
|
11
11
|
|
12
12
|
def initialize(*args)
|
13
13
|
yml = Rails.root.join('config', 'wepay.yml').to_s
|
14
14
|
@config = YAML.load_file(yml)[Rails.env].symbolize_keys
|
15
|
+
@scope = @config.delete(:scope)
|
15
16
|
@base_uri = Rails.env.production? ? "https://api.wepay.com" : "https://stage.wepay.com"
|
16
17
|
end
|
17
18
|
|
18
19
|
def access_token(auth_code)
|
19
20
|
@wepay_auth_code = auth_code
|
20
|
-
File.open('/tmp/wepay-rails.log','a') {|f| f.write(auth_code)}
|
21
|
-
File.open('/tmp/wepay-rails.log','a') {|f| f.write(@config.merge(:code => auth_code).inspect)}
|
22
21
|
response = self.class.get("#{@base_uri}/v2/oauth2/token", :query => @config.merge(:code => auth_code))
|
23
22
|
json = JSON.parse(response.body)
|
24
|
-
|
25
|
-
|
23
|
+
|
24
|
+
if json.has_key?("error")
|
25
|
+
if json.has_key?("error_description")
|
26
|
+
raise WepayRails::Exceptions::ExpiredTokenError.new("You will need to get a new authorization code") if json["error_description"] == "the code has expired"
|
27
|
+
raise WepayRails::Exceptions::AccessTokenError.new(json["error_description"])
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
raise WepayRails::Exceptions::AccessTokenError.new("A problem occurred trying to get the access token: #{json.inspect}") unless json.has_key?("access_token")
|
32
|
+
|
26
33
|
@wepay_access_token = json["access_token"]
|
27
34
|
end
|
28
35
|
|
data/wepay-rails.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
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.34"
|
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"]
|
@@ -26,6 +26,7 @@ Gem::Specification.new do |s|
|
|
26
26
|
"README.rdoc",
|
27
27
|
"Rakefile",
|
28
28
|
"VERSION",
|
29
|
+
"lib/exceptions.rb",
|
29
30
|
"lib/helpers/controller_helpers.rb",
|
30
31
|
"lib/helpers/model_helpers.rb",
|
31
32
|
"lib/wepay-rails.rb",
|
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.34
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -14,7 +14,7 @@ default_executable:
|
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: httparty
|
17
|
-
requirement: &
|
17
|
+
requirement: &2151865140 !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: *2151865140
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: shoulda
|
28
|
-
requirement: &
|
28
|
+
requirement: &2151863680 !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: *2151863680
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: bundler
|
39
|
-
requirement: &
|
39
|
+
requirement: &2151861880 !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: *2151861880
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: jeweler
|
50
|
-
requirement: &
|
50
|
+
requirement: &2151859660 !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: *2151859660
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: rcov
|
61
|
-
requirement: &
|
61
|
+
requirement: &2151857180 !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: *2151857180
|
70
70
|
description: Rails gem that interfaces with the WePay API
|
71
71
|
email: adammede@gmail.com
|
72
72
|
executables: []
|
@@ -84,6 +84,7 @@ files:
|
|
84
84
|
- README.rdoc
|
85
85
|
- Rakefile
|
86
86
|
- VERSION
|
87
|
+
- lib/exceptions.rb
|
87
88
|
- lib/helpers/controller_helpers.rb
|
88
89
|
- lib/helpers/model_helpers.rb
|
89
90
|
- lib/wepay-rails.rb
|
@@ -106,7 +107,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
106
107
|
version: '0'
|
107
108
|
segments:
|
108
109
|
- 0
|
109
|
-
hash: -
|
110
|
+
hash: -214898700293280677
|
110
111
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
112
|
none: false
|
112
113
|
requirements:
|