diff options
Diffstat (limited to 'billing/app/helpers/billing_helper.rb')
-rw-r--r-- | billing/app/helpers/billing_helper.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/billing/app/helpers/billing_helper.rb b/billing/app/helpers/billing_helper.rb new file mode 100644 index 0000000..3c0691f --- /dev/null +++ b/billing/app/helpers/billing_helper.rb @@ -0,0 +1,22 @@ +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 + + def show_or_new_customer_link(user) + # Link to show if user is admin viewing another user, or user is already a customer. + # Otherwise link to create a new customer. + if (admin? and (user != current_user)) or ((customer = Customer.find_by_user_id(user.id)) and customer.has_payment_info?) + show_customer_path(user) + else + new_customer_path + end + end + +end |