Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
d0fc9ac
configuration tweaks, daemonize unicorn, makefile for easy restarting…
Feb 20, 2015
e1406a4
make command for tail -f unicorn logs
Feb 20, 2015
e421076
stuff needed to get running in production mode
Feb 20, 2015
3da73c5
basic foundation for a referral system
kkoch986 Feb 20, 2015
93738ce
just hard code the port
kkoch986 Feb 23, 2015
3d0f4dc
add a function to lookup the referral user
kkoch986 Feb 23, 2015
c4be8e5
basic tiers and fake users tools
kkoch986 Mar 2, 2015
c63ee41
tier pricing at quantity selection
kkoch986 Mar 2, 2015
c31095d
tier based data in checkout flow
kkoch986 Mar 2, 2015
e2822f4
styles on the main campaign
kkoch986 Mar 2, 2015
b429e78
show pct off
kkoch986 Mar 3, 2015
6bbf33c
different look for current tier
kkoch986 Mar 3, 2015
3e4ee42
learn more modal
kkoch986 Mar 3, 2015
ae7a68d
show starting price
kkoch986 Mar 3, 2015
31806a5
round pct off and pct complete
kkoch986 Mar 3, 2015
2cb474d
round pct off and pct complete
kkoch986 Mar 3, 2015
93ae46e
current tier show number of orders to reach
kkoch986 Mar 3, 2015
78cb484
center imagE
kkoch986 Mar 3, 2015
d1e4c2a
make command for asset compilation
kkoch986 Mar 3, 2015
8b5db76
doh
kkoch986 Mar 3, 2015
2568b12
remove orders ramining udner price
kkoch986 Mar 3, 2015
e08529c
center days left
kkoch986 Mar 3, 2015
b2e98f6
clean up checkout page
kkoch986 Mar 3, 2015
a356888
improve quantity selection page
kkoch986 Mar 3, 2015
a9f15b5
faq and rework homepage for better responsiveness
kkoch986 Mar 3, 2015
1c617fc
new icons
kkoch986 Mar 3, 2015
4094b7c
new confirmation page
kkoch986 Mar 4, 2015
95127bd
tiers on the qty page
kkoch986 Mar 4, 2015
e93f58d
sold out flag
kkoch986 Mar 4, 2015
af9e0aa
email capture when tilt is over
kkoch986 Mar 4, 2015
9ae90b8
Add missing migration
kkoch986 Mar 4, 2015
d4cd334
swap out tilt for stripe
kkoch986 Mar 5, 2015
7d4bc15
add ip logging, remove mentions of sandbox modes
kkoch986 Mar 5, 2015
fa2505c
read stripe key from env file
kkoch986 Mar 5, 2015
cb9b890
fix pinterest button at least
kkoch986 Mar 5, 2015
4b8209f
fix
kkoch986 Mar 5, 2015
be0db84
fix z index
kkoch986 Mar 5, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ gem 'unicorn'
gem 'foreman'

gem 'crowdtilt', github: 'Crowdtilt/crowdtilt-gem'
gem 'stripe'
gem 'devise', '~> 3.2.0'
gem 'nokogiri'
gem 'friendly_id', '~> 4.0.9'
gem 'iso_country_codes'
gem 'paperclip', '~> 3.0'
gem 'ckeditor'
gem 'ckeditor', '4.0.4'
gem 'aws-sdk'
gem 'active_model_serializers'
gem 'momentjs-rails'
Expand Down
10 changes: 9 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ GEM
net-scp (1.1.1)
net-ssh (>= 2.6.5)
net-ssh (2.6.7)
netrc (0.10.3)
newrelic_rpm (3.6.3.111)
nokogiri (1.5.9)
orm_adapter (0.4.0)
Expand Down Expand Up @@ -190,6 +191,9 @@ GEM
rake (10.0.4)
rdoc (3.12.2)
json (~> 1.4)
rest-client (1.7.3)
mime-types (>= 1.16, < 3.0)
netrc (~> 0.7)
rspec-core (2.13.1)
rspec-expectations (2.13.0)
diff-lcs (>= 1.1.3, < 2.0)
Expand Down Expand Up @@ -219,6 +223,9 @@ GEM
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
stripe (1.8.8)
multi_json (>= 1.0.4, < 2)
rest-client (~> 1.4)
thor (0.18.1)
thread_safe (0.1.3)
atomic
Expand Down Expand Up @@ -249,7 +256,7 @@ DEPENDENCIES
aws-sdk
bootstrap-sass (= 2.1)
capybara
ckeditor
ckeditor (= 4.0.4)
coffee-rails (~> 3.2.1)
crowdtilt!
devise (~> 3.2.0)
Expand All @@ -273,5 +280,6 @@ DEPENDENCIES
rspec-rails
sass-rails (~> 3.2.3)
shoulda
stripe
uglifier (>= 1.0.3)
unicorn
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
all:
RAILS_ENV=production bundle exec foreman start;

stop:
cat tmp/unicorn.pid | xargs kill -QUIT ;

restart:
make stop; make;

logs:
tail -f log/unicorn.log;

