summaryrefslogtreecommitdiff
path: root/billing/app/controllers/payments_controller.rb
diff options
context:
space:
mode:
authorjessib <jessib@leap.se>2013-03-12 13:32:46 -0700
committerAzul <azul@leap.se>2013-07-17 10:46:25 +0200
commit3ffac4e77a118ee6ec7d369b0250c11830c2f7e0 (patch)
tree10bcae72b62b63cd8da65e93fb0c90f2c107fc3b /billing/app/controllers/payments_controller.rb
parentfe7a5ac0776e1bd7baf36382600e265def901e51 (diff)
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)
Diffstat (limited to 'billing/app/controllers/payments_controller.rb')
-rw-r--r--billing/app/controllers/payments_controller.rb22
1 files changed, 22 insertions, 0 deletions
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