Skip to content

Commit 22ed99f

Browse files
committed
Merge remote-tracking branch 'remotes/origin/MAGETWO-68949' into MPI-PR-Bugfixes
2 parents a940fe6 + f954a91 commit 22ed99f

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,6 +1285,15 @@ protected function _handleCallErrors($response)
12851285
);
12861286
$this->_logger->critical($exceptionLogMessage);
12871287

1288+
/**
1289+
* The response code 10415 'Transaction has already been completed for this token'
1290+
* must not fails place order. The old Paypal interface does not lock 'Send' button
1291+
* it may result to re-send data.
1292+
*/
1293+
if (in_array((string)ProcessableException::API_TRANSACTION_HAS_BEEN_COMPLETED, $this->_callErrors)) {
1294+
return;
1295+
}
1296+
12881297
$exceptionPhrase = __('PayPal gateway has rejected request. %1', $errorMessages);
12891298

12901299
/** @var \Magento\Framework\Exception\LocalizedException $exception */

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class ProcessableException extends LocalizedException
2929
const API_MAXIMUM_AMOUNT_FILTER_DECLINE = 10538;
3030
const API_OTHER_FILTER_DECLINE = 10539;
3131
const API_ADDRESS_MATCH_FAIL = 10736;
32+
const API_TRANSACTION_HAS_BEEN_COMPLETED = 10415;
3233
/**#@-*/
3334

3435
/**

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,4 +253,30 @@ public function testGetDebugReplacePrivateDataKeys()
253253
$debugReplacePrivateDataKeys = $this->_invokeNvpProperty($this->model, '_debugReplacePrivateDataKeys');
254254
$this->assertEquals($debugReplacePrivateDataKeys, $this->model->getDebugReplacePrivateDataKeys());
255255
}
256+
257+
/**
258+
* Tests case if obtained response with code 10415 'Transaction has already
259+
* been completed for this token'. It must does not throws the exception and
260+
* must returns response array.
261+
*/
262+
public function testCallTransactionHasBeenCompleted ()
263+
{
264+
$response = "\r\n" . 'ACK[7]=Failure&L_ERRORCODE0[5]=10415'
265+
. '&L_SHORTMESSAGE0[8]=Message.&L_LONGMESSAGE0[15]=Long%20Message.';
266+
$processableErrors =[10415];
267+
$this->curl->expects($this->once())
268+
->method('read')
269+
->will($this->returnValue($response));
270+
$this->model->setProcessableErrors($processableErrors);
271+
$this->customLoggerMock->expects($this->once())
272+
->method('debug');
273+
$expectedResponse = [
274+
'ACK' => 'Failure',
275+
'L_ERRORCODE0' => '10415',
276+
'L_SHORTMESSAGE0' => 'Message.',
277+
'L_LONGMESSAGE0' => 'Long Message.'
278+
];
279+
280+
$this->assertEquals($expectedResponse, $this->model->call('some method', ['data' => 'some data']));
281+
}
256282
}

0 commit comments

Comments
 (0)