Skip to content

Commit

Permalink
Merge pull request #386 from magento-mpi/MAGETWO-58282
Browse files Browse the repository at this point in the history
Fixed issues:
 - MAGETWO-56347 [Github] #5788 REST API PayPal does not call setExpressCheckout method
 - MAGETWO-57744 Configure button for Paypal solutions is shifted after changing window width
 - MAGETWO-57855 Outdated PayPal URL
 - MAGETWO-58162 PayPal Payflow Pro always using USD (even if this currency is absent on your store)
 - MAGETWO-58255 Unable to view signed up billing agreement on storefront
 - MAGETWO-58282 [PR] Bugfixes delivery for 2.2
 - MAGETWO-56934 Checkout page freezes when ordering with Authorize.net with invalid credit card
 - MAGETWO-57893 Orders processed via Paypal Payflow Pro not receiving shipping/tax charges
  • Loading branch information
Oleksii Korshenko authored Sep 14, 2016
2 parents 1ade3b7 + 656a3c5 commit 152dbdc
Show file tree
Hide file tree
Showing 19 changed files with 75 additions and 43 deletions.
4 changes: 2 additions & 2 deletions app/code/Magento/Braintree/etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</requires>
</field>
<field id="braintree_cc_vault_active" translate="label" type="select" sortOrder="12" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Vault enabled</label>
<label>Vault Enabled</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/braintree_cc_vault/active</config_path>
<requires>
Expand Down Expand Up @@ -155,7 +155,7 @@
<comment>It is recommended to set this value to "PayPal" per store views.</comment>
</field>
<field id="braintree_paypal_vault_active" translate="label" type="select" sortOrder="21" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Vault enabled</label>
<label>Vault Enabled</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/braintree_paypal_vault/active</config_path>
<requires>
Expand Down
4 changes: 2 additions & 2 deletions app/code/Magento/Braintree/view/adminhtml/web/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
* See COPYING.txt for license details.
*/

