Esempio n. 1
0
 public function formAction()
 {
     $this->_withoutView();
     $bookingref = RM_Reservation_Manager::getInstance()->getReservationID();
     $billingModel = new RM_Billing();
     $billingRow = $billingModel->createRow();
     $billingRow->reservation_id = $bookingref;
     $billingRow->total_paid = '0.00';
     $billingRow->save();
     RM_Reservation_Manager::getInstance()->setPaymentTotal('0.00')->setPaymentStatus(RM_Payments_Status::TRANSACTION_END_SUCCESSFULLY);
     $this->_forward('success', 'Payments');
 }
 /**
  * Method for manual adding payment from the Admin end.
  * All params are from request.
  *
  * @param reservation_id
  * @param transaction_id - default 'ADMIN'
  * @param provider - default curent server date
  * @param total - default 0 
  * @return array
  */
 public function addpaymentJsonAction()
 {
     $reservationID = $this->_getParam('reservation_id');
     if ($reservationID == null) {
         return array('data' => array('success' => false, 'error' => RM_Environment::getInstance()->getTranslation(RM_Environment::TRANSLATE_ERRORS)->_('Admin.Reservation.Edit', 'ReservationIDMissed')));
     }
     $model = new RM_Reservations();
     $reservation = $model->find($reservationID)->current();
     if ($reservation == null) {
         return array('data' => array('success' => false, 'error' => RM_Environment::getInstance()->getTranslation(RM_Environment::TRANSLATE_ERRORS)->_('Admin.Reservation.Edit', 'WrongReservationID')));
     }
     $transactionDate = $this->_getParam('transaction_date');
     $transactionID = $this->_getParam('transaction_id', '');
     if ($transactionID == '') {
         $transactionID = 0;
     }
     $providerName = $this->_getParam('provider', '');
     if ($providerName == '') {
         $providerName = 'Administrator';
     }
     $totalPaid = $this->_getParam('total');
     $billingModel = new RM_Billing();
     $billingRow = $billingModel->createRow();
     $billingRow->reservation_id = $reservationID;
     $billingRow->total_paid = $totalPaid;
     $billingID = $billingRow->save();
     $billingPaymentsModel = new RM_BillingPayments();
     $billingPaymentRow = $billingPaymentsModel->createRow();
     $billingPaymentRow->id = $billingID;
     $billingPaymentRow->provider = $providerName;
     $billingPaymentRow->transaction_id = $transactionID;
     $billingPaymentRow->status = 'SUCCESS';
     $billingPaymentRow->total = $totalPaid;
     $billingPaymentRow->transaction_date = $transactionDate;
     $billingPaymentRow->save();
     return array('data' => array('success' => true));
 }
Esempio n. 3
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.
     }
 }
Esempio n. 4
0
 function markPaid(RM_Reservation_Row $reservation)
 {
     $totalPrice = $reservation->getTotalPrice();
     $billingModel = new RM_Billing();
     $totalPaid = $billingModel->getPaymentsTotal($reservation);
     $total = $totalPrice - $totalPaid;
     $billingID = $billingModel->createRow(array('reservation_id' => $reservation->id, 'total_paid' => $total))->save();
     $billingPaymentsModel = new RM_BillingPayments();
     $billingPaymentsModel->createRow(array('id' => $billingID, 'provider' => 'Administrator', 'transaction_id' => '0', 'status' => 'success', 'total' => $total, 'transaction_date' => date('Y-m-d H:i:s')))->save();
     $this->confirm($reservation);
 }