Skip to content

Commit 2cb2fa5

Browse files
author
Korshenko, Olexii(okorshenko)
committed
Merge pull request #607 from magento-tango/S60PR
[Tango] S60 - Support Tool, Bug Fixes
2 parents 444e252 + e468b8e commit 2cb2fa5

File tree

12 files changed

+908
-292
lines changed

12 files changed

+908
-292
lines changed

app/code/Magento/Authorizenet/Model/Authorizenet.php

Lines changed: 49 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\Authorizenet\Model;
77

8+
use Magento\Payment\Model\Method\Logger;
9+
810
/**
911
* @SuppressWarnings(PHPMD.TooManyFields)
1012
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
@@ -54,6 +56,8 @@ abstract class Authorizenet extends \Magento\Payment\Model\Method\Cc
5456

5557
const RESPONSE_REASON_CODE_PENDING_REVIEW_DECLINED = 254;
5658

59+
const PAYMENT_UPDATE_STATUS_CODE_SUCCESS = 'Ok';
60+
5761
/**
5862
* Transaction fraud state key
5963
*/
@@ -95,6 +99,11 @@ abstract class Authorizenet extends \Magento\Payment\Model\Method\Cc
9599
*/
96100
protected $transactionDetails = [];
97101

102+
/**
103+
* {@inheritdoc}
104+
*/
105+
protected $_debugReplacePrivateDataKeys = ['merchantAuthentication', 'x_login'];
106+
98107
/**
99108
* @param \Magento\Framework\Model\Context $context
100109
* @param \Magento\Framework\Registry $registry
@@ -364,11 +373,11 @@ protected function buildRequest(\Magento\Framework\DataObject $payment)
364373
*/
365374
protected function postRequest(\Magento\Authorizenet\Model\Request $request)
366375
{
367-
$debugData = ['request' => $request->getData()];
368376
$result = $this->responseFactory->create();
369377
$client = new \Magento\Framework\HTTP\ZendClient();
370-
$uri = $this->getConfigData('cgi_url');
371-
$client->setUri($uri ? $uri : self::CGI_URL);
378+
$url = $this->getConfigData('cgi_url') ?: self::CGI_URL;
379+
$debugData = ['url' => $url, 'request' => $request->getData()];
380+
$client->setUri($url);
372381
$client->setConfig(['maxredirects' => 0, 'timeout' => 30]);
373382

374383
foreach ($request->getData() as $key => $value) {
@@ -381,21 +390,21 @@ protected function postRequest(\Magento\Authorizenet\Model\Request $request)
381390

382391
try {
383392
$response = $client->request();
393+
$responseBody = $response->getBody();
394+
$debugData['response'] = $responseBody;
384395
} catch (\Exception $e) {
385396
$result->setXResponseCode(-1)
386397
->setXResponseReasonCode($e->getCode())
387398
->setXResponseReasonText($e->getMessage());
388399

389-
$debugData['result'] = $result->getData();
390-
$this->_debug($debugData);
391400
throw new \Magento\Framework\Exception\LocalizedException(
392401
$this->dataHelper->wrapGatewayError($e->getMessage())
393402
);
403+
} finally {
404+
$this->_debug($debugData);
394405
}
395406

396-
$responseBody = $response->getBody();
397407
$r = explode(self::RESPONSE_DELIM_CHAR, $responseBody);
398-
399408
if ($r) {
400409
$result->setXResponseCode((int)str_replace('"', '', $r[0]))
401410
->setXResponseReasonCode((int)str_replace('"', '', $r[2]))
@@ -413,10 +422,6 @@ protected function postRequest(\Magento\Authorizenet\Model\Request $request)
413422
__('Something went wrong in the payment gateway.')
414423
);
415424
}
416-
417-
$debugData['result'] = $result->getData();
418-
$this->_debug($debugData);
419-
420425
return $result;
421426
}
422427

@@ -473,24 +478,35 @@ protected function loadTransactionDetails($transactionId)
473478
);
474479

475480
$client = new \Magento\Framework\HTTP\ZendClient();
476-
$uri = $this->getConfigData('cgi_url_td');
477-
$client->setUri($uri ? $uri : self::CGI_URL_TD);
481+
$url = $this->getConfigData('cgi_url_td') ?: self::CGI_URL_TD;
482+
$client->setUri($url);
478483
$client->setConfig(['timeout' => 45]);
479484
$client->setHeaders(['Content-Type: text/xml']);
480485
$client->setMethod(\Zend_Http_Client::POST);
481486
$client->setRawData($requestBody);
482487

