summaryrefslogtreecommitdiff
path: root/engines/billing
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 /engines/billing
parent70073b1ac48f96d3e375630fb7f3904351e0f696 (diff)
implemented the form and the generate
Diffstat (limited to 'engines/billing')
-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
4 files changed, 44 insertions, 19 deletions
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 = "eyJ2ZXJzaW9uIjoyLCJhdXRob3JpemF0aW9uRmluZ2VycHJpbnQiOiJkOTkwMGJkMzBkODNmMjc3NWY5ODNhMTYyZWRhNWY4MzcwMGQ2YzY0NmQxZjI5ODk5M2RmYjhkNWJlNmM1NDMyfGNyZWF0ZWRfYXQ9MjAxNS0wOS0xNVQwNDozMjo1NC4yOTA5MjU3MjYrMDAwMFx1MDAyNm1lcmNoYW50X2lkPTM0OHBrOWNnZjNiZ3l3MmJcdTAwMjZwdWJsaWNfa2V5PTJuMjQ3ZHY4OWJxOXZtcHIiLCJjb25maWdVcmwiOiJodHRwczovL2FwaS5zYW5kYm94LmJyYWludHJlZWdhdGV3YXkuY29tOjQ0My9tZXJjaGFudHMvMzQ4cGs5Y2dmM2JneXcyYi9jbGllbnRfYXBpL3YxL2NvbmZpZ3VyYXRpb24iLCJjaGFsbGVuZ2VzIjpbXSwiZW52aXJvbm1lbnQiOiJzYW5kYm94IiwiY2xpZW50QXBpVXJsIjoiaHR0cHM6Ly9hcGkuc2FuZGJveC5icmFpbnRyZWVnYXRld2F5LmNvbTo0NDMvbWVyY2hhbnRzLzM0OHBrOWNnZjNiZ3l3MmIvY2xpZW50X2FwaSIsImFzc2V0c1VybCI6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JyZW5jeUlzb0NvZGUiOiJVU0QifSwiY29pbmJhc2VFbmFibGVkIjpmYWxzZSwibWVyY2hhbnRJZCI6IjM0OHBrOWNnZjNiZ3l3MmIiLCJ2ZW5tbyI6Im9mZiJ9";
+
+
+braintree.setup(clientToken, "dropin", {
+ container: "payment-form"
+});
+</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'