Example #1
0
 /**
  * @return \XLite\Model\Payment\Method
  */
 protected function getTestMethod()
 {
     xdebug_stop_code_coverage(false);
     $method = new \XLite\Model\Payment\Method();
     $method->map($this->testMethod);
     $s = new \XLite\Model\Payment\MethodSetting();
     $s->setName('t1');
     $s->setValue('1');
     $method->addSettings($s);
     $s->setPaymentMethod($method);
     $s = new \XLite\Model\Payment\MethodSetting();
     $s->setName('t2');
     $s->setValue('2');
     $method->addSettings($s);
     $s->setPaymentMethod($method);
     \XLite\Core\Database::getEM()->persist($method);
     \XLite\Core\Database::getEM()->flush();
     $this->method = $method;
     xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
     return $method;
 }
Example #2
0
 protected function placeAmazonOrder($payment_method_text)
 {
     $cart = $this->getCart();
     if (isset(\XLite\Core\Request::getInstance()->notes)) {
         $cart->setNotes(\XLite\Core\Request::getInstance()->notes);
     }
     $cart->setDate(\XLite\Core\Converter::time());
     $cart->assignOrderNumber();
     $cart->setPaymentStatus(\XLite\Model\Order\Status\Payment::STATUS_QUEUED);
     $cart->setShippingStatus(\XLite\Model\Order\Status\Shipping::STATUS_NEW);
     // apply $payment_method_text payment method
     $_tmp_method = \XLite\Core\Database::getRepo('XLite\\Model\\Payment\\Method')->findBy(array('service_name' => 'PayWithAmazon'));
     if ($_tmp_method) {
         $_tmp_method = $_tmp_method[0];
     } else {
         // auto create it
         $_tmp_method = new \XLite\Model\Payment\Method();
         $_tmp_method->setClass('Model\\Payment\\Processor\\Offline');
         $_tmp_method->setServiceName('PayWithAmazon');
         $_tmp_method->setName($payment_method_text);
         $_tmp_method->setModuleName('Amazon_PayWithAmazon');
     }
     $this->getCart()->setPaymentMethod($_tmp_method);
     $this->getCart()->markAsOrder();
     // $this->updateCart(); // old way produce fingerprint warning in logs
     $this->getCart()->updateOrder();
     \XLite\Core\Database::getRepo('XLite\\Model\\Cart')->update($this->getCart());
     // Register 'Place order' event in the order history
     \XLite\Core\OrderHistory::getInstance()->registerPlaceOrder($this->getCart()->getOrderId());
     \XLite\Core\Database::getEM()->flush();
     return $this->getCart()->getOrderId();
 }
Example #3
0
 /**
  * Add offline method
  *
  * @return void
  */
 protected function doActionAddOfflineMethod()
 {
     $name = strval(\XLite\Core\Request::getInstance()->name);
     $instruction = strval(\XLite\Core\Request::getInstance()->instruction);
     $description = strval(\XLite\Core\Request::getInstance()->description);
     if ($name) {
         $method = new \XLite\Model\Payment\Method();
         $method->setName($name);
         $method->setTitle($name);
         $method->setDescription($description);
         $method->setClass('Model\\Payment\\Processor\\Offline');
         $method->setAdded(true);
         $method->setModuleEnabled(true);
         $method->setType(\XLite\Model\Payment\Method::TYPE_OFFLINE);
         $method->setServiceName(microtime(true));
         if ($instruction) {
             $method->setInstruction($instruction);
         }
         \XLite\Core\Database::getEM()->persist($method);
         \XLite\Core\Database::getEM()->flush();
         $method->setServiceName($method->getmethodId());
         \XLite\Core\Database::getEM()->flush();
         \XLite\Core\TopMessage::addInfo('Payment method has been added successfully');
     }
     $this->setReturnURL(\XLite\Core\Converter::buildURL('payment_settings'));
     $this->setHardRedirect(true);
 }