6 declare(strict_types=1);
10 use Braintree\Error\ErrorCollection;
11 use Braintree\Error\Validation;
14 use Magento\Payment\Gateway\Validator\ResultInterfaceFactory;
28 private static $acceptableTransactionCode = 91504;
33 private $generalResponseValidator;
38 private $subjectReader;
46 ResultInterfaceFactory $resultFactory,
50 parent::__construct($resultFactory);
51 $this->generalResponseValidator = $generalResponseValidator;
52 $this->subjectReader = $subjectReader;
60 $result = $this->generalResponseValidator->validate($validationSubject);
62 $response = $this->subjectReader->readResponseObject($validationSubject);
63 if ($this->isErrorAcceptable(
$response->errors)) {
77 private function isErrorAcceptable(ErrorCollection $errorCollection): bool
79 $errors = $errorCollection->deepAll();
88 return (
int)$error->code === self::$acceptableTransactionCode;
createResult($isValid, array $fails=[], array $errorCodes=[])
validate(array $validationSubject)
__construct(ResultInterfaceFactory $resultFactory, GeneralResponseValidator $generalResponseValidator, SubjectReader $subjectReader)