tablexi / foxy_sync

MIT License
8 stars 6 forks source link

Datafeed processing error with 1.1 #2

Closed wrburgess closed 11 years ago

wrburgess commented 11 years ago

Something is wrong with the datafeed processing aspect of the gem, but I can't figure out if it's my installation of foxy_sync or just an error in-general.

I run a purchase through FoxyCart which calls back correctly on http://[exampleapp].com/datafeed

Here's the route and controller:

# route: post "datafeed" => "orders#datafeed"

class OrdersController < ApplicationController
  include FoxySync::Datafeed

  def datafeed

    xml_doc = datafeed_unwrap params

  end

end

Here's the error I'm getting on the staging site (on heroku).

Note: I also received this error locally when using test files, but I wanted to reproduce the error between FoxyCart and my staging site.

Aug 22 15:14:47 exampleapp-staging app/web.1:  Nokogiri::XML::SyntaxError (Start tag expected, '<' not found): 
Aug 22 15:14:47 exampleapp-staging app/web.1:    app/controllers/orders_controller.rb:14:in `datafeed' 
Aug 22 15:14:48 exampleapp-staging heroku/router:  at=info method=POST path=/datafeed host=example-staging.herokuapp.com fwd="111.11.111.11" dyno=web.1 connect=1ms service=586ms status=500 bytes=643 
phred commented 11 years ago

Hey @wrburgess — not knowing the specifics of how this package works, I'd triple-check that your datafeed key is set appropriately. It sounds like the datafeed XML is garbled at the point it's handed to Nokogiri. This can happen after the decryption step if your datafeed key is wrong.

Here's the tool that we use over at FoxyCart to diagnose these kind of problems: http://wiki.foxycart.com/integration/foxycart/test_xml_post

It'll let you set a datafeed key and XML body and then POST it to your datafeed endpoint.

cstump commented 11 years ago

Good tip @phred. Thanks for posting. @wrburgess definitely check the key. I had problems with it myself. The key as it appears under Store > Advanced > API key in the FC admin panel is actually longer than the text field it is in. You have to make sure you copy the entire thing. If that's not the issue try dumping the params to your logs before calling #datafeed_unwrap. That should give us a start at debugging. Your controller as it is looks good.

wrburgess commented 11 years ago

Thanks for the feedback @phred and @cstump. That was the issue. I'm not sure why I was using the wrong key, but getting that synced up and using the test_xml_post app seemed to do the trick. Much appreciated.