/** * Set request that MAC needs to be calculated on * @param AbstractRequest $request * @return $this * @throws \Upg\Library\Serializer\Exception\VisitorCouldNotBeFound */ public function setRequest(AbstractRequest $request) { $data = array(); /**Serialize the any sub objects**/ foreach ($request->getSerializerData() as $key => $value) { if ($this->needsToBeSerialized($value)) { $data[$key] = $this->serializer->serialize($value); } else { $data[$key] = $value; } } $this->setCalculationArray($data); return $this; }
/** * Process the request * @throws Exception\Validation * @throws InvalidUrl * @throws \Upg\Library\Serializer\Exception\VisitorCouldNotBeFound */ private function processRequest() { $this->url = $this->validateUrl($this->getUrl()); /** * Validate and serialize the request */ $validationResult = $this->getValidator()->getValidator($this->request)->performValidation(); if (!empty($validationResult)) { $this->logger->debug("Got validation error on request request :" . serialize($this->request)); $this->logger->error("Got validation issue" . serialize($validationResult)); throw new \Upg\Library\Api\Exception\Validation($validationResult); } /** * Serialize the request */ $mac = $this->getMacCalculator()->setConfig($this->config)->setRequest($this->request)->calculateMac(); $this->request->setMac($mac); $this->requestRaw = $this->getSerializer()->serialize($this->request); }