Skip to content

Commit 9d52917

Browse files
committed
Merge remote-tracking branch 'remotes/origin/MAGETWO-67632' into MPI-PR-Bugfixes
2 parents eb71e35 + f24878a commit 9d52917

File tree

2 files changed

+40
-3
lines changed

2 files changed

+40
-3
lines changed

app/code/Magento/Paypal/Model/Api/Nvp.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -914,15 +914,15 @@ public function getIsFraudDetected()
914914
}
915915

916916
/**
917-
* Made additional request to paypal to get autharization id
917+
* Made additional request to PayPal to get authorization id
918918
*
919919
* @return void
920920
*/
921921
public function callDoReauthorization()
922922
{
923-
$request = $this->_export($this->_doReauthorizationRequest);
923+
$request = $this->_exportToRequest($this->_doReauthorizationRequest);
924924
$response = $this->call('DoReauthorization', $request);
925-
$this->_import($response, $this->_doReauthorizationResponse);
925+
$this->_importFromResponse($this->_doReauthorizationResponse, $response);
926926
}
927927

928928
/**

app/code/Magento/Paypal/Test/Unit/Model/Api/NvpTest.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
namespace Magento\Paypal\Test\Unit\Model\Api;
1010

1111
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
12+
use Magento\Paypal\Model\Info;
1213

1314
/**
1415
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -211,6 +212,42 @@ public function testCallGetExpressCheckoutDetails()
211212
$this->assertEquals('testSTATE', $address->getRegion());
212213
}
213214

215+
/**
216+
* Tests that callDoReauthorization method is called without errors and
217+
* needed data is imported from response.
218+
*/
219+
public function testCallDoReauthorization()
220+
{
221+
$authorizationId = 555;
222+
$paymentStatus = 'Completed';
223+
$pendingReason = 'none';
224+
$protectionEligibility = 'Eligible';
225+
$protectionEligibilityType = 'ItemNotReceivedEligible';
226+
227+
$this->curl->expects($this->once())
228+
->method('read')
229+
->willReturn(
230+
"\r\n" . 'ACK=Success'
231+
. '&AUTHORIZATIONID=' . $authorizationId
232+
. '&PAYMENTSTATUS=' . $paymentStatus
233+
. '&PENDINGREASON=' . $pendingReason
234+
. '&PROTECTIONELIGIBILITY=' . $protectionEligibility
235+
. '&PROTECTIONELIGIBILITYTYPE=' . $protectionEligibilityType
236+
);
237+
238+
$this->model->callDoReauthorization();
239+
240+
$expectedImportedData = [
241+
'authorization_id' => $authorizationId,
242+
'payment_status' => Info::PAYMENTSTATUS_COMPLETED,
243+
'pending_reason' => $pendingReason,
244+
'protection_eligibility' => $protectionEligibility
245+
];
246+
247+
$this->assertNotContains($protectionEligibilityType, $this->model->getData());
248+
$this->assertEquals($expectedImportedData, $this->model->getData());
249+
}
250+
214251
public function testGetDebugReplacePrivateDataKeys()
215252
{
216253
$debugReplacePrivateDataKeys = $this->_invokeNvpProperty($this->model, '_debugReplacePrivateDataKeys');

0 commit comments

Comments
 (0)