From 6b6da99fb4f7cf84b8e06143640164b8c594fd40 Mon Sep 17 00:00:00 2001 From: "t@thintz.com" Date: Tue, 7 Aug 2012 23:19:06 -0700 Subject: [PATCH] Add stripe! Also add compass/sass to toolchain. --- .gitignore | 9 ++ config.rb | 24 ++++++ css/club-register.css | 185 ++++++++++++++++++++++++++++------------ images/input-bg.jpg | Bin 0 -> 314 bytes js/payments.js | 34 ++++++++ keep-the-records.scm | 12 ++- mda.scm | 30 +++---- payments.scm | 80 +++++++++++++++++ scss/_common.scss | 29 +++++++ scss/club-register.scss | 59 +++++++++++++ 10 files changed, 392 insertions(+), 70 deletions(-) create mode 100644 .gitignore create mode 100644 config.rb create mode 100644 images/input-bg.jpg create mode 100644 js/payments.js create mode 100644 payments.scm create mode 100644 scss/_common.scss create mode 100644 scss/club-register.scss diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4af6e96 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +*~ +.sass-cache* +aws-setup.scm +ktr-db +nohup.out +*# +send-grid-key +send-grid-user +stripe-username.scm diff --git a/config.rb b/config.rb new file mode 100644 index 0000000..3c9feb6 --- /dev/null +++ b/config.rb @@ -0,0 +1,24 @@ +# Require any additional compass plugins here. + +# Set this to the root of your project when deployed: +http_path = "/" +css_dir = "css" +sass_dir = "scss" +images_dir = "images" +javascripts_dir = "js" + +# You can select your preferred output style here (can be overridden via the command line): +# output_style = :expanded or :nested or :compact or :compressed + +# To enable relative paths to assets via compass helper functions. Uncomment: +# relative_assets = true + +# To disable debugging comments that display the original location of your selectors. Uncomment: +# line_comments = false + + +# If you prefer the indented syntax, you might want to regenerate this +# project again passing --syntax sass, or you can uncomment this: +# preferred_syntax = :sass +# and then run: +# sass-convert -R --from scss --to sass scss scss && rm -rf sass && mv scss sass diff --git a/css/club-register.css b/css/club-register.css index 6d9153c..e7a0abf 100644 --- a/css/club-register.css +++ b/css/club-register.css @@ -1,62 +1,139 @@ +/* line 3, ../scss/_common.scss */ +.button { + border: 1px solid grey; + margin-left: 20px; + width: 304px; + color: white; + line-height: 14px; + font-size: 14px; + height: 44px; + -webkit-font-smoothing: antialiased; + font-weight: bold; + font-family: HelveticaNeue, Helvetica, Arial, sans-serif; + cursor: pointer; + text-shadow: 0 1px 1px rgba(0, 0, 0, 0.53); + -webkit-border-radius: 4px 4px; + -moz-border-radius: 4px / 4px; + border-radius: 4px / 4px; +} + +/* line 18, ../scss/_common.scss */ +.button-blue { + background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #77b7ff), color-stop(100%, #017aff)); + background-image: -webkit-linear-gradient(#77b7ff, #017aff); + background-image: -moz-linear-gradient(#77b7ff, #017aff); + background-image: -o-linear-gradient(#77b7ff, #017aff); + background-image: linear-gradient(#77b7ff, #017aff); +} +/* line 20, ../scss/_common.scss */ +.button-blue:active { + background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #017aff), color-stop(100%, #77b7ff)); + background-image: -webkit-linear-gradient(#017aff, #77b7ff); + background-image: -moz-linear-gradient(#017aff, #77b7ff); + background-image: -o-linear-gradient(#017aff, #77b7ff); + background-image: linear-gradient(#017aff, #77b7ff); +} + +/* line 23, ../scss/_common.scss */ +.button-green { + background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #9fc164), color-stop(100%, #146600)); + background-image: -webkit-linear-gradient(#9fc164, #146600); + background-image: -moz-linear-gradient(#9fc164, #146600); + background-image: -o-linear-gradient(#9fc164, #146600); + background-image: linear-gradient(#9fc164, #146600); +} +/* line 25, ../scss/_common.scss */ +.button-green:active { + background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #146600), color-stop(100%, #9fc164)); + background-image: -webkit-linear-gradient(#146600, #9fc164); + background-image: -moz-linear-gradient(#146600, #9fc164); + background-image: -o-linear-gradient(#146600, #9fc164); + background-image: linear-gradient(#146600, #9fc164); +} + +/* line 28, ../scss/_common.scss */ +.column-header-grey { + background-color: grey; +} + +/* line 4, ../scss/club-register.scss */ .action { - margin-bottom: 10px; - margin-top: 10px; - font-family: "Vollkorn"; - font-size: 36px; } + margin-bottom: 10px; + margin-top: 10px; + font-family: "Vollkorn"; + font-size: 36px; +} +/* line 10, ../scss/club-register.scss */ .form-context { - margin-bottom: 5px; - margin-left: 20px; - font-style: italic; - color: grey; - font-size: 16px; } + margin-bottom: 5px; + margin-left: 20px; + font-style: italic; + color: grey; + font-size: 16px; +} +/* line 17, ../scss/club-register.scss */ .text { - padding: 2px; - line-height: 32px; - margin-left: 20px; - margin-top: 5px; - margin-bottom: 5px; - background-color: #ededed; - width: 300px; - font-size: 24px; - font-family: 'Neucha', arial, serif; - outline: none; - border: 2px solid #ededed; - border-bottom: 2px solid black; } - + font-family: 'Helvetica', serif; + padding: 2px; + line-height: 24px; + margin-left: 20px; + margin-top: 5px; + margin-bottom: 5px; + -webkit-border-radius: 4px 4px; + -moz-border-radius: 4px / 4px; + border-radius: 4px / 4px; + width: 300px; + font-size: 16px; + outline: none; + background: white url(/images/input-bg.jpg) repeat-x; + border: 1px solid #DDD; +} +/* line 30, ../scss/club-register.scss */ .text:focus { - -webkit-box-shadow: 0px 0px 10px blue; - border: 2px solid black; - border-radius: 6px; - background-color: white; } - -.text:hover { - -webkit-box-shadow: 0px 0px 5px blue; - border: 2px solid white; - border-radius: 6px; - background-color: #eeeeee; } - -.create { - width: 330px; - font-size: 24px; - margin-top: 20px; - color: white; - background-color: green; - font-family: Verdana, sans; - border: 1px solid grey; - border-radius: 20px; - -webkit-box-shadow: 0px 0px 10px grey; } - -.create:hover { - cursor: pointer; - -webkit-box-shadow: 0px 0px 25px blue; } - -.create:focus { - -webkit-box-shadow: 0px 0px 25px blue; - border-radius: 20px; - background-color: green; - border: 1px solid grey; } + border: 1px solid #72b6e6; + -webkit-box-shadow: 0px 0px 10px #72b6e6; + -moz-box-shadow: 0px 0px 10px #72b6e6; + box-shadow: 0px 0px 10px #72b6e6; +} +/* line 34, ../scss/club-register.scss */ .menu-frame { - display: none; } \ No newline at end of file + display: none; +} + +/* line 37, ../scss/club-register.scss */ +.plan-features { + font-size: 20px; + line-height: 40px; +} + +/* line 42, ../scss/club-register.scss */ +.plan-features ul li { + font-family: 'Helvetica', serif; + border-top: solid 1px whiteSmoke; + border-bottom: solid 1px #D2D2D2; +} + +/* line 47, ../scss/club-register.scss */ +.plan-features ul li:first-child { + border-top-color: transparent; +} + +/* line 50, ../scss/club-register.scss */ +.plan-features ul li:last-child { + border-bottom-color: transparent; +} + +/* line 53, ../scss/club-register.scss */ +.plan-aside { + color: grey; + font-style: italic; +} + +/* line 57, ../scss/club-register.scss */ +.payment-errors { + color: red; + font-weight: bold; +} diff --git a/images/input-bg.jpg b/images/input-bg.jpg new file mode 100644 index 0000000000000000000000000000000000000000..1d1f6fa472754a3901bca4a396d2fc48ea1b7495 GIT binary patch literal 314 zcma)$Jqp4=5QX1lH=CGj;tq)*Mi6ZD5P}FIXy+9)Ru)zk_MSzoJ%NRX@Tc(r;uY4# zLd4293_QMhJjR~w9cD5bk3b$!x`BOwhwJ%r1A+w5bLfe5P_AYRlt)L%-mry|QunMt&NE`i@(P`CGQ=Mgbo@LFVD4MO0CF0J xkRXP~B$(_8QxLfyza&HYMFay+d}W-aX*=iNAlP1^1-X8~=wo;2a=P!>%M0({C!YWS literal 0 HcmV?d00001 diff --git a/js/payments.js b/js/payments.js new file mode 100644 index 0000000..634a43d --- /dev/null +++ b/js/payments.js @@ -0,0 +1,34 @@ +function stripeResponseHandler(status, response) { + if (response.error) { + // re-enable the submit button + $('.submit-button').removeAttr("disabled"); + // show the errors on the form + $(".payment-errors").html(response.error.message); + } else { + var form$ = $("#payment-form"); + // token contains id, last4, and card type + var token = response['id']; + // insert the token into the form so it gets submitted to the server + form$.append(""); + // and submit + form$.get(0).submit(); + } +}; + +$(document).ready(function() { + $("#payment-form").submit(function(event) { + // disable the submit button to prevent repeated clicks + $('.submit-button').attr("disabled", "disabled"); + + Stripe.createToken({ + name: $('.card-name').val(), + number: $('.card-number').val(), + cvc: $('.card-cvc').val(), + exp_month: $('.card-expiry-month').val(), + exp_year: $('.card-expiry-year').val() + }, stripeResponseHandler); + + // prevent the form from submitting with the default action + return false; + }); +}); diff --git a/keep-the-records.scm b/keep-the-records.scm index 48d4764..7dc68b0 100644 --- a/keep-the-records.scm +++ b/keep-the-records.scm @@ -11,6 +11,7 @@ (load "pdf") (load "awana-data-dsl") (load "sections") +(load "rest") (define is-production? (make-parameter (file-exists? "/keep-the-records/i-am-production"))) @@ -65,7 +66,7 @@ "PERMISSION DENIED! If you think this is an error, please email me at t@thintz.com" (abort exn)) (let ((club (first (string-split actual-path "/")))) - (when (and (not (or (string=? club "user") (string=? club "club"))) + (when (and (not (or (string=? club "user") (string=? club "club") (string=? club "sign-up") (string=? club "process-sign-up"))) (not (or (string=? ($session 'club) club) (string=? ($session 'user) "t@thintz.com")))) (error 'permission-denied)) (++ (if (and (session-valid? (read-cookie "awful-cookie")) ($session 'demo)) @@ -1736,6 +1737,10 @@ ;;; loaders +(define-page "/reload-app" + (lambda () (reload-apps (awful-apps)) "done") + no-session: #t) + (define-page "/reload/index" (lambda () (when (developer-access?) @@ -1938,3 +1943,8 @@ (
class: "tab-body padding" (
class: "attendees" id: "attendees" (attendees-html club date)))))) + + +;;; includes + +(include "payments.scm") diff --git a/mda.scm b/mda.scm index c895b29..1d08d17 100644 --- a/mda.scm +++ b/mda.scm @@ -1,4 +1,4 @@ -(use srfi-1 srfi-13 srfi-18 srfi-69 tokyocabinet mailbox (prefix amazon-s3 amazon-s3:)) +(use srfi-1 srfi-13 srfi-18 srfi-69 tokyocabinet); mailbox (prefix amazon-s3 amazon-s3:)) ;;; utils @@ -90,28 +90,28 @@ ;;; amazon-s3 stuff -(load "aws-setup.scm") ; for credentials -(define as3-bucket (make-parameter (if (is-production?) "keep-the-records-backup-db" "keep-the-records-dev-backup-db"))) +;(load "aws-setup.scm") ; for credentials +;(define as3-bucket (make-parameter (if (is-production?) "keep-the-records-backup-db" "keep-the-records-dev-backup-db"))) -(define (make-as3-thread mb) - (make-thread - (lambda () - (let loop () - (let ((k-v (mailbox-receive! mb))) - (if (eq? (first k-v) 'put!) - (amazon-s3:put-string! (as3-bucket) (second k-v) (third k-v)) - (amazon-s3:delete-object! (as3-bucket) (second k-v)))) - (loop))))) +;; (define (make-as3-thread mb) +;; (make-thread +;; (lambda () +;; (let loop () +;; (let ((k-v (mailbox-receive! mb))) +;; (if (eq? (first k-v) 'put!) +;; (amazon-s3:put-string! (as3-bucket) (second k-v) (third k-v)) +;; (amazon-s3:delete-object! (as3-bucket) (second k-v)))) +;; (loop))))) -(define as3-mailbox (make-parameter (make-mailbox))) +;(define as3-mailbox (make-parameter (make-mailbox))) ; make amazon s3 threads ;(for-each (lambda (n) (thread-start! (make-as3-thread (as3-mailbox)))) (range 20)) -(define (as3-put! k v) 'a) +;(define (as3-put! k v) 'a) ;(mailbox-send! (as3-mailbox) `(put! ,k ,v))) -(define (as3-delete! k v) 'a) +;(define (as3-delete! k v) 'a) ;(mailbox-send! (as3-mailbox) `(delete! ,k ,v))) ;;; tokyocabinet db operations / to be refactored of course! diff --git a/payments.scm b/payments.scm new file mode 100644 index 0000000..28ae68a --- /dev/null +++ b/payments.scm @@ -0,0 +1,80 @@ +; included in keep-the-records.scm + +(use striped-zebra) + +(include "stripe-username.scm") + +(define-page "/add-account" + (lambda () + (add-customer ($ 'stripeToken) email: ($ 'email) plan: ($ 'plan)) + "good") + method: 'POST + no-session: #t) + +(define plan-details + (make-parameter + '((free . ((price . 0) (clubbers . 30))) + (basic . ((price . 19.99) (clubbers . 75))) + (plus . ((price . 34.99) (clubbers . 150))) + (premier . ((price . 59.99) (clubbers . 300))) + (ultimate . ((price . 99.99) (clubbers . "infinite")))))) + +(define (get-plan plan plans) (cdr (assoc plan plans))) + +(define (plan-price plan plans) + (cdr (assoc 'price (get-plan plan plans)))) + +(define (plan-clubbers plan plans) + (cdr (assoc 'clubbers (get-plan plan plans)))) + +(define-awana-app-page (regexp "/sign-up/(free|basic|plus|premier|ultimate)") + (lambda (path) + (add-javascript "Stripe.setPublishableKey('CG3MRYjCWmMz9pgZREFBOclg677UqOLS');") + (let ((plan (second (string-split path "/")))) + (++ (
class: "grid_12" + (

class: "action" "Sign up for Keep the Records")) + (
class: "clear") + (
class: "grid_6 column-header" + (
class: "padding" "Payment Details")) + (
class: "grid_6 column-header column-header-grey" + (
class: "padding" (++ (string-upcase plan) " Plan"))) + (
class: "grid_6 column-body" + (
class: "padding" + (
class: "payment-errors") + (
action: "/add-account" method: "POST" id: "payment-form" + ( type: "hidden" name: "plan" value: (second (string-split path "/"))) (
) + ( class: "form-context" "Full Name") (
) + ( type: "text" size: "20" class: "card-name text" value: "Joe Monkey") (
) + ( class: "form-context" "Email") (
) + ( type: "text" size: "20" class: "email text" name: "email" value: "eat@good.com") (
) + ( class: "form-context" "Credit Card Number") (
) + ( type: "text" size: "20" autocomplete: "off" class: "card-number text" value: "4242424242424242") (
) + ( class: "form-context" "Credit Card CVC") + (
) + ( type: "text" style: "width: 80px;" autocomplete: "off" class: "card-cvc text" value: "123") + ( class: "form-context" "3 or 4 digits on back of card") + (
) + ( class: "form-context" "Credit Card Expiration (MM/YYYY)") (
) + ( type: "text" style: "width: 80px;" class: "card-expiry-month text" value: "12") + ( class: "form-context" "/") + ( type: "text" style: "width: 169px;" class: "card-expiry-year text" value: "2013") (
) + (