483-
$debugData = ['request' => $requestBody];
488+
$debugData = ['url' => $url, 'request' => $this->removePrivateDataFromXml($requestBody)];
484489

485490
try {
486491
$responseBody = $client->request()->getBody();
487-
$debugData['result'] = $responseBody;
488-
$this->_debug($debugData);
492+
$debugData['response'] = $responseBody;
489493
libxml_use_internal_errors(true);
490494
$responseXmlDocument = new \Magento\Framework\Simplexml\Element($responseBody);
491495
libxml_use_internal_errors(false);
492496
} catch (\Exception $e) {
493-
throw new \Magento\Framework\Exception\LocalizedException(__('Payment updating error.'));
497+
throw new \Magento\Framework\Exception\LocalizedException(
498+
__('Unable to get transaction details. Try again later.')
499+
);
500+
} finally {
501+
$this->_debug($debugData);
502+
}
503+
504+
if (!isset($responseXmlDocument->messages->resultCode)
505+
|| $responseXmlDocument->messages->resultCode != static::PAYMENT_UPDATE_STATUS_CODE_SUCCESS
506+
) {
507+
throw new \Magento\Framework\Exception\LocalizedException(
508+
__('Unable to get transaction details. Try again later.')
509+
);
494510
}
495511

496512
$this->transactionDetails[$transactionId] = $responseXmlDocument;
@@ -509,4 +525,20 @@ protected function getTransactionDetails($transactionId)
509525
? $this->transactionDetails[$transactionId]
510526
: $this->loadTransactionDetails($transactionId);
511527
}
528+
529+
/**
530+
* Remove nodes with private data from XML string
531+
*
532+
* Uses values from $_debugReplacePrivateDataKeys property
533+
*
534+
* @param string $xml
535+
* @return string
536+
*/
537+
protected function removePrivateDataFromXml($xml)
538+
{
539+
foreach ($this->getDebugReplacePrivateDataKeys() as $key) {
540+
$xml = preg_replace(sprintf('~(?<=<%s>).*?(?=</%s>)~', $key, $key), Logger::DEBUG_KEYS_MASK, $xml);
541+
}
542+
return $xml;
543+
}
512544
}

