GeneralResponseValidator.php (1665B)
1 <?php 2 /** 3 * 4 * This file is part of TALER 5 * Copyright (C) 2024 Taler Systems SA 6 * 7 * TALER is free software; you can redistribute it and/or modify it under the 8 * terms of the GNU General Public License as published by the Free Software 9 * Foundation; either version 3, or (at your option) any later version. 10 * 11 * TALER is distributed in the hope that it will be useful, but WITHOUT ANY 12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 13 * A PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License along with 16 * TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> 17 * 18 * @author Nicola Eigel 19 */ 20 21 namespace GNU\Taler\Gateway\Validator; 22 23 use Magento\Payment\Gateway\Validator\AbstractValidator; 24 use Magento\Payment\Gateway\Validator\ResultInterface; 25 26 class GeneralResponseValidator extends AbstractValidator 27 { 28 29 /** 30 * Validate result and return it to magento payment processor 31 * @param array $validationSubject 32 * @return ResultInterface 33 */ 34 public function validate(array $validationSubject) 35 { 36 $isValid = true; 37 $failsDescription = []; 38 $errorCodes = []; 39 if ($validationSubject["response"]["response"] == false) 40 $isValid = false; 41 if (!$isValid) { 42 $failsDescription = [ 43 "response" => $validationSubject["response"]["body"] 44 ]; 45 $errorCodes = ["code" => $validationSubject["response"]["result"]]; 46 } 47 return $this->createResult($isValid, $failsDescription, $errorCodes); 48 } 49 }