/**
  * AJAX action called from creditcard layer, saves client api response
  */
 public function savePseudoCardAction()
 {
     $this->Front()->Plugins()->ViewRenderer()->setNoRender();
     $userId = Shopware()->Session()->sUserId;
     $paymentData['mopt_payone__cc_truncatedcardpan'] = $this->Request()->getPost('mopt_payone__cc_truncatedcardpan');
     $paymentData['mopt_payone__cc_pseudocardpan'] = $this->Request()->getPost('mopt_payone__cc_pseudocardpan');
     $paymentData['mopt_payone__cc_cardtype'] = $this->Request()->getPost('mopt_payone__cc_cardtype');
     $paymentData['mopt_payone__cc_accountholder'] = $this->Request()->getPost('mopt_payone__cc_accountholder');
     $paymentData['mopt_payone__cc_month'] = $this->Request()->getPost('mopt_payone__cc_month');
     $paymentData['mopt_payone__cc_year'] = $this->Request()->getPost('mopt_payone__cc_year');
     $paymentData['mopt_payone__cc_paymentname'] = $this->Request()->getPost('mopt_payone__cc_paymentname');
     $paymentData['mopt_payone__cc_paymentid'] = $this->Request()->getPost('mopt_payone__cc_paymentid');
     $paymentData['mopt_payone__cc_paymentdescription'] = $this->Request()->getPost('mopt_payone__cc_paymentdescription');
     $actualPaymentId = $paymentData['mopt_payone__cc_paymentid'];
     $sql = 'replace into `s_plugin_mopt_payone_payment_data`' . '(`userId`,`moptPaymentData`) values (?,?)';
     $paymentData = serialize($paymentData);
     Shopware()->Db()->query($sql, array($userId, $paymentData));
     $previousPayment = $this->admin->sGetUserData();
     $previousPayment = $previousPayment['additional']['user']['paymentID'];
     $previousPayment = $this->admin->sGetPaymentMeanById($previousPayment);
     if ($previousPayment['paymentTable']) {
         $deleteSQL = 'DELETE FROM ' . $previousPayment['paymentTable'] . ' WHERE userID=?';
         Shopware()->Db()->query($deleteSQL, array(Shopware()->Session()->sUserId));
     }
     $sqlPayment = "UPDATE s_user SET paymentID = ? WHERE id = ?";
     Shopware()->Db()->query($sqlPayment, array($actualPaymentId, $userId));
 }
Example #2
0
 /**
  * @covers sAdmin::sGetPremiumShippingcosts
  */
 public function testsGetPremiumShippingcosts()
 {
     // No basket, return false,
     $this->assertFalse($this->module->sGetPremiumShippingcosts());
     $countries = $this->module->sGetCountryList();
     foreach ($countries as $country) {
         if ($country['countryiso']) {
             $germany = $country;
             break;
         }
     }
     $this->module->sSYSTEM->sSESSION_ID = uniqid();
     $this->session->offsetSet('sessionId', $this->module->sSYSTEM->sSESSION_ID);
     $this->basketModule->sAddArticle('SW10010');
     // With country data, no dispatch method
     $this->assertEquals(array('brutto' => 0, 'netto' => 0), $this->module->sGetPremiumShippingcosts($germany));
     // With dispatch method
     $this->session->offsetSet('sDispatch', 9);
     $result = $this->module->sGetPremiumShippingcosts($germany);
     $this->assertArrayHasKey('brutto', $result);
     $this->assertArrayHasKey('netto', $result);
     $this->assertArrayHasKey('value', $result);
     $this->assertArrayHasKey('factor', $result);
     $this->assertArrayHasKey('surcharge', $result);
     $this->assertArrayHasKey('tax', $result);
 }
 /**
  * @param \Enlight_Controller_ActionEventArgs $args
  * @return bool
  */
 public function onPaypalPlusRedirect($args)
 {
     $action = $args->getSubject();
     $request = $action->Request();
     $selectPaymentId = (int) $request->get('selectPaymentId');
     $request->setPost('sPayment', $selectPaymentId);
     $checkData = $this->admin->sValidateStep3();
     if (!empty($checkData['checkPayment']['sErrorMessages']) || empty($checkData['sProcessed'])) {
         $action->forward('payment', 'account', 'frontend', array('ppplusRedirect' => 1));
         return true;
     } else {
         $this->admin->sUpdatePayment();
     }
     $action->forward('confirm', 'checkout', 'frontend', array('ppplusRedirect' => 1));
     return true;
 }
 /**
  * Shows the reset password form and triggers password reset on submit
  */
 public function resetPasswordAction()
 {
     $hash = $this->Request()->getParam('hash', null);
     $newPassword = $this->Request()->getParam('password', null);
     $passwordConfirmation = $this->Request()->getParam('passwordConfirmation', null);
     $this->View()->assign('hash', $hash);
     if (!$this->Request()->isPost()) {
         return;
     }
     list($errors, $errorMessages) = $this->validatePasswordResetForm($hash, $newPassword, $passwordConfirmation);
     $customerModel = null;
     if (empty($errors)) {
         try {
             $customerModel = $this->resetPassword($hash, $newPassword);
         } catch (\Exception $e) {
             $errorMessages[] = $e->getMessage();
         }
     }
     if (!empty($errorMessages)) {
         $this->View()->assign('sErrorFlag', $errors);
         $this->View()->assign('sErrorMessages', $errorMessages);
         return;
     }
     // Perform a login for the user and redirect him to his account
     $this->admin->sSYSTEM->_POST['email'] = $customerModel->getEmail();
     $this->admin->sLogin();
     $target = $this->Request()->getParam('sTarget', 'account');
     $this->redirect(array('controller' => $target, 'action' => 'index', 'success' => 'resetPassword'));
 }
