Ejemplo n.º 1
0
 /**
  * Function to create a new payment
  */
 public function createPaymentsAction()
 {
     try {
         $params = $this->Request()->getParams();
         unset($params["action"]);
         $repository = Shopware()->Models()->getRepository('Shopware\\Models\\Payment\\Payment');
         $existingModel = $repository->findByName($params['name']);
         if ($existingModel) {
             throw new \Doctrine\ORM\ORMException('The name is already in use.');
         }
         if ($params['source'] == 0) {
             $params['source'] = null;
         }
         $paymentModel = new \Shopware\Models\Payment\Payment();
         $params['attribute'] = $params['attribute'][0];
         $countries = $params['countries'];
         $countryArray = array();
         foreach ($countries as $country) {
             $countryArray[] = Shopware()->Models()->find('Shopware\\Models\\Country\\Country', $country['id']);
         }
         $params['countries'] = $countryArray;
         $paymentModel->fromArray($params);
         Shopware()->Models()->persist($paymentModel);
         Shopware()->Models()->flush();
         $params['id'] = $paymentModel->getId();
         $this->View()->assign(array('success' => true, 'data' => $params));
     } catch (\Doctrine\ORM\ORMException $e) {
         $this->View()->assign(array('success' => false, 'errorMsg' => $e->getMessage()));
     }
 }
Ejemplo n.º 2
0
 /**
  * Checks if the choosen payment is a RatePAY-payment
  *
  * @return boolean
  */
 public function isRatePAYPayment()
 {
     return in_array($this->_payment->getName(), array("rpayratepayinvoice", "rpayratepayrate", "rpayratepaydebit"));
 }
Ejemplo n.º 3
0
 /**
  * copy all properties and create duplicate payment
  * 
  * @param object $payment
  * @return boolean
  */
 protected function moptDuplicatePayment($payment)
 {
     $duplicatedPayment = new \Shopware\Models\Payment\Payment();
     $duplicatedPayment->setName($this->moptCreateUniquePaymentName($payment->getName()));
     $duplicatedPayment->setDescription($payment->getDescription());
     $duplicatedPayment->setTemplate($payment->getTemplate());
     $duplicatedPayment->setAdditionalDescription($payment->getAdditionalDescription());
     $duplicatedPayment->setPosition(200);
     $duplicatedPayment->setActive(false);
     $duplicatedPayment->setAction($payment->getAction());
     $duplicatedPayment->setPluginId($payment->getPluginId());
     $duplicatedPayment->setSource(1);
     try {
         Shopware()->Models()->persist($duplicatedPayment);
         Shopware()->Models()->flush();
     } catch (Exception $e) {
         return false;
     }
     return true;
 }
Ejemplo n.º 4
0
 /**
  * Create a new payment instance
  *
  * @param   array $options
  * @param   null $description
  * @param   null $action
  * @return  \Shopware\Models\Payment\Payment
  */
 public function createPayment($options, $description = null, $action = null)
 {
     if(is_string($options)) {
         $options = array('name' => $options);
     }
     $payment = $this->Payments()->findOneBy(array(
         'name' => $options['name']
     ));
     if($payment === null) {
         $payment = new \Shopware\Models\Payment\Payment();
         $payment->setName($options['name']);
         $this->Application()->Models()->persist($payment);
     }
     $payment->fromArray($options);
     if($description !== null) {
         $payment->setDescription($description);
     }
     if($action !== null) {
         $payment->setAction($action);
     }
     $plugin = $this->Plugin();
     $plugin->getPayments()->add($payment);
     $payment->setPlugin($plugin);
     Shopware()->Models()->flush($payment);
     return $payment;
 }