app/code/Magento/Authorizenet/Model/Directpost.php

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -726,17 +726,21 @@ protected function processOrder(\Magento\Sales\Model\Order $order)
726726
*/
727727
protected function processPaymentFraudStatus(\Magento\Sales\Model\Order\Payment $payment)
728728
{
729-
$fraudDetailsResponse = $payment->getMethodInstance()
730-
->fetchTransactionFraudDetails($this->getResponse()->getXTransId());
731-
$fraudData = $fraudDetailsResponse->getData();
729+
try {
730+
$fraudDetailsResponse = $payment->getMethodInstance()
731+
->fetchTransactionFraudDetails($this->getResponse()->getXTransId());
732+
$fraudData = $fraudDetailsResponse->getData();
732733

733-
if (empty($fraudData)) {
734-
$payment->setIsFraudDetected(false);
735-
return $this;
736-
}
734+
if (empty($fraudData)) {
735+
$payment->setIsFraudDetected(false);
736+
return $this;
737+
}
737738

738-
$payment->setIsFraudDetected(true);
739-
$payment->setAdditionalInformation('fraud_details', $fraudData);
739+
$payment->setIsFraudDetected(true);
740+
$payment->setAdditionalInformation('fraud_details', $fraudData);
741+
} catch (\Exception $e) {
742+
//this request is optional
743+
}
740744

741745
return $this;
742746
}
@@ -749,23 +753,27 @@ protected function processPaymentFraudStatus(\Magento\Sales\Model\Order\Payment
749753
*/
750754
protected function addStatusComment(\Magento\Sales\Model\Order\Payment $payment)
751755
{
752-
$transactionId = $this->getResponse()->getXTransId();
753-
$data = $payment->getMethodInstance()->getTransactionDetails($transactionId);
754-
$transactionStatus = (string)$data->transaction->transactionStatus;
755-
$fdsFilterAction = (string)$data->transaction->FDSFilterAction;
756-
757-
if ($payment->getIsTransactionPending()) {
758-
$message = 'Amount of %1 is pending approval on the gateway.<br/>'
759-
. 'Transaction "%2" status is "%3".<br/>'
760-
. 'Transaction FDS Filter Action is "%4"';
761-
$message = __(
762-
$message,
763-
$payment->getOrder()->getBaseCurrency()->formatTxt($this->getResponse()->getXAmount()),
764-
$transactionId,
765-
$this->dataHelper->getTransactionStatusLabel($transactionStatus),
766-
$this->dataHelper->getFdsFilterActionLabel($fdsFilterAction)
767-
);
768-
$payment->getOrder()->addStatusHistoryComment($message);
756+
try {
757+
$transactionId = $this->getResponse()->getXTransId();
758+
$data = $payment->getMethodInstance()->getTransactionDetails($transactionId);
759+
$transactionStatus = (string)$data->transaction->transactionStatus;
760+
$fdsFilterAction = (string)$data->transaction->FDSFilterAction;
761+
762+
if ($payment->getIsTransactionPending()) {
763+
$message = 'Amount of %1 is pending approval on the gateway.<br/>'
764+
. 'Transaction "%2" status is "%3".<br/>'
765+
. 'Transaction FDS Filter Action is "%4"';
766+
$message = __(
767+
$message,
768+
$payment->getOrder()->getBaseCurrency()->formatTxt($this->getResponse()->getXAmount()),
769+
$transactionId,
770+
$this->dataHelper->getTransactionStatusLabel($transactionStatus),
771+
$this->dataHelper->getFdsFilterActionLabel($fdsFilterAction)
772+
);
773+
$payment->getOrder()->addStatusHistoryComment($message);
774+
}
775+
} catch (\Exception $e) {
776+
//this request is optional
769777
}
770778
return $this;
771779
}

app/code/Magento/Config/Model/Config/Backend/Admin/Custom.php

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,37 @@ class Custom extends \Magento\Framework\App\Config\Value
1818
const CONFIG_SCOPE_ID = 0;
1919

2020
const XML_PATH_UNSECURE_BASE_URL = 'web/unsecure/base_url';
21-
2221
const XML_PATH_SECURE_BASE_URL = 'web/secure/base_url';
23-
2422
const XML_PATH_UNSECURE_BASE_LINK_URL = 'web/unsecure/base_link_url';
25-
2623
const XML_PATH_SECURE_BASE_LINK_URL = 'web/secure/base_link_url';
24+
const XML_PATH_CURRENCY_OPTIONS_BASE = 'currency/options/base';
25+
const XML_PATH_ADMIN_SECURITY_USEFORMKEY = 'admin/security/use_form_key';
26+
const XML_PATH_MAINTENANCE_MODE = 'maintenance_mode';
27+
const XML_PATH_WEB_COOKIE_COOKIE_LIFETIME = 'web/cookie/cookie_lifetime';
28+
const XML_PATH_WEB_COOKIE_COOKE_PATH = 'web/cookie/cookie_path';
29+
const XML_PATH_WEB_COOKIE_COOKIE_DOMAIN = 'web/cookie/cookie_domain';
30+
const XML_PATH_WEB_COOKIE_HTTPONLY = 'web/cookie/cookie_httponly';
31+
const XML_PATH_WEB_COOKIE_RESTRICTION = 'web/cookie/cookie_restriction';
32+
const XML_PATH_GENERAL_LOCALE_TIMEZONE = 'general/locale/timezone';
33+
const XML_PATH_GENERAL_LOCALE_CODE = 'general/locale/code';
34+
const XML_PATH_GENERAL_COUNTRY_DEFAULT = 'general/country/default';
35+
const XML_PATH_SYSTEM_BACKUP_ENABLED = 'system/backup/enabled';
36+
const XML_PATH_DEV_JS_MERGE_FILES = 'dev/js/merge_files';
37+
const XML_PATH_DEV_JS_MINIFY_FILES = 'dev/js/minify_files';
38+
const XML_PATH_DEV_CSS_MERGE_CSS_FILES = 'dev/css/merge_css_files';
39+
const XML_PATH_DEV_CSS_MINIFY_FILES = 'dev/css/minify_files';
40+
const XML_PATH_DEV_IMAGE_DEFAULT_ADAPTER = 'dev/image/default_adapter';
41+
const XML_PATH_WEB_SESSION_USE_FRONTEND_SID = 'web/session/use_frontend_sid';
42+
const XML_PATH_WEB_SESSION_USE_HTTP_X_FORWARDED_FOR = 'web/session/use_http_x_forwarded_for';
43+
const XML_PATH_WEB_SESSION_USE_HTTP_VIA = 'web/session/use_http_via';
44+
const XML_PATH_WEB_SESSION_USE_REMOTE_ADDR = 'web/session/use_remote_addr';
45+
const XML_PATH_WEB_SESSION_USE_HTTP_USER_AGENT = 'web/session/use_http_user_agent';
46+
const XML_PATH_CATALOG_FRONTEND_FLAT_CATALOG_CATEGORY = 'catalog/frontend/flat_catalog_category';
47+
const XML_PATH_CATALOG_FRONTEND_FLAT_CATALOG_PRODUCT = 'catalog/frontend/flat_catalog_product';
48+
const XML_PATH_TAX_WEEE_ENABLE = 'tax/weee/enable';
49+
const XML_PATH_CATALOG_SEARCH_ENGINE = 'catalog/search/engine';
50+
const XML_PATH_CARRIERS = 'carriers';
51+
const XML_PATH_PAYMENT = 'payment';
2752

2853
/* @var \Magento\Framework\App\Config\Storage\WriterInterface */
2954
protected $_configWriter;

app/code/Magento/Payment/Model/Method/AbstractMethod.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ abstract class AbstractMethod extends \Magento\Framework\Model\AbstractExtensibl
5858

5959
const CHECK_ZERO_TOTAL = 'zero_total';
6060

61+
const GROUP_OFFLINE = 'offline';
62+
6163
/**
6264
* @var string
6365
*/

app/code/Magento/Store/App/Response/Redirect.php

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
*/
88
namespace Magento\Store\App\Response;
99

10+
use Magento\Store\Api\StoreResolverInterface;
11+
1012
class Redirect implements \Magento\Framework\App\Response\RedirectInterface
1113
{
1214
/**
@@ -94,6 +96,8 @@ protected function _getUrl()
9496

9597
if (!$this->_isUrlInternal($refererUrl)) {
9698
$refererUrl = $this->_storeManager->getStore()->getBaseUrl();
99+
} else {
100+
$refererUrl = $this->normalizeRefererUrl($refererUrl);
97101
}
98102
return $refererUrl;
99103
}
@@ -210,4 +214,57 @@ protected function _isUrlInternal($url)
210214
}
211215
return false;
212216
}
217+
218+
/**
219+
* Normalize path to avoid wrong store change
220+
*
221+
* @param string $refererUrl
222+
* @return string
223+
*/
224+
protected function normalizeRefererUrl($refererUrl)
225+
{
226+
if (!$refererUrl || !filter_var($refererUrl, FILTER_VALIDATE_URL)) {
227+
return $refererUrl;
228+
}
229+
230+
$redirectParsedUrl = parse_url($refererUrl);
231+
$refererQuery = [];
232+
233+
if (!isset($redirectParsedUrl['query'])) {
234+
return $refererUrl;
235+
}
236+
237+
parse_str($redirectParsedUrl['query'], $refererQuery);
238+
239+
$refererQuery = $this->normalizeRefererQueryParts($refererQuery);
240+
$normalizedUrl = $redirectParsedUrl['scheme']
241+
. '://'
242+
. $redirectParsedUrl['host']
243+
. (isset($redirectParsedUrl['port']) ? ':' . $redirectParsedUrl['port'] : '')
244+
. $redirectParsedUrl['path']
245+
. ($refererQuery ? '?' . http_build_query($refererQuery) : '');
246+
247+
return $normalizedUrl;
248+
}
249+
250+
/**
251+
* Normalize special parts of referer query
252+
*
253+
* @param array $refererQuery
254+
* @return array
255+
*/
256+
protected function normalizeRefererQueryParts($refererQuery)
257+
{
258+
$store = $this->_storeManager->getStore();
259+
260+
if (
261+
$store
262+
&& !empty($refererQuery[StoreResolverInterface::PARAM_NAME])
263+
&& ($refererQuery[StoreResolverInterface::PARAM_NAME] !== $store->getCode())
264+
) {
265+
$refererQuery[StoreResolverInterface::PARAM_NAME] = $store->getCode();
266+
}
267+
268+
return $refererQuery;
269+
}
213270
}

app/code/Magento/Theme/view/adminhtml/page_layout/admin-login.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
-->
88
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_layout.xsd">
99
<container name="root" htmlTag="section" htmlClass="page-wrapper">
10+
<container name="after.body.start" as="after.body.start" label="Page Top" before="-"/>
1011
<container name="login.header" htmlTag="header" htmlClass="login-header"/>
1112
<container name="login.content" htmlTag="div" htmlClass="login-content"/>
1213
<container name="login.footer" htmlTag="footer" htmlClass="login-footer"/>

0 commit comments

Comments
 (0)