2011-08-07 45 views
0

我試圖將braintree gem併入我的rails 3應用程序時遇到錯誤。什麼是真正奇怪的是,我能夠成功它在一個應用程序我的系統上安裝,然後當我嘗試在另一個應用程序運行它是收到以下錯誤:Braintree支付網關`confirm_payment_url'

undefined local variable or method `confirm_payment_url' for #<#<Class:0x103a2bf08>:0x103a2a298> 

這裏是默認的代碼,我是使用:

<h1>Payment: $<%= h @amount %></h1> 

<% if @result -%> 
    <div style="color: red;"><%= h @result.errors.size %> error(s)</div> 
<% end -%> 

<%= form_for :transaction, 
    :params => @result && @result.params[:transaction], 
    :errors => @result && @result.errors.for(:transaction), 
    :builder => ApplicationHelper::BraintreeFormBuilder, 
    :url => Braintree::TransparentRedirect.url, 
    :html => {:autocomplete => "off"} do |f| -%> 
    <%= field_set_tag "Customer" do -%> 
    <%= f.fields_for :customer do |c| -%> 
    <div><%= c.label :first_name, "First Name" %></div> 
    <div><%= c.text_field :first_name %></div> 
    <div><%= c.label :last_name, "Last Name" %></div> 
    <div><%= c.text_field :last_name %></div> 
    <div><%= c.label :email, "Email" %></div> 
    <div><%= c.text_field :email %></div> 
<% end -%> 
<% end -%> 
<%= field_set_tag "Credit Card" do -%> 
<%= f.fields_for :credit_card do |c| -%> 
    <div><%= c.label :number, "Number" %></div> 
    <div><%= c.text_field :number %></div> 
    <div><%= c.label :expiration_date, "Expiration Date (MM/YY)" %></div> 
    <div><%= c.text_field :expiration_date %></div> 
    <div><%= c.label :cvv, "CVV" %></div> 
    <div><%= c.text_field :cvv %></div> 
<% end -%> 
<% end -%> 
<%= hidden_field_tag :tr_data, Braintree::TransparentRedirect.transaction_data(
    :redirect_url => confirm_payment_url,   
    :transaction => {:type => "sale", :amount => @amount} 
    ) %> 
    <%= f.submit "Submit" %> 
<% end -%> 

,這裏是支付控制器

def confirm 

@result = Braintree::TransparentRedirect.confirm(request.query_string) 
if @result.success? 
    render :action => "confirm" 
else 
    @amount = calculate_amount 
    render :action => "new" 
end 
end 

能有什麼樣的變化,這樣的結果,其中一個Rails應用程序會認識到這一點的方法,但另一不會呢?真的在我的頭上撓頭。謝謝你的幫助。

+0

這兩個應用程序有什麼不同?它們是否是Rails的相同版本? –

回答

2

你永遠不會定義confirm_payment_url你很可能在你的應用程序路線中有一個錯誤,但是如果沒有更多的信息,它就會變得很困難。

在Braintree爲透明重定向提供的文檔中,似乎這是您希望在處理付款後將客戶發回給的url,並且未提供confirm_payment_url Braintree。你可以看到我參考的文檔here

+0

是 - 我的路線失蹤: 匹配「支付/確認」 =>「支付#確認」,:爲=>:confirm_payment 這件事很奇怪,因爲我仍然有 比賽「金/新」:以=>'payments#new',:as =>:new_payment 感謝您的幫助! – Andrew

+0

隨時,很高興我能夠幫助。 –