.braintree-section .heading {display: inline-block; background: url("images/braintree_logo.png") no-repeat 0 50% / 18rem auto; padding-left: 20rem;}
.braintree-section .button-container {display: inline-block; float: right;}
.braintree-section .heading {background: url("images/braintree_logo.png") no-repeat 0 50% / 18rem auto; padding-left: 20rem;}
.braintree-section .button-container {float: right;}
.braintree-section .config-alt {background: url("images/braintree_allinone.png") no-repeat scroll 0 0 / 100% auto; height: 28px; margin: 0.5rem 0 0; width: 230px;}
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ define(
*/
clearTimeout: function () {
clearTimeout(this.timeoutId);
this.fail();

return this;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,10 @@ protected function _isPaymentEnabled($element)
*/
protected function _getHeaderTitleHtml($element)
{
$html = '<div class="config-heading" ><div class="heading"><strong>' . $element->getLegend();
$html = '<div class="config-heading" >';

$groupConfig = $element->getGroup();

$html .= '</strong>';

if ($element->getComment()) {
$html .= '<span class="heading-intro">' . $element->getComment() . '</span>';
}
$html .= '<div class="config-alt"></div>';
$html .= '</div>';

$disabledAttributeString = $this->_isPaymentEnabled($element) ? '' : ' disabled="disabled"';
$disabledClassString = $this->_isPaymentEnabled($element) ? '' : ' disabled';
$htmlId = $element->getHtmlId();
Expand Down Expand Up @@ -122,6 +114,13 @@ protected function _getHeaderTitleHtml($element)
) . '</a>';
}

$html .= '</div>';
$html .= '<div class="heading"><strong>' . $element->getLegend() . '</strong>';

if ($element->getComment()) {
$html .= '<span class="heading-intro">' . $element->getComment() . '</span>';
}
$html .= '<div class="config-alt"></div>';
$html .= '</div></div>';

return $html;
Expand Down
4 changes: 3 additions & 1 deletion app/code/Magento/Paypal/Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,9 @@ public function isOrderReviewStepDisabled()
*/
public function getExpressCheckoutStartUrl($token)
{
return $this->getPaypalUrl(['cmd' => '_express-checkout', 'token' => $token]);
return sprintf('https://www.%spaypal.com/checkoutnow/2%s',
$this->getValue('sandboxFlag') ? 'sandbox.' : '',
'?token=' . urlencode($token));
}

/**
Expand Down
14 changes: 4 additions & 10 deletions app/code/Magento/Paypal/Model/Express.php
Original file line number Diff line number Diff line change
Expand Up @@ -672,19 +672,13 @@ public function assignData(\Magento\Framework\DataObject $data)

$additionalData = $data->getData(PaymentInterface::KEY_ADDITIONAL_DATA);

if (
!is_array($additionalData)
|| !isset($additionalData[ExpressCheckout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT])
) {
if (!is_array($additionalData)) {
return $this;
}

$this->getInfoInstance()
->setAdditionalInformation(
ExpressCheckout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT,
$additionalData[ExpressCheckout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT]
);

foreach ($additionalData as $key => $value) {
$this->getInfoInstance()->setAdditionalInformation($key, $value);
}
return $this;
}

Expand Down
3 changes: 3 additions & 0 deletions app/code/Magento/Paypal/Model/Payflow/Transparent.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ public function authorize(InfoInterface $payment, $amount)
$request->setData('trxtype', self::TRXTYPE_AUTH_ONLY);
$request->setData('origid', $token);
$request->setData('amt', $this->formatPrice($amount));
$request->setData('currency', $order->getBaseCurrencyCode());
$request->setData('taxamt', $this->formatPrice($order->getBaseTaxAmount()));
$request->setData('freightamt', $this->formatPrice($order->getBaseShippingAmount()));

$response = $this->postRequest($request, $this->getConfig());
$this->processErrors($response);
Expand Down
13 changes: 8 additions & 5 deletions app/code/Magento/Paypal/Test/Unit/Model/ExpressTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,9 @@ public function testAssignData()
$data = new DataObject(
[
PaymentInterface::KEY_ADDITIONAL_DATA => [
Express\Checkout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT => $transportValue
Express\Checkout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT => $transportValue,
Express\Checkout::PAYMENT_INFO_TRANSPORT_PAYER_ID => $transportValue,
Express\Checkout::PAYMENT_INFO_TRANSPORT_TOKEN => $transportValue
]
]
);
Expand All @@ -202,11 +204,12 @@ public function testAssignData()

$this->parentAssignDataExpectation($data);

$paymentInfo->expects(static::once())
$paymentInfo->expects(static::exactly(3))
->method('setAdditionalInformation')
->with(
Express\Checkout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT,
$transportValue
->withConsecutive(
[Express\Checkout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT, $transportValue],
[Express\Checkout::PAYMENT_INFO_TRANSPORT_PAYER_ID, $transportValue],
[Express\Checkout::PAYMENT_INFO_TRANSPORT_TOKEN, $transportValue]
);

$this->_model->assignData($data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ protected function initializationAuthorizeMock()
$this->orderMock = $this->getMockBuilder(\Magento\Sales\Model\Order::class)
->setMethods([
'getCustomerId', 'getBillingAddress', 'getShippingAddress', 'getCustomerEmail',
'getId', 'getIncrementId'
'getId', 'getIncrementId', 'getBaseCurrencyCode'
])
->disableOriginalConstructor()
->getMock();
Expand Down Expand Up @@ -164,6 +164,9 @@ protected function buildRequestData()
$this->paymentMock->expects($this->once())
->method('getOrder')
->willReturn($this->orderMock);
$this->orderMock->expects($this->once())
->method('getBaseCurrencyCode')
->willReturn('USD');
$this->orderMock->expects($this->once())
->method('getBillingAddress')
->willReturn($this->addressBillingMock);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
</requires>
</field>
<field id="payflowpro_cc_vault_active" translate="label" type="select" sortOrder="22" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Vault enabled</label>
<label>Vault Enabled</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/payflowpro_cc_vault/active</config_path>
<attribute type="shared">1</attribute>
Expand Down
9 changes: 4 additions & 5 deletions app/code/Magento/Paypal/view/adminhtml/web/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@
.payflow-settings-notice { border:1px solid #d1d0ce;padding:0 10px;margin: 0;}
.payflow-settings-notice .important-label {color:#f00;}
.payflow-settings-notice ul.options-list {list-style:disc;padding:0 2em;}
.paypal-express-section .heading {display: inline-block; background: url("images/pp-logo-200px.png") no-repeat 0 50% / 18rem auto; padding-left: 20rem;}
.paypal-express-section .button-container {display: inline-block; float: right;}
.paypal-express-section .config-alt {background: url("images/pp-alt.png") no-repeat; height: 26px; margin: .5rem 0 0; width: 158px;}
.paypal-express-section .heading {background: url("images/pp-logo-200px.png") no-repeat 0 50% / 18rem auto; padding-left: 20rem;}
.paypal-express-section .button-container {float: right;}
.paypal-express-section .config-alt {background: url("images/pp-alt.png") no-repeat; height: 26px; margin: 0.5rem 0 0; width: 158px;}
.paypal-express-section .link-more {margin-left: 5px;}
.paypal-other-section .heading {display: inline-block;}
.paypal-other-section .button-container {display: inline-block; float: right; margin: 1rem 0 0 !important;}
.paypal-other-section .button-container {float: right; margin: 1rem 0 0 !important;}
.paypal-other-section > .entry-edit-head > a::before {left: auto !important; right: 1.3rem !important;}
.paypal-all-in-one-section > .entry-edit-head {background: url("images/AM_mc_vs_dc_ae.jpg") no-repeat scroll 0 50% / 18rem auto; padding-left: 18rem;}
.paypal-gateways-section > .entry-edit-head {background: url("images/pp-payflow-mark.png") no-repeat scroll 0 50% / 18rem auto; padding-left: 18rem;}
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Vault/Model/Method/Vault.php
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ public function assignData(\Magento\Framework\DataObject $data)
public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null)
{
return $this->getVaultProvider()->isAvailable($quote)
&& $this->config->getValue(self::$activeKey, $this->getStore() ?: $quote->getStoreId());
&& $this->config->getValue(self::$activeKey, $this->getStore() ?: ($quote ? $quote->getStoreId() : null));
}

/**
Expand Down
28 changes: 28 additions & 0 deletions app/code/Magento/Vault/Test/Unit/Model/Method/VaultTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,4 +274,32 @@ public function isAvailableDataProvider()
['isAvailableProvider' => true, 'isActiveVault' => true, 'expected' => true],
];
}

/**
* @covers \Magento\Vault\Model\Method\Vault::isAvailable
*/
public function testIsAvailableWithoutQuote()
{
$quote = null;

$vaultProvider = $this->getMockForAbstractClass(MethodInterface::class);
$config = $this->getMockForAbstractClass(ConfigInterface::class);

$vaultProvider->expects(static::once())
->method('isAvailable')
->with($quote)
->willReturn(true);

$config->expects(static::once())
->method('getValue')
->with('active', $quote)
->willReturn(false);

/** @var Vault $model */
$model = $this->objectManager->getObject(Vault::class, [
'config' => $config,
'vaultProvider' => $vaultProvider
]);
static::assertFalse($model->isAvailable($quote));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Braintree extends Block
private $enablers = [
'Enable this Solution' => "#payment_us_braintree_section_braintree_active",
'Enable PayPal through Braintree' => '#payment_us_braintree_section_braintree_active_braintree_paypal',
'Vault enabled' => '#payment_us_braintree_section_braintree_braintree_cc_vault_active'
'Vault Enabled' => '#payment_us_braintree_section_braintree_braintree_cc_vault_active'
];

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class PayflowPro extends Block
'_payflow_required_enable_paypal_payflow',
'Enable PayPal Credit' => '#payment_us_paypal_payment_gateways_paypal_payflowpro_with_express_checkout_paypal' .
'_payflow_required_enable_express_checkout_bml_payflow',
'Vault enabled' => '#payment_us_paypal_payment_gateways_paypal_payflowpro_with_express_checkout_paypal_' .
'Vault Enabled' => '#payment_us_paypal_payment_gateways_paypal_payflowpro_with_express_checkout_paypal_' .
'payflow_required_payflowpro_cc_vault_active'
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class PaymentsPro extends Block
'_payflow',
'Enable PayPal Credit' => '#payment_us_paypal_group_all_in_one_wpp_usuk_paypal_payflow_required_enable_' .
'express_checkout_bml_payflow',
'Vault enabled' => '#payment_us_paypal_group_all_in_one_wpp_usuk_paypal_payflow_required_payflowpro_cc_vault' .
'Vault Enabled' => '#payment_us_paypal_group_all_in_one_wpp_usuk_paypal_payflow_required_payflowpro_cc_vault' .
'_active'
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ private function enablePayflowPro()
$this->payflowProConfigBlock->enablePayflowPro();
$this->assertFieldsAreActive->processAssert(
$this->systemConfigEditSectionPayment,
[$enablers['Enable this Solution'], $enablers['Enable PayPal Credit'], $enablers['Vault enabled']]
[$enablers['Enable this Solution'], $enablers['Enable PayPal Credit'], $enablers['Vault Enabled']]
);
$this->assertFieldsAreEnabled->processAssert(
$this->systemConfigEditSectionPayment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ private function enablePaymentsPro()
$this->paymentsProConfigBlock->enablePaymentsPro();
$this->assertFieldsAreActive->processAssert(
$this->systemConfigEditSectionPayment,
[$enablers['Enable this Solution'], $enablers['Enable PayPal Credit'], $enablers['Vault enabled']]
[$enablers['Enable this Solution'], $enablers['Enable PayPal Credit'], $enablers['Vault Enabled']]
);
$this->assertFieldsAreEnabled->processAssert(
$this->systemConfigEditSectionPayment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
</requires>
</field>
<field id="payflowpro_cc_vault_active" translate="label" type="select" sortOrder="22" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Vault enabled</label>
<label>Vault Enabled</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/payflowpro_cc_vault/active</config_path>
<attribute type="shared">1</attribute>
Expand Down

0 comments on commit 152dbdc

Please sign in to comment.