Created
April 9, 2011 11:06
-
-
Save marcamillion/911309 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>Payment Result</h1> | |
<div>Thank you for your payment.</div> | |
<h2>Transaction Details</h2> | |
<table> | |
<tr><td>Amount</td><td>$<%= @result.transaction.amount %></td></tr> | |
<tr><td>Transaction ID:</td><td><%= @result.transaction.id %></td></tr> | |
<tr><td>First Name:</td><td><%= h @result.transaction.customer_details.first_name %></td></tr> | |
<tr><td>Last Name:</td><td><%= h @result.transaction.customer_details.last_name %></td></tr> | |
<tr><td>Email:</td><td><%= h @result.transaction.customer_details.email %></td></tr> | |
<tr><td>Credit Card:</td><td><%= h @result.transaction.credit_card_details.masked_number %></td></tr> | |
<tr><td>Card Type:</td><td><%= h @result.transaction.credit_card_details.card_type %></td></tr> | |
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= @user.f_name %> | |
<div class="settings_form"> | |
<%= form_for :transaction, | |
:params => @result && @result.params[:transaction], | |
:errors => @result && @result.errors.for(:transaction), | |
:builder => ApplicationHelper::BraintreeFormBuilder, | |
:url => Braintree::TransparentRedirect.url, | |
#:url => 'http://localhost:3000?test=1', for testing/debugging | |
:html => {:autocomplete => "off"} do |f| -%> | |
<%= field_set_tag "Customer" do -%> | |
<%= f.fields_for :customer, @user do |c| -%> | |
<%#= f.fields_for @user do |c| -%> | |
<div><%= c.label :f_name, "First Name" %></div> | |
<div><%= c.text_field :f_name %></div> | |
<div><%= c.label :l_name, "Last Name" %></div> | |
<div><%= c.text_field :l_name %></div> | |
<div><%= c.label :email, "Email" %></div> | |
<div><%= c.text_field :email %></div> | |
<% end -%> | |
<br /><br /> | |
<% 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", :class => "primary button" %> | |
<% end -%> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PaymentsController < ApplicationController | |
def new | |
@plan = Plan.find(params[:plan_id]) | |
@user = current_user | |
@amount = @plan.price | |
end | |
def confirm | |
#@result = Braintree::TransparentRedirect.confirm(request.query_string) | |
#p env["rack.request.form_vars"] | |
@result = Braintree::TransparentRedirect.confirm(CGI.unescape(env["rack.request.form_vars"])) | |
if @result.success? | |
render :action => "confirm" | |
else | |
@amount = calculate_amount | |
render :action => "new" | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NoMethodError in PaymentsController#confirm | |
undefined method `tr' for nil:NilClass | |
{"bt_message"=>"Invalid params: transaction[customer][f_name], | |
transaction[customer][l_name]", | |
"http_status"=>"403", | |
"hash"=>"11a2e835f0e5d55fa92ba6e77c670dafd9294122"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Braintree::AuthorizationError in PaymentsController#confirm | |
Invalid params: transaction[customer][f_name], transaction[customer][l_name] | |
Parameters: | |
{"bt_message"=>"Invalid params: transaction[customer][f_name], | |
transaction[customer][l_name]", | |
"http_status"=>"403", | |
"hash"=>"11a2e835f0e5d55fa92ba6e77c670dafd9294122"} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment