Skip to content

Instantly share code, notes, and snippets.

@tjweir
Created March 16, 2009 21:02
Show Gist options
  • Save tjweir/80069 to your computer and use it in GitHub Desktop.
Save tjweir/80069 to your computer and use it in GitHub Desktop.
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