-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #409 from magento-tango/MAGETWO-38793
[Tango] S55 Authorize.net, Bug Fixes
- Loading branch information
Showing
118 changed files
with
7,756 additions
and
33 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
app/code/Magento/Authorizenet/Block/Adminhtml/Order/View/Info/FraudDetails.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Authorizenet\Block\Adminhtml\Order\View\Info; | ||
|
||
use Magento\Authorizenet\Model\Directpost; | ||
|
||
class FraudDetails extends \Magento\Backend\Block\Template | ||
{ | ||
/** | ||
* @var \Magento\Framework\Registry | ||
*/ | ||
protected $registry; | ||
|
||
/** | ||
* @param \Magento\Backend\Block\Template\Context $context | ||
* @param \Magento\Framework\Registry $registry | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
\Magento\Backend\Block\Template\Context $context, | ||
\Magento\Framework\Registry $registry, | ||
array $data = [] | ||
) { | ||
$this->registry = $registry; | ||
parent::__construct($context, $data); | ||
} | ||
|
||
/** | ||
* @return \Magento\Sales\Model\Order\Payment | ||
*/ | ||
public function getPayment() | ||
{ | ||
$order = $this->registry->registry('current_order'); | ||
return $order->getPayment(); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
protected function _toHtml() | ||
{ | ||
return ($this->getPayment()->getMethod() === Directpost::METHOD_CODE) ? parent::_toHtml() : ''; | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
app/code/Magento/Authorizenet/Block/Transparent/Iframe.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Authorizenet\Block\Transparent; | ||
|
||
use Magento\Payment\Block\Transparent\Iframe as TransparentIframe; | ||
|
||
/** | ||
* Class Iframe | ||
*/ | ||
class Iframe extends TransparentIframe | ||
{ | ||
/** | ||
* @var \Magento\Authorizenet\Helper\DataFactory | ||
*/ | ||
protected $dataFactory; | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @param \Magento\Framework\View\Element\Template\Context $context | ||
* @param \Magento\Framework\Registry $registry | ||
* @param \Magento\Authorizenet\Helper\DataFactory $dataFactory | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
\Magento\Framework\View\Element\Template\Context $context, | ||
\Magento\Framework\Registry $registry, | ||
\Magento\Authorizenet\Helper\DataFactory $dataFactory, | ||
array $data = [] | ||
) { | ||
$this->dataFactory = $dataFactory; | ||
parent::__construct($context, $registry, $data); | ||
} | ||
|
||
/** | ||
* Get helper data | ||
* | ||
* @param string $area | ||
* @return \Magento\Authorizenet\Helper\Backend\Data|\Magento\Authorizenet\Helper\Data | ||
*/ | ||
public function getHelper($area) | ||
{ | ||
return $this->dataFactory->create($area); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...gento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/AddConfigured.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
/** | ||
* | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Authorizenet\Controller\Adminhtml\Authorizenet\Directpost\Payment; | ||
|
||
class AddConfigured extends \Magento\Sales\Controller\Adminhtml\Order\Create\AddConfigured | ||
{ | ||
} |
11 changes: 11 additions & 0 deletions
11
...code/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/Cancel.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
/** | ||
* | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Authorizenet\Controller\Adminhtml\Authorizenet\Directpost\Payment; | ||
|
||
class Cancel extends \Magento\Sales\Controller\Adminhtml\Order\Create\Cancel | ||
{ | ||
} |
11 changes: 11 additions & 0 deletions
11
...thorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/ConfigureProductToAdd.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
/** | ||
* | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Authorizenet\Controller\Adminhtml\Authorizenet\Directpost\Payment; | ||
|
||
class ConfigureProductToAdd extends \Magento\Sales\Controller\Adminhtml\Order\Create\ConfigureProductToAdd | ||
{ | ||
} |
11 changes: 11 additions & 0 deletions
11
...Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/ConfigureQuoteItems.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
/** | ||
* | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Authorizenet\Controller\Adminhtml\Authorizenet\Directpost\Payment; | ||
|
||
class ConfigureQuoteItems extends \Magento\Sales\Controller\Adminhtml\Order\Create\ConfigureQuoteItems | ||
{ | ||
} |
11 changes: 11 additions & 0 deletions
11
app/code/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/Index.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
/** | ||
* | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Authorizenet\Controller\Adminhtml\Authorizenet\Directpost\Payment; | ||
|
||
class Index extends \Magento\Sales\Controller\Adminhtml\Order\Create\Index | ||
{ | ||
} |
11 changes: 11 additions & 0 deletions
11
...e/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/LoadBlock.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
/** | ||
* | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Authorizenet\Controller\Adminhtml\Authorizenet\Directpost\Payment; | ||
|
||
class LoadBlock extends \Magento\Sales\Controller\Adminhtml\Order\Create\LoadBlock | ||
{ | ||
} |
150 changes: 150 additions & 0 deletions
150
app/code/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/Place.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Authorizenet\Controller\Adminhtml\Authorizenet\Directpost\Payment; | ||
|
||
use Magento\Framework\Escaper; | ||
use Magento\Catalog\Helper\Product; | ||
use Magento\Backend\App\Action\Context; | ||
use Magento\Framework\View\Result\PageFactory; | ||
use Magento\Backend\Model\View\Result\ForwardFactory; | ||
use Magento\Authorizenet\Helper\Backend\Data as DataHelper; | ||
|
||
/** | ||
* Class Place | ||
*/ | ||
class Place extends \Magento\Sales\Controller\Adminhtml\Order\Create | ||
{ | ||
/** | ||
* @var DataHelper | ||
*/ | ||
protected $helper; | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @param Context $context | ||
* @param Product $productHelper | ||
* @param Escaper $escaper | ||
* @param PageFactory $resultPageFactory | ||
* @param ForwardFactory $resultForwardFactory | ||
* @param DataHelper $helper | ||
*/ | ||
public function __construct( | ||
Context $context, | ||
Product $productHelper, | ||
Escaper $escaper, | ||
PageFactory $resultPageFactory, | ||
ForwardFactory $resultForwardFactory, | ||
DataHelper $helper | ||
) { | ||
$this->helper = $helper; | ||
parent::__construct($context, $productHelper, $escaper, $resultPageFactory, $resultForwardFactory); | ||
} | ||
|
||
/** | ||
* Send request to authorize.net | ||
* | ||
* @return void | ||
* @SuppressWarnings(PHPMD.CyclomaticComplexity) | ||
* @SuppressWarnings(PHPMD.UnusedLocalVariable) | ||
*/ | ||
public function execute() | ||
{ | ||
$paymentParam = $this->getRequest()->getParam('payment'); | ||
$controller = $this->getRequest()->getParam('controller'); | ||
$this->getRequest()->setPostValue('collect_shipping_rates', 1); | ||
$this->_processActionData('save'); | ||
|
||
//get confirmation by email flag | ||
$orderData = $this->getRequest()->getPost('order'); | ||
$sendConfirmationFlag = 0; | ||
if ($orderData) { | ||
$sendConfirmationFlag = !empty($orderData['send_confirmation']) ? 1 : 0; | ||
} else { | ||
$orderData = []; | ||
} | ||
|
||
if (isset($paymentParam['method'])) { | ||
$result = []; | ||
//create order partially | ||
$this->_getOrderCreateModel()->setPaymentData($paymentParam); | ||
$this->_getOrderCreateModel()->getQuote()->getPayment()->addData($paymentParam); | ||
|
||
$orderData['send_confirmation'] = 0; | ||
$this->getRequest()->setPostValue('order', $orderData); | ||
|
||
try { | ||
//do not cancel old order. | ||
$oldOrder = $this->_getOrderCreateModel()->getSession()->getOrder(); | ||
$oldOrder->setActionFlag(\Magento\Sales\Model\Order::ACTION_FLAG_CANCEL, false); | ||
|
||
$order = $this->_getOrderCreateModel()->setIsValidate( | ||
true | ||
)->importPostData( | ||
$this->getRequest()->getPost('order') | ||
)->createOrder(); | ||
|
||
$payment = $order->getPayment(); | ||
if ($payment && $payment->getMethod() == $this->_objectManager->create( | ||
'Magento\Authorizenet\Model\Directpost' | ||
)->getCode() | ||
) { | ||
//return json with data. | ||
$session = $this->_objectManager->get('Magento\Authorizenet\Model\Directpost\Session'); | ||
$session->addCheckoutOrderIncrementId($order->getIncrementId()); | ||
$session->setLastOrderIncrementId($order->getIncrementId()); | ||
|
||
/** @var \Magento\Authorizenet\Model\Directpost $method */ | ||
$method = $payment->getMethodInstance(); | ||
$method->setDataHelper($this->helper); | ||
$requestToAuthorizenet = $method->generateRequestFromOrder($order); | ||
$requestToAuthorizenet->setControllerActionName($controller); | ||
$requestToAuthorizenet->setOrderSendConfirmation($sendConfirmationFlag); | ||
$requestToAuthorizenet->setStoreId($this->_getOrderCreateModel()->getQuote()->getStoreId()); | ||
|
||
$adminUrl = $this->_objectManager->get('Magento\Backend\Model\UrlInterface'); | ||
if ($adminUrl->useSecretKey()) { | ||
$requestToAuthorizenet->setKey( | ||
$adminUrl->getSecretKey('adminhtml', 'authorizenet_directpost_payment', 'redirect') | ||
); | ||
} | ||
$result['directpost'] = ['fields' => $requestToAuthorizenet->getData()]; | ||
} | ||
|
||
$result['success'] = 1; | ||
$isError = false; | ||
} catch (\Magento\Framework\Exception\LocalizedException $e) { | ||
$message = $e->getMessage(); | ||
if (!empty($message)) { | ||
$this->messageManager->addError($message); | ||
} | ||
$isError = true; | ||
} catch (\Exception $e) { | ||
$this->messageManager->addException($e, __('Order saving error: %1', $e->getMessage())); | ||
$isError = true; | ||
} | ||
|
||
if ($isError) { | ||
$result['success'] = 0; | ||
$result['error'] = 1; | ||
$result['redirect'] = $this->_objectManager->get( | ||
'Magento\Backend\Model\UrlInterface' | ||
)->getUrl( | ||
'sales/order_create/' | ||
); | ||
} | ||
|
||
$this->getResponse()->representJson( | ||
$this->_objectManager->get('Magento\Framework\Json\Helper\Data')->jsonEncode($result) | ||
); | ||
} else { | ||
$result = ['error_messages' => __('Please choose a payment method.')]; | ||
$this->getResponse()->representJson( | ||
$this->_objectManager->get('Magento\Framework\Json\Helper\Data')->jsonEncode($result) | ||
); | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/ProcessData.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
/** | ||
* | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Authorizenet\Controller\Adminhtml\Authorizenet\Directpost\Payment; | ||
|
||
class ProcessData extends \Magento\Sales\Controller\Adminhtml\Order\Create\ProcessData | ||
{ | ||
} |
Oops, something went wrong.