Example #5
0
	/**
	 * Login account by ajax request
	 */
	public function ajaxLoginAction()
	{
		Enlight()->Plugins()->Controller()->Json()->setPadding();

        // Fix same origin miss match
        $response = $this->Response();
        $shop = Shopware()->Shop();
        if ($shop->getSecure()) {
            $response->setHeader(
                'Access-Control-Allow-Origin',
                'http://' . $shop->getHost()
            );
            $response->setHeader(
                'Access-Control-Allow-Methods', 'POST, GET'
            );
            $response->setHeader(
                'Access-Control-Allow-Credentials', 'true'
            );
        }

		if($this->admin->sCheckUser()) {
			return $this->View()->setTemplate();
		}

		if(!$this->Request()->getParam('accountmode')) {
			return;
		}

		if (empty(Shopware()->Session()->sRegister)) {
			Shopware()->Session()->sRegister = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS);
		}

		$this->admin->sSYSTEM->_POST = array();
		$this->admin->sSYSTEM->_POST['email'] = $this->Request()->getParam('email');
		$this->admin->sSYSTEM->_POST['password'] = $this->Request()->getParam('password');

		if($this->Request()->getParam('accountmode')==0 || $this->Request()->getParam('accountmode')==1) {
			Shopware()->Session()->sRegister['auth']['email'] = $this->admin->sSYSTEM->_POST['email'];
			Shopware()->Session()->sRegister['auth']['accountmode'] = (int) $this->Request()->getParam('accountmode');

			$this->View()->setTemplate();
		} else {
			$checkData = $this->admin->sLogin();

			if (empty($checkData['sErrorMessages'])) {
                $this->refreshBasket();
				$this->View()->setTemplate();
			} else {
				$this->View()->sFormData = $this->Request()->getParams();
				$this->View()->sErrorFlag = $checkData['sErrorFlag'];
				$this->View()->sErrorMessages = $checkData['sErrorMessages'];
			}
		}
	}
Example #6
0
 /**
  * Get selected dispatch or select a default dispatch
  *
  * @return boolean|array
  */
 public function getSelectedDispatch()
 {
     if (empty($this->session['sCountry'])) {
         return false;
     }
     $dispatches = $this->admin->sGetPremiumDispatches($this->session['sCountry'], null, $this->session['sState']);
     if (empty($dispatches)) {
         unset($this->session['sDispatch']);
         return false;
     }
     foreach ($dispatches as $dispatch) {
         if ($dispatch['id'] == $this->session['sDispatch']) {
             return $dispatch;
         }
     }
     $dispatch = reset($dispatches);
     $this->session['sDispatch'] = (int) $dispatch['id'];
     return $dispatch;
 }
Example #7
0
 /**
  * Validates the billing information
  * and returns an json string with error
  * codes and messages
  *
  * @return void
  */
 public function ajaxValidateBillingAction()
 {
     $rules = array('salutation' => array('required' => 1), 'company' => array('required' => 0), 'firstname' => array('required' => 1), 'lastname' => array('required' => 1), 'street' => array('required' => 1), 'streetnumber' => array('required' => 1), 'zipcode' => array('required' => 1), 'city' => array('required' => 1), 'country' => array('required' => 1), 'department' => array('required' => 0));
     if (!empty($this->post['personal']['customer_type']) && $this->post['personal']['customer_type'] == 'business') {
         $rules['company']['required'] = 1;
     }
     $this->admin->sSYSTEM->_POST = array_merge($this->post['personal'], $this->post['billing']);
     $checkData = $this->admin->sValidateStep2($rules);
     $error_messages = array();
     $error_flags = array();
     if (!empty($checkData['sErrorMessages'])) {
         foreach ($checkData['sErrorMessages'] as $error_message) {
             $error_messages[] = utf8_encode($error_message);
         }
     }
     foreach ($rules as $field => $rule) {
         $error_flags[$field] = !empty($checkData['sErrorFlag'][$field]);
     }
     echo Zend_Json::encode(array('success' => empty($error_messages), 'error_flags' => $error_flags, 'error_messages' => $error_messages));
 }