public function __construct($bookers, $base, $billId)
 {
     $this->bookers = array();
     if ($base instanceof FlightBooker) {
         $bookerComp = new FlightBookerComponent();
         $bookerComp->setFlightBookerFromId($base->id);
         $base = $bookerComp;
     }
     $this->base = $base;
     foreach ($bookers as $booker) {
         if ($booker instanceof FlightBooker) {
             $bookerComp = new FlightBookerComponent();
             $bookerComp->setFlightBookerFromId($booker->id);
             $this->bookers[] = $bookerComp;
         } elseif ($booker instanceof HotelBooker) {
             $bookerComp = new HotelBookerComponent();
             $bookerComp->setHotelBookerFromId($booker->id);
             $this->bookers[] = $bookerComp;
         } else {
             $this->bookers[] = $booker;
         }
     }
     $this->_billId = $billId;
     if ($billId) {
         $this->setBillId($billId);
     }
 }
Exemple #2
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();
 }
 private function createFlightBookerWorkflow()
 {
     Yii::trace("Create FlightBooker", "FlightTripElementWorkflow.createFlightBookerWorkflow");
     $flightBookerComponent = new FlightBookerComponent();
     $flightBookerComponent->setFlightBookerFromFlightVoyage($this->item->flightVoyage, $this->item->searchParams);
     $currentFlightBookerComponent = $flightBookerComponent->getCurrent();
     $currentFlightBookerComponent->orderBookingId = self::$bookingContactInfo->id;
     if (!$currentFlightBookerComponent->save()) {
         $errMsg = "Could not save FlightBooker" . PHP_EOL . CVarDumper::dumpAsString($currentFlightBookerComponent->getErrors());
         $this->logAndThrowException($errMsg, 'OrderComponent.saveCredentialsForFlight');
     }
     Yii::trace("FlightBooker saved. FlighBooker id is " . $currentFlightBookerComponent->getPrimaryKey(), "OrderComponent.saveCredentialsForFlight");
     return $flightBookerComponent;
 }
 public function getBookers()
 {
     $bookerIds = $this->getBookerIds();
     if (!$bookerIds) {
         throw new Exception("No bookers availiable");
     }
     $bookers = array();
     foreach ($bookerIds as $entry) {
         if ($entry['type'] == 'avia') {
             $flightBookerComponent = new FlightBookerComponent();
             $flightBookerComponent->setFlightBookerFromId($entry['bookerId']);
             $bookers[] = $flightBookerComponent;
         } else {
             if ($entry['type'] == 'hotel') {
                 $hotelBookerComponent = new HotelBookerComponent();
                 $hotelBookerComponent->setHotelBookerFromId($entry['bookerId']);
                 $bookers[] = $hotelBookerComponent;
             } else {
                 throw new Exception("Unexpected segment type");
             }
         }
     }
     return $bookers;
 }
 public function actionInjectTicketNumbers($bookingId)
 {
     $booking = new FlightBookerComponent();
     $booking->setFlightBookerFromId($bookingId);
     foreach ($_POST['tickets'] as $passId => $ticket) {
         $pass = FlightBookingPassport::model()->findByPk($passId);
         $pass->ticketNumber = $ticket;
         $pass->save();
     }
     $flightVoyage = $booking->getCurrent()->flightVoyage;
     foreach ($_POST['terminal'] as $fvkey => $value) {
         foreach ($value as $fkey => $terminalCode) {
             if ($terminalCode) {
                 $flightVoyage->flights[$fvkey]->flightParts[$fkey]->departureTerminalCode = $terminalCode;
             }
         }
     }
     //! force serialization, save will be called on later status change
     $booking->getCurrent()->flightVoyage = $flightVoyage;
     //! Fixme leave 1-2 steps max
     $booking->status('manualProcessing');
     $booking->status('manualTicketing');
     $booking->status('manualSuccess');
     $this->redirect(array('view', 'id' => $booking->getCurrent()->orderBookingId));
 }