Ejemplo n.º 1
0
 /**
  * Save shipping action
  *
  * Save shipping address data
  */
 public function savePaymentAction()
 {
     if ($this->Request()->isPost()) {
         $sourceIsCheckoutConfirm = $this->Request()->getParam('sourceCheckoutConfirm');
         $values = $this->Request()->getPost('register');
         $this->admin->sSYSTEM->_POST['sPayment'] = $values['payment'];
         $checkData = $this->admin->sValidateStep3();
         if (!empty($checkData['checkPayment']['sErrorMessages']) || empty($checkData['sProcessed'])) {
             if (empty($sourceIsCheckoutConfirm)) {
                 $this->View()->sErrorFlag = $checkData['checkPayment']['sErrorFlag'];
                 $this->View()->sErrorMessages = $checkData['checkPayment']['sErrorMessages'];
             }
             return $this->forward('payment');
         } else {
             $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));
             }
             $this->admin->sUpdatePayment();
             if ($checkData['sPaymentObject'] instanceof \ShopwarePlugin\PaymentMethods\Components\BasePaymentMethod) {
                 $checkData['sPaymentObject']->savePaymentData(Shopware()->Session()->sUserId, $this->Request());
             }
         }
     }
     if (!($target = $this->Request()->getParam('sTarget'))) {
         $target = 'account';
     }
     $targetAction = $this->Request()->getParam('sTargetAction', 'index');
     $this->redirect(array('controller' => $target, 'action' => $targetAction, 'success' => 'payment'));
 }
 /**
  * @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;
 }
Ejemplo n.º 3
0
 /**
  * Action to simultaneously save shipping and payment details
  */
 public function saveShippingPaymentAction()
 {
     if (!$this->Request()->isPost()) {
         return $this->forward('shippingPayment');
     }
     // Load data from request
     $dispatch = $this->Request()->getPost('sDispatch');
     $payment = $this->Request()->getPost('payment');
     // If request is ajax, we skip the validation, because the user is still editing
     if ($this->Request()->getParam('isXHR')) {
         // Save payment and shipping method data.
         $this->admin->sUpdatePayment($payment);
         $this->setDispatch($dispatch, $payment);
         return $this->forward('shippingPayment');
     }
     $sErrorFlag = array();
     $sErrorMessages = array();
     if (is_null($dispatch) && Shopware()->Config()->get('premiumshippingnoorder') === true && !$this->getDispatches($payment)) {
         $sErrorFlag['sDispatch'] = true;
         $sErrorMessages[] = Shopware()->Snippets()->getNamespace('frontend/checkout/error_messages')->get('ShippingPaymentSelectShipping', 'Please select a shipping method');
     }
     if (is_null($payment)) {
         $sErrorFlag['payment'] = true;
         $sErrorMessages[] = Shopware()->Snippets()->getNamespace('frontend/checkout/error_messages')->get('ShippingPaymentSelectPayment', 'Please select a payment method');
     }
     // If any basic info is missing, return error messages
     if (!empty($sErrorFlag) || !empty($sErrorMessages)) {
         $this->View()->assign('sErrorFlag', $sErrorFlag);
         $this->View()->assign('sErrorMessages', $sErrorMessages);
         return $this->forward('shippingPayment');
     }
     // Validate the payment details
     Shopware()->Modules()->Admin()->sSYSTEM->_POST['sPayment'] = $payment;
     $checkData = $this->admin->sValidateStep3();
     // Problem with the payment details, return error
     if (!empty($checkData['checkPayment']['sErrorMessages']) || empty($checkData['sProcessed'])) {
         $this->View()->assign('sErrorFlag', $checkData['checkPayment']['sErrorFlag']);
         $this->View()->assign('sErrorMessages', $checkData['checkPayment']['sErrorMessages']);
         return $this->forward('shippingPayment');
     }
     // Save payment method details db
     if ($checkData['sPaymentObject'] instanceof \ShopwarePlugin\PaymentMethods\Components\BasePaymentMethod) {
         $checkData['sPaymentObject']->savePaymentData(Shopware()->Session()->sUserId, $this->Request());
     }
     // Save the payment info
     $previousPayment = Shopware()->Modules()->Admin()->sGetUserData();
     $previousPayment = $previousPayment['additional']['user']['paymentID'];
     $previousPayment = $this->admin->sGetPaymentMeanById($previousPayment);
     if ($previousPayment['paymentTable']) {
         Shopware()->Db()->delete($previousPayment['paymentTable'], array('userID = ?' => Shopware()->Session()->sUserId));
     }
     // Save payment and shipping method data.
     $this->admin->sUpdatePayment($payment);
     $this->setDispatch($dispatch, $payment);
     $this->redirect(array('controller' => $this->Request()->getParam('sTarget', 'checkout'), 'action' => $this->Request()->getParam('sTargetAction', 'confirm')));
 }
