Skip to content

Commit

Permalink
merge magento/2.3-develop into magento-techdivision/varnish6_update
Browse files Browse the repository at this point in the history
  • Loading branch information
magento-cicd2 authored Jul 23, 2019
2 parents 9c42b8e + 9b7e0cb commit 0b71e69
Show file tree
Hide file tree
Showing 57 changed files with 1,201 additions and 386 deletions.
5 changes: 5 additions & 0 deletions app/code/Magento/AuthorizenetAcceptjs/etc/adminhtml/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,9 @@
</argument>
</arguments>
</virtualType>
<virtualType name="AuthorizenetAcceptjsAuthorizeCommand" type="Magento\Payment\Gateway\Command\GatewayCommand">
<arguments>
<argument name="validator" xsi:type="object">AuthorizenetAcceptjsTransactionValidator</argument>
</arguments>
</virtualType>
</config>
2 changes: 2 additions & 0 deletions app/code/Magento/AuthorizenetAcceptjs/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
<arguments>
<argument name="requestBuilder" xsi:type="object">AuthorizenetAcceptjsRefundRequest</argument>
<argument name="handler" xsi:type="object">AuthorizenetAcceptjsRefundSettledHandler</argument>
<argument name="validator" xsi:type="object">AuthorizenetAcceptjsTransactionValidator</argument>
</arguments>
</virtualType>
<virtualType name="AuthorizenetAcceptjsCaptureCommand" type="Magento\AuthorizenetAcceptjs\Gateway\Command\CaptureStrategyCommand">
Expand All @@ -145,6 +146,7 @@
<arguments>
<argument name="requestBuilder" xsi:type="object">AuthorizenetAcceptjsCaptureRequest</argument>
<argument name="handler" xsi:type="object">AuthorizenetAcceptjsCaptureTransactionHandler</argument>
<argument name="validator" xsi:type="object">AuthorizenetAcceptjsTransactionValidator</argument>
</arguments>
</virtualType>
<virtualType name="AuthorizenetAcceptjsVoidCommand" type="Magento\Payment\Gateway\Command\GatewayCommand">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<button class="action primary checkout"
type="submit"
click="beforePlaceOrder"
css="disabled: !isPlaceOrderActionAllowed()"
attr="title: $t('Place Order')"
>
<span translate="'Place Order'"></span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use Magento\AuthorizenetAcceptjs\Gateway\SubjectReader;
use Magento\AuthorizenetCardinal\Model\Config;
use Magento\CardinalCommerce\Model\Response\JwtParser;
use Magento\CardinalCommerce\Model\Response\JwtParserInterface;
use Magento\Payment\Gateway\Request\BuilderInterface;
use Magento\Sales\Model\Order\Payment;

Expand All @@ -30,19 +30,19 @@ class Authorize3DSecureBuilder implements BuilderInterface
private $config;

/**
* @var JwtParser
* @var JwtParserInterface
*/
private $jwtParser;

