function successAction()
 {
     // this is the where the user is directed to when the payment provider has issued a success.
     $manager = RM_Reservation_Manager::getInstance();
     $reservationID = $manager->getReservationID();
     // update the the in_progress flag
     // this is also completed in the payment notification for the payment
     // module, but we do it here to make sure that reservations that are
     // sent to the successAction they are visible and no longer hidden.
     $model = new RM_Reservations();
     $reservation = $model->find($reservationID)->current();
     $model->inProgressComplete($reservation);
     RM_Log::toLog("InProgress Marker Updated");
     // fire the events
     RM_Notifications_Manager::getInstance()->fire('ReservationCompleteSuccessful', $manager);
     RM_Notifications_Manager::getInstance()->fire('ReservationPostbookingMessage', $manager);
     RM_Notifications_Manager::getInstance()->fire('ReservationNewReservationAlert', $manager);
     RM_Log::toLog("Reservation Complete ID: " . $reservationID);
     $content = $this->_getCompletePageContent($manager);
     if ($content === null) {
         $this->view->content = '';
     } else {
         $this->view->content = $content;
     }
     $manager->reset();
     $manager->setPaymentStatus(RM_Payments_Status::NO_TRANSACTION);
 }
示例#2
0
 public function ipnAction()
 {
     $this->_withoutView();
     $provider = new RM_Plugin_PayPal();
     $provider->validateIPN();
     RM_Log::toLog("PayPal ipnAction Called");
     if ($provider->ipnData['payment_status'] == "Completed" || $provider->ipnData['payment_status'] == "Pending") {
         RM_Log::toLog("PayPal payment status: " . $provider->ipnData['payment_status']);
         if (str_word_count($provider->ipnData['invoice'], 0, "RM-") > 0) {
             $bookingref = ltrim($provider->ipnData['invoice'], "RM-");
         } else {
             $bookingref = $provider->ipnData['invoice'];
         }
         RM_Log::toLog("Booking ref passed back from PayPal: " . $bookingref);
         $model = new RM_Reservations();
         $reservation = $model->find($bookingref)->current();
         RM_Log::toLog("Reservation Record ID: " . $reservation->id);
         $model->confirm($reservation);
         RM_Log::toLog("Confirmed Updated");
         $model->inProgressComplete($reservation);
         RM_Log::toLog("InProgress Marker Updated");
         // save the total
         // we have a problem here, when this action is called it is called
         // from the paypal.com server. The session is not the same so saving to it
         // is impossible. I think we need to pass to PayPal the 'custom' parameter
         // this could contain something like the session id, however I am not
         // sure if it's possible to update the data in a session with a session
         // id?
         //$manager = RM_Reservation_Manager::getInstance();
         $total_paid = $provider->ipnData['mc_gross'];
         RM_Log::toLog("Total Passed back from PayPal: " . $total_paid);
         //$manager->setPaymentTotal($total_paid); // save the total incase we need it later.
         //if (!$total_paid) $this->_redirect('Reservations', 'notcomplete'); // this handles if the total amount is null'd
         $billingModel = new RM_Billing();
         $billingRow = $billingModel->createRow();
         $billingRow->reservation_id = $bookingref;
         $billingRow->total_paid = $total_paid;
         $billingID = $billingRow->save();
         RM_Log::toLog("Billing Updated");
         // TODO: I can't get thsi working..
         // save the payment information
         $billingPaymentsModel = new RM_BillingPayments();
         $billingPaymentRow = $billingPaymentsModel->createRow();
         $billingPaymentRow->id = $billingID;
         $billingPaymentRow->provider = "PayPal";
         $billingPaymentRow->transaction_id = $provider->ipnData['txn_id'];
         $billingPaymentRow->status = $provider->ipnData['payment_status'];
         $billingPaymentRow->total = $provider->ipnData['mc_gross'];
         $billingPaymentRow->transaction_date = Date("Y-m-d");
         $billingPaymentRow->save();
         RM_Log::toLog("Billing Payments Updated");
         // TODO: if the IPN is successful then we need to set the in_progress flag to 0
         // this is also done in the reservation controller on success we have to do it here also
         // as it is possible the customer may not return to the site via the payment provider
         // return URL in this case the in_progress flag will never be updated that's why we
         // need to do this here also
         // I need to ask Valentin about a standard method for this.
         // TODO: we should also record other information such as the transaction id
         // however this can be added later.
     }
 }