Closed arthur-feral closed 10 years ago
Hi, I am trying to create an application that requires the use of mangopay. I'm trying to take over the sdk. I have a problem when creating a User.
here is my controller
class TestController < ApplicationController require 'mangopay' MangoPay.configure do |c| c.preproduction = true c.client_id = '***' c.client_passphrase = '***' end def index self.class.layout "tests" pagination = {'page' => 1, 'per_page' => 8} # get 1st page, 8 items per page @users = MangoPay::User.fetch(pagination) # => [{...}, ...]: list of 8 users data hashes @pagination # => {"page"=>1, "per_page"=>8, "total_pages"=>748, "total_items"=>5978} # @user = MangoPay::User.fetch() end def create_user user = { :Birthday => 0, :Nationality => "FR", :CountryOfResidence => "FR", } user.merge(params[:user]) res = MangoPay::User.create(user) exit_status(0, "user created", 200, { user: res}) end end
The html page
<form accept-charset="UTF-8" action="/test/create_user" id="create_user" method="post"> <div style="margin:0;padding:0;display:inline"> <input name="utf8" type="hidden" value="✓"> <input name="authenticity_token" type="hidden" value="NskliiCZMySEiuiy6sE5+XWW/TqHRdjurv0hQiLjfrw="> </div> <div class="row"> <div class="col-md-4"> <div class="form-group"> <label class="" for="user_FirstName">Firstname</label> <input class="form-control" id="user_FirstName" name="user[FirstName]" size="30" type="text"> </div> </div> <div class="col-md-4"> <div class="form-group"> <label class="" for="user_LastName">Lastname</label> <input class="form-control" id="user_LastName" name="user[LastName]" size="30" type="text"> </div> </div> <div class="col-md-4"> <div class="form-group"> <label class="" for="user_Email">Email</label> <input class="form-control" id="user_Email" name="user[Email]" size="30" type="text"> </div> </div> </div> <input class="btn btn-primary" name="commit" type="submit" value="Creer"> </form>
javascript part
$('#create_user').ajaxForm({ beforeSubmit : function(formData, jqForm, options){ options.dataType = 'json'; }, success : function(responseText, status, xhr, $form){ $('#json_response').html(responseText); }, complete: function(){ }, error : function(e){ } });
and i get this error for some reasons
MangoPay::ResponseError in TestController#create_user The requested resource does not support http method 'POST'. Rails.root: /home/stainz/Web/BoutiqueDeClips Application Trace | Framework Trace | Full Trace app/controllers/test_controller.rb:26:in `create_user' Request Parameters: {"utf8"=>"✓", "authenticity_token"=>"NskliiCZMySEiuiy6sE5+XWW/TqHRdjurv0hQiLjfrw=", "user"=>{"FirstName"=>"Arthur", "LastName"=>"Féral", "Email"=>"arthur.feral@hotmail.com"}, "commit"=>"Creer"} Show session dump Show env dump Response Headers: None
this test was performed on local machine I'd forgotten configuration settings?
thanks for any help
Try with MangoPay::NaturalUser.create instead of MangoPay::User.create.
MangoPay::NaturalUser.create
MangoPay::User.create
Hope it helps!
Hi, I am trying to create an application that requires the use of mangopay. I'm trying to take over the sdk. I have a problem when creating a User.
here is my controller
The html page
javascript part
and i get this error for some reasons
this test was performed on local machine I'd forgotten configuration settings?
thanks for any help