Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into MAGETWO-44091
Browse files Browse the repository at this point in the history
  • Loading branch information
zanilee committed Oct 23, 2015
2 parents a13e201 + 6d75339 commit b64a694
Show file tree
Hide file tree
Showing 178 changed files with 2,012 additions and 4,239 deletions.
12 changes: 11 additions & 1 deletion app/code/Magento/Authorizenet/Model/Authorizenet.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
namespace Magento\Authorizenet\Model;

use Magento\Authorizenet\Model\TransactionService;
use Magento\Framework\HTTP\ZendClientFactory;

/**
* @SuppressWarnings(PHPMD.TooManyFields)
Expand Down Expand Up @@ -97,6 +98,11 @@ abstract class Authorizenet extends \Magento\Payment\Model\Method\Cc
*/
protected $_debugReplacePrivateDataKeys = ['merchantAuthentication', 'x_login'];

/**
* @var \Magento\Framework\HTTP\ZendClientFactory
*/
protected $httpClientFactory;

/**
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
Expand All @@ -111,6 +117,7 @@ abstract class Authorizenet extends \Magento\Payment\Model\Method\Cc
* @param \Magento\Authorizenet\Model\Request\Factory $requestFactory
* @param \Magento\Authorizenet\Model\Response\Factory $responseFactory
* @param \Magento\Authorizenet\Model\TransactionService $transactionService
* @param \Magento\Framework\HTTP\ZendClientFactory $httpClientFactory
* @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
* @param array $data
Expand All @@ -130,6 +137,7 @@ public function __construct(
\Magento\Authorizenet\Model\Request\Factory $requestFactory,
\Magento\Authorizenet\Model\Response\Factory $responseFactory,
TransactionService $transactionService,
ZendClientFactory $httpClientFactory,
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
array $data = []
Expand All @@ -138,6 +146,7 @@ public function __construct(
$this->requestFactory = $requestFactory;
$this->responseFactory = $responseFactory;
$this->transactionService = $transactionService;
$this->httpClientFactory = $httpClientFactory;

parent::__construct(
$context,
Expand Down Expand Up @@ -370,7 +379,8 @@ protected function buildRequest(\Magento\Framework\DataObject $payment)
protected function postRequest(\Magento\Authorizenet\Model\Request $request)
{
$result = $this->responseFactory->create();
$client = new \Magento\Framework\HTTP\ZendClient();
/** @var \Magento\Framework\HTTP\ZendClient $client */
$client = $this->httpClientFactory->create();
$url = $this->getConfigData('cgi_url') ?: self::CGI_URL;
$debugData = ['url' => $url, 'request' => $request->getData()];
$client->setUri($url);
Expand Down
8 changes: 5 additions & 3 deletions app/code/Magento/Authorizenet/Model/Directpost.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
namespace Magento\Authorizenet\Model;

use Magento\Authorizenet\Model\TransactionService;
use Magento\Framework\HTTP\ZendClientFactory;
use Magento\Payment\Model\Method\ConfigInterface;
use Magento\Payment\Model\Method\TransparentInterface;
use Magento\Sales\Model\Order\Email\Sender\OrderSender;
Expand Down Expand Up @@ -132,6 +133,7 @@ class Directpost extends \Magento\Authorizenet\Model\Authorizenet implements Tra
* @param Directpost\Request\Factory $requestFactory
* @param Directpost\Response\Factory $responseFactory
* @param \Magento\Authorizenet\Model\TransactionService $transactionService
* @param \Magento\Framework\HTTP\ZendClientFactory $httpClientFactory
* @param \Magento\Sales\Model\OrderFactory $orderFactory
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Quote\Model\QuoteRepository $quoteRepository
Expand All @@ -156,6 +158,7 @@ public function __construct(
\Magento\Authorizenet\Model\Directpost\Request\Factory $requestFactory,
\Magento\Authorizenet\Model\Directpost\Response\Factory $responseFactory,
TransactionService $transactionService,
ZendClientFactory $httpClientFactory,
\Magento\Sales\Model\OrderFactory $orderFactory,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Quote\Model\QuoteRepository $quoteRepository,
Expand Down Expand Up @@ -187,6 +190,7 @@ public function __construct(
$requestFactory,
$responseFactory,
$transactionService,
$httpClientFactory,
$resource,
$resourceCollection,
$data
Expand Down Expand Up @@ -404,9 +408,7 @@ protected function processRefund(\Magento\Framework\DataObject $payment, $amount
if ($result->getXTransId() != $payment->getParentTransactionId()) {
$payment->setTransactionId($result->getXTransId());
}
$shouldCloseCaptureTransaction = $payment->getOrder()->canCreditmemo() ? 0 : 1;
$payment->setIsTransactionClosed(1)
->setShouldCloseParentTransaction($shouldCloseCaptureTransaction)
$payment->setIsTransactionClosed(true)
->setTransactionAdditionalInfo(self::REAL_TRANSACTION_ID_KEY, $result->getXTransId());
return $this;
}
Expand Down
Loading

0 comments on commit b64a694

Please sign in to comment.