Example #1
0
 /**
  *
  *
  *
  *
  * @return Bill bill for given booker
  */
 public function getBillForBooker($booker)
 {
     $channel = 'ecommerce';
     if ($booker instanceof FlightBookerComponent) {
         $booker = $booker->getCurrent();
     }
     if ($booker instanceof FlightBooker) {
         if ($booker->flightVoyage->webService == 'SABRE') {
             $channel = $booker->flightVoyage->valAirline->payableViaSabre ? 'gds_sabre' : 'ltr';
             $channel = 'ltr';
         }
         if ($booker->flightVoyage->webService == 'GALILEO') {
             $channel = $booker->flightVoyage->valAirline->payableViaGalileo ? 'gds_galileo' : 'ltr';
         }
     }
     if ($booker->billId) {
         return Bill::model()->findByPk($booker->billId);
     }
     $bill = new Bill();
     $bill->setChannel($channel);
     $bill->status = Bill::STATUS_NEW;
     $bill->amount = $booker->price;
     $bill->save();
     $booker->billId = $bill->id;
     $booker->save();
     return $bill;
 }
Example #2
0
 public function loadModel($id)
 {
     $model = Bill::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Example #3
0
 public function run()
 {
     if ($this->failure) {
         $method = 'FailureCallback';
     } else {
         $method = 'SuccessCallback';
     }
     $this->logEntry = PaymentLog::forMethod($method);
     $this->logEntry->request = '{"callback":1}';
     $this->logEntry->response = json_encode($_REQUEST);
     if (isset($_REQUEST['TransactionID'])) {
         $this->logEntry->transactionId = $_REQUEST['TransactionID'];
     }
     if (isset($_REQUEST['OrderId'])) {
         $this->logEntry->orderId = $_REQUEST['OrderId'];
     }
     $this->logEntry->save();
     foreach ($this->keys as $key) {
         if (!isset($_REQUEST[$key])) {
             $e = new RequestError("{$key} not found.");
             $this->handleException($e);
             return;
         }
         $params[$key] = $_REQUEST[$key];
     }
     $parts = explode('-', $params['OrderId']);
     if (count($parts) < 2) {
         $e = new RequestError("Wrong OrderId format: " . $params['OrderId']);
         $this->handleException($e);
         return;
     }
     list($orderId, $billId) = $parts;
     $bill = Bill::model()->findByPk($billId);
     $channel = $bill->getChannel();
     $sign = $channel->getSignature($params);
     if ($sign != $params['SecurityKey']) {
         $e = new SignatureError("Signature mismatch actual: " . $params['SecurityKey'] . ". Expected: " . $sign . ".");
         $this->handleException($e);
         //            return;
     }
     $booker = $channel->booker;
     if ($booker instanceof FlightBooker) {
         $booker = new FlightBookerComponent();
         $booker->setFlightBookerFromId($channel->booker->id);
     }
     // Hoteles are allways wrapped into metabooker
     //FIXME logme
     #        if($this->getStatus($booker)=='paid')
     #            return;
     if ($this->getStatus($booker) == 'paymentInProgress') {
         return;
     }
     $this->logEntry->startProfile();
     $this->handle($bill, $booker, $channel, $orderId);
     $this->logEntry->finishProfile();
     $this->logEntry->save();
 }
 public function actionConfirmBill($billId)
 {
     $bill = Bill::model()->findByPk($billId);
     if (!$bill->getChannel()->confirm()) {
         die("FIALED");
     }
     $this->redirect(array('view', 'id' => $bill->getChannel()->getOrderBookingId()));
 }