-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds solicitation of donations to the league registration process.
- Loading branch information
1 parent
19b185c
commit 0b1ef42
Showing
14 changed files
with
193 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class Donation | ||
include Mongoid::Document | ||
include Mongoid::Timestamps | ||
|
||
belongs_to :user | ||
belongs_to :registration | ||
|
||
belongs_to :payment_transaction | ||
|
||
field :amount, type: Float | ||
field :earmark, type: String | ||
|
||
validates :amount, :numericality => { integer_only: false, greater_than: 0 } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,5 @@ class PaymentTransaction | |
belongs_to :user | ||
belongs_to :league | ||
belongs_to :registration | ||
has_one :donation | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<div class="hero-unit"> | ||
<h1>Boost Your Impact</h1> | ||
<h2>Add a donation with your registration and become a game-changer!</h2> | ||
<p> | ||
By stepping onto the field, you're already supporting Ultimate in Atlanta. But here's a | ||
chance to have an even greater impact. When you add a donation with your registration, | ||
you're not just a player - you're a pillar of our community. Your <b>tax-deductible donation</b> | ||
expands the reach of our programs, empowering youth development, fostering diversity and inclusivity, | ||
and amplifying our mission to teach and celebrate the games of Ultimate and Goaltimate. | ||
It's like adding a strategic play to your game; your contribution helps us build a stronger, | ||
more vibrant community for everyone who steps onto the field. | ||
</p> | ||
<p>Ready to be more than a player? Be a game-changer with us!</p> | ||
<p style="margin-top: 64px" class="text-center"> | ||
<%=link_to "$5", pay_registration_path(@registration, donation_amount: 5), class: "btn btn-primary btn-large"%> | ||
<%=link_to "$10", pay_registration_path(@registration, donation_amount: 10), class: "btn btn-primary btn-large"%> | ||
<%=link_to "$25", pay_registration_path(@registration, donation_amount: 25), class: "btn btn-primary btn-large"%> | ||
<%=link_to "$50", pay_registration_path(@registration, donation_amount: 50), class: "btn btn-primary btn-large"%> | ||
</p> | ||
<div> | ||
<%= form_tag(pay_registration_path(@registration), method: "GET", class: "form-inline") do %> | ||
<div style=" max-width: fit-content; margin-left: auto; margin-right: auto;"> | ||
<div class="input-prepend"> | ||
<span class="add-on">$</span> | ||
<%=text_field_tag :donation_amount, "", class: "input-medium", placeholder: "amount" %> | ||
</div> | ||
<%=submit_tag "Pay", class: "btn btn-primary"%> | ||
</div> | ||
<% end %> | ||
</div> | ||
<p class="text-center"> | ||
<%=link_to "No thanks, Maybe Next Time", pay_registration_path(@registration)%> | ||
</p> | ||
</div> | ||
|
||
<% if @registration.league.donation_pitch.present? %> | ||
<div class="well"> | ||
<h2>Heads Up! <small>Donations made via this league may be reserved for a specific purpose</small></h2> | ||
<h5>A message from your commissioner:</h5> | ||
<%= @registration.league.donation_pitch.html_safe %> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<% content_for :title, @registration.league.name %> | ||
<%= render :partial => '/pageheader', :locals => {subtitle: 'Join the League', breadcrumbs: {'Leagues' => leagues_path, @registration.league.name => league_path(@registration.league), "Registration for #{@registration.user.name}" => nil}}%> | ||
<% | ||
donation = Donation.new(amount: params[:donation_amount], user: @registration.user, registration: @registration) | ||
if @registration.league.solicit_donations? == false || donation.valid? == false | ||
donation = nil | ||
end | ||
%> | ||
|
||
<div class="row"> | ||
<div class="span6 offset3"> | ||
<div class="alert alert-success"> | ||
<strong style="color: #222"> | ||
<i class="icon-lock"></i> | ||
Relax! Your connection to our payment processor is secure. | ||
</strong> | ||
<p style="font-size: 80%">Your payment details will be submitted directly from your browser to our payment processor over a secure connection; the AFDC will never see your credit card information.</p> | ||
</div> | ||
<%= form_tag payments_path, id: "payment_form" do %> | ||
<div class="row" style="padding: 15px 0"> | ||
<div class="span4"> | ||
<b>League Registration</b> | ||
<small><%= @registration.league.name %></small> | ||
</div> | ||
<div class="span2 text-right"><%= number_to_currency @registration.price %> | ||
</div> | ||
</div> | ||
<% if donation %> | ||
<div class="row" style="margin-bottom: 20px;"> | ||
<div class="span4"><b>Tax-deductible Donation</b></div> | ||
<div class="span2 text-right"><%= number_to_currency donation.amount %></div> | ||
</div> | ||
<%= hidden_field_tag 'donation_amount', donation.amount %> | ||
<% end %> | ||
<div class="row"><div class="span6"> | ||
<hr /> | ||
<h1 class="text-right"><small>Total:</small> <%= number_to_currency(@registration.price + donation&.amount.to_f) %></h1> | ||
</div></div> | ||
<div id="braintree_dropin"></div> | ||
<%= hidden_field_tag 'payment_method_nonce', '' %> | ||
<%= hidden_field_tag 'registration_id', @registration._id %> | ||
<%= button_tag "Pay now to join the league!", type: :submit, class: "btn btn-block btn-success btn-large", id: "submit_button" do %> | ||
<i class="icon-lock"></i> | ||
Pay now to join the league! | ||
<% end %> | ||
<% end %> | ||
</div> | ||
</div> | ||
|
||
<% content_for :page_scripts do %> | ||
<script src="https://js.braintreegateway.com/web/dropin/1.40.2/js/dropin.min.js"></script> | ||
<script> | ||
$(function(){ | ||
form = $("#payment_form"); | ||
braintree.dropin.create({ | ||
container: document.getElementById('braintree_dropin'), | ||
authorization: "<%=current_user.braintree_token%>", | ||
}, (error, dropinInstance) => { | ||
if (error) { | ||
console.error(error); | ||
return; | ||
} | ||
|
||
form.on('submit', function (e) { | ||
e.preventDefault(); | ||
dropinInstance.requestPaymentMethod(function (requestPaymentMethodErr, payload) { | ||
if (requestPaymentMethodErr) { | ||
console.error(requestPaymentMethodErr); | ||
return; | ||
} | ||
|
||
$("#payment_method_nonce").val(payload["nonce"]); | ||
form.off().submit(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
</script> | ||
<% end %> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters