Braintree 支付网关“confirm_ payment_url”
我在尝试将 Braintree gem 合并到我的 Rails 3 应用程序中时遇到错误。真正奇怪的是,我能够在我的系统上的一个应用程序中成功安装它,然后当我尝试在另一个应用程序上运行它时出现以下错误:
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 应用程序能够识别此方法但另一个不能识别的结果?这真是让我摸不着头脑。感谢您的帮助。
i'm running into an error while trying to incorporate the braintree gem into my rails 3 app. what's really strange is that i was able to successfully install it in one app on my system then when i try to run it on another app is get the following error:
undefined local variable or method `confirm_payment_url' for #<#<Class:0x103a2bf08>:0x103a2a298>
here is the default code that i'm using:
<h1>Payment: lt;%= 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 -%>
and here is the payments controller
def confirm
@result = Braintree::TransparentRedirect.confirm(request.query_string)
if @result.success?
render :action => "confirm"
else
@amount = calculate_amount
render :action => "new"
end
end
what type of changes could have this result where one rails app will recognize this method but another won't? really scratching my head on this one. thanks for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您从未定义
confirm_ payment_url
,您的应用程序路由很可能有错误,但是如果没有更多信息,今天就很难了。在 Braintree 提供的透明重定向文档中,似乎这是您希望在处理付款后将客户发送回的 URL,并且 Braintree 未提供
confirm_ payment_url
。您可以在此处查看我引用的文档。You never define
confirm_payment_url
you most likely have an error in your applications routes however it is dificult to day without more information.In the documentation provided by Braintree for the transparent redirect it seems as if this is a url that you want to send the customer back to after the payment is processed and that
confirm_payment_url
is not provided Braintree. You can see the documentation I am referencing here.