bitcoin-atm
bitcoin atm for pyc inc.
git clone https://9o.is/git/bitcoin-atm.git
Receipt.scala
(1231B)
1 package inc.pyc.chimera
2 package minions
3
4 import xml._
5 import akka.actor._
6 import net.liftweb._
7 import http._
8 import common._
9 import util._
10 import Helpers._
11 import System._
12
13 /**
14 * Email transaction receipt.
15 */
16 class ReceiptMinion
17 extends Actor
18 with ActorLogging
19 with Minion {
20
21 val tasks: Receive = {
22 case (email: Email, tx: CompleteTx) => send(email, tx)
23 }
24
25 /**
26 * Creates Transaction Receipt HTML message.
27 */
28 def create(tx: CompleteTx): Box[NodeSeq] = {
29 Templates("templates-hidden" :: "email" :: "receipt" :: Nil) map {
30 ".txid" #> tx.txid &
31 ".txaddress" #> tx.address &
32 ".txbtc" #> tx.bitcoins &
33 ".txpurchase" #> tx.prettyTotal &
34 ".txdate" #> tx.prettyDate &
35 ".txtime" #> tx.prettyTime &
36 ".txlocation" #> Settings(system).name &
37 "#twitter-link [href]" #> Settings(system).twitter &
38 "#facebook-link [href]" #> Settings(system).facebook &
39 "#gplus-link [href]" #> Settings(system).gplus
40 }
41 }
42
43 /**
44 * Sends email.
45 */
46 def send(email: Email, tx: CompleteTx): Unit = {
47 create(tx) foreach {
48 html =>
49 lib.Mailer(email.data,
50 "PYC Transaction Receipt", html.toString)
51 }
52 }
53 }