assets:
RAILS_ENV=production bundle exec foreman run rake assets:precompile


local:
bundle exec foreman run unicorn -p 5000 -c ./config/unicorn.rb

2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb -D
Binary file modified app/assets/images/app_icon_114px.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/assets/images/app_icon_144px.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/assets/images/app_icon_172px.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/apple-touch-icon-120x120.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/apple-touch-icon-152x152.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/apple-touch-icon-57x57.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/apple-touch-icon-76x76.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/favicon.ico
Binary file not shown.
32 changes: 30 additions & 2 deletions app/assets/javascripts/campaigns.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,39 @@ Crowdhoster.campaigns =
$('html,body').animate({scrollTop: $('#header')[0].scrollHeight})

$('#quantity').on "change", (e) ->
quantity = $(this).val()
unit_price_at_qty = parseFloat($(":selected", this).attr('data-price-at-qty'));
quantity = parseInt($(this).val())
$amount = $('#amount')
functional_total = quantity + parseInt($(".their-qty").attr("data-campaign-qty"))
new_amount = parseFloat($amount.attr('data-original')) * quantity
new_amount_display = unit_price_at_qty * quantity
$("#unit-price-at-qty").html("$" + unit_price_at_qty.toFixed(2));
$amount.val(new_amount)
$('#total').html(new_amount.toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ",");)
$('#total').html(new_amount_display.toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ","))
$(".their-qty").html(quantity)
$(".total-qty").html(functional_total)

# loop over the tiers and update them
current_tier = null
$(".tier-list .tier").each (i, item) ->
min = parseInt $(item).attr "data-min-qty"
$item = $(item);
$item.removeClass "list-group-item-success"
$item.removeClass "list-group-item-info"
$item.removeClass "active"

# we havent reached this tier
if(functional_total < min)
$item.addClass "list-group-item-info"
$(".people-needed", $item).html "<span class='remaining'>" + (min - functional_total) + "</span> More Orders to Activate"
else
$item.addClass "list-group-item-success"
$(".people-needed", $item).html "Activated with "+min+" Orders"
current_tier = $item

current_tier.addClass "active"
$(".people-needed", current_tier).html "Current Price<br />Activated with <strong>"+min+" Orders</strong>"


$('#amount').on "keyup", (e) ->
$(this).addClass('edited')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,20 @@
*= require jquery.ui.all
*= require main
*= require theme
*/
*/

#header {
font-size: 35px;

div.container {
color: #ff8e1f;

a {
color: #ff8e1f;
}

a:hover {
text-decoration: none;
}
}
}
6 changes: 3 additions & 3 deletions app/assets/stylesheets/primitives.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ $text_shadow: 0 1px 0px #fff;
$font_size: 22px;

// Lockitron uses ProximaNova Regular, but that costs money, so we're defaulting to Helveitca Neue instead.
$primary_font: "Helvetica Neue";
$primary_font: "proxima-nova-alt";
$secondary_font: "Helvetica";
$tertiary_font: "Arial";

Expand All @@ -29,7 +29,7 @@ $tertiary_font: "Arial";

