/**
  * If $this->transactions == null, all transactions are loaded by
  * including a PHP file (see save()).
  * @return array Transactions
  */
 public static function getTransactions()
 {
     if (self::$transactions == null) {
         $fn = Yii::app()->modulePath . "/payPal/data/transactions.php";
         self::$transactions = (require $fn);
     }
     return self::$transactions;
 }
 public function ipnRequest($event)
 {
     // Check if this is a transaction
     if (!isset($event->details["txn_id"])) {
         $event->msg = "Missing txn_id";
         Yii::log($event->msg, "warning", "payPal.controllers.DefaultController");
         $event->sender->onFailure($event);
         return;
     }
     // Put payment details into a transaction model
     $transaction = new PPPhpTransaction();
     $transaction->paymentStatus = $event->details["payment_status"];
     $transaction->mcCurrency = $event->details["mc_currency"];
     $transaction->mcGross = $event->details["mc_gross"];
     $transaction->receiverEmail = $event->details["receiver_email"];
     $transaction->txnId = $event->details["txn_id"];
     // Failed to process payment: Log and invoke failure event
     if (!$transaction->save()) {
         $event->msg = "Could not process payment";
         Yii::log("{$event->msg}\nTransaction ID: {$event->details["txn_id"]}", "error", "payPal.controllers.DefaultController");
         $event->sender->onFailure($event);
     } else {
         if ($transaction->save()) {
             $event->msg = "Successfully processed payment";
             Yii::log("{$event->msg}\nTransaction ID: {$event->details["txn_id"]}", "info", "payPal.controllers.DefaultController");
             $event->sender->onSuccess($event);
         }
     }
 }