/** * Action entry Login/Register page */ public function actionEntry() { $message = ''; // Check if was logged if (HelperCommon::getStore('account')) { $this->redirect($this->integrationType, 'basket'); } // Check if form was submitted if (count(filter_input_array(INPUT_POST))) { HelperCommon::clearStore('account'); $rules = array('email' => array(array('notEmpty'), array('maxLength', array(255)), array('email')), 'password' => array(array('notEmpty'), array('maxLength', array(255)))); $data = array('email' => filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL), 'password' => filter_input(INPUT_POST, 'password')); $errors = $this->validate($rules, $data); $hMessage = new HelperMessage(); $message = $hMessage->getAllMessages($errors, array('email' => 'Email', 'password' => 'Password')); // Check if login was failed if (!$errors) { $password = md5($this->sagepayConfig->getCustomerPasswordSalt() . filter_input(INPUT_POST, 'password')); $customerId = $this->checkCustomer(filter_input(INPUT_POST, 'email'), $password); if (!$customerId !== 0) { HelperCommon::setStore('account', array('email' => filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL), 'password' => $password, 'id' => $customerId)); $this->redirect($this->integrationType, 'basket'); } else { $this->error = true; $message = 'Login failed'; } } else { $this->error = true; $message = "Sorry, the following problems were found: " . $message; } } $current = array('email' => '', 'password' => ''); if (filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL)) { $current['email'] = filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL); } // render entry tpl $view = new HelperView('server-and-direct/entry'); $view->setData(array('env' => $this->sagepayConfig->getEnv(), 'vendorName' => $this->sagepayConfig->getVendorName(), 'integrationType' => false, 'controller' => $this->integrationType, 'current' => $current, 'error' => $this->error, 'message' => $message)); $view->render(); }
/** * Save extra data to session * * @param string $redirectQ * * @param string $redirectP * * @return string */ protected function saveExtra($redirectQ, $redirectP) { $message = ''; if (count(filter_input_array(INPUT_POST))) { $type = null; $extra = array(); $extraTypes = array('cruise' => 'cruise', 'hotel' => 'hotel', 'tour' => 'tourOperator', 'car' => 'carRental'); $extraName = filter_input(INPUT_POST, 'extra'); // Check extra type if (isset($extraTypes[$extraName])) { $type = $extraTypes[$extraName]; } $errors = false; if (!empty($type)) { $extraFrom = filter_input(INPUT_POST, $extraName . 'From'); $extraTo = filter_input(INPUT_POST, $extraName . 'To'); $extra[$type] = array(); $extra[$type]['checkIn'] = $extraFrom && strtotime($extraFrom) ? date("Y-m-d", strtotime($extraFrom)) : $extraFrom; $extra[$type]['checkOut'] = $extraTo && strtotime($extraTo) ? date("Y-m-d", strtotime($extraTo)) : $extraTo; if ($type === 'hotel') { $extra[$type]['numberInParty'] = filter_input(INPUT_POST, 'numberInParty'); $extra[$type]['guestName'] = filter_input(INPUT_POST, 'guestName'); $extra[$type]['folioRefNumber'] = filter_input(INPUT_POST, 'referenceNumber'); $extra[$type]['confirmedReservation'] = !!filter_input(INPUT_POST, 'confirmedReservation') ? 'Y' : 'N'; $extra[$type]['dailyRoomRate'] = filter_input(INPUT_POST, 'roomRate'); } $rules = $this->extraInformationRules($type); $errors = $this->validate($rules, $extra[$type]); } // Check collect recipient details if ($this->sagepayConfig->getCollectRecipientDetails()) { $extra['fiRecipientAcctNumber'] = filter_input(INPUT_POST, 'fiRecipientAcctNumber'); $extra['fiRecipientDob'] = filter_input(INPUT_POST, 'fiRecipientDob'); $extra['fiRecipientPostCode'] = filter_input(INPUT_POST, 'fiRecipientPostCode'); $extra['fiRecipientSurname'] = filter_input(INPUT_POST, 'fiRecipientSurname'); $fiRecipientRules = $this->recipientDetailsRules(); $fiRecipientErrors = $this->validate($fiRecipientRules, $extra); if ($fiRecipientErrors) { $errors = $errors ? $errors + $fiRecipientErrors : $fiRecipientErrors; } } // Check if extra information was failed if (!$errors) { HelperCommon::setStore('extra', $extra); $this->redirect($redirectQ, $redirectP); } else { $hMessage = new HelperMessage(); $message = $hMessage->getAllMessages($errors, array('checkIn' => 'Check In', 'checkOut' => 'Check Out', 'numberInParty' => 'Number In Party', 'guestName' => 'Guest Name', 'folioRefNumber' => 'Reference Number', 'dailyRoomRate' => 'Room Rate', 'fiRecipientAcctNumber' => 'Account number', 'fiRecipientDob' => 'Date of birth', 'fiRecipientPostCode' => 'Post code', 'fiRecipientSurname' => 'Surname')); $this->error = true; $message = "Sorry, the following problems were found: " . $message; } } return $message; }
/** * Validation for action authorise the transaction * * @param array $oldData * @param array $newData * * @return string Returns a String with all messages. */ public function validateAuthoriseAction($oldData, $newData) { $errors = $this->validate($this->_rules, $newData); $message = ''; // Check if authorise was failed if ($errors) { $hMessage = new HelperMessage(); $message = $hMessage->getAllMessages($errors, array('VendorTxCode' => 'Authorise VendorTxCode', 'Description' => 'Authorise Description', 'Amount' => 'Authorise Amount', 'ApplyAVSCV2' => 'ApplyAVSCV2')); } if ($oldData['cardType'] == 'MAESTRO') { $maxAmount = $oldData['amount']; } else { $maxAmount = $oldData['amount'] * 1.15; } if ($oldData['capturedAmount'] + $newData['Amount'] > $maxAmount) { $currentMaxAmount = $maxAmount - $oldData['capturedAmount']; $message = $message ? $message . ', ' : ''; $message .= 'Authorise Amount is out of range, must be less than ' . number_format($currentMaxAmount, 2) . '.'; } return $message; }
/** * Action card token page for direct payment */ public function actionCardToken() { $message = ''; // Check if form was submitted if (count(filter_input_array(INPUT_POST))) { $giftAid = !!filter_input(INPUT_POST, 'giftAid'); $rules = array('cv2' => array(array('notEmpty'))); $card = array('cardType' => '', 'cardNumber' => '', 'cardHolder' => '', 'startDate' => '', 'expiryDate' => '', 'cv2' => filter_input(INPUT_POST, 'cv2'), 'giftAid' => $giftAid); $errors = $this->validate($rules, $card); $hMessage = new HelperMessage(); $message = $hMessage->getAllMessages($errors, array('cv2' => 'Card Verification Value')); // Check if card token was failed if ($errors) { $this->error = true; $message = "Sorry, the following problems were found: " . $message; } else { HelperCommon::setStore('card', $card); $this->redirect('direct', 'confirm'); } } // render view card token $view = new HelperView('direct/card_token'); $view->setData(array('env' => $this->sagepayConfig->getEnv(), 'vendorName' => $this->sagepayConfig->getVendorName(), 'integrationType' => $this->integrationType, 'error' => $this->error, 'message' => $message, 'allowGiftAid' => $this->sagepayConfig->getAllowGiftAid())); $view->render(); }