h1 {
margin: 0 auto;
font-family: Helvetica;
font-family: $primary_font;
font-size: 42px;
font-weight: bold;
color: $h1_color;
Expand Down Expand Up @@ -76,7 +76,7 @@ h5 {
}

p {
font-family: "Helvetica Neue","Helvetica","Arial";
font-family: $primary_font, $secondary_font, $tertiary_font;
color: #6b6b6b;
font-size: 18px;
line-height: 1.5;
Expand Down
9 changes: 9 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ class ApplicationController < ActionController::Base
before_filter :load_settings, :set_default_mailer_host
after_filter :store_location

def capture
if(params.has_key?(:referral_code))
ReferralCode.create(params[:referral_code]);
redirect_to root_url, :flash => { :info => "Thank you for you're interest, we'll contact you before the next sale starts!" }
else
redirect_to root_url, :flash => { :error => "We're sorry there seems to have been an issue with your submission. Please try again later." }
end
end

def load_settings
@settings = Settings.first

Expand Down
99 changes: 62 additions & 37 deletions app/controllers/campaigns_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ def checkout_payment
return
end

@display_subtotal = @campaign.price_at_additional_qty(@quantity) * @quantity
@fee = (@campaign.apply_processing_fee)? calculate_processing_fee(@amount * 100)/100.0 : 0
@total = @amount + @fee
@display_total = @display_subtotal + @fee

end

Expand Down Expand Up @@ -123,53 +125,76 @@ def checkout_process
end

@payment.reward = @reward if @reward
@payment.ip_addr = request.remote_ip
@payment.save

# Execute the payment via the Crowdtilt API, if it fails, redirect user
begin
payment = {
amount: payment_params[:amount],
user_fee_amount: user_fee_amount,
admin_fee_amount: admin_fee_amount,
user_id: ct_user_id,
card_id: ct_card_id,
metadata: {
fullname: payment_params[:fullname],
email: payment_params[:email],
billing_postal_code: payment_params[:billing_postal_code],
quantity: payment_params[:quantity],
reward: @reward ? @reward.id : 0,
additional_info: payment_params[:additional_info]
}
}
@campaign.production_flag ? Crowdtilt.production(@settings) : Crowdtilt.sandbox

logger.info "CROWDTILT API REQUEST: /campaigns/#{@campaign.ct_campaign_id}/payments"
logger.info payment
response = Crowdtilt.post('/campaigns/' + @campaign.ct_campaign_id + '/payments', {payment: payment})
logger.info "CROWDTILT API RESPONSE:"
logger.info response
rescue Crowdtilt::ApiError => api_error
response = api_error.response
logger.error "API ERROR WITH POST TO /payments: #{response[:status]} #{response[:body]}"
error_attributes = {status: 'error'}
error_attributes[:ct_charge_request_id] = response[:body]['request_id'] if response[:body]['request_id']
error_attributes[:ct_charge_request_error_id] = response[:body]['error_id'] if response[:body]['error_id']
@payment.update_attributes(error_attributes)
redirect_to checkout_amount_url(@campaign), flash: { error: "There was an error processing your payment. Please try again or contact support by emailing [email protected]" } and return
rescue StandardError => exception
@payment.update_attributes({status: 'error'})
logger.error "ERROR WITH POST TO /payments: #{exception.message}"
redirect_to checkout_amount_url(@campaign), flash: { error: "There was an error processing your payment. Please try again or contact support by emailing [email protected]" } and return
require "stripe"
Stripe.api_key = ENV['STRIPE_KEY']

response = Stripe::Charge.create(
:amount => payment_params[:amount],
:currency => "usd",
:source => {
:object => "card",
:number => params[:card_no],
:exp_month => params[:expiration_month],
:exp_year => params[:expiration_year],
:name => payment_params[:fullname],
:cvc => params[:security_code],
:address_zip => params[:billing_postal_code]
},
:description => "Cincodebuyo campaign authorization",
:capture => false
)
rescue => e
redirect_to checkout_amount_url(@campaign), flash: { error: "There was an error processing your payment. Please try again or contact support by emailing [email protected]" } and return


# payment = {
# amount: payment_params[:amount],
# user_fee_amount: user_fee_amount,
# admin_fee_amount: admin_fee_amount,
# user_id: ct_user_id,
# card_id: ct_card_id,
# metadata: {
# fullname: payment_params[:fullname],
# email: payment_params[:email],
# billing_postal_code: payment_params[:billing_postal_code],
# quantity: payment_params[:quantity],
# reward: @reward ? @reward.id : 0,
# additional_info: payment_params[:additional_info]
# }
# }
# @campaign.production_flag ? Crowdtilt.production(@settings) : Crowdtilt.sandbox

# logger.info "CROWDTILT API REQUEST: /campaigns/#{@campaign.ct_campaign_id}/payments"
# logger.info payment
# response = Crowdtilt.post('/campaigns/' + @campaign.ct_campaign_id + '/payments', {payment: payment})
# logger.info "CROWDTILT API RESPONSE:"
# logger.info response
# rescue Crowdtilt::ApiError => api_error
# response = api_error.response
# logger.error "API ERROR WITH POST TO /payments: #{response[:status]} #{response[:body]}"
# error_attributes = {status: 'error'}
# error_attributes[:ct_charge_request_id] = response[:body]['request_id'] if response[:body]['request_id']
# error_attributes[:ct_charge_request_error_id] = response[:body]['error_id'] if response[:body]['error_id']
# @payment.update_attributes(error_attributes)
# redirect_to checkout_amount_url(@campaign), flash: { error: "There was an error processing your payment. Please try again or contact support by emailing [email protected]" } and return
# rescue StandardError => exception
# @payment.update_attributes({status: 'error'})
# logger.error "ERROR WITH POST TO /payments: #{exception.message}"
# redirect_to checkout_amount_url(@campaign), flash: { error: "There was an error processing your payment. Please try again or contact support by emailing [email protected]" } and return
end

# Sync payment data
@payment.update_api_data(response['payment'])
@payment.ct_charge_request_id = response['request_id']
@payment.update_api_data(response)
@payment.ct_charge_request_id = response['id']
@payment.save

# Sync campaign data
@campaign.update_api_data(response['payment']['campaign'])
@campaign.update_api_data(@payment.amount)
@campaign.save

# Send confirmation emails
Expand Down
5 changes: 5 additions & 0 deletions app/controllers/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ class PagesController < ApplicationController
before_filter :check_init

def index
# Check for referral code
if request[:referral_code]
cookies[:referral_code] = request[:referral_code]
end

if @settings.default_campaign && ((user_signed_in? && current_user.admin?) || @settings.default_campaign.published_flag)
redirect_to campaign_home_url(@settings.default_campaign)
else
Expand Down
3 changes: 3 additions & 0 deletions app/mixins/checkout_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ def basic_payment_info(params)
billing_postal_code: params[:billing_postal_code],
quantity: params[:quantity].to_i,

#Referral
referred_by: params[:referred_by],

#Shipping Info
address_one: params.has_key?(:address_one) ? params[:address_one] : '',
address_two: params.has_key?(:address_two) ? params[:address_two] : '',
Expand Down
Loading