2014-04-10 18 views
0

我正在使用braintree沙箱和braintree沙箱並嘗試設置網絡掛鉤。我有以下代碼:網絡掛鉤braintree沙箱不返回200

class PaymentsController < ApplicationController 
    def webhooks 
     challenge = request.params["bt_challenge"] 
     challenge_response = Braintree::WebhookNotification.verify(challenge) 
     return [200, challenge_response] 
    end 
end 

,但由於某種原因,當我按「創建Web鉤」在布倫特裏的網站上,有人告訴我:

Destination could not be verified. 

我檢查了服務器日誌,它正在接收的要求,但由於某種原因,返回一個HTTP 500並說以下內容:

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: 

這表明控制器正在尋找一個視圖,並不能找到它。林不知道該怎麼做。在網絡鉤子行動中的代碼直接從布蘭特裏的網站採取:https://www.braintreepayments.com/docs/ruby/guide/webhook_notifications

有誰知道如何解決這個問題?

回答

5

我在布倫特裏工作。如果您在整合過程中需要任何更多的幫助,或者遇到問題,而這些問題超出了這裏容易提出的問題,您可以聯繫our support team

Braintree Webhook Guide的代碼用於Sinatra,但你用Rails 4.

你需要做的是這樣

render plain: challenge_response, status: 200 

,而不是

return [200, challenge_response] 

渲染沒有模板和200狀態碼的質詢響應。

有關更多信息,請參見Layouts and Rendering in Rails

+0

謝謝,試過了,但我得到了同樣的錯誤 – Philip7899

+0

@ Philip7899'render:plain'不應該嘗試使用模板。如果您仍然遇到問題,最好的辦法是發送電子郵件給我們的支持團隊(在[email protected])幷包含您的代碼,以便他們可以嘗試重現問題。對不起,遲到的迴應,我在參加一個會議。 – agf

+0

你找到了這個傢伙的解決方案嗎?我面臨同樣的問題,因爲Rails試圖渲染一個模板,因此拋出一個停止BrainTree驗證過程的Exception。 – jlstr