Skip to content

Commit 664fb60

Browse files
author
Cristian Partica
committed
MAGETWO-39052: Incorporate CR from MPI team into Braintree module
- fix for multiple validation messages from braintree
1 parent e9fd476 commit 664fb60

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

app/code/Magento/Braintree/Helper/Error.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ class Error extends \Magento\Framework\App\Helper\AbstractHelper
9393
public function parseBraintreeError($result)
9494
{
9595
$message = null;
96-
if ($this->isNonceUsedMoreThanOnceError($result)) {
96+
if ($this->isCreditCardApiError($result)) {
97+
$message = __($this->isCreditCardApiError($result));
98+
} elseif ($this->isNonceUsedMoreThanOnceError($result)) {
9799
$message = __("The processor declined your transaction, please re-enter your payment information");
98100
} elseif (isset($result->transaction) && $result->transaction && $result->transaction->status) {
99101
if ($result->transaction->status == self::STATUS_GATEWAY_REJECTED) {
@@ -155,4 +157,21 @@ public function isNonceUsedMoreThanOnceError($result)
155157
}
156158
return false;
157159
}
160+
161+
/**
162+
* If result error is related to input validation
163+
*
164+
* @param \Braintree_Result_Error $result
165+
* @return boolean
166+
*/
167+
public function isCreditCardApiError($result)
168+
{
169+
$errors = $result->errors->deepAll();
170+
foreach ($errors as $error) {
171+
if (($error->code > 80000) && ($error->code < 90000)) {
172+
return $error->message;
173+
}
174+
}
175+
return false;
176+
}
158177
}

0 commit comments

Comments
 (0)