示例#1
0
 /**
  * Sets the shopware cache headers
  */
 public function setControllerOptions()
 {
     $controllerName = $this->request->getModuleName() . '/' . $this->request->getControllerName();
     if(isset($this->controllerOptions[$controllerName]) && $this->request->getParam('rewriteUrl')) {
         $options = $this->controllerOptions[$controllerName];
         $query = $this->request->getQuery();
         $result = array_intersect_key($query, $options);
         $cookie = 'controller-options-'
             . $this->request->getBaseUrl()
             . $this->request->getPathInfo();
         if(count($result) > 0) {
             $options = $this->request->getCookie($cookie);
             if($options !== null) {
                 parse_str($options, $options);
             } else {
                 $options = array();
             }
             $options = array_merge($options, $result);
             ksort($options);
             $options = http_build_query($options, '', '&');
             $this->response->setCookie(
                 $cookie, $options, 0,
                 null, //$this->request->getBasePath() . '/',
                 $this->request->getHttpHost()
             );
             $location = array_diff($query, $result);
             $location = $this->action->Front()->Router()->assemble($location);
             $this->action->redirect($location);
         } else {
             $options = $this->request->getCookie($cookie);
             if($options !== null) {
                 parse_str($options, $options);
                 $this->request->setQuery($options);
             }
         }
     }
 }
 /**
  * @param ControllerAction $action
  */
 public function onPaypalPlus(ControllerAction $action)
 {
     $config = $this->config;
     $router = $action->Front()->Router();
     $view = $action->View();
     $user = $view->getAssign('sUserData');
     $basket = $view->getAssign('sBasket');
     $cancelUrl = $router->assemble(array('controller' => 'payment_paypal', 'action' => 'cancel', 'forceSecure' => true));
     $returnUrl = $router->assemble(array('controller' => 'payment_paypal', 'action' => 'return', 'forceSecure' => true));
     $profile = $this->getProfile();
     $this->restClient->setAuthToken();
     $uri = 'payments/payment';
     $params = array('intent' => 'sale', 'experience_profile_id' => $profile['id'], 'payer' => array('payment_method' => 'paypal'), 'transactions' => $this->getTransactionData($basket, $user), 'redirect_urls' => array('return_url' => $returnUrl, 'cancel_url' => $cancelUrl));
     $payment = $this->restClient->create($uri, $params);
     if (!empty($payment['links'][1]['href'])) {
         $view->assign('PaypalPlusApprovalUrl', $payment['links'][1]['href']);
         $view->assign('PaypalPlusModeSandbox', $config->get('paypalSandbox'));
         $view->assign('PaypalLocale', $this->paypalBootstrap->getLocaleCode());
         $db = $this->bootstrap->get('db');
         $sql = 'SELECT paymentmeanID AS id, paypal_plus_media AS media
                 FROM s_core_paymentmeans_attributes WHERE paypal_plus_active = 1';
         $paymentMethods = $db->fetchAssoc($sql);
         $view->assign('PaypalPlusThirdPartyPaymentMethods', $paymentMethods);
         $this->session->PaypalPlusPayment = $payment['id'];
     }
 }
 /**
  * @param Controller $controller
  */
 private function onPaypalPlus(Controller $controller)
 {
     $router = $controller->Front()->Router();
     $view = $controller->View();
     $cancelUrl = $router->assemble(array('controller' => 'payment_paypal', 'action' => 'cancel', 'forceSecure' => true));
     $returnUrl = $router->assemble(array('controller' => 'payment_paypal', 'action' => 'return', 'forceSecure' => true));
     $profile = $this->getProfile();
     $uri = 'payments/payment';
     $params = array('intent' => 'sale', 'experience_profile_id' => $profile['id'], 'payer' => array('payment_method' => 'paypal'), 'transactions' => $this->getTransactionData($view->getAssign('sBasket'), $view->getAssign('sUserData')), 'redirect_urls' => array('return_url' => $returnUrl, 'cancel_url' => $cancelUrl));
     $payment = array();
     try {
         $payment = $this->restClient->create($uri, $params);
     } catch (Exception $e) {
         $this->logException('An error occurred on creating a payment', $e);
     }
     if (!empty($payment['links'][1]['href'])) {
         $view->assign('PaypalPlusApprovalUrl', $payment['links'][1]['href']);
         $view->assign('PaypalPlusModeSandbox', $this->config->get('paypalSandbox'));
         $view->assign('PaypalLocale', $this->paypalBootstrap->getLocaleCode());
         $this->session->PaypalPlusPayment = $payment['id'];
     }
 }