开发者

Braintree payment gateway `confirm_payment_url'

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 t开发者_JAVA技巧hen 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: $<%= 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