Reputation: 4677
I am using the braintree gem with braintree sandbox and trying to set up web hooks. I have the following code:
class PaymentsController < ApplicationController
def webhooks
challenge = request.params["bt_challenge"]
challenge_response = Braintree::WebhookNotification.verify(challenge)
return [200, challenge_response]
end
end
but for some reason when i press 'create web hook' on braintree's website, i am told:
Destination could not be verified.
I checked the server logs and it is receiving the request, but it is for some reason returning an http 500 and says the following:
2014-04-09T23:39:19.937280+00:00 app[web.1]: Completed 500 Internal Server Error in 71ms
2014-04-09T23:39:19.941486+00:00 app[web.1]: ActionView::MissingTemplate (Missing template payments/webhooks, application/webhooks with {:locale=>[:en], :formats=>[:xml, :html, :text, :js, :css, :ics, :csv, :png, :jpeg, :gif, :bmp, :tiff, :mpeg, :xml, :rss, :atom, :yaml, :multipart_form, :url_encoded_form, :json, :pdf, :zip], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :arb, :jbuilder, :haml]}. Searched in:
This suggests that the controller is looking for a view and can't find it. Im not sure what to do. The code in the web hooks action is taken directly from braintree's website: https://www.braintreepayments.com/docs/ruby/guide/webhook_notifications
Does anyone know how to fix this?
Upvotes: 0
Views: 792
Reputation: 176780
I work at Braintree. If you need any more assistance with your integration, or have questions beyond what it's easy to ask here, you can get in touch with our support team.
The code in the Braintree Webhook Guide is for Sinatra, but you're using Rails 4.
You need to do something like
render plain: challenge_response, status: 200
instead of
return [200, challenge_response]
to render the challenge response without a template and with a 200
status code.
See Layouts and Rendering in Rails for more information.
Upvotes: 5