コード例 #1
0
ファイル: admin.php プロジェクト: adrianlinner333/laravel-5
 /**
  * Action remove all the customers DIRECT mode
  */
 public function actionDeleteAllCustomers()
 {
     HelperCommon::clearStore('account');
     $sagepayToken = new SagepayToken($this->sagepayConfig);
     $cardTokens = ModelAbstract::factory('Card')->getAll();
     foreach ($cardTokens as $card) {
         $sagepayToken->remove($card->token);
     }
     $view = new HelperView('admin/deleted');
     $view->setData(array('env' => $this->sagepayConfig->getEnv(), 'vendorName' => $this->sagepayConfig->getVendorName(), 'integrationType' => $this->integrationType, 'numDeleted' => ModelAbstract::factory('Customer')->deleteAll()));
     $view->render();
 }
コード例 #2
0
 /**
  * Action to view basket page
  */
 public function actionBasket()
 {
     $this->checkAccount();
     $message = '';
     $selectedProducts = array();
     // Check if form was submitted
     if (count(filter_input_array(INPUT_POST))) {
         $selectedProducts = array();
         // Fill selected product from request
         foreach (array_keys(filter_input_array(INPUT_POST)) as $key) {
             $matches = array();
             if (preg_match('/^quantity([0-9]*)$/', $key, $matches) && isset($matches[1])) {
                 $selectedProducts[$matches[1]] = filter_input(INPUT_POST, $key, FILTER_VALIDATE_FLOAT);
             }
         }
         HelperCommon::clearStore('products');
         // Check if was select at least 1 item
         if ($this->checkProducts($selectedProducts)) {
             HelperCommon::setStore('products', $selectedProducts);
             $this->redirect($this->integrationType, $this->integrationType == SAGEPAY_DIRECT ? 'basket_checkout' : 'details');
         } else {
             $this->error = true;
             $message = 'You did not select any items to buy. Please select at least 1 item.';
         }
     }
     $productsRows = ModelAbstract::factory('Product')->getAll();
     // Create list of products for view
     $products = array();
     foreach ($productsRows as $row) {
         $products[] = array('id' => $row->id, 'title' => $row->title, 'price' => $row->price, 'tax' => $row->tax, 'image' => $row->image);
     }
     // Render view basket
     $view = new HelperView('common/basket');
     $view->setData(array('actionUrl' => url(array($this->integrationType, 'basket')), 'backUrl' => $this->integrationType == SAGEPAY_FORM ? url(array('form')) : url(array($this->integrationType, 'welcome')), 'message' => $message, 'error' => $this->error, 'products' => $products, 'selectedProducts' => $selectedProducts, 'env' => $this->sagepayConfig->getEnv(), 'vendorName' => $this->sagepayConfig->getVendorName(), 'currency' => $this->sagepayConfig->getCurrency(), 'integrationType' => $this->integrationType));
     $view->render();
 }
コード例 #3
0
ファイル: direct.php プロジェクト: adrianlinner333/laravel-5
 /**
  * Action card page for direct payment
  */
 public function actionCard()
 {
     $message = '';
     // Check if form was submitted
     if (count(filter_input_array(INPUT_POST))) {
         $useToken = filter_input(INPUT_POST, 'useToken');
         $giftAid = filter_input(INPUT_POST, 'giftAid');
         $card = array('cardType' => filter_input(INPUT_POST, 'cardType'), 'cardNumber' => filter_input(INPUT_POST, 'cardNumber'), 'cardHolder' => filter_input(INPUT_POST, 'cardHolder'), 'startDate' => filter_input(INPUT_POST, 'startDate'), 'expiryDate' => filter_input(INPUT_POST, 'expiryDate'), 'cv2' => filter_input(INPUT_POST, 'cv2'), 'giftAid' => !!$giftAid);
         $cardDetails = new SagepayCardDetails();
         $this->_populateCardDetails($cardDetails, $card);
         // Check cardType
         if ($card['cardType'] == 'PAYPAL') {
             $errors = array();
         } else {
             $errors = $cardDetails->validate();
         }
         $hMessage = new HelperMessage();
         $message = $hMessage->getAllMessages($errors, array('cardNumber' => 'Card Number', 'cardHolder' => 'Card Holder Name', 'startDate' => 'Start Date', 'expiryDate' => 'Expiry Date', 'cv2' => 'Card Verification Value'));
         // Check if card data was failed
         if ($errors) {
             $this->error = true;
             $message = "Sorry, the following problems were found: " . $message;
         } else {
             if ($useToken) {
                 $account = HelperCommon::getStore('account');
                 $sagepayToken = new SagepayToken($this->sagepayConfig);
                 $token = $sagepayToken->register($card);
                 if (!$token) {
                     $this->helperError('Card Details are invalid ', url(array('direct', 'card')));
                     exit;
                 }
                 ModelAbstract::factory('Card')->insert(array('last4digits' => SagepayUtil::getLast4Digits(filter_input(INPUT_POST, 'cardNumber')), 'token' => $token, 'customer_id' => $account['id']));
                 $account['token'] = $token;
                 HelperCommon::setStore('account', $account);
                 $card = array('cardType' => '', 'cardNumber' => '', 'cardHolder' => '', 'startDate' => '', 'expiryDate' => '', 'cv2' => filter_input(INPUT_POST, 'cv2'), 'giftAid' => $giftAid);
             }
             HelperCommon::setStore('card', $card);
             $this->redirect('direct', 'confirm');
         }
     }
     // render view card
     $view = new HelperView('direct/card');
     $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();
 }