Skip to content

Commit 0a6c5b2

Browse files
authored
Merge pull request #418 from magento-mpi/MPI-PR-bugfixes
[MPI] Bugfixes
2 parents 8007ad1 + ca6bdeb commit 0a6c5b2

File tree

33 files changed

+735
-227
lines changed

33 files changed

+735
-227
lines changed

app/code/Magento/Braintree/Helper/Country.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,20 @@
66
namespace Magento\Braintree\Helper;
77

88
use Magento\Directory\Model\ResourceModel\Country\CollectionFactory;
9+
use Magento\Braintree\Model\Adminhtml\System\Config\Country as CountryConfig;
910

1011
/**
1112
* Class Country
1213
*/
1314
class Country
1415
{
1516
/**
16-
* @var \Magento\Directory\Model\ResourceModel\Country\CollectionFactory
17+
* @var CollectionFactory
1718
*/
1819
private $collectionFactory;
1920

2021
/**
21-
* @var \Magento\Braintree\Model\Adminhtml\System\Config\Country
22+
* @var CountryConfig
2223
*/
2324
private $countryConfig;
2425

@@ -28,13 +29,11 @@ class Country
2829
private $countries;
2930

3031
/**
31-
* @param \Magento\Directory\Model\ResourceModel\Country\CollectionFactory $factory
32-
* @param \Magento\Braintree\Model\Adminhtml\System\Config\Country $countryConfig
32+
* @param CollectionFactory $factory
33+
* @param CountryConfig $countryConfig
3334
*/
34-
public function __construct(
35-
\Magento\Directory\Model\ResourceModel\Country\CollectionFactory $factory,
36-
\Magento\Braintree\Model\Adminhtml\System\Config\Country $countryConfig
37-
) {
35+
public function __construct(CollectionFactory $factory, CountryConfig $countryConfig)
36+
{
3837
$this->collectionFactory = $factory;
3938
$this->countryConfig = $countryConfig;
4039
}

app/code/Magento/Braintree/etc/di.xml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
<argument name="code" xsi:type="const">Magento\Braintree\Model\Ui\PayPal\ConfigProvider::PAYPAL_CODE</argument>
2323
<argument name="infoBlockType" xsi:type="string">BraintreePayPalInfo</argument>
2424
<argument name="valueHandlerPool" xsi:type="object">BraintreePayPalValueHandlerPool</argument>
25+
<argument name="validatorPool" xsi:type="object">BraintreePayPalValidatorPool</argument>
2526
<argument name="commandPool" xsi:type="object">BraintreePayPalCommandPool</argument>
2627
</arguments>
2728
</virtualType>
@@ -474,7 +475,7 @@
474475
</arguments>
475476
</virtualType>
476477

477-
<!-- Value validators infrastructure -->
478+
<!-- Braintree validators infrastructure -->
478479
<virtualType name="BraintreeCountryValidator" type="Magento\Payment\Gateway\Validator\CountryValidator">
479480
<arguments>
480481
<argument name="config" xsi:type="object">Magento\Braintree\Gateway\Config\Config</argument>
@@ -487,6 +488,22 @@
487488
</argument>
488489
</arguments>
489490
</virtualType>
491+
<!-- Braintree validators infrastructure -->
492+
493+
<!-- Braintree PayPal validators -->
494+
<virtualType name="BraintreePayPalCountryValidator" type="Magento\Payment\Gateway\Validator\CountryValidator">
495+
<arguments>
496+
<argument name="config" xsi:type="object">Magento\Braintree\Gateway\Config\PayPal\Config</argument>
497+
</arguments>
498+
</virtualType>
499+
<virtualType name="BraintreePayPalValidatorPool" type="Magento\Payment\Gateway\Validator\ValidatorPool">
500+
<arguments>
501+
<argument name="validators" xsi:type="array">
502+
<item name="country" xsi:type="string">BraintreePayPalCountryValidator</item>
503+
</argument>
504+
</arguments>
505+
</virtualType>
506+
<!-- END Braintree PayPal validators -->
490507

491508
<type name="Magento\Braintree\Block\Info">
492509
<arguments>

app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/paypal.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,19 @@ define([
1212
'Magento_Checkout/js/model/quote',
1313
'Magento_Checkout/js/model/full-screen-loader',
1414
'Magento_Checkout/js/model/payment/additional-validators',
15-
'Magento_Vault/js/view/payment/vault-enabler'
16-
], function ($, _, Component, Braintree, quote, fullScreenLoader, additionalValidators, VaultEnabler) {
15+
'Magento_Vault/js/view/payment/vault-enabler',
16+
'Magento_Checkout/js/action/create-billing-address'
17+
], function (
18+
$,
19+
_,
20+
Component,
21+
Braintree,
22+
quote,
23+
fullScreenLoader,
24+
additionalValidators,
25+
VaultEnabler,
26+
createBillingAddress
27+
) {
1728
'use strict';
1829

1930
return Component.extend({
@@ -172,14 +183,16 @@ define([
172183
var billingAddress = {
173184
street: [address.streetAddress],
174185
city: address.locality,
175-
regionCode: address.region,
176186
postcode: address.postalCode,
177187
countryId: address.countryCodeAlpha2,
188+
email: customer.email,
178189
firstname: customer.firstName,
179190
lastname: customer.lastName,
180191
telephone: customer.phone
181192
};
182193

194+
billingAddress['region_code'] = address.region;
195+
billingAddress = createBillingAddress(billingAddress);
183196
quote.billingAddress(billingAddress);
184197
},
185198

app/code/Magento/Braintree/view/frontend/web/template/payment/form.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@
109109
<input type="checkbox"
110110
name="vault[is_enabled]"
111111
class="checkbox"
112-
data-bind="attr: {'id': getCode() + '_vault_enabler'}, checked: vaultEnabler.isActivePaymentTokenEnabler"/>
113-
<label class="label" data-bind="attr: {'for': getCode() + '_vault_enabler'}">
112+
data-bind="attr: {'id': getCode() + '_enable_vault'}, checked: vaultEnabler.isActivePaymentTokenEnabler"/>
113+
<label class="label" data-bind="attr: {'for': getCode() + '_enable_vault'}">
114114
<span><!-- ko i18n: 'Save for later use.'--><!-- /ko --></span>
115115
</label>
116116
<div class="field-tooltip toggle">

app/code/Magento/Braintree/view/frontend/web/template/payment/paypal.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
<input type="checkbox"
3333
name="vault[is_enabled]"
3434
class="checkbox"
35-
data-bind="attr: {'id': getCode() + '_vault_enabler'}, checked: vaultEnabler.isActivePaymentTokenEnabler"/>
36-
<label class="label" data-bind="attr: {'for': getCode() + '_vault_enabler'}">
35+
data-bind="attr: {'id': getCode() + '_enable_vault'}, checked: vaultEnabler.isActivePaymentTokenEnabler"/>
36+
<label class="label" data-bind="attr: {'for': getCode() + '_enable_vault'}">
3737
<span><!-- ko i18n: 'Save for later use.'--><!-- /ko --></span>
3838
</label>
3939
<div class="field-tooltip toggle">

0 commit comments

Comments
 (0)