/**
  * Parses callback parameters from query parameters and checks if sign is correct.
  * Request has parameter "data", which is signed and holds all callback parameters
  *
  * @param array $requestData
  *
  * @return array Parsed callback parameters
  *
  * @throws WebToPayException
  * @throws WebToPay_Exception_Callback
  */
 public function validateAndParseData(array $requestData)
 {
     if (!$this->signer->checkSign($requestData)) {
         throw new WebToPay_Exception_Callback('Invalid sign parameters, check $_GET length limit');
     }
     if (!isset($requestData['data'])) {
         throw new WebToPay_Exception_Callback('"data" parameter not found');
     }
     $data = $requestData['data'];
     $queryString = $this->util->decodeSafeUrlBase64($data);
     $request = $this->util->parseHttpQuery($queryString);
     if (!isset($request['projectid'])) {
         throw new WebToPay_Exception_Callback('Project ID not provided in callback', WebToPayException::E_INVALID);
     }
     if ((string) $request['projectid'] !== (string) $this->projectId) {
         throw new WebToPay_Exception_Callback(sprintf('Bad projectid: %s, should be: %s', $request['projectid'], $this->projectId), WebToPayException::E_INVALID);
     }
     if (!isset($request['type']) || !in_array($request['type'], array('micro', 'macro'))) {
         $micro = isset($request['to']) && isset($request['from']) && isset($request['sms']);
         $request['type'] = $micro ? 'micro' : 'macro';
     }
     return $request;
 }
 /**
  * Tests parseHttpQuery. Must work with and without gpc_magic_quotes
  */
 public function testParseHttpQuery()
 {
     $this->assertEquals(array('param1' => 'some string', 'param2' => 'special symbols !!%(@_-+/=', 'param3' => 'slashes \\\'"'), $this->util->parseHttpQuery('param1=some+string&param2=special+symbols+%21%21%25%28%40_-%2B%2F%3D&param3=slashes+%5C%27%22'));
 }