/**
* @param SubjectReader $subjectReader
* @param Config $config
* @param JwtParser $jwtParser
* @param JwtParserInterface $jwtParser
*/
public function __construct(
SubjectReader $subjectReader,
Config $config,
JwtParser $jwtParser
JwtParserInterface $jwtParser
) {
$this->subjectReader = $subjectReader;
$this->config = $config;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

declare(strict_types=1);

namespace Magento\AuthorizenetCardinal\Gateway\Validator;

use Magento\AuthorizenetAcceptjs\Gateway\SubjectReader;
use Magento\AuthorizenetCardinal\Model\Config;
use Magento\Payment\Gateway\Validator\AbstractValidator;
use Magento\Payment\Gateway\Validator\ResultInterface;
use Magento\Payment\Gateway\Validator\ResultInterfaceFactory;

/**
* Validates cardholder authentication verification response code.
*/
class CavvResponseValidator extends AbstractValidator
{
/**
* The result code that authorize.net returns if CAVV passed validation.
*/
private const RESULT_CODE_SUCCESS = '2';

/**
* @var SubjectReader
*/
private $subjectReader;

/**
* @var ResultInterfaceFactory
*/
private $resultFactory;

/**
* @var Config
*/
private $config;

/**
* @param ResultInterfaceFactory $resultFactory
* @param SubjectReader $subjectReader
* @param Config $config
*/
public function __construct(
ResultInterfaceFactory $resultFactory,
SubjectReader $subjectReader,
Config $config
) {
parent::__construct($resultFactory);

$this->resultFactory = $resultFactory;
$this->subjectReader = $subjectReader;
$this->config = $config;
}

/**
* @inheritdoc
*/
public function validate(array $validationSubject): ResultInterface
{
if ($this->config->isActive() === false) {
return $this->createResult(true);
}

$response = $this->subjectReader->readResponse($validationSubject);
$transactionResponse = $response['transactionResponse'];

$cavvResultCode = $transactionResponse['cavvResultCode'] ?? '';
$isValid = $cavvResultCode === self::RESULT_CODE_SUCCESS;
$errorCodes = [];
$errorMessages = [];

if (!$isValid) {
$errorCodes[] = $transactionResponse['cavvResultCode'];
$errorMessages[] = 'CAVV failed validation';
}

return $this->createResult($isValid, $errorMessages, $errorCodes);
}
}
16 changes: 16 additions & 0 deletions app/code/Magento/AuthorizenetCardinal/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,20 @@
</argument>
</arguments>
</virtualType>
<virtualType name="Magento\AuthorizenetCardinal\Gateway\Validator\VirtualTransactionValidator" type="Magento\Payment\Gateway\Validator\ValidatorComposite">
<arguments>
<argument name="chainBreakingValidators" xsi:type="array">
<item name="general" xsi:type="boolean">true</item>
</argument>
<argument name="validators" xsi:type="array">
<item name="general" xsi:type="string">AuthorizenetAcceptjsTransactionValidator</item>
<item name="cavv_response" xsi:type="string">Magento\AuthorizenetCardinal\Gateway\Validator\CavvResponseValidator</item>
</argument>
</arguments>
</virtualType>
<virtualType name="AuthorizenetAcceptjsAuthorizeCommand">
<arguments>
<argument name="validator" xsi:type="object">Magento\AuthorizenetCardinal\Gateway\Validator\VirtualTransactionValidator</argument>
</arguments>
</virtualType>
</config>
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ define([
},

/**
* Adds cardinal response JWT to payment additional data.
*
* @returns {Object}
*/
getData: function () {
Expand Down
10 changes: 5 additions & 5 deletions app/code/Magento/Braintree/view/frontend/requirejs-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
var config = {
map: {
'*': {
braintreeClient: 'https://js.braintreegateway.com/web/3.44.1/js/client.min.js',
braintreeHostedFields: 'https://js.braintreegateway.com/web/3.44.1/js/hosted-fields.min.js',
braintreePayPal: 'https://js.braintreegateway.com/web/3.44.1/js/paypal-checkout.min.js',
braintree3DSecure: 'https://js.braintreegateway.com/web/3.44.1/js/three-d-secure.min.js',
braintreeDataCollector: 'https://js.braintreegateway.com/web/3.44.1/js/data-collector.min.js'
braintreeClient: 'https://js.braintreegateway.com/web/3.46.0-beta-3ds.8/js/client.min.js',
braintreeHostedFields: 'https://js.braintreegateway.com/web/3.46.0-beta-3ds.8/js/hosted-fields.min.js',
braintreePayPal: 'https://js.braintreegateway.com/web/3.46.0-beta-3ds.8/js/paypal-checkout.min.js',
braintree3DSecure: 'https://js.braintreegateway.com/web/3.46.0-beta-3ds.8/js/three-d-secure.min.js',
braintreeDataCollector: 'https://js.braintreegateway.com/web/3.46.0-beta-3ds.8/js/data-collector.min.js'
}
},
paths: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ define([
braintreeAdapter.getApiClient()
.then(function (clientInstance) {
return braintree3DSecure.create({
version: 2, // Will use 3DS 2 whenever possible
client: clientInstance
});
})
Expand All @@ -49,6 +50,7 @@ define([
promise.resolve(self.threeDSecureInstance);
})
.catch(function (err) {
fullScreenLoader.stopLoader();
promise.reject(err);
});

Expand Down Expand Up @@ -84,30 +86,55 @@ define([
var self = this,
totalAmount = quote.totals()['base_grand_total'],
billingAddress = quote.billingAddress(),
shippingAddress = quote.shippingAddress(),
options = {
amount: totalAmount,
nonce: context.paymentPayload.nonce,

/**
* Adds iframe to page
* @param {Object} err
* @param {Object} iframe
*/
addFrame: function (err, iframe) {
self.createModal($(iframe));
fullScreenLoader.stopLoader();
self.modal.openModal();
billingAddress: {
givenName: billingAddress.firstname,
surname: billingAddress.lastname,
phoneNumber: billingAddress.telephone,
streetAddress: billingAddress.street[0],
extendedAddress: billingAddress.street[1],
locality: billingAddress.city,
region: billingAddress.regionCode,
postalCode: billingAddress.postcode,
countryCodeAlpha2: billingAddress.countryId
},

/**
* Removes iframe from page
* Will be called after receiving ThreeDSecure response, before completing the flow.
*
* @param {Object} data - ThreeDSecure data to consume before continuing
* @param {Function} next - callback to continue flow
*/
removeFrame: function () {
self.modal.closeModal();
onLookupComplete: function (data, next) {
next();
}
};

if (context.paymentPayload.details) {
options.bin = context.paymentPayload.details.bin;
}

if (shippingAddress) {
options.additionalInformation = {
shippingGivenName: shippingAddress.firstname,
shippingSurname: shippingAddress.lastname,
shippingPhone: shippingAddress.telephone,
shippingAddress: {
streetAddress: shippingAddress.street[0],
extendedAddress: shippingAddress.street[1],
locality: shippingAddress.city,
region: shippingAddress.regionCode,
postalCode: shippingAddress.postcode,
countryCodeAlpha2: shippingAddress.countryId
}
};
}

if (!this.isAmountAvailable(totalAmount) || !this.isCountryAvailable(billingAddress.countryId)) {
self.state = $.Deferred();
self.state.resolve();

return self.state.promise();
Expand All @@ -118,6 +145,7 @@ define([
.then(function () {
self.threeDSecureInstance.verifyCard(options, function (err, payload) {
if (err) {
fullScreenLoader.stopLoader();
self.state.reject(err.message);

return;
Expand All @@ -129,6 +157,7 @@ define([
context.paymentPayload.nonce = payload.nonce;
self.state.resolve();
} else {
fullScreenLoader.stopLoader();
self.state.reject($t('Please try again with another form of payment.'));
}
});
Expand All @@ -141,42 +170,6 @@ define([
return self.state.promise();
},

/**
* Creates modal window
*
* @param {Object} $context
* @private
*/
createModal: function ($context) {
var self = this,
options = {
clickableOverlay: false,
buttons: [],
modalCloseBtnHandler: self.cancelFlow.bind(self),
keyEventHandlers: {
escapeKey: self.cancelFlow.bind(self)
}
};

// adjust iframe styles
$context.attr('width', '100%');
self.modal = Modal(options, $context);
},

/**
* Cancels 3D Secure flow
*
* @private
*/
cancelFlow: function () {
var self = this;

self.threeDSecureInstance.cancelVerifyCard(function () {
self.modal.closeModal();
self.state.reject();
});
},

/**
* Checks minimal amount for 3D Secure activation
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
use Magento\Payment\Model\Method\Logger as PaymentLogger;

/**
* Parse content of CardinalCommerce response JWT.
* Parses content of CardinalCommerce response JWT.
*/
class JwtParser
class JwtParser implements JwtParserInterface
{
/**
* @var JwtManagement
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\CardinalCommerce\Model\Response;

/**
* Parses content of CardinalCommerce response JWT.
*/
interface JwtParserInterface
{
/**
* Returns response JWT content.
*
* @param string $jwt
* @return array
*/
public function execute(string $jwt): array;
}
5 changes: 2 additions & 3 deletions app/code/Magento/CardinalCommerce/etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@
<resource>Magento_Sales::three_d_secure</resource>
<group id="cardinal" type="text" sortOrder="13" showInDefault="1" showInWebsite="1" showInStore="0">
<group id="config" translate="label comment" sortOrder="15" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Configuration</label>
<comment><![CDATA[For support contact <a href="mailto:[email protected]">[email protected]</a>.]]>
</comment>
<label>CardinalCommerce</label>
<comment><![CDATA[Please visit <a href="https://www.cardinalcommerce.com/" target="_blank">www.cardinalcommerce.com</a> to get the CardinalCommerce credentials and find out more details about PSD2 SCA requirements. For support contact <a href="mailto:[email protected]">[email protected]</a>.]]></comment>
<field id="environment" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Environment</label>
<source_model>Magento\CardinalCommerce\Model\Adminhtml\Source\Environment</source_model>
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/CardinalCommerce/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\CardinalCommerce\Model\Response\JwtPayloadValidatorInterface" type="Magento\CardinalCommerce\Model\Response\JwtPayloadValidator" />
<preference for="Magento\CardinalCommerce\Model\Response\JwtParserInterface" type="Magento\CardinalCommerce\Model\Response\JwtParser" />
</config>
Loading

0 comments on commit 0b71e69

Please sign in to comment.