Skip to content

Commit f1033b2

Browse files
author
Alexander Akimov
authored
Merge pull request #1056 from magento-mpi/PR-bugfixes-040417
[MPI] Bugfixes
2 parents ed746e3 + 7a47140 commit f1033b2

File tree

32 files changed

+870
-492
lines changed

32 files changed

+870
-492
lines changed

app/code/Magento/Braintree/view/frontend/templates/paypal/vault_token.phtml

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,22 @@ use Magento\Vault\Api\Data\PaymentTokenInterface;
99

1010
/** @var VaultTokenRenderer $block */
1111

12-
$payerEmail = $block->escapeHtml($block->getPayerEmail());
12+
$payerEmail = $block->getPayerEmail();
13+
$confirmDeleteMessage = sprintf('%s: %s?', __('Are you sure you want to delete this PayPal account'), $payerEmail);
1314
?>
1415
<tr>
1516
<td data-th="<?php echo $block->escapeHtml(__('PayPal Account')); ?>" class="col paypal-account">
1617
<img src="<?php /* @noEscape */ echo $block->getIconUrl(); ?>"
1718
width="<?php /* @noEscape */ echo $block->getIconWidth(); ?>"
1819
height="<?php /* @noEscape */ echo $block->getIconHeight(); ?>"
19-
alt="<?php echo $block->escapeHtml(__('PayPal Logo')); ?>"
20-
>
21-
<span><?php /* @noEscape */ echo $payerEmail; ?></span>
20+
alt="<?php echo $block->escapeHtml(__('PayPal Logo')); ?>">
21+
<span><?php echo $block->escapeHtml($payerEmail); ?></span>
2222
</td>
2323
<td data-th="<?php echo $block->escapeHtml(__('Actions')); ?>" class="col actions">
2424
<form
2525
class="form"
2626
action="<?php echo $block->escapeUrl($block->getUrl('vault/cards/deleteaction')); ?>"
27-
method="post"
28-
>
27+
method="post">
2928
<?php echo $block->getBlockHtml('formkey'); ?>
3029
<input
3130
name="<?php /* @noEscape */ echo PaymentTokenInterface::PUBLIC_HASH; ?>"
@@ -34,15 +33,14 @@ $payerEmail = $block->escapeHtml($block->getPayerEmail());
3433
<button type="submit"
3534
class="action delete"
3635
data-mage-init='{
37-
"Magento_Vault/js/customer_account/deleteWidget":{
38-
"type": "popup",
39-
"modalClass": "my-credit-cards-popup",
40-
"toggleEvent": "click",
41-
"title": "<?php echo $block->escapeHtml(__('Delete')); ?>",
42-
"content": "Are you sure you want to delete this PayPal account:
43-
<?php /* @noEscape */ echo $payerEmail; ?>?"
44-
}
45-
}'>
36+
"Magento_Vault/js/customer_account/deleteWidget":{
37+
"type": "popup",
38+
"modalClass": "my-credit-cards-popup",
39+
"toggleEvent": "click",
40+
"title": "<?php echo $block->escapeHtml(__('Delete')); ?>",
41+
"content":"<?php echo $block->escapeHtml($confirmDeleteMessage); ?>"
42+
}
43+
}'>
4644
<span><?php echo $block->escapeHtml(__('Delete')); ?></span>
4745
</button>
4846
</form>

app/code/Magento/OfflinePayments/Observer/BeforeOrderPaymentSaveObserver.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,13 @@ public function execute(\Magento\Framework\Event\Observer $observer)
3636
$payment->getMethodInstance()->getInstructions()
3737
);
3838
} elseif ($payment->getMethod() === Checkmo::PAYMENT_METHOD_CHECKMO_CODE) {
39-
$payment->setAdditionalInformation(
40-
'payable_to',
41-
$payment->getMethodInstance()->getPayableTo()
42-
);
43-
$payment->setAdditionalInformation(
44-
'mailing_address',
45-
$payment->getMethodInstance()->getMailingAddress()
46-
);
39+
$methodInstance = $payment->getMethodInstance();
40+
if (!empty($methodInstance->getPayableTo())) {
41+
$payment->setAdditionalInformation('payable_to', $methodInstance->getPayableTo());
42+
}
43+
if (!empty($methodInstance->getMailingAddress())) {
44+
$payment->setAdditionalInformation('mailing_address', $methodInstance->getMailingAddress());
45+
}
4746
}
4847
}
4948
}

