Skip to content

Commit 1a450df

Browse files
committed
MAGETWO-51014: Incorrect error message is shown to customer when Express Checkout fraud filters triggered
- Added 10736 error code processing
1 parent 069ef20 commit 1a450df

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

app/code/Magento/Paypal/Controller/Express/AbstractExpress/PlaceOrder.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ protected function _processPaypalApiError($exception)
141141
case ApiProcessableException::API_DO_EXPRESS_CHECKOUT_FAIL:
142142
$this->_redirectSameToken();
143143
break;
144+
case ApiProcessableException::API_ADDRESS_MATCH_FAIL:
145+
$this->_redirectToOrderReviewPageAndShowError($exception->getUserMessage());
146+
break;
144147
case ApiProcessableException::API_UNABLE_TRANSACTION_COMPLETE:
145148
if ($this->_config->getPaymentAction() == \Magento\Payment\Model\Method\AbstractMethod::ACTION_ORDER) {
146149
$paypalTransactionData = $this->_getCheckoutSession()->getPaypalTransactionData();
@@ -182,6 +185,18 @@ protected function _redirectToCartAndShowError($errorMessage)
182185
$this->_redirect('checkout/cart');
183186
}
184187

188+
/**
189+
* Redirect customer to the paypal order review page and show error message
190+
*
191+
* @param string $errorMessage
192+
* @return void
193+
*/
194+
protected function _redirectToOrderReviewPageAndShowError($errorMessage)
195+
{
196+
$this->messageManager->addErrorMessage($errorMessage);
197+
$this->_redirect('*/*/review');
198+
}
199+
185200
/**
186201
* Return true if agreements validation required
187202
*

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class ProcessableException extends LocalizedException
2525
const API_COUNTRY_FILTER_DECLINE = 10537;
2626
const API_MAXIMUM_AMOUNT_FILTER_DECLINE = 10538;
2727
const API_OTHER_FILTER_DECLINE = 10539;
28+
const API_ADDRESS_MATCH_FAIL = 10736;
2829
/**#@-*/
2930

3031
/**
@@ -61,8 +62,13 @@ public function getUserMessage()
6162
'I\'m sorry - but we are not able to complete your transaction. Please contact us so we can assist you.'
6263
);
6364
break;
65+
case self::API_ADDRESS_MATCH_FAIL:
66+
$message = __(
67+
'A match of the Shipping Address City, State, and Postal Code failed.'
68+
);
69+
break;
6470
default:
65-
$message = __($this->getMessage());
71+
$message = __('We can\'t place the order.');
6672
break;
6773
}
6874
return $message;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ protected function _setApiProcessableErrors()
266266
ApiProcessableException::API_COUNTRY_FILTER_DECLINE,
267267
ApiProcessableException::API_MAXIMUM_AMOUNT_FILTER_DECLINE,
268268
ApiProcessableException::API_OTHER_FILTER_DECLINE,
269+
ApiProcessableException::API_ADDRESS_MATCH_FAIL,
269270
]
270271
);
271272
}

0 commit comments

Comments
 (0)