From d11768e58b98312c95a8ac5e9c18e3069b4d76dc Mon Sep 17 00:00:00 2001 From: claucece Date: Tue, 15 Sep 2015 00:26:52 -0500 Subject: implemented the form and the generate --- .../billing/app/controllers/payments_controller.rb | 5 +++-- engines/billing/app/views/payments/_form.html.erb | 16 ++++++++++++++ engines/billing/app/views/payments/new.html.erb | 25 ++++++++++++++++++++++ engines/billing/app/views/payments/new.html.haml | 17 --------------- 4 files changed, 44 insertions(+), 19 deletions(-) create mode 100644 engines/billing/app/views/payments/_form.html.erb create mode 100644 engines/billing/app/views/payments/new.html.erb delete mode 100644 engines/billing/app/views/payments/new.html.haml (limited to 'engines') diff --git a/engines/billing/app/controllers/payments_controller.rb b/engines/billing/app/controllers/payments_controller.rb index fce6570..b7a8e24 100644 --- a/engines/billing/app/controllers/payments_controller.rb +++ b/engines/billing/app/controllers/payments_controller.rb @@ -2,7 +2,7 @@ class PaymentsController < BillingBaseController before_filter :require_login, :only => [:index] def new - fetch_transparent_redirect + @client_token = Braintree::ClientToken.generate end def confirm @@ -25,10 +25,11 @@ class PaymentsController < BillingBaseController protected - + def fetch_transparent_redirect @tr_data = Braintree::TransparentRedirect.transaction_data redirect_url: confirm_payment_url, transaction: { type: "sale", options: {submit_for_settlement: true } } end + end diff --git a/engines/billing/app/views/payments/_form.html.erb b/engines/billing/app/views/payments/_form.html.erb new file mode 100644 index 0000000..9713981 --- /dev/null +++ b/engines/billing/app/views/payments/_form.html.erb @@ -0,0 +1,16 @@ +-# slim template += form_tag organization_payment_path(organization) do + + #dropin + + = submit_tag 'Confirm', class: 'btn push--ends' + +- content_for :javascript do + = javascript_include_tag "https://js.braintreegateway.com/v2/braintree.js" + javascript: + var client_token = "#{@organization.payment['client_token']}"; + braintree.setup( + client_token, + 'dropin', { + container: 'dropin' + }); diff --git a/engines/billing/app/views/payments/new.html.erb b/engines/billing/app/views/payments/new.html.erb new file mode 100644 index 0000000..7eab364 --- /dev/null +++ b/engines/billing/app/views/payments/new.html.erb @@ -0,0 +1,25 @@ +
+
+

New Donation

+

Please enter your donation details (this is a donation, and will not be applied towards your account):

+
+ +<%= braintree_form_for :transaction, :html => {:autocomplete => "off"} do |f|%> + <%= f.label :amount, t(:amount)%> + <%= f.text_field :amount%> +
+ + + <%= f.submit "Submit Donation", :class => 'btn btn-primary'%> +<%end%> + diff --git a/engines/billing/app/views/payments/new.html.haml b/engines/billing/app/views/payments/new.html.haml deleted file mode 100644 index e9a8273..0000000 --- a/engines/billing/app/views/payments/new.html.haml +++ /dev/null @@ -1,17 +0,0 @@ -%h1 - = t(:Donation) -- if logged_in? - = t(:donation_not_payment) -- if @result and @result.errors.size > 0 - %div{:style => "color: red;"} - = h @result.errors.size - error(s) -- if @result and @result.transaction and @result.transaction.status != 'success' - %div{:style => "color: red;"} - = t(:processor_declined) -= braintree_form_for :transaction, :html => {:autocomplete => "off"} do |f| - = f.label :amount, t(:amount) - = f.text_field :amount - = render :partial => 'non_customer_fields', :locals => {:f => f} - = hidden_field_tag :tr_data, @tr_data - = f.submit "Submit Donation", :class => 'btn btn-primary' -- cgit v1.2.3