app/code/Magento/OfflinePayments/Test/Unit/Observer/BeforeOrderPaymentSaveObserverTest.php

Lines changed: 100 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,66 @@
55
*/
66
namespace Magento\OfflinePayments\Test\Unit\Observer;
77

8+
use Magento\Framework\Event;
9+
use Magento\Framework\Event\Observer;
810
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
911
use Magento\OfflinePayments\Model\Banktransfer;
1012
use Magento\OfflinePayments\Model\Cashondelivery;
13+
use Magento\OfflinePayments\Observer\BeforeOrderPaymentSaveObserver;
14+
use Magento\Sales\Model\Order\Payment;
15+
use PHPUnit_Framework_MockObject_MockObject as MockObject;
16+
use Magento\OfflinePayments\Model\Checkmo;
1117

1218
class BeforeOrderPaymentSaveObserverTest extends \PHPUnit_Framework_TestCase
1319
{
1420
/**
15-
* @var \Magento\OfflinePayments\Observer\BeforeOrderPaymentSaveObserver
21+
* @var BeforeOrderPaymentSaveObserver
1622
*/
1723
protected $_model;
1824

25+
/**
26+
* @var Payment|MockObject
27+
*/
28+
private $payment;
29+
30+
/**
31+
* @var Event|MockObject
32+
*/
33+
private $event;
34+
35+
/**
36+
* @var Observer|MockObject
37+
*/
38+
private $observer;
39+
40+
/**
41+
* @inheritdoc
42+
*/
1943
protected function setUp()
2044
{
2145
$objectManagerHelper = new ObjectManager($this);
22-
$this->_model = $objectManagerHelper
23-
->getObject(\Magento\OfflinePayments\Observer\BeforeOrderPaymentSaveObserver::class);
46+
$this->payment = $this->getMockBuilder(Payment::class)
47+
->disableOriginalConstructor()
48+
->getMock();
49+
50+
$this->event = $this->getMockBuilder(Event::class)
51+
->disableOriginalConstructor()
52+
->setMethods(['getPayment'])
53+
->getMock();
54+
55+
$this->event->expects(self::once())
56+
->method('getPayment')
57+
->willReturn($this->payment);
58+
59+
$this->observer = $this->getMockBuilder(Observer::class)
60+
->disableOriginalConstructor()
61+
->getMock();
62+
63+
$this->observer->expects(self::once())
64+
->method('getEvent')
65+
->willReturn($this->event);
66+
67+
$this->_model = $objectManagerHelper->getObject(BeforeOrderPaymentSaveObserver::class);
2468
}
2569

2670
/**
@@ -29,40 +73,31 @@ protected function setUp()
2973
*/
3074
public function testBeforeOrderPaymentSaveWithInstructions($methodCode)
3175
{
32-
$observer = $this->getMock(\Magento\Framework\Event\Observer::class, ['getEvent'], [], '', false);
33-
$event = $this->getMock(\Magento\Framework\Event::class, ['getPayment'], [], '', false);
34-
$payment = $this->getMock(
35-
\Magento\Sales\Model\Order\Payment::class,
36-
['getMethod', 'setAdditionalInformation', 'getMethodInstance'],
37-
[],
38-
'',
39-
false
40-
);
41-
$payment->expects($this->once())
76+
$this->payment->expects(self::once())
4277
->method('getMethod')
4378
->willReturn($methodCode);
44-
$payment->expects($this->once())
79+
$this->payment->expects(self::once())
4580
->method('setAdditionalInformation')
4681
->with('instructions', 'payment configuration');
47-
$method = $this->getMockBuilder(\Magento\OfflinePayments\Model\Banktransfer::class)
82+
$method = $this->getMockBuilder(Banktransfer::class)
4883
->disableOriginalConstructor()
4984
->getMock();
5085

51-
$method->expects($this->once())
86+
$method->expects(self::once())
5287
->method('getInstructions')
5388
->willReturn('payment configuration');
54-
$payment->expects($this->once())
89+
$this->payment->expects(self::once())
5590
->method('getMethodInstance')
5691
->willReturn($method);
57-
$event->expects($this->once())
58-
->method('getPayment')
59-
->willReturn($payment);
60-
$observer->expects($this->once())
61-
->method('getEvent')
62-
->willReturn($event);
63-
$this->_model->execute($observer);
92+
93+
$this->_model->execute($this->observer);
6494
}
6595

96+
/**
97+
* Returns list of payment method codes.
98+
*
99+
* @return array
100+
*/
66101
public function dataProviderBeforeOrderPaymentSaveWithInstructions()
67102
{
68103
return [
@@ -73,70 +108,68 @@ public function dataProviderBeforeOrderPaymentSaveWithInstructions()
73108

74109
public function testBeforeOrderPaymentSaveWithCheckmo()
75110
{
76-
$observer = $this->getMock(\Magento\Framework\Event\Observer::class, ['getEvent'], [], '', false);
77-
$event = $this->getMock(\Magento\Framework\Event::class, ['getPayment'], [], '', false);
78-
$payment = $this->getMock(
79-
\Magento\Sales\Model\Order\Payment::class,
80-
['getMethod', 'setAdditionalInformation', 'getMethodInstance'],
81-
[],
82-
'',
83-
false
84-
);
85-
$payment->expects($this->exactly(2))
111+
$this->payment->expects(self::exactly(2))
86112
->method('getMethod')
87-
->willReturn(\Magento\OfflinePayments\Model\Checkmo::PAYMENT_METHOD_CHECKMO_CODE);
88-
$payment->expects($this->exactly(2))
113+
->willReturn(Checkmo::PAYMENT_METHOD_CHECKMO_CODE);
114+
$this->payment->expects(self::exactly(2))
89115
->method('setAdditionalInformation')
90116
->willReturnMap(
91117
[
92-
['payable_to', 'payable to', $payment],
93-
['mailing_address', 'mailing address', $payment],
118+
['payable_to', 'payable to', $this->payment],
119+
['mailing_address', 'mailing address', $this->payment],
94120
]
95121
);
96122

97-
$method = $this->getMockBuilder(\Magento\OfflinePayments\Model\Checkmo::class)
123+
$method = $this->getMockBuilder(Checkmo::class)
98124
->disableOriginalConstructor()
99125
->getMock();
100-
$method->expects($this->once())
126+
$method->expects(self::exactly(2))
101127
->method('getPayableTo')
102128
->willReturn('payable to');
103-
$method->expects($this->once())
129+
$method->expects(self::exactly(2))
104130
->method('getMailingAddress')
105131
->willReturn('mailing address');
106-
$payment->expects($this->exactly(2))
132+
$this->payment->expects(self::once())
107133
->method('getMethodInstance')
108134
->willReturn($method);
109-
$event->expects($this->once())
110-
->method('getPayment')
111-
->willReturn($payment);
112-
$observer->expects($this->once())
113-
->method('getEvent')
114-
->willReturn($event);
115-
$this->_model->execute($observer);
135+
$this->_model->execute($this->observer);
136+
}
137+
138+
/**
139+
* Checks a case when payment method is Check Money order and
140+
* payable person and mailing address do not specified.
141+
*/
142+
public function testBeforeOrderPaymentSaveWithCheckmoWithoutConfig()
143+
{
144+
$this->payment->expects(self::exactly(2))
145+
->method('getMethod')
146+
->willReturn(Checkmo::PAYMENT_METHOD_CHECKMO_CODE);
147+
$this->payment->expects(self::never())
148+
->method('setAdditionalInformation');
149+
150+
$method = $this->getMockBuilder(Checkmo::class)
151+
->disableOriginalConstructor()
152+
->getMock();
153+
$method->expects(self::once())
154+
->method('getPayableTo')
155+
->willReturn(null);
156+
$method->expects(self::once())
157+
->method('getMailingAddress')
158+
->willReturn(null);
159+
$this->payment->expects(self::once())
160+
->method('getMethodInstance')
161+
->willReturn($method);
162+
$this->_model->execute($this->observer);
116163
}
117164

118165
public function testBeforeOrderPaymentSaveWithOthers()
119166
{
120-
$observer = $this->getMock(\Magento\Framework\Event\Observer::class, ['getEvent'], [], '', false);
121-
$event = $this->getMock(\Magento\Framework\Event::class, ['getPayment'], [], '', false);
122-
$payment = $this->getMock(
123-
\Magento\Sales\Model\Order\Payment::class,
124-
['getMethod', 'setAdditionalInformation', 'getMethodInstance'],
125-
[],
126-
'',
127-
false
128-
);
129-
$payment->expects($this->exactly(2))
167+
$this->payment->expects(self::exactly(2))
130168
->method('getMethod')
131169
->willReturn('somepaymentmethod');
132-
$payment->expects($this->never())
170+
$this->payment->expects(self::never())
133171
->method('setAdditionalInformation');
134-
$event->expects($this->once())
135-
->method('getPayment')
136-
->willReturn($payment);
137-
$observer->expects($this->once())
138-
->method('getEvent')
139-
->willReturn($event);
140-
$this->_model->execute($observer);
172+
173+
$this->_model->execute($this->observer);
141174
}
142175
}

app/code/Magento/Paypal/Controller/Payflow/ReturnUrl.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class ReturnUrl extends Payflow
1818
protected $allowedOrderStates = [
1919
Order::STATE_PROCESSING,
2020
Order::STATE_COMPLETE,
21+
Order::STATE_PAYMENT_REVIEW
2122
];
2223

2324
/**

app/code/Magento/Paypal/Model/Payflowlink.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -315,11 +315,8 @@ protected function _processOrder(\Magento\Sales\Model\Order $order)
315315
) {
316316
$canSendNewOrderEmail = false;
317317

318-
$payment->setIsTransactionPending(
319-
true
320-
)->setIsFraudDetected(
321-
true
322-
);
318+
$payment->setIsTransactionPending(true)
319+
->setIsFraudDetected(true);
323320

324321
$fraudMessage = $response->getData('respmsg');
325322
if ($response->getData('fps_prexmldata')) {

app/code/Magento/Paypal/Model/Payflowpro.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use Magento\Payment\Model\Method\ConfigInterfaceFactory;
1313
use Magento\Payment\Model\Method\Online\GatewayInterface;
1414
use Magento\Payment\Observer\AbstractDataAssignObserver;
15-
use Magento\Paypal\Model\Config;
1615
use Magento\Paypal\Model\Payflow\Service\Gateway;
1716
use Magento\Paypal\Model\Payflow\Service\Response\Handler\HandlerInterface;
1817
use Magento\Quote\Model\Quote;
@@ -646,7 +645,7 @@ public function processErrors(DataObject $response)
646645
$response->getResultCode() != self::RESPONSE_CODE_FRAUDSERVICE_FILTER
647646
) {
648647
throw new \Magento\Framework\Exception\LocalizedException(__($response->getRespmsg()));
649-
} elseif ($response->getOrigresult() == self::RESPONSE_CODE_FRAUDSERVICE_FILTER) {
648+
} elseif ($response->getOrigresult() == self::RESPONSE_CODE_DECLINED_BY_FILTER) {
650649
throw new \Magento\Framework\Exception\LocalizedException(__($response->getRespmsg()));
651650
}
652651
}

0 commit comments

Comments
 (0)