Closed lvxn0va closed 11 years ago
Fixed. Was an error on my end. went back to [:root_callback_uri] and added the following:
def redirect_uri project = Project.find_by_id (params[:project_id]) "#{WepayRails::Configuration.settings[:root_callback_uri]}/projects/#{project.id}/gateways/wepay_auth" end
Now the next problem is no matter what I do, update_atributes isn't saving the wepay_account_id => account_id in the database, even after using the create/account call.
Glad to hear you got the first part figured out. Sounds like the other problem is also most likely on your end. Try checking your console log for clues. Might have something to do with attr_accessible in your model preventing you from mass assigning protected attributes. Maybe if you post your controller action and your model we could take a closer look.
Second part fixed. Adding an acct/create method to my controller directly after the auth method, and saving the account_id there did the trick. I believe I had created the accounts in an earlier version and saved the ID's to the database, but erased them during a refactor of my code. I was still calling the same accts from wepay though. It feels like it had something to do with the reference_id being unique.
if anybody runs into something similar, they can see the code here: (https://github.com/lvxn0va/catarse/blob/fundmob-prod-payments/app/controllers/projects/gateways_controller.rb)
Thanks for your response.
In my crowdfunding app, we are nesting the oauth2 authorization url in routes.rb to attach each authorization to a certain project.
This allows each user to have multiple projects, and multiple wepay payment accounts, each attached to it's own individual project. Users are able to use a button to connect and disconnect each project's payment account in their profile.
The routing for this looks like so:
match "/projects/:project_id/gateways/wepay_auth" => "projects/gateways#wepay_auth", :as :wepay_auth
_http://example.com/projects/:project_id/gateways/wepay_auth_But the wepay.yml file only accepts a full URL as a http string, so my :redirect_uri shows: in my custom wepay-rails gem:
params[:redirect_uri] ||= @wepay_config[:auth_redirect_uri]
in wepay.yml
:auth_redirect_uri: "http://localhost:3000/wepay_auth"
which returns the browser to: _http://localhost:3000/wepay_auth?code:xxxxxxxxxxxxxxxx_
Which then can't find the correct project_id to attach the wepay_access_token to.
I've tried passing some ruby code in the wepay.yml file like so:
:auth_redirect_uri: <%= wepay_auth_url =>
But get an error stating that the redirect_uri must be a full url
Do I need to create a helper in the gem and/or hardcode the url there in wepay-rails.rb or is it possible to do it in the yaml file using .erb and I'm just not seeing it? thanks so much