From 3ffac4e77a118ee6ec7d369b0250c11830c2f7e0 Mon Sep 17 00:00:00 2001 From: jessib Date: Tue, 12 Mar 2013 13:32:46 -0700 Subject: Basic functionality for one time transactions using Braintree's transparent redirect API based from https://github.com/braintree/braintree_ruby_examples/tree/master/rails3_tr_checkout (very little changes were required) --- billing/app/controllers/payments_controller.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 billing/app/controllers/payments_controller.rb (limited to 'billing/app/controllers/payments_controller.rb') diff --git a/billing/app/controllers/payments_controller.rb b/billing/app/controllers/payments_controller.rb new file mode 100644 index 0000000..2a76bb1 --- /dev/null +++ b/billing/app/controllers/payments_controller.rb @@ -0,0 +1,22 @@ +class PaymentsController < ApplicationController + def new + @amount = calculate_amount + 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 + + protected + + def calculate_amount + # in a real app this be calculated from a shopping cart, determined by the product, etc. + "100.00" + end +end -- cgit v1.2.3