summaryrefslogtreecommitdiff
path: root/billing/app
diff options
context:
space:
mode:
Diffstat (limited to 'billing/app')
-rw-r--r--billing/app/controllers/billing_base_controller.rb2
-rw-r--r--billing/app/controllers/subscriptions_controller.rb2
-rw-r--r--billing/app/helpers/billing_helper.rb12
-rw-r--r--billing/app/views/credit_card_info/edit.html.haml4
-rw-r--r--billing/app/views/customer/edit.html.haml2
-rw-r--r--billing/app/views/customer/new.html.haml4
-rw-r--r--billing/app/views/payments/new.html.haml4
7 files changed, 22 insertions, 8 deletions
diff --git a/billing/app/controllers/billing_base_controller.rb b/billing/app/controllers/billing_base_controller.rb
index b7f449c..dc15194 100644
--- a/billing/app/controllers/billing_base_controller.rb
+++ b/billing/app/controllers/billing_base_controller.rb
@@ -1,6 +1,8 @@
class BillingBaseController < ApplicationController
before_filter :assign_user
+ helper 'billing'
+
# required for navigation to work.
def assign_user
@user = current_user
diff --git a/billing/app/controllers/subscriptions_controller.rb b/billing/app/controllers/subscriptions_controller.rb
index 366a457..38dbff1 100644
--- a/billing/app/controllers/subscriptions_controller.rb
+++ b/billing/app/controllers/subscriptions_controller.rb
@@ -1,4 +1,4 @@
-class SubscriptionsController < ApplicationController
+class SubscriptionsController < BillingBaseController
before_filter :authorize
before_filter :fetch_subscription, :only => [:show, :destroy]
before_filter :confirm_no_active_subscription, :only => [:new, :create]
diff --git a/billing/app/helpers/billing_helper.rb b/billing/app/helpers/billing_helper.rb
new file mode 100644
index 0000000..f91d9c9
--- /dev/null
+++ b/billing/app/helpers/billing_helper.rb
@@ -0,0 +1,12 @@
+module BillingHelper
+
+ def braintree_form_for(object, options = {}, &block)
+ options.reverse_merge! params: @result && @result.params[object],
+ errors: @result && @result.errors.for(object),
+ builder: BraintreeFormHelper::BraintreeFormBuilder,
+ url: Braintree::TransparentRedirect.url
+
+ form_for object, options, &block
+ end
+
+end
diff --git a/billing/app/views/credit_card_info/edit.html.haml b/billing/app/views/credit_card_info/edit.html.haml
index 57322de..39269ca 100644
--- a/billing/app/views/credit_card_info/edit.html.haml
+++ b/billing/app/views/credit_card_info/edit.html.haml
@@ -3,7 +3,7 @@
#total-errors{:style => "color:red;"}
= h(@result.errors.size)
error(s)
-= form_for :credit_card,:url => Braintree::TransparentRedirect.url, :params => @result && @result.params[:credit_card], :builder => BraintreeFormHelper::BraintreeFormBuilder, :existing => @credit_card, :errors => @result && @result.errors.for(:credit_card) do |f| |
+= braintree_form_for :credit_card, :existing => @credit_card do |f|
= field_set_tag "Credit Card" do
%dl
%dt= f.label :number, 'Number'
@@ -14,4 +14,4 @@
%dd= f.text_field :cvv
= hidden_field_tag :tr_data, @tr_data
= f.submit 'Save Payment Info', :class => :btn
- = link_to t(:cancel), edit_customer_path(@credit_card.customer_id), :class => :btn \ No newline at end of file
+ = link_to t(:cancel), edit_customer_path(@credit_card.customer_id), :class => :btn
diff --git a/billing/app/views/customer/edit.html.haml b/billing/app/views/customer/edit.html.haml
index f11e948..76c678b 100644
--- a/billing/app/views/customer/edit.html.haml
+++ b/billing/app/views/customer/edit.html.haml
@@ -2,7 +2,7 @@
#total-errors{:style => "color:red;"}
= h(@result.errors.size)
error(s)
-= form_for :customer, url: Braintree::TransparentRedirect.url, params: @result && @result.params[:customer], existing: @customer, builder: BraintreeFormHelper::BraintreeFormBuilder, errors: @result && @result.errors.for(:customer) do |f| |
+= braintree_form_for :customer, existing: @customer do |f|
= field_set_tag "Customer" do
%dl
%dt= f.label :first_name, 'First Name'
diff --git a/billing/app/views/customer/new.html.haml b/billing/app/views/customer/new.html.haml
index 6eaa3d1..e1f5ba9 100644
--- a/billing/app/views/customer/new.html.haml
+++ b/billing/app/views/customer/new.html.haml
@@ -2,7 +2,7 @@
#total-errors{:style => "color:red;"}
= h(@result.errors.size)
error(s)
-= form_for :customer, :url => Braintree::TransparentRedirect.url, :params => @result && @result.params[:customer], :builder => BraintreeFormHelper::BraintreeFormBuilder, :errors => @result && @result.errors.for(:customer) do |f|
+= braintree_form_for :customer do |f|
= field_set_tag "Customer" do
%dl
%dt= f.label :first_name, 'First Name'
@@ -21,4 +21,4 @@
%dt= cc.label :cvv, 'CVV'
%dd= cc.text_field :cvv
= hidden_field_tag :tr_data, @tr_data
- = f.submit 'Save Payment Info' \ No newline at end of file
+ = f.submit 'Save Payment Info'
diff --git a/billing/app/views/payments/new.html.haml b/billing/app/views/payments/new.html.haml
index 14f6697..0d9452f 100644
--- a/billing/app/views/payments/new.html.haml
+++ b/billing/app/views/payments/new.html.haml
@@ -7,7 +7,7 @@
- if @result and @result.transaction.status == 'processor_declined'
%div{:style => "color: red;"}
Processor Declined
-= form_for :transaction, :params => @result && @result.params[:transaction], :errors => @result && @result.errors.for(:transaction), :builder => BraintreeFormHelper::BraintreeFormBuilder, :url => Braintree::TransparentRedirect.url, :html => {:autocomplete => "off"} do |f| #TODO: add helper
+= braintree_form_for :transaction, :html => {:autocomplete => "off"} do |f|
= f.label :amount, "Amount"
= f.text_field :amount
- if !@customer
@@ -15,4 +15,4 @@
- else
= render :partial => 'customer_data'
= hidden_field_tag :tr_data, @tr_data
- = f.submit "Submit Payment", :class => :btn \ No newline at end of file
+ = f.submit "Submit Payment", :class => :btn