for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Pagantis\Pagantis\Gateway\Validator;
use Magento\Payment\Gateway\Validator\AbstractValidator;
use Magento\Payment\Gateway\Validator\ResultInterface;
use Pagantis\Pagantis\Gateway\Http\Client\ClientMock;
class ResponseCodeValidator extends AbstractValidator
{
const RESULT_CODE = 'RESULT_CODE';
* Performs validation of result code
*
* @param array $validationSubject
* @return ResultInterface
public function validate(array $validationSubject)
if (!isset($validationSubject['response']) || !is_array($validationSubject['response'])) {
throw new \InvalidArgumentException('Response does not exist');
}
$response = $validationSubject['response'];
if ($this->isSuccessfulTransaction($response)) {
return $this->createResult(
true,
[]
);
} else {
false,
[__('Gateway rejected the transaction.')]
* @param array $response
* @return bool
private function isSuccessfulTransaction(array $response)
return isset($response[self::RESULT_CODE])
&& $response[self::RESULT_CODE] !== ClientMock::FAILURE;