Skip to content

Commit 6a38dd7

Browse files
authored
Merge pull request #98 from magento-mpi/MAGETWO-54214
[MPI] Bug Fixes
2 parents c201d36 + 6ccada9 commit 6a38dd7

File tree

2 files changed

+67
-6
lines changed

2 files changed

+67
-6
lines changed

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

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,17 @@
88
use Magento\Framework\DataObject;
99
use Magento\Framework\Exception\LocalizedException;
1010
use Magento\Payment\Model\InfoInterface;
11+
use Magento\Payment\Model\Method\ConfigInterface;
1112
use Magento\Payment\Model\Method\ConfigInterfaceFactory;
13+
use Magento\Payment\Model\Method\Online\GatewayInterface;
14+
use Magento\Payment\Observer\AbstractDataAssignObserver;
15+
use Magento\Paypal\Model\Config;
1216
use Magento\Paypal\Model\Payflow\Service\Gateway;
1317
use Magento\Paypal\Model\Payflow\Service\Response\Handler\HandlerInterface;
14-
use Magento\Paypal\Model\Payflow\Transparent;
1518
use Magento\Quote\Model\Quote;
16-
use Magento\Sales\Model\Order\Payment;
17-
use Magento\Payment\Model\Method\Online\GatewayInterface;
18-
use Magento\Payment\Model\Method\ConfigInterface;
19-
use Magento\Paypal\Model\Config;
2019
use Magento\Sales\Model\Order;
20+
use Magento\Sales\Model\Order\Payment;
2121
use Magento\Store\Model\ScopeInterface;
22-
use Magento\Vault\Api\Data\PaymentTokenInterface;
2322

2423
/**
2524
* Payflow Pro payment gateway model
@@ -861,6 +860,36 @@ public function addRequestOrderInfo(DataObject $request, Order $order)
861860
->setComment1($orderIncrementId);
862861
}
863862

863+
/**
864+
* Assign data to info model instance
865+
*
866+
* @param array|DataObject $data
867+
* @return $this
868+
* @throws \Magento\Framework\Exception\LocalizedException
869+
*/
870+
public function assignData(DataObject $data)
871+
{
872+
$this->_eventManager->dispatch(
873+
'payment_method_assign_data_' . $this->getCode(),
874+
[
875+
AbstractDataAssignObserver::METHOD_CODE => $this,
876+
AbstractDataAssignObserver::MODEL_CODE => $this->getInfoInstance(),
877+
AbstractDataAssignObserver::DATA_CODE => $data
878+
]
879+
);
880+
881+
$this->_eventManager->dispatch(
882+
'payment_method_assign_data',
883+
[
884+
AbstractDataAssignObserver::METHOD_CODE => $this,
885+
AbstractDataAssignObserver::MODEL_CODE => $this->getInfoInstance(),
886+
AbstractDataAssignObserver::DATA_CODE => $data
887+
]
888+
);
889+
890+
return $this;
891+
}
892+
864893
/**
865894
* @param InfoInterface $payment
866895
* @param string $transactionId

app/code/Magento/Paypal/Test/Unit/Model/PayflowproTest.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@
1111

1212
use Magento\Framework\DataObject;
1313
use Magento\Framework\Exception\LocalizedException;
14+
use Magento\Framework\Event\ManagerInterface;
1415
use Magento\Payment\Model\Method\ConfigInterface;
1516
use Magento\Paypal\Model\Config;
1617
use Magento\Paypal\Model\Payflowpro;
1718
use Magento\Store\Model\ScopeInterface;
19+
use Magento\Payment\Model\InfoInterface;
1820

1921
/**
2022
* Class PayflowproTest
@@ -54,6 +56,11 @@ class PayflowproTest extends \PHPUnit_Framework_TestCase
5456
*/
5557
protected $scopeConfigMock;
5658

59+
/**
60+
* @var ManagerInterface|\PHPUnit_Framework_MockObject_MockObject
61+
*/
62+
private $eventManager;
63+
5764
protected function setUp()
5865
{
5966
$configFactoryMock = $this->getMock(
@@ -114,10 +121,13 @@ protected function setUp()
114121
$clientFactory = $this->getMock('Magento\Framework\HTTP\ZendClientFactory', ['create'], [], '', false);
115122
$clientFactory->expects($this->any())->method('create')->will($this->returnValue($client));
116123

124+
$this->eventManager = $this->getMockForAbstractClass(ManagerInterface::class);
125+
117126
$this->helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
118127
$this->payflowpro = $this->helper->getObject(
119128
'Magento\Paypal\Model\Payflowpro',
120129
[
130+
'eventDispatcher' => $this->eventManager,
121131
'configFactory' => $configFactoryMock,
122132
'httpClientFactory' => $clientFactory,
123133
'storeManager' => $this->storeManagerMock,
@@ -498,4 +508,26 @@ public function testPostRequestException()
498508

499509
$this->payflowpro->postRequest($request, $config);
500510
}
511+
512+
/**
513+
* @covers \Magento\Paypal\Model\Payflowpro::assignData
514+
*/
515+
public function testAssignData()
516+
{
517+
$data = [
518+
'cc_type' => 'VI',
519+
'cc_last_4' => 1111,
520+
'cc_exp_month' => 12,
521+
'cc_exp_year' => 2023
522+
];
523+
$dataObject = new DataObject($data);
524+
525+
$infoInstance = $this->getMockForAbstractClass(InfoInterface::class);
526+
$this->payflowpro->setData('info_instance', $infoInstance);
527+
528+
$this->eventManager->expects(static::exactly(2))
529+
->method('dispatch');
530+
531+
$this->payflowpro->assignData($dataObject);
532+
}
501533
}

0 commit comments

Comments
 (0)