Skip to content

Commit

Permalink
merge magento/2.3-develop into magento-tsg/2.3-develop-pr67
Browse files Browse the repository at this point in the history
  • Loading branch information
magento-cicd2 authored Sep 17, 2019
2 parents c4b62a3 + 27985bc commit b16b1eb
Show file tree
Hide file tree
Showing 220 changed files with 9,378 additions and 1,472 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Braintree\Gateway\Request;

use Magento\Payment\Gateway\Request\BuilderInterface;
use Magento\Braintree\Gateway\SubjectReader;

/**
* Class BillingAddressDataBuilder
*/
class BillingAddressDataBuilder implements BuilderInterface
{
/**
* @var SubjectReader
*/
private $subjectReader;

/**
* BillingAddress block name
*/
private const BILLING_ADDRESS = 'billing';

/**
* The customer’s company. 255 character maximum.
*/
private const COMPANY = 'company';

/**
* The first name value must be less than or equal to 255 characters.
*/
private const FIRST_NAME = 'firstName';

/**
* The last name value must be less than or equal to 255 characters.
*/
private const LAST_NAME = 'lastName';

/**
* The street address. Maximum 255 characters, and must contain at least 1 digit.
* Required when AVS rules are configured to require street address.
*/
private const STREET_ADDRESS = 'streetAddress';

/**
* The postal code. Postal code must be a string of 5 or 9 alphanumeric digits,
* optionally separated by a dash or a space. Spaces, hyphens,
* and all other special characters are ignored.
*/
private const POSTAL_CODE = 'postalCode';

/**
* The ISO 3166-1 alpha-2 country code specified in an address.
* The gateway only accepts specific alpha-2 values.
*
* @link https://developers.braintreepayments.com/reference/general/countries/php#list-of-countries
*/
private const COUNTRY_CODE = 'countryCodeAlpha2';

/**
* The extended address information—such as apartment or suite number. 255 character maximum.
*/
private const EXTENDED_ADDRESS = 'extendedAddress';

/**
* The locality/city. 255 character maximum.
*/
private const LOCALITY = 'locality';

/**
* The state or province. For PayPal addresses, the region must be a 2-letter abbreviation;
*/
private const REGION = 'region';

/**
* @param SubjectReader $subjectReader
*/
public function __construct(SubjectReader $subjectReader)
{
$this->subjectReader = $subjectReader;
}

/**
* @inheritdoc
*/
public function build(array $buildSubject)
{
$paymentDO = $this->subjectReader->readPayment($buildSubject);

$result = [];
$order = $paymentDO->getOrder();

$billingAddress = $order->getBillingAddress();
if ($billingAddress) {
$result[self::BILLING_ADDRESS] = [
self::REGION => $billingAddress->getRegionCode(),
self::POSTAL_CODE => $billingAddress->getPostcode(),
self::COUNTRY_CODE => $billingAddress->getCountryId(),
self::FIRST_NAME => $billingAddress->getFirstname(),
self::STREET_ADDRESS => $billingAddress->getStreetLine1(),
self::LAST_NAME => $billingAddress->getLastname(),
self::COMPANY => $billingAddress->getCompany(),
self::EXTENDED_ADDRESS => $billingAddress->getStreetLine2(),
self::LOCALITY => $billingAddress->getCity()
];
}

return $result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ public function getErrorCodeDataProvider(): array
'errors' => [],
'transaction' => [
'status' => 'processor_declined',
'processorResponseCode' => '1000'
'processorResponseCode' => '2059'
],
'expectedResult' => ['1000']
'expectedResult' => ['2059']
],
[
'errors' => [
Expand Down
6 changes: 3 additions & 3 deletions app/code/Magento/Braintree/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
"magento/module-sales": "*",
"magento/module-ui": "*",
"magento/module-vault": "*",
"magento/module-multishipping": "*"
"magento/module-multishipping": "*",
"magento/module-theme": "*"
},
"suggest": {
"magento/module-checkout-agreements": "*",
"magento/module-theme": "*"
"magento/module-checkout-agreements": "*"
},
"type": "magento2-module",
"license": [
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/Braintree/etc/braintree_error_mapping.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<message code="81723" translate="true">Cardholder name is too long.</message>
<message code="81736" translate="true">CVV verification failed.</message>
<message code="cvv" translate="true">CVV verification failed.</message>
<message code="2059" translate="true">Address Verification Failed.</message>
<message code="81737" translate="true">Postal code verification failed.</message>
<message code="81750" translate="true">Credit card number is prohibited.</message>
<message code="81801" translate="true">Addresses must have at least one field filled in.</message>
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Braintree/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@
<item name="customer" xsi:type="string">Magento\Braintree\Gateway\Request\CustomerDataBuilder</item>
<item name="payment" xsi:type="string">Magento\Braintree\Gateway\Request\PaymentDataBuilder</item>
<item name="channel" xsi:type="string">Magento\Braintree\Gateway\Request\ChannelDataBuilder</item>
<item name="address" xsi:type="string">Magento\Braintree\Gateway\Request\AddressDataBuilder</item>
<item name="address" xsi:type="string">Magento\Braintree\Gateway\Request\BillingAddressDataBuilder</item>
<item name="dynamic_descriptor" xsi:type="string">Magento\Braintree\Gateway\Request\DescriptorDataBuilder</item>
<item name="store" xsi:type="string">Magento\Braintree\Gateway\Request\StoreConfigBuilder</item>
<item name="merchant_account" xsi:type="string">Magento\Braintree\Gateway\Request\MerchantAccountDataBuilder</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ define([
'Magento_Vault/js/view/payment/vault-enabler',
'Magento_Checkout/js/action/create-billing-address',
'Magento_Braintree/js/view/payment/kount',
'mage/translate'
'mage/translate',
'Magento_Ui/js/model/messageList'
], function (
$,
_,
Expand All @@ -31,7 +32,8 @@ define([
VaultEnabler,
createBillingAddress,
kount,
$t
$t,
globalMessageList
) {
'use strict';

Expand Down Expand Up @@ -415,6 +417,18 @@ define([
*/
onVaultPaymentTokenEnablerChange: function () {
this.reInitPayPal();
},

/**
* Show error message
*
* @param {String} errorMessage
* @private
*/
showError: function (errorMessage) {
globalMessageList.addErrorMessage({
message: errorMessage
});
}
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="AdminAssociateBundleProductToWebsitesTest">
<annotations>
<features value="Bundle"/>
<stories value="Create/Edit bundle product in Admin"/>
<title value="Admin should be able to associate bundle product to websites"/>
<description value="Admin should be able to associate bundle product to websites"/>
<testCaseId value="MC-3344"/>
<severity value="CRITICAL"/>
<group value="bundle"/>
<group value="catalog"/>
</annotations>
<before>
<!-- Configure Store URLs -->
<magentoCLI command="config:set {{StorefrontEnableAddStoreCodeToUrls.path}} {{StorefrontEnableAddStoreCodeToUrls.value}}" stepKey="setAddStoreCodeToUrlsToYes"/>

<!-- Create category -->
<createData entity="SimpleSubCategory" stepKey="createCategory"/>

<!-- Create Simple product -->
<createData entity="SimpleProduct2" stepKey="createSimpleProduct"/>

<!-- Create Bundle product -->
<createData entity="ApiBundleProductPriceViewRange" stepKey="createBundleProduct">
<requiredEntity createDataKey="createCategory"/>
</createData>
<createData entity="DropDownBundleOption" stepKey="bundleOption">
<requiredEntity createDataKey="createBundleProduct"/>
</createData>
<createData entity="ApiBundleLink" stepKey="createNewBundleLink">
<requiredEntity createDataKey="createBundleProduct"/>
<requiredEntity createDataKey="bundleOption"/>
<requiredEntity createDataKey="createSimpleProduct"/>
</createData>

<!-- Reindex -->
<magentoCLI command="indexer:reindex" stepKey="reindex"/>

<!-- Login as admin -->
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>

<!--Create website-->
<actionGroup ref="AdminCreateWebsiteActionGroup" stepKey="createSecondWebsite">
<argument name="newWebsiteName" value="{{secondCustomWebsite.name}}"/>
<argument name="websiteCode" value="{{secondCustomWebsite.code}}"/>
</actionGroup>
<!-- Create second store -->
<actionGroup ref="AdminCreateNewStoreGroupActionGroup" stepKey="createSecondStoreGroup">
<argument name="website" value="{{secondCustomWebsite.name}}"/>
<argument name="storeGroupName" value="{{SecondStoreGroupUnique.name}}"/>
<argument name="storeGroupCode" value="{{SecondStoreGroupUnique.code}}"/>
</actionGroup>
<!-- Create second store view -->
<actionGroup ref="AdminCreateStoreViewActionGroup" stepKey="createSecondStoreView">
<argument name="StoreGroup" value="SecondStoreGroupUnique"/>
<argument name="customStore" value="SecondStoreUnique"/>
</actionGroup>
</before>
<after>
<!-- Disabled Store URLs -->
<magentoCLI command="config:set {{StorefrontDisableAddStoreCodeToUrls.path}} {{StorefrontDisableAddStoreCodeToUrls.value}}" stepKey="setAddStoreCodeToUrlsToNo"/>

<!-- Delete simple product -->
<deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/>
<!-- Delete bundle product -->
<deleteData createDataKey="createBundleProduct" stepKey="deleteBundleProduct"/>

<!-- Delete second website -->
<actionGroup ref="AdminDeleteWebsiteActionGroup" stepKey="deleteWebsite">
<argument name="websiteName" value="{{secondCustomWebsite.name}}"/>
</actionGroup>

<actionGroup ref="NavigateToAndResetProductGridToDefaultView" stepKey="resetProductGridFilter"/>

<!-- Admin logout -->
<actionGroup ref="logout" stepKey="adminLogout"/>
</after>

<!-- Open product page and assign grouped project to second website -->
<actionGroup ref="filterAndSelectProduct" stepKey="openAdminProductPage">
<argument name="productSku" value="$$createBundleProduct.sku$$"/>
</actionGroup>
<actionGroup ref="AdminAssignProductInWebsiteActionGroup" stepKey="assignProductToSecondWebsite">
<argument name="website" value="{{secondCustomWebsite.name}}"/>
</actionGroup>
<actionGroup ref="AdminUnassignProductInWebsiteActionGroup" stepKey="unassignProductFromDefaultWebsite">
<argument name="website" value="{{_defaultWebsite.name}}"/>
</actionGroup>
<actionGroup ref="saveProductForm" stepKey="saveGroupedProduct"/>

<!-- Assert product is assigned to Second website -->
<actionGroup ref="AssertProductIsAssignedToWebsite" stepKey="seeCustomWebsiteIsChecked">
<argument name="website" value="{{secondCustomWebsite.name}}"/>
</actionGroup>

<!-- Assert product is not assigned to Main website -->
<actionGroup ref="AssertProductIsNotAssignedToWebsite" stepKey="seeMainWebsiteIsNotChecked">
<argument name="website" value="{{_defaultWebsite.name}}"/>
</actionGroup>

<!-- Go to frontend and open product on Main website -->
<actionGroup ref="StorefrontOpenProductPageActionGroup" stepKey="openProductPage">
<argument name="productUrl" value="$$createBundleProduct.custom_attributes[url_key]$$"/>
</actionGroup>

<!-- Assert 404 page -->
<actionGroup ref="StorefrontAssertPageNotFoundErrorOnProductDetailPageActionGroup" stepKey="assertPageNotFoundError">
<argument name="product" value="$$createBundleProduct$$"/>
</actionGroup>

<!-- Assert product is present at Second website -->
<actionGroup ref="StorefrontOpenProductPageUsingStoreCodeInUrlActionGroup" stepKey="openProductPageUsingStoreCodeInUrl">
<argument name="product" value="$$createBundleProduct$$"/>
<argument name="storeView" value="SecondStoreUnique"/>
</actionGroup>
</test>
</tests>
Loading

0 comments on commit b16b1eb

Please sign in to comment.