/** * <p> * Method produces <code>HppResponse</code> object from JSON. * Carries out the following actions: * <ul> * <li>Deserialises JSON to response object</li> * <li>Decodes Base64 inputs</li> * <li>Validates hash</li> * </ul> * </p> * * @param string $json * @param bool $encoded * @return HppResponse */ public function responseFromJson($json, $encoded = true) { $this->logger->info("Converting JSON to HppResponse."); //convert to HppResponse from JSON $hppResponse = JsonUtils::fromJsonHppResponse($json); //decode if necessary if ($encoded) { $this->logger->debug("Decoding object."); try { $hppResponse = $hppResponse->decode(self::ENCODING_CHARSET); } catch (Exception $e) { $this->logger->error("Exception decoding HPP response.", $e); throw new RealexException("Exception decoding HPP response.", $e); } } //validate HPP response hash $this->logger->debug("Validating response hash."); ValidationUtils::validateResponse($hppResponse, $this->secret); return $hppResponse; }