/** * End the current session and clear local session * @return void */ public function endSession() { $session = CheckfrontModule::session(); if ($sessionID = $session->getID()) { CheckfrontModule::api()->post(new CheckfrontAPIRequest('session/end', array('session_id' => $sessionID))); } $session->clear(null); }
/** * Add package to the current checkfront session. * * @param CheckfrontPackageModel $package * @param array $addOrUpdateParams * @return CheckfrontAPIResponse */ public function addPackageToSession(CheckfrontPackageModel $package, array $addOrUpdateParams = array()) { $params = array_merge(array('session_id' => CheckfrontModule::session()->getID()), $package->toCheckfront('booking/session'), $addOrUpdateParams); $response = new CheckfrontAPIResponse($this()->post(new CheckfrontAPIRequest('booking/session', $params))); return $response; }
public function makeBooking(CheckfrontBookingModel $booking) { $sessionID = CheckfrontModule::session()->getID(); $params = array_merge(array('session_id' => $sessionID), $booking->toCheckfront('booking/create')); return new CheckfrontAPIBookingResponse($this()->api(new CheckfrontAPIRequest('booking/create', $params))); }
/** * Override empty parent to store the session ID and data in CheckfrontSession. * @param $sessionID * @param array $data */ public function session($sessionID, $data = array()) { CheckfrontModule::session()->setID($sessionID)->setData('request', $data); parent::session($sessionID, $data); }
/** * Returns a simple form where user can enter the access key they have been provided. * Form will post back to the request url. * * @param SS_HTTPRequest $request * * @return array - CheckfrontForm => CheckfrontAccessKeyForm instance */ protected function buildAccessKeyForm(SS_HTTPRequest $request) { CheckfrontModule::session()->clear(null); $form = new CheckfrontAccessKeyForm($this->owner, '', new FieldList(), new FieldList()); $form->setFormAction('/' . $this->owner->getRequest()->getURL()); return array(self::FormName => $form); }