adamthedeveloper / wepay-rails

Collect payments from wepay in your rails application.
MIT License
32 stars 24 forks source link

prefill_info not working #19

Closed thinkmorebetter closed 12 years ago

thinkmorebetter commented 12 years ago

Hi,

I have another issue with wepay-rails that I wonder if anyone else has seen. I'm trying to pass in some user info to the checkout so at least some of the fields are prefilled, but I'm getting the following error no matter what I've tried:

WepayRails::Exceptions::WepayCheckoutError

An error occurred: {:error=>"invalid_request", :error_description=>"expecting JSON object for parameter prefill_info", :security_token=>"10138d3836223d54bb9bfbd3cf71e532f9f333b14de2b9bd5406562e59083960"}

I'm using the following for the params, where the prefill_info is the sample provided by WePay.

checkout_params = {
          :account_id => @owner.wepay_account,
          :amount => @price,
          :short_description => "An order",
          :app_fee => (@price * 0.1),
          :fee_payer => "Payer",
          :mode => 'iframe',
          :prefill_info => '{"name":"Bill Clerico","phone_number":"855-469-3729"}'
      }

Any help would be appreciated. Thanks!

SteveAquino commented 12 years ago

I have not tried passing prefil options to a checkout object yet, so I'm not exactly sure. I'll look into this a little later this evening, in the mean time I would try calling to_json or looking into a Rubyish/Railsish way to convert a string into a JSON object. My guess is you'd have to escape the quotes, ie: '{\"name\":\"Bill Clerico\",\"phone_number\":\"855-469-3729\"}', but I'm not 100% on that.

On 06/25/2012 05:30 PM, Alex Perelman wrote:

Hi,

I have another issue with wepay-rails that I wonder if anyone else has seen. I'm trying to pass in some user info to the checkout so at least some of the fields are prefilled, but I'm getting the following error no matter what I've tried:

WepayRails::Exceptions::WepayCheckoutError An error occurred: {:error=>"invalid_request", :error_description=>"expecting JSON object for parameter prefill_info", :security_token=>"10138d3836223d54bb9bfbd3cf71e532f9f333b14de2b9bd5406562e59083960"} I'm using the following for the params, where the prefill_info is the sample provided by WePay.

checkout_params = {
           :account_id => @owner.wepay_account,
           :amount => @price,
           :short_description => "An order",
           :app_fee => (@price * 0.1),
           :fee_payer => "Payer",
           :mode => 'iframe',
           :prefill_info => '{"name":"Bill Clerico","phone_number":"855-469-3729"}'
       }

Any help would be appreciated. Thanks!


Reply to this email directly or view it on GitHub: https://github.com/adamthedeveloper/wepay-rails/issues/19

thinkmorebetter commented 12 years ago

Yeah, I've tried to jsonify it every which way I could think of.. there must be something happening internally before the request is sent that changes it somehow. Appreciate you looking into it.

SteveAquino commented 12 years ago

Hmm, from what I can see there's nothing on our end that's changing the hash, it just gets passed down the method chain until HTTParty takes over. The relavent method is in wepay_rails.rb:

response = self.class.post("#{@api_endpoint}#{api_path}", {:headers => wepay_auth_header}.merge!({:body => params}))

Where params would be your checkout_params hash. I didn't author this part of the gem and don't particularly have experience dealing with HTTParty, but my guess is there's something going on there. I'm also not particularly fluent in JSON.

thinkmorebetter commented 12 years ago

Ok, sorted it out with a little help from the WePay API team. I checked in the changes in my branch for now, but I'm not sure if it's good enough to be pulled in here, haven't done enough testing.

https://github.com/ChromeBurner/wepay-rails/commit/2d52a56942bf583221df1d614a0c752eb5764c79

thinkmorebetter commented 12 years ago

I don't know what changed on WePay's end, but I started getting more json-related errors today, so I reverted my changes and everything seems to work... voodoo.

SteveAquino commented 12 years ago

What do you mean "reverted your changes"? I find it very frustrating that this keeps happening.

On 06/27/2012 06:07 PM, Alex Perelman wrote:

I don't know what changed on WePay's end, but I started getting more json-related errors today, so I reverted my changes and everything seems to work... voodoo.


Reply to this email directly or view it on GitHub: https://github.com/adamthedeveloper/wepay-rails/issues/19#issuecomment-6619672

thinkmorebetter commented 12 years ago

Believe me, I am very frustrated too. Yesterday, a whole bunch of things on WePay's stage server got messed up on their end and it took until the end of the day for them to fix it. I wish I had a clue on why prefill_info decided to work today without any local changes to the gem, but given my recent experience I can only attribute it to something changing on their end.

SteveAquino commented 12 years ago

I've got some time scheduled tomorrow to work on this gem a bit, so we'll merge your changes and keep doing what we can on our end. First order of business for me is to stub the API calls on the tests so we can keep developing the gem and keep up with WePay despite the seeming unreliability of their services.

On 06/27/2012 06:13 PM, Alex Perelman wrote:

Believe me, I am very frustrated too. Yesterday, a whole bunch of things on WePay's stage server got messed up on their end and it took until the end of the day for them to fix it. I wish I had a clue on why prefill_info decided to work today without any local changes to the gem, but given my recent experience I can only attribute it to something changing on their end.


Reply to this email directly or view it on GitHub: https://github.com/adamthedeveloper/wepay-rails/issues/19#issuecomment-6619739