Ejemplo n.º 4
0
 /**
  * Validates the payment informations
  *
  * @return array - payment data with error flags and msg
  */
 public function validatePayment()
 {
     if (empty($this->post['payment'])) {
         return array('sErrorFlag' => array('payment'), 'sErrorMessages' => array(Shopware()->Snippets()->getSnippet()->get('sErrorBillingAdress')));
     }
     $this->admin->sSYSTEM->_POST['sPayment'] = $this->post['payment'];
     $checkData = $this->admin->sValidateStep3();
     if (!empty($checkData['checkPayment']['sErrorMessages'])) {
         return array('sErrorFlag' => $checkData['checkPayment']['sErrorFlag'], 'sErrorMessages' => $checkData['checkPayment']['sErrorMessages']);
     }
     return $checkData;
 }
Ejemplo n.º 5
0
 /**
  * @covers sAdmin::sValidateStep3
  */
 public function testsValidateStep3()
 {
     $this->front->Request()->setPost('sPayment', 2);
     $result = $this->module->sValidateStep3();
     $this->assertArrayHasKey('checkPayment', $result);
     $this->assertArrayHasKey('paymentData', $result);
     $this->assertArrayHasKey('sProcessed', $result);
     $this->assertArrayHasKey('sPaymentObject', $result);
     $this->assertInternalType('array', $result['checkPayment']);
     $this->assertCount(2, $result['checkPayment']);
     $this->assertInternalType('array', $result['paymentData']);
     $this->assertCount(19, $result['paymentData']);
     $this->assertInternalType('boolean', $result['sProcessed']);
     $this->assertTrue($result['sProcessed']);
     $this->assertInternalType('object', $result['sPaymentObject']);
     $this->assertInstanceOf('ShopwarePlugin\\PaymentMethods\\Components\\BasePaymentMethod', $result['sPaymentObject']);
 }
Ejemplo n.º 6
0
	/**
	 * Save shipping action
	 *
	 * Save shipping address data
	 */
	public function savePaymentAction()
	{
		if($this->Request()->isPost())
		{
			$values = $this->Request()->getPost('register');
			$this->admin->sSYSTEM->_POST['sPayment'] = $values['payment'];

			$checkData = $this->admin->sValidateStep3();

			if (!empty($checkData['checkPayment']['sErrorMessages']) || empty($checkData['sProcessed']))
			{
				$this->View()->sErrorFlag = $checkData['checkPayment']['sErrorFlag'];
				$this->View()->sErrorMessages = $checkData['checkPayment']['sErrorMessages'];
				return $this->forward('payment');
			}
			else
			{
				$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));
				}

				$this->admin->sUpdatePayment();

				if (method_exists($checkData['sPaymentObject'],'sUpdate')){
					$checkData['sPaymentObject']->sUpdate();
				}
			}
		}

		if(!$target = $this->Request()->getParam('sTarget'))
		{
			$target = 'account';
		}
		$this->redirect(array('controller'=>$target, 'action'=>'index', 'success'=>'payment'));
	}