I'm new to JSON, callbacks, and webhooks so I appreciate any help.
I'm looking to use Venmo's webhook here: (https://developer.venmo.com/docs/webhooks) to collect JSON and store it in the database of my Rails app on heroku.
Any help on how to set up the receive
action would be a huge help!
My Controller:
class WebhooksController < ApplicationController
skip_before_filter :verify_authenticity_token
def receive
end
def verify
#venmo verification
render text: params[:venmo_challenge]
end
end
My routes:
post '/webhooks/receive' => 'webhooks#receive'
get '/webhooks/receive' => 'webhooks#verify'
My heroku logs
2014-11-17T23:42:54.770290+00:00 heroku[web.1]: State changed from starting to up
2014-11-17T23:43:41.105707+00:00 heroku[router]: at=info method=POST path="/webhooks/receive" host=infinite-badlands-3074.herokuapp.com request_id=0ad13de0-f44c-4de3-b068-1e82800c770a fwd="184.73.153.84" dyno=web.1 connect=1ms service=79ms status=200 bytes=1145
2014-11-17T23:43:41.032647+00:00 app[web.1]: Started POST "/webhooks/receive" for 184.73.153.84 at 2014-11-17 23:43:41 +0000
2014-11-17T23:43:41.100217+00:00 app[web.1]: Rendered webhooks/receive.html.erb within layouts/application (1.2ms)
2014-11-17T23:43:41.090310+00:00 app[web.1]: Processing by WebhooksController#receive as */*
2014-11-17T23:43:41.090341+00:00 app[web.1]: Parameters: {"date_created"=>"2014-11-17T17:22:51.414052", "type"=>"payment.created", "data"=>{"status"=>"settled", "id"=>"1"}, "webhook"=>{}}
2014-11-17T23:43:41.090879+00:00 app[web.1]: WARNING: Can't verify CSRF token authenticity
2014-11-17T23:43:41.102859+00:00 app[web.1]: Completed 200 OK in 12ms (Views: 11.6ms | ActiveRecord: 0.0ms)
The venmo call isn't to the right url. It's making a GET to:
"/articles?venmo_challenge=b376d17e-977b-4a91-829c-b2eb9a074686"
But you want it to make a GET to:
"/webhooks/receive?venmo_challenge=b376d17e-977b-4a91-829c-b2eb9a074686"
I don't know where you set this in venmo, but it looks like it's set wrong. As a result, the action is hitting your ArticlesController instead of WebhooksController.