summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorclaucece <soficeli0@gmail.com>2015-09-15 00:26:52 -0500
committerclaucece <soficeli0@gmail.com>2015-10-05 22:34:21 -0500
commitd11768e58b98312c95a8ac5e9c18e3069b4d76dc (patch)
tree35b4cfaf0814222e675f7fbd5423f6214b5d4aef
parent70073b1ac48f96d3e375630fb7f3904351e0f696 (diff)
implemented the form and the generate
-rw-r--r--Gemfile1
-rw-r--r--Gemfile.lock12
-rw-r--r--engines/billing/app/controllers/payments_controller.rb5
-rw-r--r--engines/billing/app/views/payments/_form.html.erb16
-rw-r--r--engines/billing/app/views/payments/new.html.erb25
-rw-r--r--engines/billing/app/views/payments/new.html.haml17
6 files changed, 56 insertions, 20 deletions
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 @@
+<form id="checkout" method="post" action="/checkout">
+ <div id="payment-form"></div>
+ <h2 class="mbs">New Donation</h2>
+ <p>Please enter your donation details (this is a donation, and will not be applied towards your account):</p>
+</form>
+
+<%= braintree_form_for :transaction, :html => {:autocomplete => "off"} do |f|%>
+ <%= f.label :amount, t(:amount)%>
+ <%= f.text_field :amount%>
+ <div>
+<script src="https://js.braintreegateway.com/v2/braintree.js"></script>
+<script>
+// We generated a client token for you so you can test out this code
+// immediately. In a production-ready integration, you will need to
+// generate a client token on your server (see section below).
+var clientToken = "eyJ2ZXJzaW9uIjoyLCJhdXRob3JpemF0aW9uRmluZ2VycHJpbnQiOiJkOTkwMGJkMzBkODNmMjc3NWY5ODNhMTYyZWRhNWY4MzcwMGQ2YzY0NmQxZjI5ODk5M2RmYjhkNWJlNmM1NDMyfGNyZWF0ZWRfYXQ9MjAxNS0wOS0xNVQwNDozMjo1NC4yOTA5MjU3MjYrMDAwMFx1MDAyNm1lcmNoYW50X2lkPTM0OHBrOWNnZjNiZ3l3MmJcdTAwMjZwdWJsaWNfa2V5PTJuMjQ3ZHY4OWJxOXZtcHIiLCJjb25maWdVcmwiOiJodHRwczovL2FwaS5zYW5kYm94LmJyYWludHJlZWdhdGV3YXkuY29tOjQ0My9tZXJjaGFudHMvMzQ4cGs5Y2dmM2JneXcyYi9jbGllbnRfYXBpL3YxL2NvbmZpZ3VyYXRpb24iLCJjaGFsbGVuZ2VzIjpbXSwiZW52aXJvbm1lbnQiOiJzYW5kYm94IiwiY2xpZW50QXBpVXJsIjoiaHR0cHM6Ly9hcGkuc2FuZGJveC5icmFpbnRyZWVnYXRld2F5LmNvbTo0NDMvbWVyY2hhbnRzLzM0OHBrOWNnZjNiZ3l3MmIvY2xpZW50X2FwaSIsImFzc2V0c1VybCI6Imh0dHBzOi8vYXNzZXRzLmJyYWludHJlZWdhdGV3YXkuY29tIiwiYXV0aFVybCI6Imh0dHBzOi8vYXV0aC52ZW5tby5zYW5kYm94LmJyYWludHJlZWdhdGV3YXkuY29tIiwiYW5hbHl0aWNzIjp7InVybCI6Imh0dHBzOi8vY2xpZW50L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script>
+ <%= 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'