Skip to content

Commit 0a47fa8

Browse files
committed
Merge branch 'ACP2E-25' of https://github.com/magento-l3/magento2ce into PR1-21-01-2022
2 parents 92b3163 + 7ba2c87 commit 0a47fa8

File tree

4 files changed

+95
-3
lines changed

4 files changed

+95
-3
lines changed

app/code/Magento/Paypal/Controller/Transparent/Response.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
use Magento\Paypal\Model\Payflow\Service\Response\Validator\ResponseValidator;
1919
use Magento\Paypal\Model\Payflow\Transparent;
2020
use Magento\Sales\Api\PaymentFailuresInterface;
21-
use Magento\Checkout\Model\Session;
21+
use Magento\Framework\Session\SessionManager as Session;
2222
use Magento\Framework\App\Action\HttpPostActionInterface;
2323

2424
/**
@@ -28,8 +28,6 @@
2828
class Response extends \Magento\Framework\App\Action\Action implements CsrfAwareActionInterface, HttpPostActionInterface
2929
{
3030
/**
31-
* Core registry
32-
*
3331
* @var Registry
3432
*/
3533
private $coreRegistry;

app/code/Magento/Paypal/etc/adminhtml/di.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,9 @@
7474
</argument>
7575
</arguments>
7676
</type>
77+
<type name="Magento\Paypal\Controller\Adminhtml\Transparent\Response">
78+
<arguments>
79+
<argument name="sessionTransparent" xsi:type="object">Magento\Framework\Session\Generic</argument>
80+
</arguments>
81+
</type>
7782
</config>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@
149149
<type name="Magento\Paypal\Controller\Transparent\Response">
150150
<arguments>
151151
<argument name="responseValidator" xsi:type="object">Magento\Paypal\Model\Payflow\Service\Response\Validator\ResponseValidatorInController</argument>
152+
<argument name="sessionTransparent" xsi:type="object">Magento\Checkout\Model\Session</argument>
152153
</arguments>
153154
</type>
154155

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Paypal\Controller\Adminhtml\Transparent;
9+
10+
use Magento\Checkout\Model\Session;
11+
use Magento\Framework\Api\SearchCriteriaBuilder;
12+
use Magento\Framework\Exception\NoSuchEntityException;
13+
use Magento\Framework\Session\Generic;
14+
use Magento\Paypal\Model\Payflow\Transparent;
15+
use Magento\Quote\Api\CartRepositoryInterface;
16+
use Magento\Quote\Api\Data\CartInterface;
17+
use Magento\Quote\Api\PaymentMethodManagementInterface;
18+
use Magento\TestFramework\TestCase\AbstractController;
19+
20+
/**
21+
* Tests PayPal transparent response controller.
22+
*
23+
* @magentoAppArea adminhtml
24+
*/
25+
class ResponseTest extends AbstractController
26+
{
27+
/**
28+
* Tests storing payment information on backend from PayPal response.
29+
*
30+
* @throws NoSuchEntityException
31+
*
32+
* @magentoConfigFixture current_store payment/payflowpro/active 1
33+
* @magentoDataFixture Magento/Sales/_files/quote.php
34+
*/
35+
public function testStoringPaymentInformation()
36+
{
37+
$reservedOrderId = 'test01';
38+
$pnref = 'A10AAD866C87';
39+
$postData = [
40+
'EXPDATE' => '0321',
41+
'AMT' => '0.00',
42+
'RESPMSG' => 'Verified',
43+
'CVV2MATCH' => 'Y',
44+
'PNREF' => $pnref,
45+
'SECURETOKEN' => '3HYEHfG06skydAdBXbpIl8QJZ',
46+
'AVSDATA' => 'YNY',
47+
'RESULT' => '0',
48+
'IAVS' => 'N',
49+
'AVSADDR' => 'Y',
50+
'SECURETOKENID' => 'yqanLisRZbI0HAG8q3SbbKbhiwjNZAGf',
51+
];
52+
53+
$quote = $this->getQuote($reservedOrderId);
54+
$this->getRequest()->setPostValue($postData);
55+
$this->getRequest()->setMethod('POST');
56+
/** @var Session $checkoutSession */
57+
$checkoutSession = $this->_objectManager->get(Generic::class);
58+
$checkoutSession->setQuoteId($quote->getId());
59+
60+
$this->dispatch('backend/paypal/transparent/response');
61+
62+
/** @var PaymentMethodManagementInterface $paymentManagment */
63+
$paymentManagment = $this->_objectManager->get(PaymentMethodManagementInterface::class);
64+
$payment = $paymentManagment->get($quote->getId());
65+
66+
$this->assertEquals($pnref, $payment->getAdditionalInformation(Transparent::PNREF));
67+
}
68+
69+
/**
70+
* Gets quote by reserved order ID.
71+
*
72+
* @param string $reservedOrderId
73+
* @return CartInterface
74+
*/
75+
private function getQuote(string $reservedOrderId): CartInterface
76+
{
77+
$searchCriteria = $this->_objectManager->get(SearchCriteriaBuilder::class)
78+
->addFilter('reserved_order_id', $reservedOrderId)
79+
->create();
80+
81+
/** @var CartRepositoryInterface $quoteRepository */
82+
$quoteRepository = $this->_objectManager->get(CartRepositoryInterface::class);
83+
$items = $quoteRepository->getList($searchCriteria)
84+
->getItems();
85+
86+
return array_pop($items);
87+
}
88+
}

0 commit comments

Comments
 (0)