Permalink
Browse files

Add callback_uri to get_access_token, which uses WePay's /oauth2/toke…

…n API. The callback_uri is used to receive IPNs when the user revokes an access_token or is deleted.
  • Loading branch information...
1 parent 4dc9c39 commit e80b3e20fa5c752b3b7778c2c47fb78bdf6e1c5a @jules27 jules27 committed Apr 11, 2013
Showing with 4 additions and 2 deletions.
  1. +4 −2 lib/wepay-rails.rb
View
6 lib/wepay-rails.rb
@@ -144,12 +144,14 @@ def call_api(api_path, params={}, timeout=30000)
end
# Fetch the access token from wepay for the auth code
- def get_access_token(auth_code, redirect_uri)
+ def get_access_token(auth_code, redirect_uri, callback_uri = nil)
params = {
:client_id => @wepay_config[:client_id],
:client_secret => @wepay_config[:client_secret],
:redirect_uri => redirect_uri,
- :code => auth_code
+ :code => auth_code,
+ :callback_uri => callback_uri # Optional field in which you will receive IPNs with the user_id
+ # when the user revokes an access_token or is deleted.
}
json = call_api("/oauth2/token", params)
raise WepayRails::Exceptions::AccessTokenError.new("A problem occurred trying to get the access token: #{json.inspect}") unless json.has_key?(:access_token)

0 comments on commit e80b3e2

Please sign in to comment.