Skip to content

Commit e328175

Browse files
author
Michail Slabko
committed
Merge remote-tracking branch 'mainline/develop' into MAGETWO-37174
2 parents 48a3a03 + 2cb2fa5 commit e328175

File tree

49 files changed

+1234
-461
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1234
-461
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/Dhl/Block/Adminhtml/Unitofmeasure.php

Lines changed: 33 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,45 @@
33
* Copyright © 2015 Magento. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
7-
// @codingStandardsIgnoreFile
8-
96
namespace Magento\Dhl\Block\Adminhtml;
107

8+
use Magento\Dhl\Model;
9+
use Magento\Shipping\Helper;
10+
use Magento\Backend\Block\Template\Context;
11+
use Magento\Config\Block\System\Config\Form\Field;
12+
use Magento\Framework\Data\Form\Element\AbstractElement;
13+
1114
/**
1215
* Frontend model for DHL shipping methods for documentation
1316
*/
14-
class Unitofmeasure extends \Magento\Config\Block\System\Config\Form\Field
17+
class Unitofmeasure extends Field
1518
{
1619
/**
1720
* Carrier helper
1821
*
19-
* @var \Magento\Shipping\Helper\Carrier
22+
* @var Helper\Carrier
2023
*/
21-
protected $_carrierHelper;
24+
protected $carrierHelper;
2225

2326
/**
24-
* @var \Magento\Dhl\Model\Carrier
27+
* @var Model\Carrier
2528
*/
2629
protected $carrierDhl;
2730

2831
/**
29-
* @param \Magento\Backend\Block\Template\Context $context
30-
* @param \Magento\Dhl\Model\Carrier $carrierDhl
31-
* @param \Magento\Shipping\Helper\Carrier $carrierHelper
32+
* @param Context $context
33+
* @param Model\Carrier $carrierDhl
34+
* @param Helper\Carrier $carrierHelper
3235
* @param array $data
3336
*/
3437
public function __construct(
35-
\Magento\Backend\Block\Template\Context $context,
36-
\Magento\Dhl\Model\Carrier $carrierDhl,
37-
\Magento\Shipping\Helper\Carrier $carrierHelper,
38+
Context $context,
39+
Model\Carrier $carrierDhl,
40+
Helper\Carrier $carrierHelper,
3841
array $data = []
3942
) {
4043
$this->carrierDhl = $carrierDhl;
41-
$this->_carrierHelper = $carrierHelper;
44+
$this->carrierHelper = $carrierHelper;
4245
parent::__construct($context, $data);
4346
}
4447

@@ -51,29 +54,25 @@ public function _construct()
5154
{
5255
parent::_construct();
5356

54-
$carrierModel = $this->carrierDhl;
57+
$this->setInch($this->carrierDhl->getCode('unit_of_dimension_cut', 'I'));
58+
$this->setCm($this->carrierDhl->getCode('unit_of_dimension_cut', 'C'));
5559

56-
$this->setInch($this->escapeJsQuote($carrierModel->getCode('unit_of_dimension_cut', 'I')));
57-
$this->setCm($this->escapeJsQuote($carrierModel->getCode('unit_of_dimension_cut', 'C')));
58-
59-
$this->setHeight($this->escapeJsQuote($carrierModel->getCode('dimensions', 'height')));
60-
$this->setDepth($this->escapeJsQuote($carrierModel->getCode('dimensions', 'depth')));
61-
$this->setWidth($this->escapeJsQuote($carrierModel->getCode('dimensions', 'width')));
60+
$this->setHeight($this->carrierDhl->getCode('dimensions', 'height'));
61+
$this->setDepth($this->carrierDhl->getCode('dimensions', 'depth'));
62+
$this->setWidth($this->carrierDhl->getCode('dimensions', 'width'));
6263

6364
$kgWeight = 70;
6465

6566
$this->setDivideOrderWeightNoteKg(
66-
$this->escapeJsQuote(
67-
__(
68-
'Select this to allow DHL to optimize shipping charges by splitting the order if it exceeds %1 %2.',
69-
$kgWeight,
70-
'kg'
71-
)
67+
__(
68+
'Select this to allow DHL to optimize shipping charges by splitting the order if it exceeds %1 %2.',
69+
$kgWeight,
70+
'kg'
7271
)
7372
);
7473

7574
$weight = round(
76-
$this->_carrierHelper->convertMeasureWeight(
75+
$this->carrierHelper->convertMeasureWeight(
7776
$kgWeight,
7877
\Zend_Measure_Weight::KILOGRAM,
7978
\Zend_Measure_Weight::POUND
@@ -82,12 +81,10 @@ public function _construct()
8281
);
8382

8483
$this->setDivideOrderWeightNoteLbp(
85-
$this->escapeJsQuote(
86-
__(
87-
'Select this to allow DHL to optimize shipping charges by splitting the order if it exceeds %1 %2.',
88-
$weight,
89-
'pounds'
90-
)
84+
__(
85+
'Select this to allow DHL to optimize shipping charges by splitting the order if it exceeds %1 %2.',
86+
$weight,
87+
'pounds'
9188
)
9289
);
9390

@@ -97,10 +94,10 @@ public function _construct()
9794
/**
9895
* Retrieve Element HTML fragment
9996
*
100-
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
97+
* @param AbstractElement $element
10198
* @return string
10299
*/
103-
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
100+
protected function _getElementHtml(AbstractElement $element)
104101
{
105102
return parent::_getElementHtml($element) . $this->_toHtml();
106103
}

0 commit comments

Comments
 (0)