-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
69174ab
commit dadad5b
Showing
8 changed files
with
126 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
module FreyaMusicStore.Checkout | ||
|
||
open Arachne.Http | ||
|
||
open Freya.Core | ||
open Freya.Lenses.Http | ||
open Freya.Machine | ||
open Freya.Machine.Extensions.Http | ||
open Freya.Router | ||
|
||
let ok _ = | ||
freya { | ||
return! writeHtml ("checkout", () ) | ||
} | ||
|
||
let post = | ||
freya { | ||
let ctx = Db.getContext() | ||
let! a = getAuthResult | ||
let userName = userName a.Value | ||
Db.placeOrder userName ctx | ||
} | ||
|
||
let seeOther _ = | ||
freya { | ||
return! writeHtml ("checkoutComplete", () ) | ||
} | ||
|
||
let onUnauthorized _ = | ||
freya { | ||
return! writeHtml ("logon", {Logon.Logon.ReturnUrl = Uris.checkout; Logon.Logon.ValidationMsg = ""}) | ||
} | ||
|
||
let pipe = | ||
freyaMachine { | ||
including common | ||
authorized isLoggedOn | ||
handleUnauthorized onUnauthorized | ||
methodsSupported ( freya { return [ GET; POST ] } ) | ||
postRedirect (Freya.init true) | ||
handleSeeOther seeOther | ||
handleOk ok | ||
doPost post } |> FreyaMachine.toPipeline |
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
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 @@ | ||
@using FreyaMusicStore | ||
@{ | ||
Layout = "mylayout"; | ||
} | ||
|
||
@section Main | ||
{ | ||
<form method="POST" action="@Uris.checkout"> | ||
<h2>Address And Payment</h2> | ||
<fieldset> | ||
<legend>Shipping Information</legend> | ||
|
||
<div class="editor-label">Address</div> | ||
<div class="editor-field"> | ||
<input type="text" name="Address" /> | ||
</div> | ||
|
||
<div class="editor-label">Phone</div> | ||
<div class="editor-field"> | ||
<input type="text" name="Phone" /> | ||
</div> | ||
|
||
<div class="editor-label">Street</div> | ||
<div class="editor-field"> | ||
<input type="text" name="Street" /> | ||
</div> | ||
|
||
</fieldset> | ||
<fieldset> | ||
<legend>Payment</legend> | ||
<p>We're running a promotion: all music is free with the promo code: "FREE"</p> | ||
|
||
<div class="editor-label">Promo Code</div> | ||
<div class="editor-field"> | ||
<input type="text" name="PromoCode" /> | ||
</div> | ||
</fieldset> | ||
|
||
<input type="submit" value="Submit Order" /> | ||
|
||
</form> | ||
} |
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,17 @@ | ||
@using FreyaMusicStore | ||
@{ | ||
Layout = "mylayout"; | ||
} | ||
|
||
@section Main | ||
{ | ||
|
||
<h2>Checkout Complete</h2> | ||
|
||
<p>Thanks for your order!</p> | ||
|
||
<p> | ||
How about shopping for some more music in our <a href="@Uris.home">store</a>? | ||
</p> | ||
|
||
} |