Created
March 16, 2009 21:02
-
-
Save tjweir/80069 to your computer and use it in GitHub Desktop.
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
object MyPayPalIPN extends PayPalIPN { | |
def actions = { | |
case (action, info, _) => { | |
val payAmt: Long = info.paymentGross match { | |
case Full(gross) => gross.roboSplit("\\.") match { | |
case whole :: fraction => println("split case");toLong(whole) * 100 + toLong(fraction) | |
case _ => println("non-split case"); toLong(info.paymentGross) | |
} | |
case _ => 0 | |
} | |
val quantity: Long = info.quantity match { | |
case Full(quantityStr) => toLong(quantityStr) | |
case _ => 0 | |
} | |
for (id <- info.custom; | |
sku <- info.itemNumber; | |
paymentCurrency <- info.paymentCurrency; | |
account <- Account.find(By(Account.uniqueId, id))) { | |
val trans = AccountTransaction.create.transactionDate(timeNow).amount(payAmt).amountCurrency(paymentCurrency).saveMe | |
AccountEntry.create.account(account).transaction(trans).SKU(sku).itemCount(quantity).entryDate(timeNow).save | |
} | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment