Skip to content

Commit

Permalink
Merge branch 'develop-mainline' into MAGETWO-40015
Browse files Browse the repository at this point in the history
Conflicts:
	app/code/Magento/Catalog/Setup/UpgradeSchema.php
	app/code/Magento/Catalog/etc/module.xml
  • Loading branch information
akaplya committed Jul 11, 2015
2 parents ef3b197 + aa2088f commit 74de932
Show file tree
Hide file tree
Showing 755 changed files with 44,344 additions and 7,675 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,44 @@
*/
namespace Magento\Authorizenet\Controller\Directpost\Payment;

class Place extends \Magento\Authorizenet\Controller\Directpost\Payment
use Magento\Authorizenet\Controller\Directpost\Payment;
use Magento\Authorizenet\Helper\DataFactory;
use Magento\Checkout\Model\Type\Onepage;
use Magento\Framework\App\Action\Context;
use Magento\Framework\Event\ManagerInterface;
use Magento\Framework\Object;
use Magento\Framework\Registry;
use Magento\Payment\Model\IframeConfigProvider;
use Magento\Quote\Api\CartManagementInterface;

/**
* Class Place
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class Place extends Payment
{
/**
* @var \Magento\Quote\Api\CartManagementInterface
* @var CartManagementInterface
*/
protected $cartManagement;

/**
* @var \Magento\Framework\Event\ManagerInterface
* @var ManagerInterface
*/
protected $eventManager;

/**
* @param \Magento\Framework\App\Action\Context $context
* @param \Magento\Framework\Registry $coreRegistry
* @param \Magento\Authorizenet\Helper\DataFactory $dataFactory
* @param \Magento\Quote\Api\CartManagementInterface $cartManagement
* @param Context $context
* @param Registry $coreRegistry
* @param DataFactory $dataFactory
* @param CartManagementInterface $cartManagement
*/
public function __construct(
\Magento\Framework\App\Action\Context $context,
\Magento\Framework\Registry $coreRegistry,
\Magento\Authorizenet\Helper\DataFactory $dataFactory,
\Magento\Quote\Api\CartManagementInterface $cartManagement
Context $context,
Registry $coreRegistry,
DataFactory $dataFactory,
CartManagementInterface $cartManagement
) {
$this->eventManager = $context->getEventManager();
$this->cartManagement = $cartManagement;
Expand All @@ -44,10 +59,12 @@ public function execute()
{
$paymentParam = $this->getRequest()->getParam('payment');
$controller = $this->getRequest()->getParam('controller');

if (isset($paymentParam['method'])) {
$this->_getDirectPostSession()->setQuoteId($this->_getCheckout()->getQuote()->getId());
$this->_getCheckout()->getQuote()->setCheckoutMethod($this->getCheckoutMethod());

if ($controller == \Magento\Payment\Model\IframeConfigProvider::CHECKOUT_IDENTIFIER) {
if ($controller == IframeConfigProvider::CHECKOUT_IDENTIFIER) {
return $this->placeCheckoutOrder();
}

Expand All @@ -64,10 +81,32 @@ public function execute()
);
} else {
$result = ['error_messages' => __('Please choose a payment method.'), 'goto_section' => 'payment'];
$this->getResponse()->representJson(
$this->_objectManager->get('Magento\Framework\Json\Helper\Data')->jsonEncode($result)
);
$this->getResponse()->representJson($this->getJsonHelper()->jsonEncode($result));
}
}

/**
* Get quote checkout method
*
* @return string
*/
protected function getCheckoutMethod()
{
$checkoutMethod = $this->_getCheckout()->getQuote()->getCheckoutMethod();

if ($this->getCustomerSession()->isLoggedIn()) {
$checkoutMethod = Onepage::METHOD_CUSTOMER;
}

if (!$checkoutMethod) {
if ($this->getCheckoutHelper()->isAllowedGuestCheckout($this->_getCheckout()->getQuote())) {
$checkoutMethod = Onepage::METHOD_GUEST;
} else {
$checkoutMethod = Onepage::METHOD_REGISTER;
}
}

return $checkoutMethod;
}

/**
Expand All @@ -77,7 +116,7 @@ public function execute()
*/
protected function placeCheckoutOrder()
{
$result = new \Magento\Framework\Object();
$result = new Object();
try {
$this->cartManagement->placeOrder($this->_getCheckout()->getQuote()->getId());
$result->setData('success', true);
Expand All @@ -92,8 +131,30 @@ protected function placeCheckoutOrder()
$result->setData('error', true);
$result->setData('error_messages', __('Cannot place order.'));
}
$this->getResponse()->representJson(
$this->_objectManager->get('Magento\Framework\Json\Helper\Data')->jsonEncode($result)
);
$this->getResponse()->representJson($this->getJsonHelper()->jsonEncode($result));
}

/**
* @return \Magento\Customer\Model\Session
*/
protected function getCustomerSession()
{
return $this->_objectManager->get('Magento\Checkout\Model\Cart')->getCustomerSession();
}

/**
* @return \Magento\Checkout\Helper\Data
*/
protected function getCheckoutHelper()
{
return $this->_objectManager->get('Magento\Checkout\Helper\Data');
}

/**
* @return \Magento\Framework\Json\Helper\Data
*/
protected function getJsonHelper()
{
return $this->_objectManager->get('Magento\Framework\Json\Helper\Data');
}
}
22 changes: 22 additions & 0 deletions app/code/Magento/Authorizenet/Model/Directpost.php
Original file line number Diff line number Diff line change
Expand Up @@ -898,4 +898,26 @@ protected function addStatusCommentOnUpdate(
}
return $this;
}

/**
* Sets method code
*
* @param string $methodCode
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
* @return void
*/
public function setMethodCode($methodCode)
{
}

/**
* Sets path pattern
*
* @param string $pathPattern
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
* @return void
*/
public function setPathPattern($pathPattern)
{
}
}
Loading

0 comments on commit 74de932

Please sign in to comment.