From 6fafef09b01636633b635e9ff6d2564b0b9573c4 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Sat, 28 Oct 2017 23:07:20 -0700 Subject: [PATCH] new payment system --- order-failure.html.pm | 9 +++++++++ order-success.html.pm | 10 ++++++++++ pricing-table.rkt | 37 +++++++++++++++++++++++++++++++------ template.html.p | 5 ++++- 4 files changed, 54 insertions(+), 7 deletions(-) create mode 100644 order-failure.html.pm create mode 100644 order-success.html.pm diff --git a/order-failure.html.pm b/order-failure.html.pm new file mode 100644 index 0000000..c5f1bd1 --- /dev/null +++ b/order-failure.html.pm @@ -0,0 +1,9 @@ +#lang pollen + +◊(define-meta title "Regrettably your payment failed") +◊(section-from-metas metas) +◊(define-meta toolbar-blank "true") +  +Click the back button to try again, or ◊a[#:href "mailto:mb@beautifulracket.com"]{email me} if you think something is amiss. + +◊link["/index.html"]{Return to the Typography for Lawyers home page.} \ No newline at end of file diff --git a/order-success.html.pm b/order-success.html.pm new file mode 100644 index 0000000..f1a204c --- /dev/null +++ b/order-success.html.pm @@ -0,0 +1,10 @@ +#lang pollen + +◊(define-meta title "Thank you for your order") +◊(section-from-metas metas) +◊(define-meta toolbar-blank "true") +  +A confirmation will be sent to the email address you used for payment. + + +◊link["/index.html"]{Return to the Typography for Lawyers home page.} \ No newline at end of file diff --git a/pricing-table.rkt b/pricing-table.rkt index d316ad6..27ed4e2 100644 --- a/pricing-table.rkt +++ b/pricing-table.rkt @@ -41,9 +41,6 @@ (define (get-variant-id sku which) (dict-ref (sku-variant-ids sku) which)) -(define (make-buy-url sku which) - (format "http://typo.la/bc.html?item=~a" (get-variant-id sku which))) - (define (grid->table grid) (define (table-row row [cell-tag 'td]) @@ -52,8 +49,8 @@ (table-row row 'th)) `(table ((class "buy-table")) - ,(table-header (car grid)) - ,@(map table-row (cdr grid)))) + ,(table-header (car grid)) + ,@(map table-row (cdr grid)))) (define (people->string p) (define p-string (format "~a" @@ -62,11 +59,39 @@ p))) (string-append p-string " " (if (= p 1) "person" "people"))) +(require txexpr racket/string) +(define (textify x) + (cond + ;; convert nbsp to string + [(string? x) (string-replace x #px"[\\s#\u00A0]+" " ")] + [(eq? 'nbsp x) " "] + [(list? x) (string-append* (map textify (if (txexpr? x) + (get-elements x) + x)))])) + +(module+ test + (require rackunit) + (check-equal? + (textify + '(span (a ((href "equity.html")) "Equity") " + " (a ((href "concourse.html")) "Concourse Standard") " + " (a ((href "triplicate.html")) "Triplicate"))) + "Equity + Concourse Standard + Triplicate")) + +(define (buy-link sku people) + (define price (get-price sku people)) + (define item (textify (sku-name sku))) + `(a ((class "checkout_clicker") + (href "#") + (item ,item) + (label ,(format "~a (~a-person license)" item people)) + (quantity ,(number->string people)) + (amount ,(number->string price))) + ,(format "$~a" price))) + (define (make-buy-grid #:people people-list #:skus sku-list) (cons (cons "" (map people->string people-list)) (map (λ(sku) (cons (sku-name sku) - (map (λ(p) `(a ((href ,(make-buy-url sku p))) ,(format "$~a" (get-price sku p)))) people-list))) sku-list))) + (map (λ(p) (buy-link sku p)) people-list))) sku-list))) (define (make-buy-table #:people people-list #:skus sku-list) diff --git a/template.html.p b/template.html.p index c608551..9cce86d 100644 --- a/template.html.p +++ b/template.html.p @@ -81,7 +81,10 @@ document.write(' +})