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 --- Gemfile | 1 + Gemfile.lock | 12 ++++++++++- .../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 --------------- 6 files changed, 56 insertions(+), 20 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 diff --git a/Gemfile b/Gemfile index f0d50df..e87573d 100644 --- a/Gemfile +++ b/Gemfile @@ -79,6 +79,7 @@ end group :test, :development do gem 'thin' gem 'i18n-missing_translations' + gem 'pry' end group :production do diff --git a/Gemfile.lock b/Gemfile.lock index 5ffb0c8..3a0c535 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -63,7 +63,7 @@ GEM debug_inspector (>= 0.0.1) bootstrap-sass (2.3.2.2) sass (~> 3.2) - braintree (2.38.0) + braintree (2.48.1) builder (>= 2.0.0) builder (3.0.4) capybara (2.4.4) @@ -159,6 +159,7 @@ GEM mime-types (~> 1.16) treetop (~> 1.4.8) metaclass (0.0.4) + method_source (0.8.2) mime-types (1.25.1) mini_portile (0.6.1) minitest-stub-const (0.2) @@ -176,6 +177,10 @@ GEM multi_json (~> 1.0) websocket-driver (>= 0.2.0) polyglot (0.3.5) + pry (0.10.1) + coderay (~> 1.1.0) + method_source (~> 0.8.1) + slop (~> 3.4) quiet_assets (1.0.3) railties (>= 3.1, < 5.0) rack (1.4.5) @@ -227,6 +232,7 @@ GEM rack (~> 1.4) rack-protection (~> 1.4) tilt (~> 1.3, >= 1.3.4) + slop (3.6.0) sprockets (2.2.3) hike (~> 1.2) multi_json (~> 1.0) @@ -295,6 +301,7 @@ DEPENDENCIES mocha (~> 0.13.0) phantomjs-binaries poltergeist + pry quiet_assets rails (~> 3.2.21) rails-i18n @@ -307,3 +314,6 @@ DEPENDENCIES thin uglifier (~> 1.2.7) valid_email + +BUNDLED WITH + 1.10.5 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